[v3,11/20] iommu/fsl_pamu: Add set_platform_dma callback

Message ID 20221128064648.1934720-12-baolu.lu@linux.intel.com
State New
Headers
Series iommu: Retire detach_dev callback |

Commit Message

Baolu Lu Nov. 28, 2022, 6:46 a.m. UTC
  This IOMMU driver doesn't support default domain. Add the implementation
of set_platform_dma callback so that the IOMMU core could return the
DMA control.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/fsl_pamu_domain.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

Jason Gunthorpe Nov. 28, 2022, 2:14 p.m. UTC | #1
On Mon, Nov 28, 2022 at 02:46:39PM +0800, Lu Baolu wrote:
> This IOMMU driver doesn't support default domain. Add the implementation
> of set_platform_dma callback so that the IOMMU core could return the
> DMA control.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
>  drivers/iommu/fsl_pamu_domain.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
> index 4408ac3c49b6..b8c716e7c424 100644
> --- a/drivers/iommu/fsl_pamu_domain.c
> +++ b/drivers/iommu/fsl_pamu_domain.c
> @@ -314,6 +314,14 @@ static void fsl_pamu_detach_device(struct iommu_domain *domain,
>  		pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
>  }
>  
> +static void fsl_pamu_set_platform_dma(struct device *dev)
> +{
> +	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
> +
> +	if (domain)
> +		fsl_pamu_detach_device(domain, dev);
> +}

This is a bit ugly, it would be better to make the previous patch call
set_platform_dma if it is set instead of detach_dev and then these
patches should just rename the driver's fsl_pamu_detach_device to
fsl_pamu_set_platform_dma

Then the last patch just deletes the op and the core code

Jason
  
Baolu Lu Nov. 29, 2022, 3:46 a.m. UTC | #2
On 11/28/22 10:14 PM, Jason Gunthorpe wrote:
> On Mon, Nov 28, 2022 at 02:46:39PM +0800, Lu Baolu wrote:
>> This IOMMU driver doesn't support default domain. Add the implementation
>> of set_platform_dma callback so that the IOMMU core could return the
>> DMA control.
>>
>> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com>
>> ---
>>   drivers/iommu/fsl_pamu_domain.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
>> index 4408ac3c49b6..b8c716e7c424 100644
>> --- a/drivers/iommu/fsl_pamu_domain.c
>> +++ b/drivers/iommu/fsl_pamu_domain.c
>> @@ -314,6 +314,14 @@ static void fsl_pamu_detach_device(struct iommu_domain *domain,
>>   		pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
>>   }
>>   
>> +static void fsl_pamu_set_platform_dma(struct device *dev)
>> +{
>> +	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
>> +
>> +	if (domain)
>> +		fsl_pamu_detach_device(domain, dev);
>> +}
> This is a bit ugly, it would be better to make the previous patch call
> set_platform_dma if it is set instead of detach_dev and then these
> patches should just rename the driver's fsl_pamu_detach_device to
> fsl_pamu_set_platform_dma
> 
> Then the last patch just deletes the op and the core code

Yes. That's better. I will update the series.

Best regards,
baolu
  

Patch

diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 4408ac3c49b6..b8c716e7c424 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -314,6 +314,14 @@  static void fsl_pamu_detach_device(struct iommu_domain *domain,
 		pr_debug("missing fsl,liodn property at %pOF\n", dev->of_node);
 }
 
+static void fsl_pamu_set_platform_dma(struct device *dev)
+{
+	struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
+
+	if (domain)
+		fsl_pamu_detach_device(domain, dev);
+}
+
 /* Set the domain stash attribute */
 int fsl_pamu_configure_l1_stash(struct iommu_domain *domain, u32 cpu)
 {
@@ -452,6 +460,7 @@  static const struct iommu_ops fsl_pamu_ops = {
 	.domain_alloc	= fsl_pamu_domain_alloc,
 	.probe_device	= fsl_pamu_probe_device,
 	.device_group   = fsl_pamu_device_group,
+	.set_platform_dma = fsl_pamu_set_platform_dma;
 	.default_domain_ops = &(const struct iommu_domain_ops) {
 		.attach_dev	= fsl_pamu_attach_device,
 		.detach_dev	= fsl_pamu_detach_device,