From patchwork Wed Aug 9 10:07:14 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: 109700 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp646443qge; Wed, 9 Aug 2017 03:08:55 -0700 (PDT) X-Received: by 10.98.89.66 with SMTP id n63mr7522143pfb.137.1502273335161; Wed, 09 Aug 2017 03:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502273335; cv=none; d=google.com; s=arc-20160816; b=gxUhhIBfN0bKZ/Jzo9wkoM4+dvIhHmmwRDL/7CdbEEYpkOWdE/tylNVA6QTroq1yNa o0gh6jbkwjb6CBZIHM8WrrjmpsPnrMUga3dy+8bUqFAmaTSU+EV+hrjPvove0t6BDNd4 6z4DILDxX3Fa+mavs1BXOzDnBdRqQm/EudIIBPAZVnMpbTx4R67Ey38uCuLz41vGS6P/ QzmJxRWvDPIaFP8Yr94va5hamAXxfuAdZ0tUzAY4fK8QE+5Pv8v2C39W0KeE3mHdLR0X HiwWa84mI11sadTkau45/6NhfrDgm3b0j4DEtrJ32ZcfdYddHPD2Hnm7wdxeXsa14JeB +S2g== 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=3TBYFP9z5+9ebCsjZY1cYmzJja1apwJqmdgVWE53spM=; b=Eoom6RNBsrj/9cPnDtJOBhXqY2XAHQKK8zyhc5W3l9HLbVfEKGrMasifEB0S9gpi54 6r9CHMfBi6K4fYKljOcgSTs//Q75FMgY6FFI2lh5KVEmgSA1UjPRL0aYoucaMwaWAmXU /nik8vtXPrEOJGuP1+GZwMbqiKvcvcr8fMuGJJC/zDAgtHMBy6W99NSWcSLQVVEPUkTO ZIcO8t04T4bEMhcFi308Ex+aZEekSK1OgXTa/zUVqOCNe4v7rV2d8OzOJtIsBy9LjPHC r6kn86SyM9aMOR88aAfRQJSOurYUI/GfH4D+oUOcVAADYvXkuUa+G2L6aLQcTutOPvqn RaiQ== 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 v7si2201572pgb.858.2017.08.09.03.08.55; Wed, 09 Aug 2017 03:08:55 -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 S1752839AbdHIKIx (ORCPT + 7 others); Wed, 9 Aug 2017 06:08:53 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3478 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752991AbdHIKIw (ORCPT ); Wed, 9 Aug 2017 06:08:52 -0400 Received: from 172.30.72.58 (EHLO DGGEMS414-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DEU02374; Wed, 09 Aug 2017 18:08:49 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.203.177.212) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.301.0; Wed, 9 Aug 2017 18:08:38 +0800 From: Shameer Kolothum To: , , , , , CC: , , , , , , , , , Shameer Kolothum Subject: [PATCH v6 2/3] iommu/dma: Add a helper function to reserve HW MSI address regions for IOMMU drivers Date: Wed, 9 Aug 2017 11:07:14 +0100 Message-ID: <20170809100715.870516-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20170809100715.870516-1-shameerali.kolothum.thodi@huawei.com> References: <20170809100715.870516-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.0A010202.598ADF32.000D, 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: 85f986704d28e17d6a881cce5807dd13 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 --- 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..952ecdd 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 @@ -198,6 +199,24 @@ 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. For now, this only + * covers ITS MSI region reservation using ACPI IORT helper function. + */ +int iommu_dma_get_msi_resv_regions(struct device *dev, struct list_head *list) +{ + if (!is_of_node(dev->iommu_fwspec->iommu_fwnode)) + return iort_iommu_its_get_resv_regions(dev, list); + + return -ENODEV; +} +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 */