From patchwork Sun Mar 28 07:40: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: 410675 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83A32C433E0 for ; Sun, 28 Mar 2021 07:41:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B4C2619A0 for ; Sun, 28 Mar 2021 07:41:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229647AbhC1HlM (ORCPT ); Sun, 28 Mar 2021 03:41:12 -0400 Received: from new2-smtp.messagingengine.com ([66.111.4.224]:58063 "EHLO new2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbhC1Hke (ORCPT ); Sun, 28 Mar 2021 03:40:34 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.nyi.internal (Postfix) with ESMTP id BBA45580830; Sun, 28 Mar 2021 03:40:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Sun, 28 Mar 2021 03:40:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=svenpeter.dev; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm1; bh=MI94jwmE2zLqhfN/R9l+Jdqfny JcLTSsv9uX8W7RVRE=; b=ssuZv+AFrzSuDD41TBt4dn2cF94qJZKbByHwNkWB8U 0MDHj9gb+fzYfS7q0BEUsRFqeoLm910DZH0xfd7YADc3RhgZjDCG2v2raUxMU/fR j04JbluAfqKyQHB0S+PqshL+nZgbYZ6gF/JXAqN1iSKNFnx2pctngaUzizgCnWS/ hZlNULm3Jsg2CZAfy/TGumBaUcUg+vnhZpnT7qkLjBsx8Q+l5P9jbqt8RuE0WLay CthyAiIa6be75L+rQDQqY33LQ2K1tFtc6ejsFNKtrZorU/HnyMaFTmZhAsKUa13K j29mv95y2Zs7gDzuqX1hHDAaGsnauNmRapc5fFrfl5Kg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=MI94jwmE2zLqhfN/R 9l+JdqfnyJcLTSsv9uX8W7RVRE=; b=ENkFBFRf0FHBKM5TXCf9p+OXBY87FTrZU IkEXDP7nbhhphIwE5P8tj/yEOldBFtrfx7DBm2Jwbh4XKfK2yGPL1tFR5hJQIiQc 5m+UIvJr0Jd3cK73W4djH6NpsiMMBHZrvSRm57ZiZwetKJzm8LQGAorc1WVz2oHj BdMly1dGvQRSzjrCTtB9puhe80vcx2Qmbg0j/ZtqlId9idkp3OfDMALyQkODerUV VwzxOfbWP3hOosl9CgxILNbNPhIdkEMa46jAJ2Ib89yPHnxI4mIgYSp+a8A+FxEg wbkRQOycolY4yNOc7gtYqJgFxzmyTpNSP8euXrmJh6rCESLCIUtPQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudehhedguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgggfestdekredtredttdenucfhrhhomhepufhvvghnucfr vghtvghruceoshhvvghnsehsvhgvnhhpvghtvghrrdguvghvqeenucggtffrrghtthgvrh hnpeeiueeljedutdfgvdegleekjeetveehffdvudefteeklefhgffgkeeljeevheelhfen ucffohhmrghinhepkhgvrhhnvghlrdhorhhgpdhgihhthhhusgdrtghomhenucfkphepud ejiedrudelledrvddutddrudehieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehsvhgvnhesshhvvghnphgvthgvrhdruggvvh X-ME-Proxy: Received: from localhost.localdomain (ip-176-199-210-156.hsi06.unitymediagroup.de [176.199.210.156]) by mail.messagingengine.com (Postfix) with ESMTPA id 41B0624005A; Sun, 28 Mar 2021 03:40:29 -0400 (EDT) From: Sven Peter To: Will Deacon , Robin Murphy , Joerg Roedel , Rob Herring Cc: Sven Peter , Arnd Bergmann , devicetree@vger.kernel.org, Hector Martin , linux-kernel@vger.kernel.org, Marc Zyngier , Mohamed Mediouni , Stan Skowronek , linux-arm-kernel@lists.infradead.org, Mark Kettenis , iommu@lists.linux-foundation.org Subject: [PATCH v2 0/3] Apple M1 DART IOMMU driver Date: Sun, 28 Mar 2021 09:40:06 +0200 Message-Id: <20210328074009.95932-1-sven@svenpeter.dev> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Hi, Here's v2 of my Apple M1 DART IOMMU driver series as a follow up to the original version [1]. Short summary: this series adds support for the iommu found in Apple's new M1 SoC which is required to use DMA on most peripherals. So far this code has been tested with dwc3 in host and device mode on a M1 Mac Mini on top of the latest version of Hector's bringup series [2,3] together with my m1n1 bootloader branch to bring up USB [4]. It will also apply (but not be very useful) on top of iommu/next and v5.12-rc3. Thanks everyone for the suggestions and discussions so far. I believe they have already significantly improved the state of this driver and our understanding of the DART iommu! The part I'm most unsure about is the way I keep track of the multiple iommu nodes attached to a device. I would love to especially get some feedback there. Changes for v2: - fixed devicetree binding linting issues pointed out by Rob Herring and reworked that file. - made DART-specific code in io-pgtable.c unconditional and removed flag from Kconfig as proposed by Robin Murphy. - allowed multiple DART nodes in the "iommus" property as proposed by Rob Herring and Robin Murphy. this resulted in significant changes to apple-iommu-dart.c. - the domain aperture is now forced to 32bit if translation is enabled after the original suggestion to limit the aperture by Mark Kettenis and the follow-up discussion and investigation with Mark Kettenis, Arnd Bergmann, Robin Murphy and Rob Herring. This change also simplified the code in io-pgtable.c and made some of the improvements suggested during review not apply anymore. - added support for bypassed and isolated domain modes. - reject IOMMU_MMIO and IOMMU_NOEXEC since it's unknown how to set these up for now or if the hardware even supports these flags. - renamed some registers to be less confusing (mainly s/DOMAIN/STREAM/ to prevent confusion with linux's iommu domain concept). I have also fixed my email provider so this time the series should actually be a single thread and not contain any HTML by accident anymore... Best, Sven [1] https://lore.kernel.org/linux-iommu/20210320151903.60759-1-sven@svenpeter.dev/ [2] https://lore.kernel.org/linux-arch/20210304213902.83903-1-marcan@marcan.st/ [3] https://github.com/AsahiLinux/linux/tree/upstream-bringup-v4 [4] https://github.com/svenpeter42/m1n1/tree/usb-dwc3-serial-wip Sven Peter (3): iommu: io-pgtable: add DART pagetable format dt-bindings: iommu: add DART iommu bindings iommu: dart: Add DART iommu driver .../devicetree/bindings/iommu/apple,dart.yaml | 81 ++ MAINTAINERS | 7 + drivers/iommu/Kconfig | 14 + drivers/iommu/Makefile | 1 + drivers/iommu/apple-dart-iommu.c | 858 ++++++++++++++++++ drivers/iommu/io-pgtable-arm.c | 59 ++ drivers/iommu/io-pgtable.c | 1 + include/linux/io-pgtable.h | 6 + 8 files changed, 1027 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/apple,dart.yaml create mode 100644 drivers/iommu/apple-dart-iommu.c