From patchwork Wed Nov 17 21:15:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12692990 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69AE1C433F5 for ; Wed, 17 Nov 2021 21:17:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 30B5B61B62 for ; Wed, 17 Nov 2021 21:17:08 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 30B5B61B62 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=epvPnAyUMPTB5uqPq2Wf33iu4wFQR6eUF7caxvMMPYE=; b=EXscRJYhOZMMZ4 Jg6FnaPWmMP09gUblKTjKFvuhKN8J5C5t0SBXdxFrmfTXyclOlz1znRb0KUaZRuaHJtO0/p2c8XUK 3DKtPTnxJQORC1Op6x4dqytj6yhH0wEpt01nqGUn9gvVVDL68hiJnrwYrW531WQ157A6+66V7DiPl NSB7FcWE5dWu8ZF4mqRSTjEJFAn+aoy7cP7QVGR9IPepLGtxmT79i+GMkFdfUlZvFTq2pHSW7ERhy oGXgualJAqLMWGMBtVh5ehLPyseelruzNgFs3hpxaxxFi/wi1u/4XAfW5YN2SKtWS8WR/1YhXctPC wds0JOOIXjxCvQ2yzArw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHI-006Hw8-5N; Wed, 17 Nov 2021 21:15:36 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHD-006HuE-PK for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 21:15:33 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id B07525806CF; Wed, 17 Nov 2021 16:15:27 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 17 Nov 2021 16:15:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=6Npdq0g1uutbB Z9rJk6TgIsiQnFffMQoa5oYcoXUq4Y=; b=loVGdIYH0RXWcIuL8+DFCdvcL9Ytu kWFWTopXKNdJwlCN/9vvounhYbXmDHlKshsvxcS3pQ10iR5efqy/iuyURjo3HbSu 4/4SQA0LczuBpstNXuC3CHtrJ70seY9rwlWOChyyrei2QZNjr7kzALasLowXDBZP iPUw58yiB/34vgvOF3POlYHyEnYxkxwte5vq4RQ90sMCMbxv+llWwIUwKxq+lBok M5oDHiVgXmn58Td1y4f7CjdJEO+B/TAlsXpunyBOVspfxrOnaxvMyYO2wBsnwdlF vmFH/aWqx2YQC4bPfe1ZNV+JlvOiG/zSxtDygbI9sEhS+Zg9LyienDRmg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=6Npdq0g1uutbBZ9rJk6TgIsiQnFffMQoa5oYcoXUq4Y=; b=c62a+hD0 5cXn2bSqK3hK3xmvXKk4kGZ7PJOjNjACG0KRQhN5zRSElF82P63Jsfe8gt0BUb58 S4RAmgchW6JQAIfB8zWZsbLC8sVDWT1BlHgpjdgeZXXQPXKkgPMKax5tTN5Heelp 8NP6vsGPsFPQ8QoQxrUUqeXctcpOujmam362wdDnBXUXaJpKUMpzVcc3zFyXUKxU 91FfQZZSaebV2KMbEvYHamZ/SlE4fO3pkLp6b3s3eowEgequODNdbCp83lpuMOid xy8WysYbfjC4lJP+o3a3kaxdKEeCHrPLCNFg5tqsAP7+vYPh/FckxuDq0RjRqtHa OsrwtKlR+I+vRg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeeggddugedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Nov 2021 16:15:25 -0500 (EST) From: Sven Peter To: iommu@lists.linux-foundation.org, Rob Herring , devicetree@vger.kernel.org Cc: Sven Peter , Joerg Roedel , Will Deacon , Janne Grunau , Hector Martin , Robin Murphy , Alyssa Rosenzweig , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/4] dt-bindings: iommu: dart: add t6000 compatible Date: Wed, 17 Nov 2021 22:15:06 +0100 Message-Id: <20211117211509.28066-2-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211117211509.28066-1-sven@svenpeter.dev> References: <20211117211509.28066-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_131531_999450_F3F037F0 X-CRM114-Status: UNSURE ( 9.72 ) X-CRM114-Notice: Please train this message. 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 The M1 Max/Pro SoCs come with a new DART variant that is incompatible with the previous one. Add a new compatible for those. Signed-off-by: Sven Peter Acked-by: Rob Herring --- Documentation/devicetree/bindings/iommu/apple,dart.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml index 94aa9e9afa59..ca2cbde9f3c9 100644 --- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml +++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml @@ -22,7 +22,9 @@ description: |+ properties: compatible: - const: apple,t8103-dart + enum: + - apple,t8103-dart + - apple,t6000-dart reg: maxItems: 1 From patchwork Wed Nov 17 21:15:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12692992 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B735C433EF for ; Wed, 17 Nov 2021 21:17:20 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6E63B6139F for ; Wed, 17 Nov 2021 21:17:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6E63B6139F Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=zxcaGDUADH6gYA9ujmAEKCoHUUU+FxO7I1VYKGjqfMo=; b=U4V8Nj2GPyr5M6 vHXVa9uDqziNgcPW+S3Fh2Pw1IGM1PKtveyiTX8fXHnzfj2Hp8GeTg05O+U+on2Oaz6HmtZwJoR9b NqlCxF7KkIkReiwTV5nC5hQexyggZn/N3Ae7U/WFClHVsAPHNbRGO8TuBK6Fw/9d5EBKDa4vhILAG 2/5MhIl07Y4F+Qbhsbtia59ApUb+7WtXbGSf1uYlip7ZCnQfoug1sGuL8SoPrevMvk+FsYEBlEeXW XQkS83HDZvhbzbzfpkoa1xdyfO0HXXbJMpb86FIB02qlQ01ngG3hTIh/CH+RiFOc8WEzRHR16TqY8 TrYzHOB/Edvcx/oXMJGQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHf-006I3G-4H; Wed, 17 Nov 2021 21:15:59 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHE-006HuP-N2 for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 21:15:34 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 0D6945806D0; Wed, 17 Nov 2021 16:15:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 17 Nov 2021 16:15:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=wPBXm1hEB0gt3 4jZTLq7duc5h40FbhA9Yj5in8Tpo00=; b=F2QEnSh7HLLmJz1viZ1cWsA7UicA7 SX6lcHbylYTro07UIqm4ni5LevGAViojKswXZtIXWTskxfudYwpUJOPdmHGZBSfH cl9oVUVaR63S6MzMXJndhY8ZkP36aTJcOVfI7I2Ro3j1I7+L5x3O6mEOaLHkLIK6 hs+4Kk4JYIWYuupu1CDpnVqUGy1c7VKIQayM+AokxbDeLao9I4QdZj7AKEI/51lm UnWXi3AjNkoV2ext3XWHhf5zRNReIeYZAW8VUsktJAm6m5E4dffYFcJlJZNKrs7q JUOm15DCgL08/0cF9R2ifFdXGhsVG7KYA/28nAoeeXRtRyX4spJY3TnDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=wPBXm1hEB0gt34jZTLq7duc5h40FbhA9Yj5in8Tpo00=; b=cNK5VYz0 y3f1fiaPuvaRg193CzV90rdNs4a03fEjmgh7wR4cImrGkxlVPZK9r6Hna1BREClu FMRubxTmsD3MuLKfMEvmVgzeQjvcnxG+OhB7zZ7gn0rUYbrSHqEXMDaoh4iv+j7Z NIV1MMUWg1Mwws05GG7sj2a1n0/TsUpULvxy+v+dO/BoDH0cGzeYOZCIUqVDX1LW 8U8BSd6fWPJFi5zbqJ4d+rtfJN6hQoXmuThRTigu0SMaESyzgINl9b9X3Ww0fpTX nx44qttS7VWKIREVUJSSJz4nYgu2JNH1D3fSxswgQVke/VqJtwyHbvTGcXPLoRLu G7qnGzAWqVAO9Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeeggddugedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Nov 2021 16:15:27 -0500 (EST) From: Sven Peter To: iommu@lists.linux-foundation.org, Robin Murphy Cc: Sven Peter , Joerg Roedel , Will Deacon , Rob Herring , Janne Grunau , Hector Martin , Alyssa Rosenzweig , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 2/4] iommu/io-pgtable: Add DART subpage protection support Date: Wed, 17 Nov 2021 22:15:07 +0100 Message-Id: <20211117211509.28066-3-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211117211509.28066-1-sven@svenpeter.dev> References: <20211117211509.28066-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_131532_851086_5DC92C5F X-CRM114-Status: GOOD ( 12.43 ) 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 DART allows to only expose a subpage to the device. While this is an optional feature on the M1 DARTs the new ones present on the Pro/Max models require this field in every PTE. Signed-off-by: Sven Peter --- drivers/iommu/io-pgtable-arm.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index dd9e47189d0d..a8c660b8b3e9 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -10,6 +10,7 @@ #define pr_fmt(fmt) "arm-lpae io-pgtable: " fmt #include +#include #include #include #include @@ -133,6 +134,9 @@ #define APPLE_DART_PTE_PROT_NO_WRITE (1<<7) #define APPLE_DART_PTE_PROT_NO_READ (1<<8) +#define APPLE_DART_PTE_SUBPAGE_START GENMASK_ULL(63, 52) +#define APPLE_DART_PTE_SUBPAGE_END GENMASK_ULL(51, 40) + /* IOPTE accessors */ #define iopte_deref(pte,d) __va(iopte_to_paddr(pte, d)) @@ -273,6 +277,12 @@ static void __arm_lpae_init_pte(struct arm_lpae_io_pgtable *data, else pte |= ARM_LPAE_PTE_TYPE_BLOCK; + if (data->iop.fmt == APPLE_DART) { + /* subpage protection: always allow access to the entire page */ + pte |= FIELD_PREP(APPLE_DART_PTE_SUBPAGE_START, 0); + pte |= FIELD_PREP(APPLE_DART_PTE_SUBPAGE_END, 0xfff); + } + for (i = 0; i < num_entries; i++) ptep[i] = pte | paddr_to_iopte(paddr + i * sz, data); From patchwork Wed Nov 17 21:15:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12692993 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31F5CC433F5 for ; Wed, 17 Nov 2021 21:17:29 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id EE85361B44 for ; Wed, 17 Nov 2021 21:17:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EE85361B44 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=E+Rn7nDKegL9hksALLR49CBGsNh+Q5iBEZKyCT6nycU=; b=eSpqGBlbz9aXw8 njebBMC6/u92HLmXCCTKafZ5shaIVOE7pbPcltjD5TwFDj4MBXcIu2R2cooU8iTrMRiStnsO3rlZ6 bOzpt11M7VrsQFfEsPpAaGkFlc3k8T0OEciIVLppwwqeh8kRgv/zNyMJIuRA32S1zkW6gij/WmGsl yEbmkOkpZCIGS3PxgZSr1toZc4qxiBf/wj74hzHehoNdbKsNgFIKeyQwbN/7xfQAKo6AnnG7ns6Q4 ErZoo2YO28Ar1bRrrTa54a0X3INvis/ncPfdApgr5BpisRlzbzWfi3Cm25jFJMxsjQMMOjvLptwC+ UXT7wBu86dCsBiE3dY2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHp-006I6F-TN; Wed, 17 Nov 2021 21:16:10 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHE-006Huw-Os for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 21:15:34 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 1A2645806D3; Wed, 17 Nov 2021 16:15:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 17 Nov 2021 16:15:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=mT0wnBBvzdwTn WLPC9AuFvDLgJbzDS9nH0+PdHCOPmI=; b=Hyb0PqficAU0VQumZ7+H0pDKZUAVE 5XBlkFfmehx45j9lWRYfguU2Qq4MGmzsJyg6oOirv73l8pvDqmi54LRniooSvJV2 tmX3ptZAbKUMC7uj8qLNlwU0ZmKhSh2UlLcI9eQWGiIdqsslgFlq8I06amiCzv3I AeW4t+YoO+5WZ5WnH5qnxZvtEqZio7XRdX0fpCM/UZEuxA1bugjmrMq1C44VEPmQ nLoAtk4HJJPXrFIA6j6EAxQOipJ18yHEfvS6ZEvUGLZcKri8WjROv5+6D9RdI0sR rHs7dpHP2q706y5+dmvV70ZXpxP+bQZrP/k90GrvNbZjJccT488T+YBBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=mT0wnBBvzdwTnWLPC9AuFvDLgJbzDS9nH0+PdHCOPmI=; b=IsYHOIOK tcYaz1g8U5/xHBRNpZ0o3Qpyu/9ZSb5jAMA24Q4noDL+FkUFpIDv/gVENR8H+ea3 C7G2rV0uR6I/CQLGj6Am9UVAfvsn8o+OnM5d6hRutF/pVLW4d+G6PeXXBRR3zCbs PGSmELjHwOgesGFUeV6VD+p5fgn5h3YNDNZrTEewCvso+xJ4CR0xcuDIhiGnuKA0 OkTkm1joWKxn1Q4jQyLciM/rd5jMdTjWAuhGcv+/o7vuK49CM3dsVwUwGVFUXIhZ cftS61HIIF4sl/WN5l7nVh/PSzxPSUJf/Z9dYJTQs0wJVm1Jl6MDYTG28YLHLB/F 1vzoYElooUz0+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeeggddugedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnhepteejvdehleduvddthfetgeeljeegfeeludetkedtkedvteffvdejhfefvdevtedt necuffhomhgrihhnpegtfhhgrdgrphhplhgvnecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepshhvvghnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Nov 2021 16:15:30 -0500 (EST) From: Sven Peter To: iommu@lists.linux-foundation.org, Robin Murphy Cc: Sven Peter , Joerg Roedel , Will Deacon , Rob Herring , Janne Grunau , Hector Martin , Alyssa Rosenzweig , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] iommu/io-pgtable: Add DART PTE support for t6000 Date: Wed, 17 Nov 2021 22:15:08 +0100 Message-Id: <20211117211509.28066-4-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211117211509.28066-1-sven@svenpeter.dev> References: <20211117211509.28066-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_131532_907635_45F78E46 X-CRM114-Status: GOOD ( 13.96 ) 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 The DARTs present in the M1 Pro/Max SoC support a 42bit physical address space by shifting the paddr and extending its mask inside the PTE. Signed-off-by: Sven Peter --- drivers/iommu/io-pgtable-arm.c | 30 +++++++++++++++++++++++++++++- include/linux/io-pgtable.h | 2 ++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index a8c660b8b3e9..be66774aaf70 100644 --- a/drivers/iommu/io-pgtable-arm.c +++ b/drivers/iommu/io-pgtable-arm.c @@ -137,6 +137,11 @@ #define APPLE_DART_PTE_SUBPAGE_START GENMASK_ULL(63, 52) #define APPLE_DART_PTE_SUBPAGE_END GENMASK_ULL(51, 40) +#define APPLE_DART_PADDR_MASK_PS_36BIT GENMASK_ULL(35, 12) +#define APPLE_DART_PADDR_SHIFT_PS_36BIT (0) +#define APPLE_DART_PADDR_MASK_PS_42BIT GENMASK_ULL(37, 10) +#define APPLE_DART_PADDR_SHIFT_PS_42BIT (4) + /* IOPTE accessors */ #define iopte_deref(pte,d) __va(iopte_to_paddr(pte, d)) @@ -171,6 +176,13 @@ static arm_lpae_iopte paddr_to_iopte(phys_addr_t paddr, { arm_lpae_iopte pte = paddr; + if (data->iop.fmt == APPLE_DART) { + pte = paddr >> data->iop.cfg.apple_dart_cfg.paddr_shift; + pte &= data->iop.cfg.apple_dart_cfg.paddr_mask; + + return pte; + } + /* Of the bits which overlap, either 51:48 or 15:12 are always RES0 */ return (pte | (pte >> (48 - 12))) & ARM_LPAE_PTE_ADDR_MASK; } @@ -180,6 +192,12 @@ static phys_addr_t iopte_to_paddr(arm_lpae_iopte pte, { u64 paddr = pte & ARM_LPAE_PTE_ADDR_MASK; + if (data->iop.fmt == APPLE_DART) { + paddr = pte & data->iop.cfg.apple_dart_cfg.paddr_mask; + paddr <<= data->iop.cfg.apple_dart_cfg.paddr_shift; + return paddr; + } + if (ARM_LPAE_GRANULE(data) < SZ_64K) return paddr; @@ -1122,8 +1140,18 @@ apple_dart_alloc_pgtable(struct io_pgtable_cfg *cfg, void *cookie) struct arm_lpae_io_pgtable *data; int i; - if (cfg->oas > 36) + switch (cfg->oas) { + case 36: + cfg->apple_dart_cfg.paddr_shift = APPLE_DART_PADDR_SHIFT_PS_36BIT; + cfg->apple_dart_cfg.paddr_mask = APPLE_DART_PADDR_MASK_PS_36BIT; + break; + case 42: + cfg->apple_dart_cfg.paddr_shift = APPLE_DART_PADDR_SHIFT_PS_42BIT; + cfg->apple_dart_cfg.paddr_mask = APPLE_DART_PADDR_MASK_PS_42BIT; + break; + default: return NULL; + } data = arm_lpae_alloc_pgtable(cfg); if (!data) diff --git a/include/linux/io-pgtable.h b/include/linux/io-pgtable.h index 86af6f0a00a2..4e26ebb0be93 100644 --- a/include/linux/io-pgtable.h +++ b/include/linux/io-pgtable.h @@ -136,6 +136,8 @@ struct io_pgtable_cfg { struct { u64 ttbr[4]; u32 n_ttbrs; + u32 paddr_shift; + u64 paddr_mask; } apple_dart_cfg; }; }; From patchwork Wed Nov 17 21:15:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Peter X-Patchwork-Id: 12692994 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DA2AC433F5 for ; Wed, 17 Nov 2021 21:17:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6E28F61B44 for ; Wed, 17 Nov 2021 21:17:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6E28F61B44 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=svenpeter.dev Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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=Pc9bCE6yY4U3lT549Xlhd1KY+c9XgJmMvb9iA9WbZZU=; b=hsJbfIEbgsfiKG yAuknNo0mxQeZU33fYrtyUabdY5KDpNvgb7F8OEPXtTt+5gm63Vy9DKkBiWOZ0wf9nL9w8CFQv4qf vFIAQfoW7pZtkjKK+GNNbbL+5nPmPZ6y+ITw9KPboFwGKoKabgJalg8Ys+kxKfZfpjQGMCqf1Te+S MflvMA/fAY1hDP7OaCLTM14YEwt+nLD8N2b0Eim0NWF4yySLhmEMSbILqjM1R0WutviPBu+By0Qjp QFSVVwunKCokyyezyJRJcC4HMFhsPCDrDd5m5D/lJDxINmW8ARf9ng7NKA96f/IUzt1NvPqna7iig JGO4/5rC2CtGkB0MjzNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSI1-006I9L-A0; Wed, 17 Nov 2021 21:16:21 +0000 Received: from new2-smtp.messagingengine.com ([66.111.4.224]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnSHG-006Hw7-Vs for linux-arm-kernel@lists.infradead.org; Wed, 17 Nov 2021 21:15:36 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.nyi.internal (Postfix) with ESMTP id 403315806CC; Wed, 17 Nov 2021 16:15:34 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 17 Nov 2021 16:15:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=RZy5jJe6QukHS cO8gascVhRqt3WsYPfRDs+/HqZFOpA=; b=YJtXE1hmGj34qSjO2WQuEyQ4F8+5s UkH5mJWpoIobxM7vUCc9vSPfUm/m6eMrGprM2H6LcymYwdLz4SFknXzm+mYteVJ3 Cn/XiCa0wtxIe59v5r8Ho0QRdLeMalYq8IpAv4hLWAUWYEUJlWXDKOMWgGY88iKh grWhApXgc1uf0g/dlAlOeLgD2gpuBlO8QvmjfuJeiz2ZmVouO9Gt/PmsellU4VmK dyFJPEnV3Vor91HN0OOpARdTuxqFIamtKks50K5aL0iZ+xJRutdxmG82UzQhSfn1 lNKQbbh6G95v0aAmkGU9CwG6z4U9pgVwdeE8muWiUvAMHxguFk5vNrXeQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=RZy5jJe6QukHScO8gascVhRqt3WsYPfRDs+/HqZFOpA=; b=a1rJLphZ 0RUNMQKrBvu8DOFqUxD5MrSeEmXZjn/A+QMfSyti8rMgQXKnUNjQQtPzAX36UnWM t17bK8yagNVfgTEbCjrAi1PgVIHl0i6j2sJvda3F+eAS2ViTqOcJ6bePuKAl4iCK jRIKzvqB6umoeASgQx1Tqu6WJK22Vgf9ixGncx3bRQnEXENTe9uh1asoiXcfMjo7 Kt18HRQQ6JFwB4QjI5nMhaPv1+4EbTDJSR7NxWROlXQpyJWa/KPPE5H1cuxtUq4/ DybtaqhqdSc855XYRzJG+iFu+DjCxPBPT6sjBZFaXOvv7Mq7JSaZSbVXn1KJY/X3 ZWT/utmEpRF6cA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeeggddugedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefuvhgvnhcu rfgvthgvrhcuoehsvhgvnhesshhvvghnphgvthgvrhdruggvvheqnecuggftrfgrthhtvg hrnheptedvkeetleeuffffhfekteetffeggffgveehieelueefvddtueffveevlefhfeej necuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepshhvvg hnsehsvhgvnhhpvghtvghrrdguvghv X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 17 Nov 2021 16:15:32 -0500 (EST) From: Sven Peter To: iommu@lists.linux-foundation.org Cc: Sven Peter , Joerg Roedel , Will Deacon , Rob Herring , Janne Grunau , Hector Martin , Robin Murphy , Alyssa Rosenzweig , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 4/4] iommu: dart: Support t6000 variant Date: Wed, 17 Nov 2021 22:15:09 +0100 Message-Id: <20211117211509.28066-5-sven@svenpeter.dev> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20211117211509.28066-1-sven@svenpeter.dev> References: <20211117211509.28066-1-sven@svenpeter.dev> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211117_131535_174940_CB98430A X-CRM114-Status: GOOD ( 14.11 ) 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 The M1 Pro/Max SoCs come with a new variant of DART which supports a larger physical address space with a slightly different PTE format. Pass through the correct paddr address space size to the io-pgtable code which will take care of the rest. Signed-off-by: Sven Peter --- drivers/iommu/apple-dart.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 565ef5598811..c04648dfd747 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -81,10 +81,15 @@ #define DART_TTBR_VALID BIT(31) #define DART_TTBR_SHIFT 12 +struct apple_dart_hw { + u32 oas; +}; + /* * 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 +103,7 @@ */ struct apple_dart { struct device *dev; + const struct apple_dart_hw *hw; void __iomem *regs; @@ -421,7 +427,7 @@ 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, }; @@ -855,6 +861,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); @@ -944,8 +951,16 @@ static int apple_dart_remove(struct platform_device *pdev) return 0; } +static const struct apple_dart_hw apple_dart_hw_t8103 = { + .oas = 36, +}; +static const struct apple_dart_hw apple_dart_hw_t6000 = { + .oas = 42, +}; + 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);