Re: [RFC PATCH 11/34] iommu: Split off default domain allocation from group assignment

From: joro@xxxxxxxxxx
Date: Tue Apr 14 2020 - 11:28:20 EST


Hi Jonathan,

On Mon, Apr 13, 2020 at 10:10:50PM +0000, Derrick, Jonathan wrote:
> I had to add the following for initial VMD support. The new PCIe domain
> added on VMD endpoint probe didn't have the dev_iommu member set on the
> VMD subdevices, which I'm guessing is due to probe_iommu_group already
> having been run on the VMD endpoint's group prior to those subdevices
> being added.
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 8a5e1ac328dd..ac1e4fb9bf48 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1577,6 +1577,9 @@ static int iommu_bus_notifier(struct notifier_block *nb,
> if (action == BUS_NOTIFY_ADD_DEVICE) {
> int ret;
>
> + if (!dev_iommu_get(dev))
> + return -ENOMEM;
> +
> ret = iommu_probe_device(dev);
> return (ret) ? NOTIFY_DONE : NOTIFY_OK;
> } else if (action == BUS_NOTIFY_REMOVED_DEVICE) {

Right, thanks for catching this. The hotplug path does not allocate the
dev->iommu structure yet. I'll have to figure out if the above patch
adds it at the right place, but I'll fix it in the next version.

Thanks again,

Joerg