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

[Xen-changelog] [linux-2.6.18-xen] xen: Cleanup of MSI code



# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1210667520 -3600
# Node ID 29b8c3f366031a6f047777da6be0bed9b307ad5a
# Parent  cf3f9f1c7edb92c08291c71c142f28a049c2766e
xen: Cleanup of MSI code

A few cleanups of the MSI code.  There were a couple of race
conditions in the use of msi_dev_head which this patch fixes.  Use
list_empty rather than list_empty_careful since pirq_list_head is only
ever accessed under pirq_list_lock.  I removed some unused variables.

Signed-off-by: Neil Turton <nturton@xxxxxxxxxxxxxx>
---
 drivers/pci/msi-xen.c                           |   22 ++++++++--------------
 drivers/xen/pciback/conf_space_capability_msi.c |    5 +----
 2 files changed, 9 insertions(+), 18 deletions(-)

diff -r cf3f9f1c7edb -r 29b8c3f36603 drivers/pci/msi-xen.c
--- a/drivers/pci/msi-xen.c     Tue May 13 09:22:10 2008 +0100
+++ b/drivers/pci/msi-xen.c     Tue May 13 09:32:00 2008 +0100
@@ -32,7 +32,7 @@ int msi_register(struct msi_ops *ops)
        return 0;
 }
 
-static struct list_head msi_dev_head;
+static LIST_HEAD(msi_dev_head);
 static int msi_dev_head_inited = 0;
 DEFINE_SPINLOCK(msi_dev_lock);
 
@@ -54,11 +54,6 @@ static struct msi_dev_list *get_msi_dev_
        struct msi_dev_list *msi_dev_list, *ret = NULL;
        unsigned long flags;
 
-       if (!msi_dev_head_inited) {
-               INIT_LIST_HEAD(&msi_dev_head);
-               msi_dev_head_inited = 1;
-       }
-
        spin_lock_irqsave(&msi_dev_lock, flags);
 
        list_for_each_entry(msi_dev_list, &msi_dev_head, list)
@@ -79,10 +74,10 @@ static struct msi_dev_list *get_msi_dev_
                return NULL;
        }
 
+       spin_lock_init(&ret->pirq_list_lock);
+       INIT_LIST_HEAD(&ret->pirq_list_head);
        list_add_tail(&ret->list, &msi_dev_head);
        spin_unlock_irqrestore(&msi_dev_lock, flags);
-       spin_lock_init(&ret->pirq_list_lock);
-       INIT_LIST_HEAD(&ret->pirq_list_head);
        return ret;
 }
 
@@ -304,10 +299,9 @@ int pci_save_msix_state(struct pci_dev *
        msi_dev_entry = get_msi_dev_pirq_list(dev);
 
        spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
-       if (!list_empty_careful(&msi_dev_entry->pirq_list_head))
-               list_for_each_entry_safe(pirq_entry, tmp,
-                                        &msi_dev_entry->pirq_list_head, list)
-                       msi_unmap_pirq(dev, pirq_entry->pirq);
+        list_for_each_entry_safe(pirq_entry, tmp,
+                                 &msi_dev_entry->pirq_list_head, list)
+               msi_unmap_pirq(dev, pirq_entry->pirq);
        spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
 
        disable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
@@ -394,7 +388,7 @@ static int msix_capability_init(struct p
                return -ENOMEM;
 
        spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
-       if (!list_empty_careful(&msi_dev_entry->pirq_list_head))
+       if (!list_empty(&msi_dev_entry->pirq_list_head))
        {
                printk(KERN_WARNING "msix pirqs for dev %02x:%02x:%01x are not 
freed \
                       before acquire again.\n", dev->bus->number, 
PCI_SLOT(dev->devfn),
@@ -677,7 +671,7 @@ void msi_remove_pci_irq_vectors(struct p
        msi_dev_entry = get_msi_dev_pirq_list(dev);
 
        spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
-       if (!list_empty_careful(&msi_dev_entry->pirq_list_head))
+       if (!list_empty(&msi_dev_entry->pirq_list_head))
        {
                printk(KERN_WARNING "msix pirqs for dev %02x:%02x:%01x are not 
freed \
                       before acquire again.\n", dev->bus->number, 
PCI_SLOT(dev->devfn),
diff -r cf3f9f1c7edb -r 29b8c3f36603 
drivers/xen/pciback/conf_space_capability_msi.c
--- a/drivers/xen/pciback/conf_space_capability_msi.c   Tue May 13 09:22:10 
2008 +0100
+++ b/drivers/xen/pciback/conf_space_capability_msi.c   Tue May 13 09:32:00 
2008 +0100
@@ -11,7 +11,6 @@ int pciback_enable_msi(struct pciback_de
                struct pci_dev *dev, struct xen_pci_op *op)
 {
        int otherend = pdev->xdev->otherend_id;
-       int irq;
        int status;
 
        status = pci_enable_msi(dev);
@@ -29,8 +28,6 @@ int pciback_disable_msi(struct pciback_d
 int pciback_disable_msi(struct pciback_device *pdev,
                struct pci_dev *dev, struct xen_pci_op *op)
 {
-       int old_irq = dev->irq;
-
        pci_disable_msi(dev);
 
        op->value = dev->irq;
@@ -40,7 +37,7 @@ int pciback_enable_msix(struct pciback_d
 int pciback_enable_msix(struct pciback_device *pdev,
                struct pci_dev *dev, struct xen_pci_op *op)
 {
-       int otherend = pdev->xdev->otherend_id, result, i;
+       int result;
 
        result = pci_enable_msix(dev, op->msix_entries, op->value);
 

_______________________________________________
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®.