Re: [PATCH v4 05/23] iommufd/driver: Let iommufd_viommu_alloc helper save ictx to viommu->ictx

Jason Gunthorpe
2025-05-30T18:27:29Z

On Tue, May 27, 2025 at 11:41:19AM -0700, Nicolin Chen wrote:
> On Mon, May 26, 2025 at 10:30:46AM -0300, Jason Gunthorpe wrote:
> > On Fri, May 16, 2025 at 01:56:26PM -0700, Nicolin Chen wrote:
> >
> > > > You don't need to move this unless you are using inlines. Just use a
> > > > forward declaration.
> > >
> > > Since we forward ucmd now, ictx is in the ucmd so we need this
> > > structure for:
> > >
> > > - if (!IS_ERR(ret)) \
> > > + if (!IS_ERR(ret)) { \
> > > ret->member.ops = viommu_ops; \
> > > + ret->member.ictx = ucmd->ictx; \
> > > + } \
> >
> > De-inline more of that function probably..
> >
> > Also seem my other remarks about not storing ictx so much..
>
> I found that all other ictx pointers in vdev/hw_queue are unused,
> as the core simply gets an ictx from their viommu pointers. This
> means that only this viommu allocator here needs such a storing.
>
> With that, how about a change like this v.s. inline:

So I think the other suggestion with init vs alloc supersedes this and
makes it all pretty clean?

Jason