From: Joerg Roedel <jroedel@suse.de>
Date: Tue, 30 Sep 2014 13:02:03 +0200
Subject: iommu/vt-d: Only remove domain when device is removed
Git-commit: 1196c2fb0407683c2df92d3d09f9144d42830894
Patch-mainline: v3.18 or v3.17-rc8 (next release)
References: bnc#920960

This makes sure any RMRR mappings stay in place when the
driver is unbound from the device.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Tested-by: Jerry Hoemann <jerry.hoemann@hp.com>
---
 drivers/pci/intel-iommu.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Index: linux-3.0-SLE11-SP4/drivers/pci/intel-iommu.c
===================================================================
--- linux-3.0-SLE11-SP4.orig/drivers/pci/intel-iommu.c
+++ linux-3.0-SLE11-SP4/drivers/pci/intel-iommu.c
@@ -3563,11 +3563,14 @@ static int device_notifier(struct notifi
 	if (iommu_no_mapping(dev))
 		return 0;
 
+	if (action != BUS_NOTIFY_REMOVED_DEVICE)
+		return 0;
+
 	domain = find_domain(pdev);
 	if (!domain)
 		return 0;
 
-	if (action == BUS_NOTIFY_UNBOUND_DRIVER && !iommu_pass_through) {
+	if (!iommu_pass_through) {
 		domain_remove_one_dev_info(domain, pdev);
 
 		if (!(domain->flags & DOMAIN_FLAG_VIRTUAL_MACHINE) &&
