diff mbox series

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

Message ID 20211116090625.53702-2-yangyicong@hisilicon.com (mailing list archive)
State Superseded
Delegated to: Bjorn Helgaas
Headers show
Series Add support for HiSilicon PCIe Tune and Trace device | expand

Commit Message

Yicong Yang Nov. 16, 2021, 9:06 a.m. UTC
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 <yangyicong@hisilicon.com>
---
 drivers/iommu/iommu.c | 2 ++
 include/linux/iommu.h | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Mathieu Poirier Nov. 24, 2021, 5:51 p.m. UTC | #1
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 <yangyicong@hisilicon.com>
> ---
>  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 <mathieu.poirier@linaro.org>

>  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
>
Joerg Roedel Dec. 6, 2021, 11:56 a.m. UTC | #2
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
Yicong Yang Dec. 6, 2021, 12:56 p.m. UTC | #3
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/20210805080724.480-1-shameerali.kolothum.thodi@huawei.com/

Thanks,
Yicong
diff mbox series

Patch

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);