[PATCH v7 14/16] iommufd/viommu: Allow PCI TSM backends to provide vIOMMU operations
Jason Gunthorpe
jgg at nvidia.com
Wed Oct 28 12:07:21 PDT 2026
> [ ... 178 lines skipped ... ]
> +/**
> + * tsm_get_device() - Pin the TSM attached to a device
> + * @dev: device whose TSM is to be pinned
> + *
> + * A successful lookup pins the backend module. Backends providing vIOMMU
> + * operations must not unregister their TSM independently of module unload.
> + * Return: NULL if no vIOMMU-capable TSM is attached, an error if the module
> + * cannot be pinned, or the TSM device associated with the pinned backend.
> + */
> +struct tsm_dev *tsm_get_device(struct device *dev)
> +{
> + if (!dev_is_pci(dev))
> + return NULL;
> + return pci_tsm_get_device(to_pci_dev(dev));
> +}
> +EXPORT_SYMBOL_GPL(tsm_get_device);
This maze of dead code and strange layering is pretty obfuscating, I
hope we can delete it someday.
Aside from that, this looks OK.
I know Jacob and others were talking about needing to discover the
driver from id using a lookup table like you did originaly, but I
don't think tsm should use that if it does get created. It is
simplifying to route things this way so the tsm struct is pinned down
by the core code.
--
Jason
More information about the linux-arm-kernel
mailing list