[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] vtd: change code style of pci.c file, and add spin_unlock(&pdev->lock)



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1216975587 -3600
# Node ID 630ee9fd6f8c03fe813abab0cb47db7982b566c8
# Parent  5e44f5d764323c713ee804c5b78087c652bd9747
vtd: change code style of pci.c file, and add spin_unlock(&pdev->lock)
when iommu_add_device() fails.

Signed-off-by: Weidong Han <weidong.han@xxxxxxxxx>
---
 xen/drivers/passthrough/pci.c |   79 ++++++++++++++++++++++--------------------
 1 files changed, 42 insertions(+), 37 deletions(-)

diff -r 5e44f5d76432 -r 630ee9fd6f8c xen/drivers/passthrough/pci.c
--- a/xen/drivers/passthrough/pci.c     Fri Jul 25 09:45:41 2008 +0100
+++ b/xen/drivers/passthrough/pci.c     Fri Jul 25 09:46:27 2008 +0100
@@ -34,11 +34,11 @@ struct pci_dev *alloc_pdev(u8 bus, u8 de
 
     list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
-           return pdev;
+            return pdev;
 
     pdev = xmalloc(struct pci_dev);
     if ( !pdev )
-       return NULL;
+        return NULL;
 
     *((u8*) &pdev->bus) = bus;
     *((u8*) &pdev->devfn) = devfn;
@@ -63,12 +63,12 @@ struct pci_dev *pci_lock_pdev(int bus, i
     read_lock(&pcidevs_lock);
     list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
         if ( (pdev->bus == bus || bus == -1) &&
-            (pdev->devfn == devfn || devfn == -1) )
-       {
-           spin_lock(&pdev->lock);
-           read_unlock(&pcidevs_lock);
-           return pdev;
-       }
+             (pdev->devfn == devfn || devfn == -1) )
+    {
+        spin_lock(&pdev->lock);
+        read_unlock(&pcidevs_lock);
+        return pdev;
+    }
     read_unlock(&pcidevs_lock);
 
     return NULL;
@@ -81,15 +81,15 @@ struct pci_dev *pci_lock_domain_pdev(str
     read_lock(&pcidevs_lock);
     list_for_each_entry ( pdev, &d->arch.pdev_list, domain_list )
     {
-       spin_lock(&pdev->lock);
+        spin_lock(&pdev->lock);
         if ( (pdev->bus == bus || bus == -1) &&
-            (pdev->devfn == devfn || devfn == -1) &&
-            (pdev->domain == d) )
-       {
-           read_unlock(&pcidevs_lock);
-           return pdev;
-       }
-       spin_unlock(&pdev->lock);
+             (pdev->devfn == devfn || devfn == -1) &&
+             (pdev->domain == d) )
+        {
+            read_unlock(&pcidevs_lock);
+            return pdev;
+        }
+        spin_unlock(&pdev->lock);
     }
     read_unlock(&pcidevs_lock);
 
@@ -104,19 +104,24 @@ int pci_add_device(u8 bus, u8 devfn)
     write_lock(&pcidevs_lock);
     pdev = alloc_pdev(bus, devfn);
     if ( !pdev )
-       goto out;
+        goto out;
 
     ret = 0;
     spin_lock(&pdev->lock);
     if ( !pdev->domain )
     {
-       pdev->domain = dom0;
-       list_add(&pdev->domain_list, &dom0->arch.pdev_list);
-       ret = iommu_add_device(pdev);
+        pdev->domain = dom0;
+        ret = iommu_add_device(pdev);
+        if ( ret )
+        {
+            spin_unlock(&pdev->lock);
+            goto out;
+        }
+        list_add(&pdev->domain_list, &dom0->arch.pdev_list);
     }
     spin_unlock(&pdev->lock);
     printk(XENLOG_DEBUG "PCI add device %02x:%02x.%x\n", bus,
-          PCI_SLOT(devfn), PCI_FUNC(devfn));
+           PCI_SLOT(devfn), PCI_FUNC(devfn));
 
 out:
     write_unlock(&pcidevs_lock);
@@ -131,17 +136,17 @@ int pci_remove_device(u8 bus, u8 devfn)
     write_lock(&pcidevs_lock);
     list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
-       {
-           spin_lock(&pdev->lock);
-           ret = iommu_remove_device(pdev);
-           if ( pdev->domain )
-               list_del(&pdev->domain_list);
-           pci_cleanup_msi(pdev);
-           free_pdev(pdev);
-           printk(XENLOG_DEBUG "PCI remove device %02x:%02x.%x\n", bus,
-                  PCI_SLOT(devfn), PCI_FUNC(devfn));
-           break;
-       }
+        {
+            spin_lock(&pdev->lock);
+            ret = iommu_remove_device(pdev);
+            if ( pdev->domain )
+                list_del(&pdev->domain_list);
+            pci_cleanup_msi(pdev);
+            free_pdev(pdev);
+            printk(XENLOG_DEBUG "PCI remove device %02x:%02x.%x\n", bus,
+                   PCI_SLOT(devfn), PCI_FUNC(devfn));
+            break;
+        }
 
     write_unlock(&pcidevs_lock);
     return ret;
@@ -171,14 +176,14 @@ static void dump_pci_devices(unsigned ch
 
     list_for_each_entry ( pdev, &alldevs_list, alldevs_list )
     {
-       spin_lock(&pdev->lock);
+        spin_lock(&pdev->lock);
         printk("%02x:%02x.%x - dom %-3d - MSIs < ",
                pdev->bus, PCI_SLOT(pdev->devfn), PCI_FUNC(pdev->devfn),
                pdev->domain ? pdev->domain->domain_id : -1);
-       list_for_each_entry ( msi, &pdev->msi_list, list )
-           printk("%d ", msi->vector);
-       printk(">\n");
-       spin_unlock(&pdev->lock);
+        list_for_each_entry ( msi, &pdev->msi_list, list )
+               printk("%d ", msi->vector);
+        printk(">\n");
+        spin_unlock(&pdev->lock);
     }
 
     read_unlock(&pcidevs_lock);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.