On Wed, Sep 24, 2025 at 04:10:55PM -0300, Jason Gunthorpe wrote:
> On Sun, Aug 31, 2025 at 04:31:57PM -0700, Nicolin Chen wrote:
> > diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
> > index ea2ef53bd4fef..99680cdb57265 100644
> > --- a/drivers/iommu/dma-iommu.c
> > +++ b/drivers/iommu/dma-iommu.c
> > @@ -2097,7 +2097,7 @@ EXPORT_SYMBOL_GPL(dma_iova_destroy);
> >
> > void iommu_setup_dma_ops(struct device *dev)
> > {
> > - struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
> > + struct iommu_domain *domain = iommu_get_domain_for_dev_locked(dev);
>
> Lets have another patch to tidy this. This function can only be called on
> the default_domain. We can trivally pass it in. In all three cases the
> default domain was just attached to the device.
Will replace with your patch.
> > +/* Caller must be a general/external function that isn't an IOMMU callback
> > */
> > struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
>
> Maybe a kdoc?
>
> /**
> * iommu_get_domain_for_dev() - Return the DMA API domain pointer
> * @dev - Device to query
> *
> * This function can be called within a driver bound to dev. The returned
> * pointer is valid for the lifetime of the bound driver.
> *
> * It should not be called by drivers with driver_managed_dma = true.
> */
> struct iommu_domain *iommu_get_domain_for_dev(struct device *dev)
Will add this.
> I really wanted to say this should just always return the
> default_domain, but it looks like host1x_client_iommu_detach() is the
> only place outside the iommu drivers that would be unhappy with that.
I suppose any external user that allocates/attaches a domain has a
risk of potentially using this helper, in which case group->domain
may not be default_domain?
Thanks
Nicolin