From patchwork Wed Sep 27 13:32:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 114372 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp5050654qgf; Wed, 27 Sep 2017 06:35:28 -0700 (PDT) X-Google-Smtp-Source: AOwi7QBIxVKgUpxbRWu6tjHIl8fdcPehXdTtgPpp3tj8/1KwOqMeR2qfNLQPj1EQkg0jwFggtqpL X-Received: by 10.98.236.17 with SMTP id k17mr1379565pfh.191.1506519328702; Wed, 27 Sep 2017 06:35:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1506519328; cv=none; d=google.com; s=arc-20160816; b=pvo16Ja9Hq6YGK1gvz4tm7GZQh7uVIIWmsbGyTeypZxnXgJLi4oRyBTGWOiXcogf98 h8vkXgxbGsfjPp7Bcoyk8J2B4cR/asU/iHTq5kUBGWIu+06khJUCI/dCPOSFs1CCCE8+ kaONcVME7JpMOr86b2CAI6RQwfQVTyw3g2dUNz+FRRSUq42zzfFOoO3flUGQTNZi+Stx /MasGU/BIPIkUqmDo6zd3EQ1GKjGtvIAEPSjJ9DP4wr0wsdr2sK7SGmgaylFVxpqZPOo bj0FzNuRFJYtO7s2mLjzvxlAfH3imGsY8MZg1KqQ1JagGr5shiLXlORk8MKHacX6D+aI N0pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=ZAFUJV/JskuWjjMWKykUZ3a/fyD41ekBoyXbE8o9PLc=; b=baOsFy5vO7GPBUB4rAXNRMdrGAWf3xg4/UzXJRgQeOfYBj8PVv54E5iteQsTDTod51 dR/VUEH0UeoCrzfARzIXBjXmMtnpagk+USkYwoZO6Rp0mjb36/Wp7z5P1Ycso7xRDAh4 F8lY0RyZIqDNWZqPgJYcK5eZP2lswiXJmRgwlcMGt0I7UslmV1sXFbNKwbmWl4g2pNlK Rr6o00hAwLxyj+xvXbqq7LaXXURoy+rg0vZ9YIy5exFM7tJqpgLBw4qhNpFJaQzO1hso PZ9K0TsGpiiEVbluBglZwp6VovPBmqnL0+uXFUOqsZq7OGwywYgelRiaGzirpj57ZZhK S5Hw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u9si7660961pge.139.2017.09.27.06.35.28; Wed, 27 Sep 2017 06:35:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752845AbdI0Nf1 (ORCPT + 7 others); Wed, 27 Sep 2017 09:35:27 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7450 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751959AbdI0Nf1 (ORCPT ); Wed, 27 Sep 2017 09:35:27 -0400 Received: from 172.30.72.59 (EHLO DGGEMS401-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIB16869; Wed, 27 Sep 2017 21:35:21 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.203.177.212) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.301.0; Wed, 27 Sep 2017 21:35:14 +0800 From: Shameer Kolothum To: , , , , , , , CC: , , , , , , , , , , Shameer Kolothum Subject: [PATCH v8 4/5] iommu/dma: Add a helper function to reserve HW MSI address regions for IOMMU drivers Date: Wed, 27 Sep 2017 14:32:40 +0100 Message-ID: <20170927133241.21036-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170927133241.21036-1-shameerali.kolothum.thodi@huawei.com> References: <20170927133241.21036-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.203.177.212] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.59CBA919.0131, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: a2e0ebeb286de661b7de6e2805547181 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org IOMMU drivers can use this to implement their .get_resv_regions callback for HW MSI specific reservations(e.g. ARM GICv3 ITS MSI region). Signed-off-by: Shameer Kolothum [John: added DT support] Signed-off-by: John Garry --- drivers/iommu/dma-iommu.c | 19 +++++++++++++++++++ include/linux/dma-iommu.h | 7 +++++++ 2 files changed, 26 insertions(+) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 9d1cebe..f8709a2 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -19,6 +19,7 @@ * along with this program. If not, see . */ +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +200,23 @@ void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list) } EXPORT_SYMBOL(iommu_dma_get_resv_regions); +/** + * iommu_dma_get_msi_resv_regions - Reserved region driver helper + * @dev: Device from iommu_get_resv_regions() + * @list: Reserved region list from iommu_get_resv_regions() + * + * IOMMU drivers can use this to implement their .get_resv_regions + * callback for HW MSI specific reservations. + */ +int iommu_dma_get_msi_resv_regions(struct device *dev, struct list_head *list) +{ + if (is_of_node(dev->iommu_fwspec->iommu_fwnode)) + return of_iommu_msi_get_resv_regions(dev, list); + + return iort_iommu_msi_get_resv_regions(dev, list); +} +EXPORT_SYMBOL(iommu_dma_get_msi_resv_regions); + static int cookie_init_hw_msi_region(struct iommu_dma_cookie *cookie, phys_addr_t start, phys_addr_t end) { diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h index 92f2083..6062ef0 100644 --- a/include/linux/dma-iommu.h +++ b/include/linux/dma-iommu.h @@ -74,6 +74,8 @@ void iommu_dma_unmap_resource(struct device *dev, dma_addr_t handle, void iommu_dma_map_msi_msg(int irq, struct msi_msg *msg); void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list); +int iommu_dma_get_msi_resv_regions(struct device *dev, struct list_head *list); + #else struct iommu_domain; @@ -107,6 +109,11 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he { } +static inline int iommu_dma_get_msi_resv_regions(struct device *dev, struct list_head *list) +{ + return -ENODEV; +} + #endif /* CONFIG_IOMMU_DMA */ #endif /* __KERNEL__ */ #endif /* __DMA_IOMMU_H */