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, 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 v4 3/8] ACPI/IORT: Add a helper to retrieve RMR memory regions
Date: Thu, 3 Jun 2021 12:20:54 +0100 [thread overview]
Message-ID: <20210603112054.GA14606@lpieralisi> (raw)
In-Reply-To: <20210513134550.2117-4-shameerali.kolothum.thodi@huawei.com>
On Thu, May 13, 2021 at 02:45:45PM +0100, Shameer Kolothum wrote:
> Add a helper function that retrieves RMR memory descriptors
> associated with a given IOMMU. This will be used by IOMMU
> drivers to setup necessary mappings.
>
> Now that we have this, invoke it from the generic helper
"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()."
> interface.
>
> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
> ---
> drivers/acpi/arm64/iort.c | 40 +++++++++++++++++++++++++++++++++++++++
> drivers/iommu/dma-iommu.c | 3 +++
> include/linux/acpi_iort.h | 7 +++++++
> 3 files changed, 50 insertions(+)
>
> diff --git a/drivers/acpi/arm64/iort.c b/drivers/acpi/arm64/iort.c
> index fea1ffaedf3b..6ca88c38987a 100644
> --- a/drivers/acpi/arm64/iort.c
> +++ b/drivers/acpi/arm64/iort.c
> @@ -12,6 +12,7 @@
>
> #include <linux/acpi_iort.h>
> #include <linux/bitfield.h>
> +#include <linux/dma-iommu.h>
> #include <linux/iommu.h>
> #include <linux/kernel.h>
> #include <linux/list.h>
> @@ -837,6 +838,43 @@ static inline int iort_add_device_replay(struct device *dev)
> return err;
> }
>
> +/**
> + * iort_iommu_get_rmrs - Helper to retrieve RMR info associated with IOMMU
iort_iommu_get_rmrs()
please check other functions comments in the patchset.
> + * @iommu: fwnode for the IOMMU
Does not match the parameter.
> + * @head: RMR list head to be populated
> + *
> + * Returns: 0 on success, <0 failure
> + */
> +int iort_iommu_get_rmrs(struct fwnode_handle *iommu_fwnode,
> + struct list_head *head)
> +{
> + struct iort_rmr_entry *e;
> + struct acpi_iort_node *iommu;
> +
> + iommu = iort_get_iort_node(iommu_fwnode);
> + if (!iommu)
> + return -EINVAL;
> +
> + list_for_each_entry(e, &iort_rmr_list, list) {
> + struct acpi_iort_rmr_desc *rmr_desc;
> + struct iommu_rmr *rmr;
> +
> + if (e->smmu != iommu)
> + continue;
> +
> + rmr_desc = e->rmr_desc;
> + rmr = iommu_dma_alloc_rmr(rmr_desc->base_address,
> + rmr_desc->length, e->sid,
> + e->flags);
> + if (!rmr)
> + return -ENOMEM;
I suppose it is OK to leave the already allocated regions allocated
on -ENOMEM.
Probably worth clarifying it in the function comment.
Lorenzo
> +
> + list_add_tail(&rmr->list, head);
> + }
> +
> + return 0;
> +}
> +
> /**
> * iort_iommu_msi_get_resv_regions - Reserved region driver helper
> * @dev: Device from iommu_get_resv_regions()
> @@ -1108,6 +1146,8 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)
> const struct iommu_ops *iort_iommu_configure_id(struct device *dev,
> const u32 *input_id)
> { return NULL; }
> +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 674bd8815159..2d9caf548a32 100644
> --- a/drivers/iommu/dma-iommu.c
> +++ b/drivers/iommu/dma-iommu.c
> @@ -203,6 +203,9 @@ EXPORT_SYMBOL(iommu_dma_get_resv_regions);
> 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);
> diff --git a/include/linux/acpi_iort.h b/include/linux/acpi_iort.h
> index 1a12baa58e40..e8c45fa59531 100644
> --- a/include/linux/acpi_iort.h
> +++ b/include/linux/acpi_iort.h
> @@ -39,6 +39,8 @@ const struct iommu_ops *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)
> @@ -59,6 +61,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-06-03 11:21 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-13 13:45 [PATCH v4 0/8] ACPI/IORT: Support for IORT RMR node Shameer Kolothum
2021-05-13 13:45 ` [PATCH v4 1/8] ACPI/IORT: Add support for RMR node parsing Shameer Kolothum
2021-06-03 11:36 ` Lorenzo Pieralisi
2021-06-03 11:48 ` Shameerali Kolothum Thodi
2021-05-13 13:45 ` [PATCH v4 2/8] iommu/dma: Introduce generic helper to retrieve RMR info Shameer Kolothum
2021-05-18 8:49 ` Joerg Roedel
2021-05-19 9:30 ` Shameerali Kolothum Thodi
2021-05-19 11:48 ` Robin Murphy
2021-05-13 13:45 ` [PATCH v4 3/8] ACPI/IORT: Add a helper to retrieve RMR memory regions Shameer Kolothum
2021-06-03 11:20 ` Lorenzo Pieralisi [this message]
2021-05-13 13:45 ` [PATCH v4 4/8] iommu/arm-smmu-v3: Introduce strtab init helper Shameer Kolothum
2021-05-13 13:45 ` [PATCH v4 5/8] iommu/arm-smmu-v3: Add bypass flag to arm_smmu_write_strtab_ent() Shameer Kolothum
2021-05-13 13:45 ` [PATCH v4 6/8] iommu/arm-smmu-v3: Get associated RMR info and install bypass STE Shameer Kolothum
2021-05-13 13:45 ` [PATCH v4 7/8] iommu/arm-smmu: Get associated RMR info and install bypass SMR Shameer Kolothum
2021-05-13 13:45 ` [PATCH v4 8/8] iommu/dma: Reserve any RMR regions associated with a dev Shameer Kolothum
2021-05-21 12:55 ` [PATCH v4 0/8] ACPI/IORT: Support for IORT RMR node Steven Price
2021-05-21 13:12 ` Shameerali Kolothum Thodi
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=20210603112054.GA14606@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=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