Skip to contentSkip to conversation

AMD IOMMU: Fix a dead lock in device assignment.

PATCH New Wei Wang2 1 participant 1 message Jan 13, 2009

lore
Share & tools
lore

Wei Wang2

author
#0 lore raw

PATCH 1/1 AMD IOMMU: Fix a dead lock in device assignment.

Do not obtain pcidevs_lock in reassign_device() to avoid the dead lock.

Thanks,
Wei

Signature · 11 lines
AMD GmbH, Germany
Operating System Research Center

Legal Information:
Advanced Micro Devices GmbH
Karl-Hammerschmidt-Str. 34
85609 Dornach b. München

Geschäftsführer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni
Sitz: Dornach, Gemeinde Aschheim, Landkreis München
Registergericht München, HRB Nr. 43632
xen/drivers/passthrough/amd/pci_amd_iommu.c +6 -10
diff -r 95d8788bf4be xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -271,26 +271,22 @@ static int reassign_device( struct domai
     struct amd_iommu *iommu;
     int bdf;
 
-    spin_lock(&pcidevs_lock);
+    ASSERT(spin_is_locked(&pcidevs_lock));
     pdev = pci_get_pdev_by_domain(source, bus, devfn);
     if ( !pdev )
-    {
-        spin_unlock(&pcidevs_lock);
-        return -ENODEV;
-    }
+        return -ENODEV;
 
     bdf = (bus << 8) | devfn;
     /* supported device? */
     iommu = (bdf < ivrs_bdf_entries) ?
-	find_iommu_for_device(bus, pdev->devfn) : NULL;
+    find_iommu_for_device(bus, pdev->devfn) : NULL;
 
     if ( !iommu )
     {
-        spin_unlock(&pcidevs_lock);
         amd_iov_error("Fail to find iommu."
-		      " %x:%x.%x cannot be assigned to domain %d\n", 
-		      bus, PCI_SLOT(devfn), PCI_FUNC(devfn), target->domain_id);
-	return -ENODEV;
+            " %x:%x.%x cannot be assigned to domain %d\n", 
+            bus, PCI_SLOT(devfn), PCI_FUNC(devfn), target->domain_id);
+        return -ENODEV;
     }
 
     amd_iommu_disable_domain_device(source, iommu, bdf);

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel