All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Turton <nturton@solarflare.com>
To: xen-devel <xen-devel@lists.xensource.com>
Subject: [PATCH] Cleanup of MSI code
Date: Mon, 12 May 2008 18:21:17 +0100	[thread overview]
Message-ID: <48287C8D.1010603@solarflare.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 324 bytes --]

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@solarflare.com>



[-- Attachment #2: msi.patch --]
[-- Type: text/plain, Size: 3586 bytes --]

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);
 


[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

                 reply	other threads:[~2008-05-12 17:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48287C8D.1010603@solarflare.com \
    --to=nturton@solarflare.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.