From patchwork Mon May 24 11:02:16 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: 446434 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp3237772jac; Mon, 24 May 2021 04:03:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxA8U2YcqrRfwnxx74IIsMpP8NBbJDkcL3v6BQRf9WiKLYkg2HRI0GfZo+lvOVV3LsN+XyV X-Received: by 2002:a17:907:980c:: with SMTP id ji12mr21946373ejc.152.1621854212892; Mon, 24 May 2021 04:03:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621854212; cv=none; d=google.com; s=arc-20160816; b=0VSS0qN0Gif4UQRs9B9//SMdmvL1qARVnIbJs0dGU2Wg4OdCZY07WdiuFnrqaGA20J pPvnKFDMttu6+J44Ab8qHihQ/pa4QeO4bcg66fZ2GRLT6F9hdWOZzE4Tql8d2b3H6W0I 3890+gHpUZIYfFzCIFa04Et+z2LuE3aoy89vaEoPB1z5116IGxK204FyWzCx5Tt87fhu 4StcX/HPxinZeZeuKP22e7CH6qPjPbTdj3qXDb9SQMJylWwO3Q4rtkbKvmfD9QTmUVfE CUnoQvj4ii7toeifELQS3PFPtoFE9gY9iOG02RovF1od4eVAmK6E2mw0A4uXvaVpJ4ol Of2g== 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=MYjVJwbDogdtmHNT7/w2fpw8iYIwHfX6P2/1ra/LW/I=; b=fR7VecWJuPnC+h2YOo1BuCNaiCtWdlX5drlMEY++VyfPR1SWtCN56UltnfM8nXr6YV xL03XtoZOGNk8fNCUlchlueePtprKokwkqVWNN5qY4/jH2Go62wxQfZUOjFZAPGe5bwx siSiOiR+GTPx7+BC0XTmqzsB+nck05Fi3wVFutTL4xQLPkDvww1ClRhvGMATYFccRwEI e/AQhrLXg+H+8Kwx2b36IfEgftpvWxIxF95bU1UrTUYXAb9KU1Fr8RrAenqiJXM5VBJF hgR32iQu4rzESAUPQDt3FWlKBGLJ16dc3SudVNXAaDkQ4I2XhTQwCIq/Jk7YNm7neBmz xECw== 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 m5si12473319eds.484.2021.05.24.04.03.32; Mon, 24 May 2021 04:03:32 -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 S232646AbhEXLE7 (ORCPT + 4 others); Mon, 24 May 2021 07:04:59 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:5532 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232574AbhEXLE6 (ORCPT ); Mon, 24 May 2021 07:04:58 -0400 Received: from dggems706-chm.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4FpZ4l1SlwzkYwQ; Mon, 24 May 2021 19:00:39 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by dggems706-chm.china.huawei.com (10.3.19.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:03:28 +0800 Received: from A2006125610.china.huawei.com (10.47.80.77) 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; Mon, 24 May 2021 12:03:19 +0100 From: Shameer Kolothum To: , , CC: , , , , , , , , , , Subject: [PATCH v5 2/8] iommu/dma: Introduce generic helper to retrieve RMR info Date: Mon, 24 May 2021 12:02:16 +0100 Message-ID: <20210524110222.2212-3-shameerali.kolothum.thodi@huawei.com> X-Mailer: git-send-email 2.12.0.windows.1 In-Reply-To: <20210524110222.2212-1-shameerali.kolothum.thodi@huawei.com> References: <20210524110222.2212-1-shameerali.kolothum.thodi@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.47.80.77] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) 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. Also introduce a union to struct iommu_resv_region to hold any firmware specific data(eg:RMR specific info). Signed-off-by: Shameer Kolothum --- drivers/iommu/dma-iommu.c | 29 +++++++++++++++++++++++++++++ include/linux/dma-iommu.h | 13 +++++++++++++ include/linux/iommu.h | 10 ++++++++++ 3 files changed, 52 insertions(+) -- 2.17.1 Reported-by: kernel test robot diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 7bcdd1205535..229ec65d98be 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 6e75a2d689b4..a83e6c09444c 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 size) @@ -83,5 +87,14 @@ static inline void iommu_dma_get_resv_regions(struct device *dev, struct list_he { } +int iommu_dma_get_rmrs(struct fwnode_handle *iommu, struct list_head *list) +{ + return -ENODEV; +} + +void iommu_dma_put_rmrs(struct fwnode_handle *iommu, struct list_head *list) +{ +} + #endif /* CONFIG_IOMMU_DMA */ #endif /* __DMA_IOMMU_H */ diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 32d448050bf7..856a1736c744 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -114,6 +114,12 @@ enum iommu_resv_type { IOMMU_RESV_SW_MSI, }; +struct iommu_iort_rmr_data { +#define IOMMU_RMR_REMAP_PERMITTED (1 << 0) + u32 flags; + u32 sid; /* Stream Id associated with RMR entry */ +}; + /** * struct iommu_resv_region - descriptor for a reserved memory region * @list: Linked list pointers @@ -121,6 +127,7 @@ enum iommu_resv_type { * @length: Length of the region in bytes * @prot: IOMMU Protection flags (READ/WRITE/...) * @type: Type of the reserved region + * @rmr: ACPI IORT RMR specific data */ struct iommu_resv_region { struct list_head list; @@ -128,6 +135,9 @@ struct iommu_resv_region { size_t length; int prot; enum iommu_resv_type type; + union { + struct iommu_iort_rmr_data rmr; + } fw_data; }; /**