xen/pciback: Don't deadlock when unbinding.
[deliverable/linux.git] / drivers / xen / xen-pciback / pci_stub.c
index 017069a455d432af73af8939aee93195a5821a61..9cbe1a31c1e5bc98d5e0ba1d0eb8433b4d6d5410 100644 (file)
@@ -250,6 +250,8 @@ struct pci_dev *pcistub_get_pci_dev(struct xen_pcibk_device *pdev,
  *  - 'echo BDF > unbind' with a guest still using it. See pcistub_remove
  *
  *  As such we have to be careful.
+ *
+ *  To make this easier, the caller has to hold the device lock.
  */
 void pcistub_put_pci_dev(struct pci_dev *dev)
 {
@@ -276,11 +278,8 @@ void pcistub_put_pci_dev(struct pci_dev *dev)
        /* Cleanup our device
         * (so it's ready for the next domain)
         */
-
-       /* This is OK - we are running from workqueue context
-        * and want to inhibit the user from fiddling with 'reset'
-        */
-       pci_reset_function(dev);
+       lockdep_assert_held(&dev->dev.mutex);
+       __pci_reset_function_locked(dev);
        pci_restore_state(dev);
 
        /* This disables the device. */
@@ -567,7 +566,8 @@ static void pcistub_remove(struct pci_dev *dev)
                        /* N.B. This ends up calling pcistub_put_pci_dev which ends up
                         * doing the FLR. */
                        xen_pcibk_release_pci_dev(found_psdev->pdev,
-                                               found_psdev->dev);
+                                               found_psdev->dev,
+                                               false /* caller holds the lock. */);
                }
 
                spin_lock_irqsave(&pcistub_devices_lock, flags);
This page took 0.026262 seconds and 5 git commands to generate.