Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343421
b: refs/heads/master
c: b3e40b7
h: refs/heads/master
i:
  343419: f0ea2dd
v: v3
  • Loading branch information
Jan Beulich authored and Konrad Rzeszutek Wilk committed Nov 2, 2012
1 parent 7e930da commit d1939e3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 13 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: 5b71fbdc64225b7a86944f4f0de80e59071187c7
refs/heads/master: b3e40b72bb24237b0aee9f6ba2e9f88dd4ff3c0a
39 changes: 27 additions & 12 deletions trunk/drivers/xen/xen-pciback/pci_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ static struct pcistub_device *pcistub_device_find(int domain, int bus,
if (psdev->dev != NULL
&& domain == pci_domain_nr(psdev->dev->bus)
&& bus == psdev->dev->bus->number
&& PCI_DEVFN(slot, func) == psdev->dev->devfn) {
&& slot == PCI_SLOT(psdev->dev->devfn)
&& func == PCI_FUNC(psdev->dev->devfn)) {
pcistub_device_get(psdev);
goto out;
}
Expand Down Expand Up @@ -191,7 +192,8 @@ struct pci_dev *pcistub_get_pci_dev_by_slot(struct xen_pcibk_device *pdev,
if (psdev->dev != NULL
&& domain == pci_domain_nr(psdev->dev->bus)
&& bus == psdev->dev->bus->number
&& PCI_DEVFN(slot, func) == psdev->dev->devfn) {
&& slot == PCI_SLOT(psdev->dev->devfn)
&& func == PCI_FUNC(psdev->dev->devfn)) {
found_dev = pcistub_device_get_pci_dev(pdev, psdev);
break;
}
Expand Down Expand Up @@ -936,14 +938,14 @@ static inline int str_to_quirk(const char *buf, int *domain, int *bus, int
{
int parsed = 0;

sscanf(buf, " %4x:%2x:%2x.%d-%8x:%1x:%8x %n", domain, bus, slot, func,
sscanf(buf, " %x:%x:%x.%x-%x:%x:%x %n", domain, bus, slot, func,
reg, size, mask, &parsed);
if (parsed && !buf[parsed])
return 0;

/* try again without domain */
*domain = 0;
sscanf(buf, " %2x:%2x.%d-%8x:%1x:%8x %n", bus, slot, func, reg, size,
sscanf(buf, " %x:%x.%x-%x:%x:%x %n", bus, slot, func, reg, size,
mask, &parsed);
if (parsed && !buf[parsed])
return 0;
Expand All @@ -955,7 +957,7 @@ static int pcistub_device_id_add(int domain, int bus, int slot, int func)
{
struct pcistub_device_id *pci_dev_id;
unsigned long flags;
int rc = 0;
int rc = 0, devfn = PCI_DEVFN(slot, func);

if (slot < 0) {
for (slot = 0; !rc && slot < 32; ++slot)
Expand All @@ -969,13 +971,24 @@ static int pcistub_device_id_add(int domain, int bus, int slot, int func)
return rc;
}

if ((
#if !defined(MODULE) /* pci_domains_supported is not being exported */ \
|| !defined(CONFIG_PCI_DOMAINS)
!pci_domains_supported ? domain :
#endif
domain < 0 || domain > 0xffff)
|| bus < 0 || bus > 0xff
|| PCI_SLOT(devfn) != slot
|| PCI_FUNC(devfn) != func)
return -EINVAL;

pci_dev_id = kmalloc(sizeof(*pci_dev_id), GFP_KERNEL);
if (!pci_dev_id)
return -ENOMEM;

pci_dev_id->domain = domain;
pci_dev_id->bus = bus;
pci_dev_id->devfn = PCI_DEVFN(slot, func);
pci_dev_id->devfn = devfn;

pr_debug(DRV_NAME ": wants to seize %04x:%02x:%02x.%d\n",
domain, bus, slot, func);
Expand Down Expand Up @@ -1016,14 +1029,18 @@ static int pcistub_device_id_remove(int domain, int bus, int slot, int func)
return err;
}

static int pcistub_reg_add(int domain, int bus, int slot, int func, int reg,
int size, int mask)
static int pcistub_reg_add(int domain, int bus, int slot, int func,
unsigned int reg, unsigned int size,
unsigned int mask)
{
int err = 0;
struct pcistub_device *psdev;
struct pci_dev *dev;
struct config_field *field;

if (reg > 0xfff || (size < 4 && (mask >> (size * 8))))
return -EINVAL;

psdev = pcistub_device_find(domain, bus, slot, func);
if (!psdev) {
err = -ENODEV;
Expand Down Expand Up @@ -1254,13 +1271,11 @@ static ssize_t permissive_add(struct device_driver *drv, const char *buf,
int err;
struct pcistub_device *psdev;
struct xen_pcibk_dev_data *dev_data;

err = str_to_slot(buf, &domain, &bus, &slot, &func);
if (err)
goto out;
if (slot < 0 || func < 0) {
err = -EINVAL;
goto out;
}

psdev = pcistub_device_find(domain, bus, slot, func);
if (!psdev) {
err = -ENODEV;
Expand Down

0 comments on commit d1939e3

Please sign in to comment.