From patchwork Sat Jan 28 11:11:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 49848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1294333wrn; Sat, 28 Jan 2023 03:16:11 -0800 (PST) X-Google-Smtp-Source: AK7set/URRUjs4p72nOkP9xkO3UrMMZYm1RRioWlt72Nz6R6A+w0aJhM4NgdLIzMcBe72yL3T89d X-Received: by 2002:a05:6402:530a:b0:49f:f60d:1692 with SMTP id eo10-20020a056402530a00b0049ff60d1692mr18414949edb.24.1674904571676; Sat, 28 Jan 2023 03:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674904571; cv=none; d=google.com; s=arc-20160816; b=xZs7Pjb5O46Md0ZavhW2RpE412h1HSaDeXoZA2svbuvmWHQd6d8Ja+aEnyxUpeFndv NQi8kxt3JvKXYWYWbERTdvUjecU5dj103fERY77dvoKkbEJ962o6TbJ4RYvKv91k/gHp voYO5g8Ab+rdTnJ2TbWe8JbuFWAkDWLmuu+PjoLxnHe2nXpmJHtBKc/+AypA9Ofzf1oa 0iQnP1PhTF8IOjVIvIPEavh3wNfDH/aO67Aq7QD6HymCbMfLmhg+hV62pEYAPlfBsmFl 3ESFNbuvkNpuraIH/oXo5mjb3c0HyHCZ1vorRDdFhRv4s1uGytLDBeIdGMirzTxuHK4f 5lRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=493UH9whhEk1w0ep2M9HRG0EP8+U1OlA4AfdHG/OFhw=; b=s35N3bkjFmmCa9rKlWjFtZPrb/q8ARsMNeaEcLw9MrnP9jFIhl5/p1Fd+BKkIWpn0s 3qfjTfDOVz6iihkmFXeZwydc9O3CXZbl1qcJmEhjUOMm9LeCs9IOoVPpABRyEp7cV06F ROTUQDSZZ1R+DeitM1d55HYkSutU3G8GBvNy4ryDV+2QOjdTER0XyRIN8kGktU2/R2jM 2MKu94cGCPV6AN0jv1i+nacZAI5c3gE5nDvXgr3oxpJIzlMaisephXNXTMQ5lboFqDFG HEVzhVXcjcPsaF64awsO/wRY564QmhMoUkhDaMHQq0zdjNja3yZU5Zn3+Myq5m/jyYbH 5Prg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm3 header.b=de1jlgU3; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="PiC/NiSw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b12-20020a50cccc000000b0049e89e692e8si8802689edj.190.2023.01.28.03.15.48; Sat, 28 Jan 2023 03:16:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@svenpeter.dev header.s=fm3 header.b=de1jlgU3; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="PiC/NiSw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=svenpeter.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234024AbjA1LMJ (ORCPT + 99 others); Sat, 28 Jan 2023 06:12:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234360AbjA1LLw (ORCPT ); Sat, 28 Jan 2023 06:11:52 -0500 Received: from wout5-smtp.messagingengine.com (wout5-smtp.messagingengine.com [64.147.123.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07FF46DFE8; Sat, 28 Jan 2023 03:11:44 -0800 (PST) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 501583200437; Sat, 28 Jan 2023 06:11:43 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 28 Jan 2023 06:11:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=cc:cc:content-transfer-encoding:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1674904302; x= 1674990702; bh=493UH9whhEk1w0ep2M9HRG0EP8+U1OlA4AfdHG/OFhw=; b=d e1jlgU34CGxuCvyj8cZMBK6/bWoiFIZZ14RcjZHMjYqEeQhToEkBt90vb4EG/Fzv ptuZ1dki+TmLwHkSUoHsw/FQCSC6jrAX9gtJYcucp/E7FKWkWXAJzF7bxBbC9PBf ZbeWNtztp4wUs0FvUdASrT+bk2cN1Ftkf0lK9rgdiGj2/6ljdFsXfTuKFgh2T1lp 3MzKs3vpVbXcuCzTKOj9Qv3W8h6Ly2u/zzWsJxF3zaPcJ0EhNtcsnUMZDigSMDaN Yl9dC/aSurjv2YkLsul5saJgHY43Oejy9rL7z/3WqMQXou/vOhmDLiIqNEjx6q/a hn9I43GvOxJ7j3OqSLagA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1674904302; x=1674990702; bh=493UH9whhEk1w 0ep2M9HRG0EP8+U1OlA4AfdHG/OFhw=; b=PiC/NiSwFoLtaE5G9J5ld6e2XJUJc 15KN4gg4UVQFlPLMuT1t7H0mzQXqsehV8LNDs+cfarFaZBfPwgl2ZfE5uyS+IKUG w5Xj+QbmPDj5d/aby83veig5W0liEQ15XRFOI76cpcQsPv3VDuevHTVcwZbbsQJg knsaiOTyyk7zmCokE591nRt84XTYNhtmfc+9EmYqwx4ilwTgOAE30/unrQd6IOyZ cH8E8u6PSa1EqImcI4ROrNHxk3daX0GksTtT75G0BzufUlaQfA8yAoQydiY2Enef Y9R+AFqB+Cv5GYRQ0tkiBUzTQyXREMPA4Sh6NI8pTVFbUrbr5CsEFrhfQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddvkedgvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepufhvvghn ucfrvghtvghruceoshhvvghnsehsvhgvnhhpvghtvghrrdguvghvqeenucggtffrrghtth gvrhhnpeejieehheekgedvjefhveekjefguddtfefhteehtdeiffelkeeiuedufeelkeej geenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehsvh gvnhesshhvvghnphgvthgvrhdruggvvh X-ME-Proxy: Feedback-ID: i51094778:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 28 Jan 2023 06:11:40 -0500 (EST) From: Sven Peter To: Hector Martin , Sven Peter , Joerg Roedel , Will Deacon , Robin Murphy Cc: Rob Herring , Krzysztof Kozlowski , Alyssa Rosenzweig , linux-arm-kernel@lists.infradead.org, asahi@lists.linux.dev, iommu@lists.linux.dev, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] iommu: dart: Add support for M1 USB4 PCIe DART Date: Sat, 28 Jan 2023 12:11:14 +0100 Message-Id: <20230128111114.4049-5-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20230128111114.4049-1-sven@svenpeter.dev> References: <20230128111114.4049-1-sven@svenpeter.dev> MIME-Version: 1.0 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756264735936015825?= X-GMAIL-MSGID: =?utf-8?q?1756264735936015825?= This variant of the regular t8103 DART is used for the two USB4/Thunderbolt PCIe controllers. It supports 64 instead of 16 streams which requires a slightly different MMIO layout. We also disallow bypass support since these DARTs will only ever be used for externally facing devices on the USB4 ports. Signed-off-by: Sven Peter Acked-by: Hector Martin --- drivers/iommu/apple-dart.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 7579c97a9062..a1304ba3639b 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -81,6 +81,7 @@ #define DART_T8020_TCR_BYPASS_DAPF BIT(12) #define DART_T8020_TTBR 0x200 +#define DART_T8020_USB4_TTBR 0x400 #define DART_T8020_TTBR_VALID BIT(31) #define DART_T8020_TTBR_ADDR_FIELD_SHIFT 0 #define DART_T8020_TTBR_SHIFT 12 @@ -1184,6 +1185,35 @@ static const struct apple_dart_hw apple_dart_hw_t8103 = { .ttbr_shift = DART_T8020_TTBR_SHIFT, .ttbr_count = 4, }; + +static const struct apple_dart_hw apple_dart_hw_t8103_usb4 = { + .type = DART_T8020, + .irq_handler = apple_dart_t8020_irq, + .invalidate_tlb = apple_dart_t8020_hw_invalidate_tlb, + .oas = 36, + .fmt = APPLE_DART, + .max_sid_count = 64, + + .enable_streams = DART_T8020_STREAMS_ENABLE, + .lock = DART_T8020_CONFIG, + .lock_bit = DART_T8020_CONFIG_LOCK, + + .error = DART_T8020_ERROR, + + .tcr = DART_T8020_TCR, + .tcr_enabled = DART_T8020_TCR_TRANSLATE_ENABLE, + .tcr_disabled = 0, + .tcr_bypass = 0, + + .ttbr = DART_T8020_USB4_TTBR, + .ttbr_valid = DART_T8020_TTBR_VALID, + .ttbr_addr_field_shift = DART_T8020_TTBR_ADDR_FIELD_SHIFT, + .ttbr_shift = DART_T8020_TTBR_SHIFT, + .ttbr_count = 4, + + .disable_bypass = true, +}; + static const struct apple_dart_hw apple_dart_hw_t6000 = { .type = DART_T6000, .irq_handler = apple_dart_t8020_irq, @@ -1276,6 +1306,7 @@ DEFINE_SIMPLE_DEV_PM_OPS(apple_dart_pm_ops, apple_dart_suspend, apple_dart_resum static const struct of_device_id apple_dart_of_match[] = { { .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 }, + { .compatible = "apple,t8103-dart-usb4", .data = &apple_dart_hw_t8103_usb4 }, { .compatible = "apple,t8110-dart", .data = &apple_dart_hw_t8110 }, { .compatible = "apple,t6000-dart", .data = &apple_dart_hw_t6000 }, {},