ia64/linux-2.6.18-xen.hg

changeset 545:29b8c3f36603

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@solarflare.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 13 09:32:00 2008 +0100 (2008-05-13)
parents cf3f9f1c7edb
children 3044873a84b7
files drivers/pci/msi-xen.c drivers/xen/pciback/conf_space_capability_msi.c
line diff
     1.1 --- a/drivers/pci/msi-xen.c	Tue May 13 09:22:10 2008 +0100
     1.2 +++ b/drivers/pci/msi-xen.c	Tue May 13 09:32:00 2008 +0100
     1.3 @@ -32,7 +32,7 @@ int msi_register(struct msi_ops *ops)
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 -static struct list_head msi_dev_head;
     1.8 +static LIST_HEAD(msi_dev_head);
     1.9  static int msi_dev_head_inited = 0;
    1.10  DEFINE_SPINLOCK(msi_dev_lock);
    1.11  
    1.12 @@ -54,11 +54,6 @@ static struct msi_dev_list *get_msi_dev_
    1.13  	struct msi_dev_list *msi_dev_list, *ret = NULL;
    1.14  	unsigned long flags;
    1.15  
    1.16 -	if (!msi_dev_head_inited) {
    1.17 -		INIT_LIST_HEAD(&msi_dev_head);
    1.18 -		msi_dev_head_inited = 1;
    1.19 -	}
    1.20 -
    1.21  	spin_lock_irqsave(&msi_dev_lock, flags);
    1.22  
    1.23  	list_for_each_entry(msi_dev_list, &msi_dev_head, list)
    1.24 @@ -79,10 +74,10 @@ static struct msi_dev_list *get_msi_dev_
    1.25  		return NULL;
    1.26  	}
    1.27  
    1.28 +	spin_lock_init(&ret->pirq_list_lock);
    1.29 +	INIT_LIST_HEAD(&ret->pirq_list_head);
    1.30  	list_add_tail(&ret->list, &msi_dev_head);
    1.31  	spin_unlock_irqrestore(&msi_dev_lock, flags);
    1.32 -	spin_lock_init(&ret->pirq_list_lock);
    1.33 -	INIT_LIST_HEAD(&ret->pirq_list_head);
    1.34  	return ret;
    1.35  }
    1.36  
    1.37 @@ -304,10 +299,9 @@ int pci_save_msix_state(struct pci_dev *
    1.38  	msi_dev_entry = get_msi_dev_pirq_list(dev);
    1.39  
    1.40  	spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
    1.41 -	if (!list_empty_careful(&msi_dev_entry->pirq_list_head))
    1.42 -		list_for_each_entry_safe(pirq_entry, tmp,
    1.43 -		                         &msi_dev_entry->pirq_list_head, list)
    1.44 -			msi_unmap_pirq(dev, pirq_entry->pirq);
    1.45 +        list_for_each_entry_safe(pirq_entry, tmp,
    1.46 +                                 &msi_dev_entry->pirq_list_head, list)
    1.47 +		msi_unmap_pirq(dev, pirq_entry->pirq);
    1.48  	spin_unlock_irqrestore(&msi_dev_entry->pirq_list_lock, flags);
    1.49  
    1.50  	disable_msi_mode(dev, pos, PCI_CAP_ID_MSIX);
    1.51 @@ -394,7 +388,7 @@ static int msix_capability_init(struct p
    1.52  		return -ENOMEM;
    1.53  
    1.54  	spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
    1.55 -	if (!list_empty_careful(&msi_dev_entry->pirq_list_head))
    1.56 +	if (!list_empty(&msi_dev_entry->pirq_list_head))
    1.57  	{
    1.58  		printk(KERN_WARNING "msix pirqs for dev %02x:%02x:%01x are not freed \
    1.59  		       before acquire again.\n", dev->bus->number, PCI_SLOT(dev->devfn),
    1.60 @@ -677,7 +671,7 @@ void msi_remove_pci_irq_vectors(struct p
    1.61  	msi_dev_entry = get_msi_dev_pirq_list(dev);
    1.62  
    1.63  	spin_lock_irqsave(&msi_dev_entry->pirq_list_lock, flags);
    1.64 -	if (!list_empty_careful(&msi_dev_entry->pirq_list_head))
    1.65 +	if (!list_empty(&msi_dev_entry->pirq_list_head))
    1.66  	{
    1.67  		printk(KERN_WARNING "msix pirqs for dev %02x:%02x:%01x are not freed \
    1.68  		       before acquire again.\n", dev->bus->number, PCI_SLOT(dev->devfn),
     2.1 --- a/drivers/xen/pciback/conf_space_capability_msi.c	Tue May 13 09:22:10 2008 +0100
     2.2 +++ b/drivers/xen/pciback/conf_space_capability_msi.c	Tue May 13 09:32:00 2008 +0100
     2.3 @@ -11,7 +11,6 @@ int pciback_enable_msi(struct pciback_de
     2.4  		struct pci_dev *dev, struct xen_pci_op *op)
     2.5  {
     2.6  	int otherend = pdev->xdev->otherend_id;
     2.7 -	int irq;
     2.8  	int status;
     2.9  
    2.10  	status = pci_enable_msi(dev);
    2.11 @@ -29,8 +28,6 @@ int pciback_enable_msi(struct pciback_de
    2.12  int pciback_disable_msi(struct pciback_device *pdev,
    2.13  		struct pci_dev *dev, struct xen_pci_op *op)
    2.14  {
    2.15 -	int old_irq = dev->irq;
    2.16 -
    2.17  	pci_disable_msi(dev);
    2.18  
    2.19  	op->value = dev->irq;
    2.20 @@ -40,7 +37,7 @@ int pciback_disable_msi(struct pciback_d
    2.21  int pciback_enable_msix(struct pciback_device *pdev,
    2.22  		struct pci_dev *dev, struct xen_pci_op *op)
    2.23  {
    2.24 -	int otherend = pdev->xdev->otherend_id, result, i;
    2.25 +	int result;
    2.26  
    2.27  	result = pci_enable_msix(dev, op->msix_entries, op->value);
    2.28