From patchwork Fri Jul 16 08:34:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shameerali Kolothum Thodi X-Patchwork-Id: 478368 Delivered-To: patch@linaro.org Received: by 2002:a02:c94a:0:0:0:0:0 with SMTP id u10csp1146336jao; Fri, 16 Jul 2021 01:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwblx0bPBzkE4rpvePE+5NqY8SxAHk7C/5zarwTRmGvsKDGELwP8N2vqNHu8PbuivAGx2Mr X-Received: by 2002:a05:6402:100e:: with SMTP id c14mr12922728edu.51.1626424522436; Fri, 16 Jul 2021 01:35:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626424522; cv=none; d=google.com; s=arc-20160816; b=bS5ovUizZaB1hg0+X8I9yUfruy3EzvxoJcLTTd+v8Nf2zr0z+pBFJDxcbOo8WTd0be 7fTZnlWbpCB5HqKsZvaDmCOC+uNQSL0rX+gvHOiF/w1gomDdcFfP1IEnFRJN+bOHpLEJ lZ/kl32ajjRom01giV7TUiefnFbKvrp3Kp4/W4L4i77q71D8o1/85i1y4/TzbCXcupqM ENp4ASf3O9bnPzmOjX89dllg7sOsgRtBrB94uVwJenIsMIzRntw3UqdXO9zBE1qTehVh wAc+deo+1Hv3q7zkiXCL2DlslcQabTC/HKNO2bG2y/b9z73TYHGSpvIPgzF6hVpJLbEN OBvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=goYH1kxTUVniKteiIS7yqNleQTw7O8pk3eq1u9rBwJ4=; b=hp7L4YzaaXp1Iji7P+6ffGLXPEp75IecYLQ0PxYmlU5nY5mOt9les4p3f9UL4a4rGk 8Qw87Esp1uQVDDeBA75QIx3rxto7QUlvN48gR4n4fxCBvD5dSAQrTegq8T+4MxGJ+oZj Nni82uo1CT54siDWBoyWjVQCLTWWltRZ+QrmBrBb3TQMoBxVAYNp/qta3uTy94XsLkHb FP4sVfjA6Q9HpVVZlTggF5hsCMm3jxGWNt9YXHdpOBdmds5S5HRLNBuuMGYcj35CMPRp zhJ5nbKysAI9woEooP+GuADeaMO07Z4RD99mgpZU/QPmODIgV/AYjTTxLJIe3+01KQNa 4qkw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dd21si2610993edb.514.2021.07.16.01.35.22; Fri, 16 Jul 2021 01:35:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238233AbhGPIiO (ORCPT + 4 others); Fri, 16 Jul 2021 04:38:14 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3420 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238195AbhGPIiN (ORCPT ); Fri, 16 Jul 2021 04:38:13 -0400 Received: from fraeml711-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4GR45Z5n6pz6H7Mp; Fri, 16 Jul 2021 16:24:02 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml711-chm.china.huawei.com (10.206.15.60) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 10:35:17 +0200 Received: from A2006125610.china.huawei.com (10.47.80.222) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 16 Jul 2021 09:35:10 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v6 3/9] iommu/dma: Introduce generic helper to retrieve RMR info Date: Fri, 16 Jul 2021 09:34:36 +0100 Message-ID: <20210716083442.1708-4-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> References: <20210716083442.1708-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.80.222] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Reserved Memory Regions(RMR) associated with an IOMMU can be described through ACPI IORT tables in systems with devices that require a unity mapping or bypass for those regions. Introduce a generic interface so that IOMMU drivers can retrieve and set up necessary mappings. Signed-off-by: Shameer Kolothum --- drivers/iommu/dma-iommu.c | 29 +++++++++++++++++++++++++++++ include/linux/dma-iommu.h | 13 +++++++++++++ 2 files changed, 42 insertions(+) -- 2.17.1 diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 98ba927aee1a..2fa2445e9070 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -174,6 +174,35 @@ void iommu_put_dma_cookie(struct iommu_domain *domain) } EXPORT_SYMBOL(iommu_put_dma_cookie); +/** + * + * iommu_dma_get_rmrs - Retrieve Reserved Memory Regions(RMRs) associated + * with a given IOMMU + * @iommu_fwnode: fwnode associated with IOMMU + * @list: RMR list to be populated + * + */ +int iommu_dma_get_rmrs(struct fwnode_handle *iommu_fwnode, + struct list_head *list) +{ + return -EINVAL; +} +EXPORT_SYMBOL(iommu_dma_get_rmrs); + +/** + * + * iommu_dma_put_rmrs - Release Reserved Memory Regions(RMRs) associated + * with a given IOMMU + * @iommu_fwnode: fwnode associated with IOMMU + * @list: RMR list + * + */ +void iommu_dma_put_rmrs(struct fwnode_handle *iommu_fwnode, + struct list_head *list) +{ +} +EXPORT_SYMBOL(iommu_dma_put_rmrs); + /** * iommu_dma_get_resv_regions - Reserved region driver helper * @dev: Device from iommu_get_resv_regions() diff --git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h index 758ca4694257..3b7b2d096c6e 100644 --- a/include/linux/dma-iommu.h +++ b/include/linux/dma-iommu.h @@ -42,12 +42,16 @@ void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, extern bool iommu_dma_forcedac; +int iommu_dma_get_rmrs(struct fwnode_handle *iommu, struct list_head *list); +void iommu_dma_put_rmrs(struct fwnode_handle *iommu, struct list_head *list); + #else /* CONFIG_IOMMU_DMA */ struct iommu_domain; struct msi_desc; struct msi_msg; struct device; +struct fwnode_handle; static inline void iommu_setup_dma_ops(struct device *dev, u64 dma_base, u64 dma_limit) @@ -83,5 +87,14 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he { } +static int iommu_dma_get_rmrs(struct fwnode_handle *iommu, struct list_head *list) +{ + return -ENODEV; +} + +static void iommu_dma_put_rmrs(struct fwnode_handle *iommu, struct list_head *list) +{ +} + #endif /* CONFIG_IOMMU_DMA */ #endif /* __DMA_IOMMU_H */