> From: Jason Gunthorpe <jgg@xxxxxxxxxx> > Sent: Friday, April 29, 2022 8:39 PM > > > >> * There's no capabilities API in IOMMUFD, and in this RFC each vendor > tracks > > > > > > there was discussion adding device capability uAPI somewhere. > > > > > ack let me know if there was snippets to the conversation as I seem to have > missed that. > > It was just discssion pending something we actually needed to report. > > Would be a very simple ioctl taking in the device ID and fulling a > struct of stuff. > > > > probably this can be reported as a device cap as supporting of dirty bit is > > > an immutable property of the iommu serving that device. > > It is an easier fit to read it out of the iommu_domain after device > attach though - since we don't need to build new kernel infrastructure > to query it from a device. > > > > Userspace can > > > enable dirty tracking on a hwpt if all attached devices claim the support > > > and kernel will does the same verification. > > > > Sorry to be dense but this is not up to 'devices' given they take no > > part in the tracking? I guess by 'devices' you mean the software > > idea of it i.e. the iommu context created for attaching a said > > physical device, not the physical device itself. > > Indeed, an hwpt represents an iommu_domain and if the iommu_domain > has > dirty tracking ops set then that is an inherent propery of the domain > and does not suddenly go away when a new device is attached. > In concept this is an iommu property instead of a domain property. The two can draw an equation only if the iommu driver registers dirty tracking ops only when all IOMMUs in the platform support the capability, i.e. sort of managing this iommu property in a global way. But the global way sort of conflicts with the on-going direction making iommu capability truly per-iommu (though I'm not sure whether heterogeneity would exist for dirty tracking). Following that trend a domain property is not inherent as it is meaningless if no device is attached at all. >From this angle IMHO it's more reasonable to report this IOMMU property to userspace via a device capability. If all devices attached to a hwpt claim IOMMU dirty tracking capability, the user can call set_dirty_tracking() on the hwpt object. Once dirty tracking is enabled on a hwpt, further attaching a device which doesn't claim this capability is simply rejected. Thanks Kevin