From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Wang2 Subject: [PATCH] AMD IOMMU: Fix a dead lock in device assignment. Date: Tue, 13 Jan 2009 16:09:58 +0100 Message-ID: <1231859398.3380.285.camel@gran.amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-zj0SpPIvnzxpmrr2nmR0" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel List-Id: xen-devel@lists.xenproject.org --=-zj0SpPIvnzxpmrr2nmR0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Do not obtain pcidevs_lock in reassign_device() to avoid the dead lock. Thanks, Wei Signed-off-by: Wei Wang --=20 AMD GmbH, Germany Operating System Research Center Legal Information: Advanced Micro Devices GmbH Karl-Hammerschmidt-Str. 34 85609 Dornach b. M=C3=BCnchen Gesch=C3=A4ftsf=C3=BChrer: Jochen Polster, Thomas M. McCoy, Giuliano Meroni Sitz: Dornach, Gemeinde Aschheim, Landkreis M=C3=BCnchen Registergericht M=C3=BCnchen, HRB Nr. 43632 --=-zj0SpPIvnzxpmrr2nmR0 Content-Disposition: attachment; filename="deadlock.patch" Content-Type: text/x-patch; name="deadlock.patch"; charset="UTF-8" Content-Transfer-Encoding: 7bit diff -r 95d8788bf4be xen/drivers/passthrough/amd/pci_amd_iommu.c --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Jan 12 10:23:55 2009 +0000 +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c Mon Jan 12 15:43:35 2009 +0100 @@ -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); --=-zj0SpPIvnzxpmrr2nmR0 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-zj0SpPIvnzxpmrr2nmR0--