]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.16.3/iommu-vt-d-defer-domain-removal-if-device-is-assigned-to-a-driver.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.16.3 / iommu-vt-d-defer-domain-removal-if-device-is-assigned-to-a-driver.patch
CommitLineData
fc58cd71
GKH
1From e7f9fa5498d91fcdc63d93007ba43f36b1a30538 Mon Sep 17 00:00:00 2001
2From: Joerg Roedel <jroedel@suse.de>
3Date: Tue, 5 Aug 2014 12:55:45 +0200
4Subject: iommu/vt-d: Defer domain removal if device is assigned to a driver
5
6From: Joerg Roedel <jroedel@suse.de>
7
8commit e7f9fa5498d91fcdc63d93007ba43f36b1a30538 upstream.
9
10When the BUS_NOTIFY_DEL_DEVICE event is received the device
11might still be attached to a driver. In this case the domain
12can't be released as the mappings might still be in use.
13
14Defer the domain removal in this case until we receivce the
15BUS_NOTIFY_UNBOUND_DRIVER event.
16
17Cc: Jiang Liu <jiang.liu@linux.intel.com>
18Cc: David Woodhouse <dwmw2@infradead.org>
19Signed-off-by: Joerg Roedel <jroedel@suse.de>
20Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
21
22---
23 drivers/iommu/intel-iommu.c | 8 ++++++++
24 1 file changed, 8 insertions(+)
25
26--- a/drivers/iommu/intel-iommu.c
27+++ b/drivers/iommu/intel-iommu.c
28@@ -3891,6 +3891,14 @@ static int device_notifier(struct notifi
29 action != BUS_NOTIFY_DEL_DEVICE)
30 return 0;
31
32+ /*
33+ * If the device is still attached to a device driver we can't
34+ * tear down the domain yet as DMA mappings may still be in use.
35+ * Wait for the BUS_NOTIFY_UNBOUND_DRIVER event to do that.
36+ */
37+ if (action == BUS_NOTIFY_DEL_DEVICE && dev->driver != NULL)
38+ return 0;
39+
40 domain = find_domain(dev);
41 if (!domain)
42 return 0;