Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 264454
b: refs/heads/master
c: 74d33de
h: refs/heads/master
v: v3
  • Loading branch information
Konrad Rzeszutek Wilk committed Sep 21, 2011
1 parent 382ccfa commit 515e3d0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b1766b62890e3bba1a778a20ef8bf9348d6096c2
refs/heads/master: 74d33dedc2fb8d98821bcf7df9800ce59456502e
26 changes: 11 additions & 15 deletions trunk/drivers/xen/xen-pciback/vpci.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
#include <linux/list.h>
#include <linux/slab.h>
#include <linux/pci.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include "pciback.h"

#define PCI_SLOT_MAX 32

struct vpci_dev_data {
/* Access to dev_list must be protected by lock */
struct list_head dev_list[PCI_SLOT_MAX];
spinlock_t lock;
struct mutex lock;
};

static inline struct list_head *list_first(struct list_head *head)
Expand All @@ -32,13 +32,12 @@ static struct pci_dev *__xen_pcibk_get_pci_dev(struct xen_pcibk_device *pdev,
struct pci_dev_entry *entry;
struct pci_dev *dev = NULL;
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
unsigned long flags;

if (domain != 0 || bus != 0)
return NULL;

if (PCI_SLOT(devfn) < PCI_SLOT_MAX) {
spin_lock_irqsave(&vpci_dev->lock, flags);
mutex_lock(&vpci_dev->lock);

list_for_each_entry(entry,
&vpci_dev->dev_list[PCI_SLOT(devfn)],
Expand All @@ -49,7 +48,7 @@ static struct pci_dev *__xen_pcibk_get_pci_dev(struct xen_pcibk_device *pdev,
}
}

spin_unlock_irqrestore(&vpci_dev->lock, flags);
mutex_unlock(&vpci_dev->lock);
}
return dev;
}
Expand All @@ -70,7 +69,6 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
int err = 0, slot, func = -1;
struct pci_dev_entry *t, *dev_entry;
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
unsigned long flags;

if ((dev->class >> 24) == PCI_BASE_CLASS_BRIDGE) {
err = -EFAULT;
Expand All @@ -89,7 +87,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,

dev_entry->dev = dev;

spin_lock_irqsave(&vpci_dev->lock, flags);
mutex_lock(&vpci_dev->lock);

/* Keep multi-function devices together on the virtual PCI bus */
for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
Expand Down Expand Up @@ -128,7 +126,7 @@ static int __xen_pcibk_add_pci_dev(struct xen_pcibk_device *pdev,
"No more space on root virtual PCI bus");

unlock:
spin_unlock_irqrestore(&vpci_dev->lock, flags);
mutex_unlock(&vpci_dev->lock);

/* Publish this device. */
if (!err)
Expand All @@ -144,9 +142,8 @@ static void __xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev,
int slot;
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
struct pci_dev *found_dev = NULL;
unsigned long flags;

spin_lock_irqsave(&vpci_dev->lock, flags);
mutex_lock(&vpci_dev->lock);

for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
struct pci_dev_entry *e;
Expand All @@ -162,7 +159,7 @@ static void __xen_pcibk_release_pci_dev(struct xen_pcibk_device *pdev,
}

out:
spin_unlock_irqrestore(&vpci_dev->lock, flags);
mutex_unlock(&vpci_dev->lock);

if (found_dev)
pcistub_put_pci_dev(found_dev);
Expand All @@ -177,7 +174,7 @@ static int __xen_pcibk_init_devices(struct xen_pcibk_device *pdev)
if (!vpci_dev)
return -ENOMEM;

spin_lock_init(&vpci_dev->lock);
mutex_init(&vpci_dev->lock);

for (slot = 0; slot < PCI_SLOT_MAX; slot++)
INIT_LIST_HEAD(&vpci_dev->dev_list[slot]);
Expand Down Expand Up @@ -221,10 +218,9 @@ static int __xen_pcibk_get_pcifront_dev(struct pci_dev *pcidev,
struct pci_dev_entry *entry;
struct pci_dev *dev = NULL;
struct vpci_dev_data *vpci_dev = pdev->pci_dev_data;
unsigned long flags;
int found = 0, slot;

spin_lock_irqsave(&vpci_dev->lock, flags);
mutex_lock(&vpci_dev->lock);
for (slot = 0; slot < PCI_SLOT_MAX; slot++) {
list_for_each_entry(entry,
&vpci_dev->dev_list[slot],
Expand All @@ -242,7 +238,7 @@ static int __xen_pcibk_get_pcifront_dev(struct pci_dev *pcidev,
}
}
}
spin_unlock_irqrestore(&vpci_dev->lock, flags);
mutex_lock(&vpci_dev->lock);
return found;
}

Expand Down

0 comments on commit 515e3d0

Please sign in to comment.