lkml.org 
[lkml]   [2023]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [RFC 2/8] iommufd: replace attach_fn with a structure
Date
> From: Baolu Lu <baolu.lu@linux.intel.com>
> Sent: Wednesday, September 27, 2023 10:18 AM
>
> On 9/26/23 5:26 PM, Yi Liu wrote:
> >
> > -typedef struct iommufd_hw_pagetable *(*attach_fn)(
> > - struct iommufd_device *idev, struct iommufd_hw_pagetable *hwpt);
> > +static struct iommufd_hw_pagetable *do_attach(struct iommufd_device
> *idev,
> > + struct iommufd_hw_pagetable *hwpt, struct attach_data
> *data)
> > +{
> > + return data->attach_fn(idev, hwpt);
> > +}
>
> I assume that this change was made because we need to pass the pasid
> value to the attach_fn() callback.
>
> If so, how about passing it directly to attach_fn() function?
>
> typedef struct iommufd_hw_pagetable *(*attach_fn)(
> struct iommufd_device *idev,
> struct iommufd_hw_pagetable *hwpt,
> ioasid_t pasid);
>
> In no pasid case, use IOMMU_NO_PASID.
>

that is one option, but also means the existing device attach_fn() needs
to accept an unused pasid parameter which doesn't read good.

So this patch chooses to handle the pasid necessity in an outer wrapper
and contain the pasid awareness only in pasid related attach_fn.
\
 
 \ /
  Last update: 2023-09-27 18:54    [W:0.068 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site