2021-11-16 09:09:19

by Yicong Yang

[permalink] [raw]
Subject: [PATCH v2 1/6] iommu: Export iommu_{get,put}_resv_regions()

Export iommu_{get,put}_resv_regions() to the modules so that the driver
can retrieve and use the reserved regions of the device.

Signed-off-by: Yicong Yang <[email protected]>
---
drivers/iommu/iommu.c | 2 ++
include/linux/iommu.h | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index dd7863e453a5..e96711eee965 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -2792,6 +2792,7 @@ void iommu_get_resv_regions(struct device *dev, struct list_head *list)
if (ops && ops->get_resv_regions)
ops->get_resv_regions(dev, list);
}
+EXPORT_SYMBOL_GPL(iommu_get_resv_regions);

void iommu_put_resv_regions(struct device *dev, struct list_head *list)
{
@@ -2800,6 +2801,7 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list)
if (ops && ops->put_resv_regions)
ops->put_resv_regions(dev, list);
}
+EXPORT_SYMBOL_GPL(iommu_put_resv_regions);

/**
* generic_iommu_put_resv_regions - Reserved region driver helper
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index d2f3435e7d17..1b7b0f370e28 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -450,8 +450,8 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t io
extern void iommu_set_fault_handler(struct iommu_domain *domain,
iommu_fault_handler_t handler, void *token);

-extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
-extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
+void iommu_get_resv_regions(struct device *dev, struct list_head *list);
+void iommu_put_resv_regions(struct device *dev, struct list_head *list);
extern void generic_iommu_put_resv_regions(struct device *dev,
struct list_head *list);
extern void iommu_set_default_passthrough(bool cmd_line);
--
2.33.0



2021-11-24 17:51:19

by Mathieu Poirier

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] iommu: Export iommu_{get,put}_resv_regions()

On Tue, Nov 16, 2021 at 05:06:20PM +0800, Yicong Yang wrote:
> Export iommu_{get,put}_resv_regions() to the modules so that the driver
> can retrieve and use the reserved regions of the device.
>
> Signed-off-by: Yicong Yang <[email protected]>
> ---
> drivers/iommu/iommu.c | 2 ++
> include/linux/iommu.h | 4 ++--
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index dd7863e453a5..e96711eee965 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -2792,6 +2792,7 @@ void iommu_get_resv_regions(struct device *dev, struct list_head *list)
> if (ops && ops->get_resv_regions)
> ops->get_resv_regions(dev, list);
> }
> +EXPORT_SYMBOL_GPL(iommu_get_resv_regions);
>
> void iommu_put_resv_regions(struct device *dev, struct list_head *list)
> {
> @@ -2800,6 +2801,7 @@ void iommu_put_resv_regions(struct device *dev, struct list_head *list)
> if (ops && ops->put_resv_regions)
> ops->put_resv_regions(dev, list);
> }
> +EXPORT_SYMBOL_GPL(iommu_put_resv_regions);
>
> /**
> * generic_iommu_put_resv_regions - Reserved region driver helper
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index d2f3435e7d17..1b7b0f370e28 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -450,8 +450,8 @@ extern phys_addr_t iommu_iova_to_phys(struct iommu_domain *domain, dma_addr_t io
> extern void iommu_set_fault_handler(struct iommu_domain *domain,
> iommu_fault_handler_t handler, void *token);
>
> -extern void iommu_get_resv_regions(struct device *dev, struct list_head *list);
> -extern void iommu_put_resv_regions(struct device *dev, struct list_head *list);
> +void iommu_get_resv_regions(struct device *dev, struct list_head *list);
> +void iommu_put_resv_regions(struct device *dev, struct list_head *list);

Acked-by: Mathieu Poirier <[email protected]>

> extern void generic_iommu_put_resv_regions(struct device *dev,
> struct list_head *list);
> extern void iommu_set_default_passthrough(bool cmd_line);
> --
> 2.33.0
>

2021-12-06 11:56:37

by Joerg Roedel

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] iommu: Export iommu_{get,put}_resv_regions()

On Tue, Nov 16, 2021 at 05:06:20PM +0800, Yicong Yang wrote:
> Export iommu_{get,put}_resv_regions() to the modules so that the driver
> can retrieve and use the reserved regions of the device.

Why should any driver bother? These functions are only used by the iommu
core to call into iommu drivers to get information about needed direct
mappings. Why drivers need this information belongs into this commit
message.

Regards,

Joerg


2021-12-06 12:56:12

by Yicong Yang

[permalink] [raw]
Subject: Re: [PATCH v2 1/6] iommu: Export iommu_{get,put}_resv_regions()

On 2021/12/6 19:56, Joerg Roedel wrote:
> On Tue, Nov 16, 2021 at 05:06:20PM +0800, Yicong Yang wrote:
>> Export iommu_{get,put}_resv_regions() to the modules so that the driver
>> can retrieve and use the reserved regions of the device.
>
> Why should any driver bother? These functions are only used by the iommu
> core to call into iommu drivers to get information about needed direct
> mappings. Why drivers need this information belongs into this commit
> message.
>

Our driver makes use of RMR[1], so we need these APIs to retrieve the reserved
memory region in the driver. The device will store the traced data to
the rmr memory and the drivers needs to know the memory address for reading
the data. Due to some hardware limitation, the device can only use direct
mapping for DMA so we need RMR when the iommu is presented and the policy
of the iommu domain is not passthrough.

[1] https://lore.kernel.org/linux-acpi/[email protected]/

Thanks,
Yicong