Skip to content

Commit

Permalink
intel-iommu: Support PCIe hot-plug
Browse files Browse the repository at this point in the history
To support PCIe hot plug in IOMMU, we register a notifier to respond to device
change action.

When the notifier gets BUS_NOTIFY_UNBOUND_DRIVER, it removes the device
from its DMAR domain.

A hot added device will be added into an IOMMU domain when it first does IOMMU
op. So there is no need to add more code for hot add.

Without the patch, after a hot-remove, a hot-added device on the same
slot will not work.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Tested-by: Yinghai Lu <yinghai@kernel.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Fenghua Yu authored and David Woodhouse committed Nov 12, 2009
1 parent e8bb910 commit 99dcade
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions drivers/pci/intel-iommu.c
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,33 @@ static int __init init_iommu_sysfs(void)
}
#endif /* CONFIG_PM */

/*
* Here we only respond to action of unbound device from driver.
*
* Added device is not attached to its DMAR domain here yet. That will happen
* when mapping the device to iova.
*/
static int device_notifier(struct notifier_block *nb,
unsigned long action, void *data)
{
struct device *dev = data;
struct pci_dev *pdev = to_pci_dev(dev);
struct dmar_domain *domain;

domain = find_domain(pdev);
if (!domain)
return 0;

if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through)
domain_remove_one_dev_info(domain, pdev);

return 0;
}

static struct notifier_block device_nb = {
.notifier_call = device_notifier,
};

int __init intel_iommu_init(void)
{
int ret = 0;
Expand Down Expand Up @@ -3267,6 +3294,8 @@ int __init intel_iommu_init(void)

register_iommu(&intel_iommu_ops);

bus_register_notifier(&pci_bus_type, &device_nb);

return 0;
}

Expand Down

0 comments on commit 99dcade

Please sign in to comment.