RE: [PATCH] iommu/vt-d: Handle hotplug devices' default identity mapping setting

From: James Dong
Date: Sun Feb 24 2019 - 11:10:42 EST


Baolu:

Yes, it is a generic issue for hotplug devices with current Intel IOMMU driver,
as reported in this thread as well.

The patch you provided does the job in our case. Please update this thread once
your patch is merged. Thanks.

Best Regards,
James

On 2/23/19 12:56 AM, Lu Baolu wrote
>
> @@ -4807,16 +4807,19 @@ static int device_notifier(struct notifier_block *nb,
> if (iommu_dummy(dev))
> return 0;
>
>- if (action != BUS_NOTIFY_REMOVED_DEVICE)
>- return 0;
>-
>- domain = find_domain(dev);
>- if (!domain)
>- return 0;
>+ if (action == BUS_NOTIFY_REMOVED_DEVICE) {
>+ domain = find_domain(dev);
>+ if (!domain)
>+ return 0;
>
>- dmar_remove_one_dev_info(dev);
>- if (!domain_type_is_vm_or_si(domain) && list_empty(&domain->devices))
>- domain_exit(domain);
>+ dmar_remove_one_dev_info(dev);
>+ if (!domain_type_is_vm_or_si(domain) &&
>+ list_empty(&domain->devices))
>+ domain_exit(domain);
>+ } else if (action == BUS_NOTIFY_ADD_DEVICE) {
>+ if (iommu_should_identity_map(dev, 1))
>+ domain_add_dev_info(si_domain, dev);
>+ }