Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 222922
b: refs/heads/master
c: af42b8d
h: refs/heads/master
v: v3
  • Loading branch information
Stefano Stabellini committed Dec 2, 2010
1 parent 5adce0c commit dfa46b2
Show file tree
Hide file tree
Showing 4 changed files with 44 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: e5fc7345412d5e4758fcef55a74354c5cbefd61e
refs/heads/master: af42b8d12f8adec6711cb824549a0edac6a4ae8f
27 changes: 20 additions & 7 deletions trunk/arch/x86/pci/xen.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
struct xen_pci_frontend_ops *xen_pci_frontend;
EXPORT_SYMBOL_GPL(xen_pci_frontend);

#define XEN_PIRQ_MSI_DATA (MSI_DATA_TRIGGER_EDGE | \
MSI_DATA_LEVEL_ASSERT | (3 << 8) | MSI_DATA_VECTOR(0))

static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,
struct msi_msg *msg)
{
Expand All @@ -83,12 +86,7 @@ static void xen_msi_compose_msg(struct pci_dev *pdev, unsigned int pirq,
MSI_ADDR_REDIRECTION_CPU |
MSI_ADDR_DEST_ID(pirq);

msg->data =
MSI_DATA_TRIGGER_EDGE |
MSI_DATA_LEVEL_ASSERT |
/* delivery mode reserved */
(3 << 8) |
MSI_DATA_VECTOR(0);
msg->data = XEN_PIRQ_MSI_DATA;
}

static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
Expand All @@ -98,8 +96,23 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
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) {
xen_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
"msi-x" : "msi", &irq, &pirq, XEN_ALLOC_IRQ);
if (irq < 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_allocate_pirq_msi((type == PCI_CAP_ID_MSIX) ?
"msi-x" : "msi", &irq, &pirq);
"msi-x" : "msi", &irq, &pirq, (XEN_ALLOC_IRQ | XEN_ALLOC_PIRQ));
if (irq < 0 || pirq < 0)
goto error;
printk(KERN_DEBUG "xen: msi --> irq=%d, pirq=%d\n", irq, pirq);
Expand Down
24 changes: 17 additions & 7 deletions trunk/drivers/xen/events.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,17 +668,21 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name)
#include <linux/msi.h>
#include "../pci/msi.h"

void xen_allocate_pirq_msi(char *name, int *irq, int *pirq)
void xen_allocate_pirq_msi(char *name, int *irq, int *pirq, int alloc)
{
spin_lock(&irq_mapping_update_lock);

*irq = find_unbound_irq();
if (*irq == -1)
goto out;
if (alloc & XEN_ALLOC_IRQ) {
*irq = find_unbound_irq();
if (*irq == -1)
goto out;
}

*pirq = find_unbound_pirq(MAP_PIRQ_TYPE_MSI);
if (*pirq == -1)
goto out;
if (alloc & XEN_ALLOC_PIRQ) {
*pirq = find_unbound_pirq(MAP_PIRQ_TYPE_MSI);
if (*pirq == -1)
goto out;
}

set_irq_chip_and_handler_name(*irq, &xen_pirq_chip,
handle_level_irq, name);
Expand Down Expand Up @@ -766,6 +770,7 @@ int xen_destroy_irq(int irq)
printk(KERN_WARNING "unmap irq failed %d\n", rc);
goto out;
}
pirq_to_irq[info->u.pirq.pirq] = -1;
}
irq_info[irq] = mk_unbound_info();

Expand All @@ -786,6 +791,11 @@ int xen_gsi_from_irq(unsigned irq)
return gsi_from_irq(irq);
}

int xen_irq_from_pirq(unsigned pirq)
{
return pirq_to_irq[pirq];
}

int bind_evtchn_to_irq(unsigned int evtchn)
{
int irq;
Expand Down
7 changes: 6 additions & 1 deletion trunk/include/xen/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name);

#ifdef CONFIG_PCI_MSI
/* Allocate an irq and a pirq to be used with MSIs. */
void xen_allocate_pirq_msi(char *name, int *irq, int *pirq);
#define XEN_ALLOC_PIRQ (1 << 0)
#define XEN_ALLOC_IRQ (1 << 1)
void xen_allocate_pirq_msi(char *name, int *irq, int *pirq, int alloc_mask);
int xen_create_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc, int type);
#endif

Expand All @@ -89,4 +91,7 @@ int xen_vector_from_irq(unsigned pirq);
/* Return gsi allocated to pirq */
int xen_gsi_from_irq(unsigned pirq);

/* Return irq from pirq */
int xen_irq_from_pirq(unsigned pirq);

#endif /* _XEN_EVENTS_H */

0 comments on commit dfa46b2

Please sign in to comment.