Cleanup of MSI code
Subsystems (3)
PATCH 1/1 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 <[email protected]>
drivers/pci/msi-xen.c +8 -14
@@ -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 preturn -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),
drivers/xen/pciback/conf_space_capability_msi.c +1 -4
@@ -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_dint 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_dint 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
[email protected]
http://lists.xensource.com/xen-devel