From patchwork Fri Oct 6 14:04:48 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: 115068 Delivered-To: patch@linaro.org Received: by 10.80.163.170 with SMTP id s39csp1411029edb; Fri, 6 Oct 2017 07:08:02 -0700 (PDT) X-Google-Smtp-Source: AOwi7QC9dWfeiKDtRxvUpzpoSlV9Rm84uTdP3j9kPKrh30TcfaO0yvgm+L1KfemXnRoPwaFUBzFC X-Received: by 10.98.48.65 with SMTP id w62mr2349450pfw.91.1507298882767; Fri, 06 Oct 2017 07:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507298882; cv=none; d=google.com; s=arc-20160816; b=rr7AT01WMcqBVIE4fK+rig0ysmF0KfQoqhzl5bNVEnKPkpbCrCtheZFsmiOa6B2xmB +eLAIKtAGQd6wtkBFgjPoF6aN9rwMrudljNdWBT66Ddqo35DwydG+zFN7QRvIANWtOOs wl33mb1iUNAS3NTdhW+10xG15nClOktaxRDRjy4KBzJGeFHvZE+Or5giTWrpPucG6Abe SLpzzHAqHqyilSjH5H3LDVguvallSFsv3lGBRCj7RSGDyMpt04lZK9BKG68HaqUn8IsD MClT6cgjp4p3+ypWX1uVIrhhtCmjj6xtNy5AbN0g2RLUpZgBvoZWnv8WYC2+hwNxvEjx ZfEg== 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=90NCsH1553NAEej2SLF3aW35aSV1oVht+b3gzu3janE=; b=trnOfzdLgF+V6ndI2wT3RvHXa4+vEIrYm7WkSbaPPuzg44kqCHfCiOM7SVsgJnaD3L sABXSmmnEt4bDL35lB5QG39fyem35BUyKZmqDUks5lUqvh3t1sRtb0zX/jNIvoq0Nfra 2lVth3OQEcQgIiDKXbyefo61/oQpG+knIgAeBuLdO2sppS8r8uWSh5rN40bzKfJgPCDD g+LWMD6PGY4qcp4Qt549KAhqQRaYOtNjYvrGwoPQ83JwhHfa6tJHlkwa4WhndyBbQAWV uo+CfeTW+9yZVQm7h+IkyoC5QLaICDvTYPJwvAKyYWy0yHjdcQr18zlbJf3S5DABZPdj 33sA== 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 r145si1303201pfr.567.2017.10.06.07.08.02; Fri, 06 Oct 2017 07:08:02 -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 S1751866AbdJFOIA (ORCPT + 7 others); Fri, 6 Oct 2017 10:08:00 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7500 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751755AbdJFOH7 (ORCPT ); Fri, 6 Oct 2017 10:07:59 -0400 Received: from 172.30.72.58 (EHLO DGGEMS403-HUB.china.huawei.com) ([172.30.72.58]) by dggrg04-dlp.huawei.com (MOS 4.4.6-GA FastPath queued) with ESMTP id DIO33388; Fri, 06 Oct 2017 22:07:53 +0800 (CST) Received: from S00345302A-PC.china.huawei.com (10.202.227.237) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.301.0; Fri, 6 Oct 2017 22:07:26 +0800 From: Shameer Kolothum To: , , , , , , , CC: , , , , , , , , , Shameer Kolothum Subject: [PATCH v9 2/4] iommu/dma: Add a helper function to reserve HW MSI address regions for IOMMU drivers Date: Fri, 6 Oct 2017 15:04:48 +0100 Message-ID: <20171006140450.89652-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20171006140450.89652-1-shameerali.kolothum.thodi@huawei.com> References: <20171006140450.89652-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.202.227.237] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090201.59D78E39.0312, 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: ccee44145571a8a2311c8cc4b0d93011 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 | 20 ++++++++++++++++++++ include/linux/dma-iommu.h | 7 +++++++ 2 files changed, 27 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..bae677e 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,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_msi_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 */