[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 28/31] For non-privileged domains, implement a pcibios_enable_irq (xen_pcifront_enable_irq) function.



This function calls the 'xen_allocate_pirq' which does the 
majority of work: allocate a free IRQ descriptor, setup an IRQ chip, etc.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
 arch/x86/pci/xen.c   |   15 +++++++++++++++
 drivers/xen/events.c |   12 ++++++++++--
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 1b922aa..c4580b8 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -14,8 +14,23 @@
 
 #include <asm/xen/hypervisor.h>
 
+#include <xen/events.h>
+
 static int xen_pcifront_enable_irq(struct pci_dev *dev)
 {
+       int rc;
+
+       dev_info(&dev->dev, "Xen PCI enabling IRQ: %d\n", dev->irq);
+
+       if (dev->irq < 0)
+               return -EINVAL;
+
+       rc = xen_allocate_pirq(dev->irq, "pcifront");
+       if (rc < 0) {
+               dev_warn(&dev->dev, "Xen PCI IRQ: %d, failed to register:%d\n",
+                        dev->irq, rc);
+               return rc;
+       }
        return 0;
 }
 
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index b2c1b09..40bcbde 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -561,7 +561,9 @@ int xen_allocate_pirq(unsigned gsi, char *name)
                goto out;       /* XXX need refcount? */
        }
 
-       if (identity_mapped_irq(gsi)) {
+       /* If we are a PV guest, we don't have GSIs (no ACPI passed). Therefore
+        * we are using the !xen_initial_domain() to drop in the function.*/
+       if (identity_mapped_irq(gsi) || !xen_initial_domain()) {
                irq = gsi;
                irq_to_desc_alloc_node(irq, 0);
                dynamic_irq_init(irq);
@@ -572,7 +574,13 @@ int xen_allocate_pirq(unsigned gsi, char *name)
                                      handle_level_irq, name);
 
        irq_op.irq = gsi;
-       if (HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op)) {
+       irq_op.vector = 0;
+
+       /* Only the privileged domain can do this. For non-priv, the pcifront
+        * driver provides a PCI bus that does the call to do exactly
+        * this in the priv domain. */
+       if (xen_initial_domain() &&
+           HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op)) {
                dynamic_irq_cleanup(irq);
                irq = -ENOSPC;
                goto out;
-- 
1.6.2.5


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.