From patchwork Thu Nov 12 12:55:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 11900137 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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=no 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 D341AC63798 for ; Thu, 12 Nov 2020 13:03:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 5CE6921D7F for ; Thu, 12 Nov 2020 13:03:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ItWm5dN/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="UphNYMQS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5CE6921D7F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=wCY5us2P1+08Un0+c5/5gR5Kh8xys3roHI4+OtBG4kw=; b=ItWm5dN/NLRPmwlF3BNMKRdbSy /3AZ1fNvkC1LC03l1YT/NO1uo9fi8l2HfVerwzIgeebsrEvj5igxBrLDVRRd8mjWfp06yKIRO/uSK 7bxXjHjH195lF+WXJdomfmD5BqcJIqQTyOCyRenlWMRQxv1ieyxy1kaLWbbzwEFYKSHfQ00pTvjQt H+qDWk9ngFmOvNgLKjBqmNvCS+Cf7FTB32o1RiKm1+ohC9dk3xdDs85dznppamQ2Xdg8HJlDQoO/8 spwrVz5ZkyPrclRzcPDeCcYdpDlmG40vqOrV6BbUeqkt4C1ESKL2P9YYNdbGUw0opYoewNMbvKypZ jtAKZ01A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdCG1-0006YB-Nf; Thu, 12 Nov 2020 13:03:21 +0000 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdCFx-0006WK-02 for linux-arm-kernel@lists.infradead.org; Thu, 12 Nov 2020 13:03:18 +0000 Received: by mail-wr1-x442.google.com with SMTP id b8so5942072wrn.0 for ; Thu, 12 Nov 2020 05:03:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XoAG1pru+t0E0RGbZFAgVVNe78IlOrfO4ZdEb2/m39k=; b=UphNYMQS/LN28Yxb1McSQM05xn0X1V0x7rJ0PnNKfQvzO7zSoSBhZ9CLBwJKzAgh16 17BMyTB6gytjqNUMMUrH82FFJY2PEIruw0bKT5P4mlmuWOAislyFW6xOumTDMAcADDJ/ 3I+1KO/GAtkaunGBQ3cAe+TPQ8lRQuZK1Uk3iHPKADw+iRsHWUINdXk0j0p0aLmHWSQD Lar/biWGCcmxYMOxn5/aO0uFOlgWdelEDWUgUAG103fCjfzlpWK4j4svUJKEmpdBgdzE qnbdv6qFgKnizUAGgssYpzF9v1UwcuGMLi2IRXc/YY0k9b1cqi77VreSmTVMP/3andg7 tthQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XoAG1pru+t0E0RGbZFAgVVNe78IlOrfO4ZdEb2/m39k=; b=QDONJUNxInGAqqdMPEDBFWGeHElGEaMozeXx0rLNQvk5Y1IR6BarOuTaNMB2FUC6xp 3K4qn2oQnC7RnYQ36xqvNNJVtz12RuTVv3DN/VUI2JJ9lFImyOku90fWIML9eYEvbGcO 4xopNy4J/gOjICdPxi/Skg9xwV4DOnPf5RW9aTlYe2bfASq45nCGOOpmuXMRW/fnOfqA CqYUdkpvBGgNQw1EnlD3k0a+CREY1oApNrOEJZaiwInPQDZ8Yy3t3vSdd71g6X/0ENC6 RpTNIjhQ2u4Ls9oL34vmfCmMMsQZtkbnMn55pNev3ha/vJQNSdrObXUZnlVYzc8biy0p ppdw== X-Gm-Message-State: AOAM53249yrAURxEdn53+URFIXKwrozeSsJ8UCZBXHzF6nHDaQqjEu3t U2NJaPfc/X5C21FKwgo0aMbM7w== X-Google-Smtp-Source: ABdhPJxMBUohVh2fAAvMFdY17a6lP3nz140iaaxKiNjcDkvE3A2fsz0yM/aFafAdvuPkFa1NZKXESQ== X-Received: by 2002:adf:ce87:: with SMTP id r7mr4434152wrn.212.1605186194089; Thu, 12 Nov 2020 05:03:14 -0800 (PST) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id m22sm6877508wrb.97.2020.11.12.05.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Nov 2020 05:03:13 -0800 (PST) From: Jean-Philippe Brucker To: joro@8bytes.org, will@kernel.org, lorenzo.pieralisi@arm.com, robh+dt@kernel.org Subject: [PATCH v8 0/9] iommu: I/O page faults for SMMUv3 Date: Thu, 12 Nov 2020 13:55:12 +0100 Message-Id: <20201112125519.3987595-1-jean-philippe@linaro.org> X-Mailer: git-send-email 2.29.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201112_080317_074056_5A411E16 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, guohanjun@huawei.com, rjw@rjwysocki.net, shameerali.kolothum.thodi@huawei.com, eric.auger@redhat.com, iommu@lists.linux-foundation.org, Jonathan.Cameron@huawei.com, sudeep.holla@arm.com, bhelgaas@google.com, zhangfei.gao@linaro.org, vivek.gautam@arm.com, baolu.lu@linux.intel.com, robin.murphy@arm.com, Jean-Philippe Brucker , linux-arm-kernel@lists.infradead.org, lenb@kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add support for stall and PRI to the SMMUv3 driver, along with a common I/O Page Fault handler. These patches were last sent as part of v7 of the larger SVA series [1]. Main changes since v7: * Dropped CONFIG_IOMMU_PAGE_FAULT, reuse CONFIG_IOMMU_SVA_LIB instead. * Extracted devicetree support into patch 4. * Added patch 5 for ACPI support. * Dropped event queue flush on unbind(). Since device drivers must complete DMA transactions before calling unbind(), there cannot be any pending stalled event. * A few small fixes. The series depends on "iommu/sva: Add PASID helpers" [2], since it provides the function to search an mm_struct by PASID. Has anyone been testing the PRI patches on hardware? I still only have a software model to test them, so as much as I'd like to cross this off my list, we could leave out patches 7-9 for now. [1] https://lore.kernel.org/linux-iommu/20200519175502.2504091-1-jean-philippe@linaro.org/ [2] https://lore.kernel.org/linux-iommu/20201106155048.997886-1-jean-philippe@linaro.org/ Jean-Philippe Brucker (9): iommu: Add a page fault handler iommu/arm-smmu-v3: Maintain a SID->device structure dt-bindings: document stall property for IOMMU masters of/iommu: Support dma-can-stall property ACPI/IORT: Enable stall support for platform devices iommu/arm-smmu-v3: Add stall support for platform devices PCI/ATS: Add PRI stubs PCI/ATS: Export PRI functions iommu/arm-smmu-v3: Add support for PRI drivers/iommu/Makefile | 1 + .../devicetree/bindings/iommu/iommu.txt | 18 + drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 69 +- drivers/iommu/iommu-sva-lib.h | 53 ++ include/linux/iommu.h | 4 + include/linux/pci-ats.h | 7 + drivers/acpi/arm64/iort.c | 1 + .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 52 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 605 +++++++++++++++--- drivers/iommu/io-pgfault.c | 462 +++++++++++++ drivers/iommu/of_iommu.c | 5 +- drivers/pci/ats.c | 4 + 12 files changed, 1191 insertions(+), 90 deletions(-) create mode 100644 drivers/iommu/io-pgfault.c Tested-by: Vivek Gautam