RE: [PATCH v3 20/20] iommu: Rename attach_dev to set_dev
From: Tian, Kevin
Date: Mon Nov 28 2022 - 22:59:30 EST
> From: Robin Murphy <robin.murphy@xxxxxxx>
> Sent: Monday, November 28, 2022 11:53 PM
>
> On 2022-11-28 15:00, Jason Gunthorpe wrote:
> > On Mon, Nov 28, 2022 at 01:41:56PM +0000, Robin Murphy wrote:
> >> On 2022-11-28 06:46, Lu Baolu wrote:
> >>> With the retirement of the detach_dev callback, the naming of
> attach_dev
> >>> isn't meaningful anymore. Rename it to set_dev to restore its real
> >>> meaning, that is, setting an iommu domain to a device.
> >>
> >> English grammar alert: this part is confusing, since the usual in-context
> >> reading* of "set[ting] X to Y" is going to imply assigning a value of Y to
> >> some unique property of X. Given the actual semantic that when we
> attach the
> >> device to the domain, we are setting the (current) domain as a property of
> >> the device, I think the most logical and intuitive abbreviation for this
> >> method would be set_domain(), where the target device is then clearly
> >> implied by the argument (as the target domain was for attach_dev()).
> >
> > This is the iommu_domain_ops, it seems a bit weird to call it
> > set_domain when it is already acting on a domain object.
> >
> > set_device_domain()
> >
> > ?
>
> Ah, the iommu_domain_ops split had completely slipped my mind - maybe
> with that additional context, assign_dev() might work well enough to
> maintain the pattern while still being sufficiently different?
>
> Otherwise, set_device_domain() (or just set_dev_domain()) sounds fair to
> me.
>
This kind of introduces a new concept as 'device domain'...
I prefer to device_set_domain() similar to __iommu_group_set_domain().
Then set_platform_dma() can be device_set_platform_dma().
Both have 'device' as the subject to differentiate from other domain ops.