From patchwork Thu Sep 14 12:57:55 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: 112555 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp714732qgf; Thu, 14 Sep 2017 06:00:59 -0700 (PDT) X-Google-Smtp-Source: ADKCNb4d1MK3mS2jQ9dKsWsGqqY7+k2tzOYYs1RqW5uZRtVPAOXqwU8xOGBSR8OgBfbH+SxrKrHg X-Received: by 10.98.158.26 with SMTP id s26mr20710610pfd.284.1505394058965; Thu, 14 Sep 2017 06:00:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505394058; cv=none; d=google.com; s=arc-20160816; b=rFKf+W1L2zdMT9JdMxzvNQKRsz+Ap7FJbSWGbgLi80peOaOAItWqTydClXy2O7RUDx oM02NpowKw/Z7EYg+gSecYB9eH5beRNLo9cQkOG2+WMZkQEJmBrnqr3t0D0JR/C9ZTG1 hvDbK9shrDawkNkKJ/eX1tENEUtOxcfTvi8lguOBA+J8R/R1OTUPm2eelSO0/dHcqpdm 6CXtnHGXaW9HQHsn2YCkMpMKXIEGYBp+K1VQQiu4ridS4gc+GLJTSx9eeibgiI96aJ0X 351myvQJ7RAUQV0Qnx5AZfSqeApecwnc0BZW984jPwuxAgJIMF+GZzNhlnfLJqEbLEuW YoyA== 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=Sn/OZrn9QWe9KSs2wWcRA5lEvPUrdMrXYxpPPAmOK4A=; b=dR+icTTLpapjXwY/P6VxxYSvD41KCfQrWh17a5EG3fzwj2ZhRlAwA+gsoP4ap2pZA8 9Qv9yKiLZwFkVIetLoLvAzWhimXhoDXA+pMIZSTSPM5u0dibh3cAc8aA05aitTLD2zpr aWCMCBuA8M+ZOSNiC4+K4uzW4ZAPZ0lOSbvtz5p9SnPJIyIpStR9lfOlBIVguXeLmTsF exfIjm6H0yuf9igmMgh81NU8Y3dEIrRqoGFcY8nhLYsUExJMPEQlShCh/EVnZ3wxe5jR drONqSCiVyoR0qlWEZbG7oyQbEcsoY9SUA4WpmsrLiMgpWjp61kZ0TDOjjfKBB9bXYOV JvpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-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 e92si12526571plk.739.2017.09.14.06.00.58; Thu, 14 Sep 2017 06:00:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751352AbdINNA5 (ORCPT + 6 others); Thu, 14 Sep 2017 09:00:57 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6479 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751318AbdINNA4 (ORCPT ); Thu, 14 Sep 2017 09:00:56 -0400 Received: from 172.30.72.59 (EHLO DGGEMS413-HUB.china.huawei.com) ([172.30.72.59]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DHF34346; Thu, 14 Sep 2017 21:00:54 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.212.247.163) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.301.0; Thu, 14 Sep 2017 21:00:47 +0800 From: Shameer Kolothum To: , , , , , , , CC: , , , , , , , , , , Shameer Kolothum Subject: [PATCH v7 4/5] iommu/dma: Add a helper function to reserve HW MSI address regions for IOMMU drivers Date: Thu, 14 Sep 2017 13:57:55 +0100 Message-ID: <20170914125756.14836-5-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170914125756.14836-1-shameerali.kolothum.thodi@huawei.com> References: <20170914125756.14836-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.212.247.163] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090205.59BA7D86.0116, 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: ad2e8d7bb81a8ce18279d6c843ef64eb Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 devicetree" 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 */