Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234205
b: refs/heads/master
c: bf480d9
h: refs/heads/master
i:
  234203: b96712c
v: v3
  • Loading branch information
Ian Campbell authored and Konrad Rzeszutek Wilk committed Mar 10, 2011
1 parent 3e06c4e commit 313853f
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 60 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: 5cad61a6ba6f4956a218ffbb64cafcc1daefaca0
refs/heads/master: bf480d952bcf25e8ff7e95d2a23964107513ac51
68 changes: 26 additions & 42 deletions trunk/arch/x86/pci/xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,47 +86,40 @@ static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,

static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
int irq, pirq, ret = 0;
int irq, pirq;
struct msi_desc *msidesc;
struct msi_msg msg;

list_for_each_entry(msidesc, &dev->msi_list, list) {
__read_msi_msg(msidesc, &msg);
pirq = MSI_ADDR_EXT_DEST_ID(msg.address_hi) |
((msg.address_lo >> MSI_ADDR_DEST_ID_SHIFT) & 0xff);
if (xen_irq_from_pirq(pirq) >= 0 && msg.data == XEN_PIRQ_MSI_DATA) {
irq = xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
"msi-x" : "msi", &pirq, 0);
if (irq < 0)
if (msg.data != XEN_PIRQ_MSI_DATA ||
xen_irq_from_pirq(pirq) < 0) {
pirq = xen_allocate_pirq_msi(dev, msidesc);
if (pirq < 0)
goto error;
ret = set_irq_msi(irq, msidesc);
if (ret < 0)
goto error_while;
printk(KERN_DEBUG "xen: msi already setup: msi --> irq=%d"
" pirq=%d\n", irq, pirq);
return 0;
xen_msi_compose_msg(dev, pirq, &msg);
__write_msi_msg(msidesc, &msg);
dev_dbg(&dev->dev, "xen: msi bound to pirq=%d\n", pirq);
} else {
dev_dbg(&dev->dev,
"xen: msi already bound to pirq=%d\n", pirq);
}
irq = xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
"msi-x" : "msi", &pirq, 1);
if (irq < 0 || pirq < 0)
irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq,
(type == PCI_CAP_ID_MSIX) ?
"msi-x" : "msi");
if (irq < 0)
goto error;
printk(KERN_DEBUG "xen: msi --> irq=%d, pirq=%d\n", irq, pirq);
xen_msi_compose_msg(dev, pirq, &msg);
ret = set_irq_msi(irq, msidesc);
if (ret < 0)
goto error_while;
write_msi_msg(irq, &msg);
dev_dbg(&dev->dev,
"xen: msi --> pirq=%d --> irq=%d\n", pirq, irq);
}
return 0;

error_while:
unbind_from_irqhandler(irq, NULL);
error:
if (ret == -ENODEV)
dev_err(&dev->dev, "Xen PCI frontend has not registered" \
" MSI/MSI-X support!\n");

return ret;
dev_err(&dev->dev,
"Xen PCI frontend has not registered MSI/MSI-X support!\n");
return -ENODEV;
}

/*
Expand All @@ -152,28 +145,19 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
goto error;
i = 0;
list_for_each_entry(msidesc, &dev->msi_list, list) {
irq = xen_allocate_pirq_msi(
(type == PCI_CAP_ID_MSIX) ?
"pcifront-msi-x" : "pcifront-msi",
&v[i], 0);
if (irq < 0) {
ret = -1;
irq = xen_bind_pirq_msi_to_irq(dev, msidesc, v[i],
(type == PCI_CAP_ID_MSIX) ?
"pcifront-msi-x" :
"pcifront-msi");
if (irq < 0)
goto free;
}
ret = set_irq_msi(irq, msidesc);
if (ret)
goto error_while;
i++;
}
kfree(v);
return 0;

error_while:
unbind_from_irqhandler(irq, NULL);
error:
if (ret == -ENODEV)
dev_err(&dev->dev, "Xen PCI frontend has not registered" \
" MSI/MSI-X support!\n");
dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
free:
kfree(v);
return ret;
Expand Down
30 changes: 14 additions & 16 deletions trunk/drivers/xen/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,12 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name)
#include <linux/msi.h>
#include "../pci/msi.h"

static int find_unbound_pirq(int type)
int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc)
{
int rc;
struct physdev_get_free_pirq op_get_free_pirq;

op_get_free_pirq.type = type;
op_get_free_pirq.type = MAP_PIRQ_TYPE_MSI;
rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_free_pirq, &op_get_free_pirq);

WARN_ONCE(rc == -ENOSYS,
Expand All @@ -661,34 +661,32 @@ static int find_unbound_pirq(int type)
return rc ? -1 : op_get_free_pirq.pirq;
}

int xen_allocate_pirq_msi(char *name, int *pirq, int alloc_pirq)
int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc,
int pirq, const char *name)
{
int irq;
int irq, ret;

spin_lock(&irq_mapping_update_lock);

irq = xen_allocate_irq_dynamic();
if (irq == -1)
goto out;

if (alloc_pirq) {
*pirq = find_unbound_pirq(MAP_PIRQ_TYPE_MSI);
if (*pirq == -1) {
xen_free_irq(irq);
irq = -1;
goto out;
}
}

set_irq_chip_and_handler_name(irq, &xen_pirq_chip,
handle_level_irq, name);

irq_info[irq] = mk_pirq_info(0, *pirq, 0, 0);
pirq_to_irq[*pirq] = irq;

irq_info[irq] = mk_pirq_info(0, pirq, 0, 0);
pirq_to_irq[pirq] = irq;
ret = set_irq_msi(irq, msidesc);
if (ret < 0)
goto error_irq;
out:
spin_unlock(&irq_mapping_update_lock);
return irq;
error_irq:
spin_unlock(&irq_mapping_update_lock);
xen_free_irq(irq);
return -1;
}

int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type)
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/xen/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ int xen_allocate_pirq(unsigned gsi, int shareable, char *name);
int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name);

#ifdef CONFIG_PCI_MSI
int xen_allocate_pirq_msi(char *name, int *pirq, int alloc_pirq);
int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc);
int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc,
int pirq, const char *name);
int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type);
#endif

Expand Down

0 comments on commit 313853f

Please sign in to comment.