Re: [PATCH 1/2] iommufd/selftest: Use a fwnode to distinguish devices
From: Jason Gunthorpe
Date: Tue Nov 28 2023 - 09:43:36 EST
On Tue, Nov 28, 2023 at 10:42:11AM +0000, Robin Murphy wrote:
> With bus ops gone, the trick of registering against a specific bus no
> longer really works, and we start getting given devices from other buses
> to probe,
Make sense
> which leads to spurious groups for devices with no IOMMU on
> arm64,
I'm not sure I'm fully understanding what this means?
I guess that the mock driver is matching random things once it starts
being called all the time because this is missing:
static struct iommu_device *mock_probe_device(struct device *dev)
{
+ if (dev->bus != &iommufd_mock_bus_type)
+ return -ENODEV;
return &mock_iommu_device;
}
Is that sufficient to solve the problem?
> but may inadvertently steal devices from the real IOMMU on Intel,
> AMD or S390.
AMD/Intel/S390 drivers already reject bus's they don't understand.
Intel's device_to_iommu() will fail because
for_each_active_dev_scope() will never match the mock device.
amd fails because check_device() -> get_device_sbdf_id() fails due to
no PCI and not get_acpihid_device_id().
s390 fails because !dev_is_pci(dev).
The fwspec drivers should all fail if they don't have a fwspec, and
they shouldn't for mock bus devices since it doesn't implement
dma_configure.
Jason