WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] Cleanup of MSI code

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH] Cleanup of MSI code
From: Neil Turton <nturton@xxxxxxxxxxxxxx>
Date: Mon, 12 May 2008 18:21:17 +0100
Delivery-date: Mon, 12 May 2008 10:21:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.0 (X11/20070326)
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>


diff -r 0da2e3c3ae18 -r e48832688d07 drivers/pci/msi-xen.c
--- a/drivers/pci/msi-xen.c     Thu May 08 13:44:57 2008 +0100
+++ b/drivers/pci/msi-xen.c     Fri May 09 14:13:44 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),
@@ -678,7 +672,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 0da2e3c3ae18 -r e48832688d07 
drivers/xen/pciback/conf_space_capability_msi.c
--- a/drivers/xen/pciback/conf_space_capability_msi.c   Thu May 08 13:44:57 
2008 +0100
+++ b/drivers/xen/pciback/conf_space_capability_msi.c   Fri May 09 14:13:44 
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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] Cleanup of MSI code, Neil Turton <=