diff mbox series

[v12,08/17] iommu: Make free of iommu_domain_ops optional

Message ID 20220826121141.50743-9-baolu.lu@linux.intel.com (mailing list archive)
State Superseded
Headers show
Series iommu: SVA and IOPF refactoring | expand

Commit Message

Baolu Lu Aug. 26, 2022, 12:11 p.m. UTC
So that the drivers are able to implement static singleton instance for
some special domains. The blocking domain is an example. The driver has
no need to allocate different memory for each blocking domain allocation
request. Hence, no need for a free callback.

Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Tested-by: Tony Zhu <tony.zhu@intel.com>
---
 drivers/iommu/iommu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Jason Gunthorpe Aug. 26, 2022, 2:53 p.m. UTC | #1
On Fri, Aug 26, 2022 at 08:11:32PM +0800, Lu Baolu wrote:
> So that the drivers are able to implement static singleton instance for
> some special domains. The blocking domain is an example. The driver has
> no need to allocate different memory for each blocking domain allocation
> request. Hence, no need for a free callback.
> 
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> Tested-by: Tony Zhu <tony.zhu@intel.com>
> ---
>  drivers/iommu/iommu.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index e985f4d5895f..630e1b64ed89 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1972,7 +1972,8 @@ void iommu_domain_free(struct iommu_domain *domain)
>  	if (domain->type == IOMMU_DOMAIN_SVA)
>  		mmdrop(domain->mm);
>  	iommu_put_dma_cookie(domain);
> -	domain->ops->free(domain);
> +	if (domain->ops->free)
> +		domain->ops->free(domain);
>  }
>  EXPORT_SYMBOL_GPL(iommu_domain_free);

This patch is in the wrong order, it needs to be before the ARM patch
implementing the blocking domain

But looks OK

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason
Jason Gunthorpe Aug. 26, 2022, 2:55 p.m. UTC | #2
On Fri, Aug 26, 2022 at 11:53:15AM -0300, Jason Gunthorpe wrote:
> On Fri, Aug 26, 2022 at 08:11:32PM +0800, Lu Baolu wrote:
> > So that the drivers are able to implement static singleton instance for
> > some special domains. The blocking domain is an example. The driver has
> > no need to allocate different memory for each blocking domain allocation
> > request. Hence, no need for a free callback.
> > 
> > Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> > Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org>
> > Tested-by: Tony Zhu <tony.zhu@intel.com>
> > ---
> >  drivers/iommu/iommu.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> > index e985f4d5895f..630e1b64ed89 100644
> > --- a/drivers/iommu/iommu.c
> > +++ b/drivers/iommu/iommu.c
> > @@ -1972,7 +1972,8 @@ void iommu_domain_free(struct iommu_domain *domain)
> >  	if (domain->type == IOMMU_DOMAIN_SVA)
> >  		mmdrop(domain->mm);
> >  	iommu_put_dma_cookie(domain);
> > -	domain->ops->free(domain);
> > +	if (domain->ops->free)
> > +		domain->ops->free(domain);
> >  }
> >  EXPORT_SYMBOL_GPL(iommu_domain_free);
> 
> This patch is in the wrong order, it needs to be before the ARM patch
> implementing the blocking domain

Oh, nevermind, I am reading them in the wrong order :)

Jason
diff mbox series

Patch

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index e985f4d5895f..630e1b64ed89 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1972,7 +1972,8 @@  void iommu_domain_free(struct iommu_domain *domain)
 	if (domain->type == IOMMU_DOMAIN_SVA)
 		mmdrop(domain->mm);
 	iommu_put_dma_cookie(domain);
-	domain->ops->free(domain);
+	if (domain->ops->free)
+		domain->ops->free(domain);
 }
 EXPORT_SYMBOL_GPL(iommu_domain_free);