Re: [PATCH v4 5/7] iommu: Add iommu_get_domain_for_dev_locked() helper

Jason Gunthorpe
2025-09-24T21:02:34Z

On Wed, Sep 24, 2025 at 01:02:54PM -0700, Nicolin Chen wrote:
> On Wed, Sep 24, 2025 at 04:52:54PM -0300, Jason Gunthorpe wrote:
> > On Wed, Sep 24, 2025 at 12:49:14PM -0700, Nicolin Chen wrote:
> > > > 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?
> >
> > Yes, host1x seemed to be the only place that had that intersection.
>
> I meant, we cannot prevent others from calling it like host1x does?
>
> Even if we have those replacement APIs that we discussed last time,
> such a driver might still want its own domain v.s. default_domain,
> for pgsize or other use?

If a driver allocates its own domain and attaches it then it should be
able to track it and not need to ask the iommu subsystem to give it
back to them :)

Jason