On 09.03.2026 12:08, Mykyta Poturai wrote:
> before trying to remove them.
> Some IOMMU platforms, such as SMMU-V3 and IPMMU-VMSA don't support
> removing devices. Trying to call remove_device will result in a crash.
> So check that platform_ops have remove_device set before calling it.
Hmm, but both have .add_device populated. They ought to support
.remove_device, especially if ...
> --- a/xen/drivers/passthrough/pci.c
> +++ b/xen/drivers/passthrough/pci.c
> @@ -1545,6 +1545,12 @@ static int iommu_remove_device(struct pci_dev *pdev)
> if ( !is_iommu_enabled(pdev->domain) )
> return 0;
>
> + if ( !hd->platform_ops->remove_device )
> + {
> + printk(XENLOG_ERR "IOMMU: remove_device not supported by platform\n");
> + return -EOPNOTSUPP;
> + }
> +
> for ( devfn = pdev->devfn ; pdev->phantom_stride; )
> {
> int rc;
... this is for PCI. (I'm simply not qualified to discuss DT.) This
being in the SR-IOV series, I have to assume for the change to be about
a PF de-configuring its VFs. This imo shouldn't end in -EOPNOTSUPP. In
fact PHYSDEVOP_pci_device_remove serves largely as a notification -
please check the xen_remove_device() use in Linux. That is, the device
is going to be gone anyway, and hence we'd better take care of that fact
in Xen.
Jan