From patchwork Tue May 3 06:23:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janne Grunau X-Patchwork-Id: 12835046 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 89FEDC433EF for ; Tue, 3 May 2022 06:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=FhL5mWjLKwHfcyJD4OnNPfDy31hNrDLoe0Td8i8j1QQ=; b=PSz4EioJnswQHX snJEUnpCq2iaTBWa7spL38GBfl2/d31aDYcg/IKoEXU6fnnl69Th9bfh9eYBS9sLUnuIJqPQzuRFa xFozgYpFWBrTWjNJC9y/FFS34mLxNcHxZLh7UnDQ8d+H+EQdmSDicAEOP/xczUP8g5fdqGFY1rYPQ Z7PBsuJ4LsI4LiUYrVPsvOxNywN4dEYy22UzyqBhBgIY9nIEvf5Yu3Evqb1UdiWBQ1PDF6LQdiOyf fIruO3gG7+LdF/oVnTDUn+qr8W3Qa2u9K54gluV7oUShai4sA7BTVSF/2xGCFexP//eFUPBCrvr7j yxFbmiEZCCNY72UxjFgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nllwg-003xAC-IS; Tue, 03 May 2022 06:23:38 +0000 Received: from soltyk.jannau.net ([144.76.91.90]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nllwC-003wyz-7r for linux-arm-kernel@lists.infradead.org; Tue, 03 May 2022 06:23:11 +0000 Received: from coburn.home.jannau.net (p579ad988.dip0.t-ipconnect.de [87.154.217.136]) by soltyk.jannau.net (Postfix) with ESMTPSA id 30E1126E9B7; Tue, 3 May 2022 08:23:04 +0200 (CEST) From: Janne Grunau To: iommu@lists.linux-foundation.org Cc: Sven Peter , Alyssa Rosenzweig , Hector Martin , Mark Kettenis , Joerg Roedel , Will Deacon , Rob Herring , Robin Murphy , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 4/4] iommu: dart: Support t6000 variant Date: Tue, 3 May 2022 08:23:01 +0200 Message-Id: <20220503062301.20872-5-j@jannau.net> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220503062301.20872-1-j@jannau.net> References: <20220503062301.20872-1-j@jannau.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220502_232308_894148_F5F8416A X-CRM114-Status: GOOD ( 15.46 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Sven Peter The M1 Pro/Max/Ultra SoCs come with a new variant of DART which supports a larger physical address space with a different PTE format. Pass through the correct paddr address space size and the PTE format to the io-pgtable code which will take care of the rest. Signed-off-by: Sven Peter Co-developed-by: Janne Grunau Signed-off-by: Janne Grunau --- Changes since v1: - use APPLE_DART PTE format for dart-t6000 --- drivers/iommu/apple-dart.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index decafb07ad08..fe0dedd67fd8 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -81,10 +81,16 @@ #define DART_TTBR_VALID BIT(31) #define DART_TTBR_SHIFT 12 +struct apple_dart_hw { + u32 oas; + enum io_pgtable_fmt fmt; +}; + /* * Private structure associated with each DART device. * * @dev: device struct + * @hw: SoC-specific hardware data * @regs: mapped MMIO region * @irq: interrupt number, can be shared with other DARTs * @clks: clocks associated with this DART @@ -98,6 +104,7 @@ */ struct apple_dart { struct device *dev; + const struct apple_dart_hw *hw; void __iomem *regs; @@ -421,13 +428,13 @@ static int apple_dart_finalize_domain(struct iommu_domain *domain, pgtbl_cfg = (struct io_pgtable_cfg){ .pgsize_bitmap = dart->pgsize, .ias = 32, - .oas = 36, + .oas = dart->hw->oas, .coherent_walk = 1, .iommu_dev = dart->dev, }; dart_domain->pgtbl_ops = - alloc_io_pgtable_ops(APPLE_DART, &pgtbl_cfg, domain); + alloc_io_pgtable_ops(dart->hw->fmt, &pgtbl_cfg, domain); if (!dart_domain->pgtbl_ops) { ret = -ENOMEM; goto done; @@ -857,6 +864,7 @@ static int apple_dart_probe(struct platform_device *pdev) return -ENOMEM; dart->dev = dev; + dart->hw = of_device_get_match_data(dev); spin_lock_init(&dart->lock); res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -946,8 +954,18 @@ static int apple_dart_remove(struct platform_device *pdev) return 0; } +static const struct apple_dart_hw apple_dart_hw_t8103 = { + .oas = 36, + .fmt = APPLE_DART, +}; +static const struct apple_dart_hw apple_dart_hw_t6000 = { + .oas = 42, + .fmt = APPLE_DART2, +}; + static const struct of_device_id apple_dart_of_match[] = { - { .compatible = "apple,t8103-dart", .data = NULL }, + { .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 }, + { .compatible = "apple,t6000-dart", .data = &apple_dart_hw_t6000 }, {}, }; MODULE_DEVICE_TABLE(of, apple_dart_of_match);