aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/xen/xen-pciback/passthrough.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/xen/xen-pciback/passthrough.c')
-rw-r--r--drivers/xen/xen-pciback/passthrough.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/drivers/xen/xen-pciback/passthrough.c b/drivers/xen/xen-pciback/passthrough.c
index 828dddc360df..f16a30e2a110 100644
--- a/drivers/xen/xen-pciback/passthrough.c
+++ b/drivers/xen/xen-pciback/passthrough.c
@@ -69,7 +69,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
69} 69}
70 70
71static void __xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev, 71static void __xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev,
72 struct pci_dev *dev) 72 struct pci_dev *dev, bool lock)
73{ 73{
74 struct passthrough_dev_data *dev_data = pdev->pci_dev_data; 74 struct passthrough_dev_data *dev_data = pdev->pci_dev_data;
75 struct pci_dev_entry *dev_entry, *t; 75 struct pci_dev_entry *dev_entry, *t;
@@ -87,8 +87,13 @@ static void __xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev,
87 87
88 mutex_unlock(&dev_data->lock); 88 mutex_unlock(&dev_data->lock);
89 89
90 if (found_dev) 90 if (found_dev) {
91 if (lock)
92 device_lock(&found_dev->dev);
91 pcistub_put_pci_dev(found_dev); 93 pcistub_put_pci_dev(found_dev);
94 if (lock)
95 device_unlock(&found_dev->dev);
96 }
92} 97}
93 98
94static int __xen_pcibk_init_devices(struct xen_pcibk_device *pdev) 99static int __xen_pcibk_init_devices(struct xen_pcibk_device *pdev)
@@ -156,8 +161,11 @@ static void __xen_pcibk_release_devices(struct xen_pcibk_device *pdev)
156 struct pci_dev_entry *dev_entry, *t; 161 struct pci_dev_entry *dev_entry, *t;
157 162
158 list_for_each_entry_safe(dev_entry, t, &dev_data->dev_list, list) { 163 list_for_each_entry_safe(dev_entry, t, &dev_data->dev_list, list) {
164 struct pci_dev *dev = dev_entry->dev;
159 list_del(&dev_entry->list); 165 list_del(&dev_entry->list);
160 pcistub_put_pci_dev(dev_entry->dev); 166 device_lock(&dev->dev);
167 pcistub_put_pci_dev(dev);
168 device_unlock(&dev->dev);
161 kfree(dev_entry); 169 kfree(dev_entry);
162 } 170 }
163 171