From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Cc: linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org,
iommu@lists.linux-foundation.org, linuxarm@huawei.com,
joro@8bytes.org, robin.murphy@arm.com, will@kernel.org,
wanghuiqiang@huawei.com, guohanjun@huawei.com,
steven.price@arm.com, Sami.Mujawar@arm.com, jon@solid-run.com,
eric.auger@redhat.com, yangyicong@huawei.com
Subject: Re: [PATCH v7 4/9] ACPI/IORT: Add a helper to retrieve RMR memory regions
Date: Thu, 5 Aug 2021 16:43:49 +0100 [thread overview]
Message-ID: <20210805154349.GA23085@lpieralisi> (raw)
In-Reply-To: <20210805080724.480-5-shameerali.kolothum.thodi@huawei.com>
On Thu, Aug 05, 2021 at 09:07:19AM +0100, Shameer Kolothum wrote:
> Add a helper function (iort_iommu_get_rmrs()) that retrieves RMR
> memory descriptors associated with a given IOMMU. This will be used
> by IOMMU drivers to setup necessary mappings.
>
> Invoke it from the generic helper iommu_dma_get_rmrs().
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> drivers/acpi/arm64/iort.c | 38 ++++++++++++++++++++++++++++++++++++++
> drivers/iommu/dma-iommu.c | 4 ++++
> include/linux/acpi_iort.h | 7 +++++++
> 3 files changed, 49 insertions(+)
Reviewed-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index d76ba46ebe67..3c32d62e63b6 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -809,6 +809,42 @@ static struct acpi_iort_node *iort_get_msi_resv_iommu(struct device *dev)
> return NULL;
> }
>
> +/**
> + * iort_iommu_get_rmrs() - Helper to retrieve RMR info associated with IOMMU
> + * @iommu_fwnode: fwnode for the IOMMU
> + * @head: RMR list head to be populated
> + *
> + * Returns: 0 on success, <0 failure. Please note, we will keep the already
> + * allocated RMR reserve regions in case of a kmemdup()
> + * failure.
> + */
> +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode,
> + struct list_head *head)
> +{
> + struct iommu_resv_region *e;
> + struct acpi_iort_node *iommu;
> + int rmrs = 0;
> +
> + iommu = iort_get_iort_node(iommu_fwnode);
> + if (!iommu || list_empty(&iort_rmr_list))
> + return -ENODEV;
> +
> + list_for_each_entry(e, &iort_rmr_list, list) {
> + struct iommu_resv_region *region;
> +
> + if (e->fw_data.rmr.smmu != iommu)
> + continue;
> +
> + region = kmemdup(e, sizeof(*region), GFP_KERNEL);
> + if (region) {
> + list_add_tail(®ion->list, head);
> + rmrs++;
> + }
> + }
> +
> + return (rmrs == 0) ? -ENODEV : 0;
> +}
> +
> /**
> * iort_iommu_msi_get_resv_regions - Reserved region driver helper
> * @dev: Device from iommu_get_resv_regions()
> @@ -1041,6 +1077,8 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
> { return 0; }
> int iort_iommu_configure_id(struct device *dev, const u32 *input_id)
> { return -ENODEV; }
> +int iort_iommu_get_rmrs(struct fwnode_handle *fwnode, struct list_head *head)
> +{ return -ENODEV; }
> #endif
>
> static int nc_dma_get_range(struct device *dev, u64 *size)
> diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> index 2fa2445e9070..1b6e27475279 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -185,6 +185,9 @@ EXPORT_SYMBOL(iommu_put_dma_cookie);
> int iommu_dma_get_rmrs(struct fwnode_handle *iommu_fwnode,
> struct list_head *list)
> {
> + if (!is_of_node(iommu_fwnode))
> + return iort_iommu_get_rmrs(iommu_fwnode, list);
> +
> return -EINVAL;
> }
> EXPORT_SYMBOL(iommu_dma_get_rmrs);
> @@ -200,6 +203,7 @@ EXPORT_SYMBOL(iommu_dma_get_rmrs);
> void iommu_dma_put_rmrs(struct fwnode_handle *iommu_fwnode,
> struct list_head *list)
> {
> + generic_iommu_put_resv_regions(iommu_fwnode->dev, list);
> }
> EXPORT_SYMBOL(iommu_dma_put_rmrs);
>
> diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h
> index f1f0842a2cb2..d8c030c103f5 100644
> --- a/include/linux/acpi_iort.h
> +++ b/include/linux/acpi_iort.h
> @@ -38,6 +38,8 @@ int iort_dma_get_ranges(struct device *dev, u64 *size);
> int iort_iommu_configure_id(struct device *dev, const u32 *id_in);
> int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head);
> phys_addr_t acpi_iort_dma_get_max_cpu_address(void);
> +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode,
> + struct list_head *list);
> #else
> static inline void acpi_iort_init(void) { }
> static inline u32 iort_msi_map_id(struct device *dev, u32 id)
> @@ -57,6 +59,11 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
>
> static inline phys_addr_t acpi_iort_dma_get_max_cpu_address(void)
> { return PHYS_ADDR_MAX; }
> +
> +static inline
> +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode,
> + struct list_head *list)
> +{ return -ENODEV; }
> #endif
>
> #endif /* __ACPI_IORT_H__ */
> --
> 2.17.1
>
next prev parent reply other threads:[~2021-08-05 15:44 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-05 8:07 [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node Shameer Kolothum
2021-08-05 8:07 ` [PATCH v7 1/9] iommu: Introduce a union to struct iommu_resv_region Shameer Kolothum
2021-08-20 10:22 ` Steven Price
2021-10-08 12:14 ` Robin Murphy
2021-10-09 6:57 ` Jon Nettleton
2021-10-11 5:47 ` Shameerali Kolothum Thodi
2021-10-11 13:47 ` Robin Murphy
2021-08-05 8:07 ` [PATCH v7 2/9] ACPI/IORT: Add support for RMR node parsing Shameer Kolothum
2021-08-05 16:03 ` Lorenzo Pieralisi
2021-08-05 16:31 ` Jon Nettleton
2021-08-05 18:37 ` Laurentiu Tudor
2021-09-06 17:44 ` Robin Murphy
2021-09-06 19:51 ` Jon Nettleton
2021-09-16 7:26 ` Shameerali Kolothum Thodi
2021-09-16 7:52 ` Jon Nettleton
2021-09-16 8:26 ` Shameerali Kolothum Thodi
2021-09-16 11:16 ` Jon Nettleton
2021-09-17 11:26 ` Shameerali Kolothum Thodi
2021-10-05 10:53 ` Laurentiu Tudor
2021-10-08 12:48 ` Robin Murphy
2021-10-09 7:06 ` Jon Nettleton
2021-10-11 14:04 ` Robin Murphy
2021-10-12 8:00 ` Jon Nettleton
2021-12-08 12:18 ` Lorenzo Pieralisi
2021-12-08 13:26 ` Jon Nettleton
2021-12-08 14:37 ` Robin Murphy
2021-12-08 15:11 ` Jon Nettleton
2021-10-11 5:59 ` Shameerali Kolothum Thodi
2021-08-05 8:07 ` [PATCH v7 3/9] iommu/dma: Introduce generic helper to retrieve RMR info Shameer Kolothum
2021-10-08 13:03 ` Robin Murphy
2021-10-11 5:51 ` Shameerali Kolothum Thodi
2021-08-05 8:07 ` [PATCH v7 4/9] ACPI/IORT: Add a helper to retrieve RMR memory regions Shameer Kolothum
2021-08-05 15:43 ` Lorenzo Pieralisi [this message]
2021-08-05 8:07 ` [PATCH v7 5/9] iommu/arm-smmu-v3: Introduce strtab init helper Shameer Kolothum
2021-08-05 8:07 ` [PATCH v7 6/9] iommu/arm-smmu-v3: Refactor arm_smmu_init_bypass_stes() to force bypass Shameer Kolothum
2021-08-05 8:07 ` [PATCH v7 7/9] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE Shameer Kolothum
2021-08-05 8:07 ` [PATCH v7 8/9] iommu/arm-smmu: Get associated RMR info and install bypass SMR Shameer Kolothum
2021-08-05 8:07 ` [PATCH v7 9/9] iommu/dma: Reserve any RMR regions associated with a dev Shameer Kolothum
2021-10-08 13:09 ` Robin Murphy
2021-10-09 7:07 ` Jon Nettleton
2021-10-11 15:00 ` Robin Murphy
2021-10-11 15:42 ` Shameerali Kolothum Thodi
2021-08-05 13:22 ` [PATCH v7 0/9] ACPI/IORT: Support for IORT RMR node Ard Biesheuvel
2021-08-05 13:35 ` Shameerali Kolothum Thodi
2021-08-05 14:09 ` Ard Biesheuvel
2021-08-31 5:06 ` Jon Nettleton
2021-09-30 9:47 ` Eric Auger
2021-09-30 10:50 ` Shameerali Kolothum Thodi
2022-01-25 13:00 ` Shameerali Kolothum Thodi
2022-01-25 19:30 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210805154349.GA23085@lpieralisi \
--to=lorenzo.pieralisi@arm.com \
--cc=Sami.Mujawar@arm.com \
--cc=eric.auger@redhat.com \
--cc=guohanjun@huawei.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jon@solid-run.com \
--cc=joro@8bytes.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=robin.murphy@arm.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.com \
--cc=wanghuiqiang@huawei.com \
--cc=will@kernel.org \
--cc=yangyicong@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox