]>
Commit | Line | Data |
---|---|---|
fc58cd71 GKH |
1 | From e7f9fa5498d91fcdc63d93007ba43f36b1a30538 Mon Sep 17 00:00:00 2001 |
2 | From: Joerg Roedel <jroedel@suse.de> | |
3 | Date: Tue, 5 Aug 2014 12:55:45 +0200 | |
4 | Subject: iommu/vt-d: Defer domain removal if device is assigned to a driver | |
5 | ||
6 | From: Joerg Roedel <jroedel@suse.de> | |
7 | ||
8 | commit e7f9fa5498d91fcdc63d93007ba43f36b1a30538 upstream. | |
9 | ||
10 | When the BUS_NOTIFY_DEL_DEVICE event is received the device | |
11 | might still be attached to a driver. In this case the domain | |
12 | can't be released as the mappings might still be in use. | |
13 | ||
14 | Defer the domain removal in this case until we receivce the | |
15 | BUS_NOTIFY_UNBOUND_DRIVER event. | |
16 | ||
17 | Cc: Jiang Liu <jiang.liu@linux.intel.com> | |
18 | Cc: David Woodhouse <dwmw2@infradead.org> | |
19 | Signed-off-by: Joerg Roedel <jroedel@suse.de> | |
20 | Signed-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; |