* [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1
@ 2011-06-15 19:19 Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 1/8] xen/pci: Shuffle code around Konrad Rzeszutek Wilk
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Proposing these eight patches for 3.1. The goal of these patches is to:
- clean up the Xen PCI glue code in xen.c to make it easier to maintain
- squash some common code together if possible
I've tested it as PV PCI, PV Dom0, and lightly PVonHVM - I keep on getting
some really weird bootup problems with PVonHVM (it hangs on transitiong from
IDE to PV drivers with or without these patches) - so I will redo that test
shortly once I find out what is happening.
The patches are also available at
git://git.kernel.org/pub/scm/linux/kernel/git/konrad/xen.git stable/pci.cleanups
arch/x86/include/asm/xen/pci.h | 5 +-
arch/x86/pci/xen.c | 370 ++++++++++++++++++----------------------
drivers/xen/events.c | 2 +-
3 files changed, 170 insertions(+), 207 deletions(-)
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/8] xen/pci: Shuffle code around.
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 2/8] xen/pci: Update comments and fix empty spaces Konrad Rzeszutek Wilk
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
That file is hard to read. Move the code around so that
the contents of it follows a uniform format:
- setup GSIs - PV, HVM, and initial domain case
- then MSI/MSI-x setup - PV, HVM and then initial domain case.
- then MSI/MSI-x teardown - same order.
- lastly, the __init functions in PV, HVM, and initial domain order.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 343 ++++++++++++++++++++++++++--------------------------
1 files changed, 172 insertions(+), 171 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 8214724..a2a8e2e 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -19,6 +19,44 @@
#include <xen/events.h>
#include <asm/xen/pci.h>
+
+static int xen_pcifront_enable_irq(struct pci_dev *dev)
+{
+ int rc;
+ int share = 1;
+ int pirq;
+ u8 gsi;
+
+ rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
+ if (rc < 0) {
+ dev_warn(&dev->dev, "Xen PCI: failed to read interrupt line: %d\n",
+ rc);
+ return rc;
+ }
+
+ rc = xen_allocate_pirq_gsi(gsi);
+ if (rc < 0) {
+ dev_warn(&dev->dev, "Xen PCI: failed to allocate a PIRQ for GSI%d: %d\n",
+ gsi, rc);
+ return rc;
+ }
+ pirq = rc;
+
+ if (gsi < NR_IRQS_LEGACY)
+ share = 0;
+
+ rc = xen_bind_pirq_gsi_to_irq(gsi, pirq, share, "pcifront");
+ if (rc < 0) {
+ dev_warn(&dev->dev, "Xen PCI: failed to bind GSI%d (PIRQ%d) to IRQ: %d\n",
+ gsi, pirq, rc);
+ return rc;
+ }
+
+ dev->irq = rc;
+ dev_info(&dev->dev, "Xen PCI mapped GSI%d to IRQ%d\n", gsi, dev->irq);
+ return 0;
+}
+
#ifdef CONFIG_ACPI
static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
int trigger, int polarity)
@@ -58,6 +96,85 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
}
#endif
+#ifdef CONFIG_XEN_DOM0
+static int xen_register_pirq(u32 gsi, int triggering)
+{
+ int rc, pirq, irq = -1;
+ struct physdev_map_pirq map_irq;
+ int shareable = 0;
+ char *name;
+
+ if (!xen_pv_domain())
+ return -1;
+
+ if (triggering == ACPI_EDGE_SENSITIVE) {
+ shareable = 0;
+ name = "ioapic-edge";
+ } else {
+ shareable = 1;
+ name = "ioapic-level";
+ }
+
+ pirq = xen_allocate_pirq_gsi(gsi);
+ if (pirq < 0)
+ goto out;
+
+ irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name);
+ if (irq < 0)
+ goto out;
+
+ printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq);
+
+ map_irq.domid = DOMID_SELF;
+ map_irq.type = MAP_PIRQ_TYPE_GSI;
+ map_irq.index = gsi;
+ map_irq.pirq = pirq;
+
+ rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
+ if (rc) {
+ printk(KERN_WARNING "xen map irq failed %d\n", rc);
+ return -1;
+ }
+
+out:
+ return irq;
+}
+
+static int xen_register_gsi(u32 gsi, int triggering, int polarity)
+{
+ int rc, irq;
+ struct physdev_setup_gsi setup_gsi;
+
+ if (!xen_pv_domain())
+ return -1;
+
+ printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n",
+ gsi, triggering, polarity);
+
+ irq = xen_register_pirq(gsi, triggering);
+
+ setup_gsi.gsi = gsi;
+ setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1);
+ setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
+
+ rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi);
+ if (rc == -EEXIST)
+ printk(KERN_INFO "Already setup the GSI :%d\n", gsi);
+ else if (rc) {
+ printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n",
+ gsi, rc);
+ }
+
+ return irq;
+}
+
+static int acpi_register_gsi_xen(struct device *dev, u32 gsi,
+ int trigger, int polarity)
+{
+ return xen_register_gsi(gsi, trigger, polarity);
+}
+#endif
+
#if defined(CONFIG_PCI_MSI)
#include <linux/msi.h>
#include <asm/msidef.h>
@@ -65,6 +182,46 @@ 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);
+/*
+ * For MSI interrupts we have to use drivers/xen/event.s functions to
+ * allocate an irq_desc and setup the right */
+static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
+{
+ int irq, ret, i;
+ struct msi_desc *msidesc;
+ int *v;
+
+ v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
+ if (!v)
+ return -ENOMEM;
+
+ if (type == PCI_CAP_ID_MSIX)
+ ret = xen_pci_frontend_enable_msix(dev, v, nvec);
+ else
+ ret = xen_pci_frontend_enable_msi(dev, v);
+ if (ret)
+ goto error;
+ i = 0;
+ list_for_each_entry(msidesc, &dev->msi_list, list) {
+ irq = xen_bind_pirq_msi_to_irq(dev, msidesc, v[i], 0,
+ (type == PCI_CAP_ID_MSIX) ?
+ "pcifront-msi-x" :
+ "pcifront-msi",
+ DOMID_SELF);
+ if (irq < 0)
+ goto free;
+ i++;
+ }
+ kfree(v);
+ return 0;
+
+error:
+ dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
+free:
+ kfree(v);
+ return ret;
+}
+
#define XEN_PIRQ_MSI_DATA (MSI_DATA_TRIGGER_EDGE | \
MSI_DATA_LEVEL_ASSERT | (3 << 8) | MSI_DATA_VECTOR(0))
@@ -123,67 +280,6 @@ error:
return -ENODEV;
}
-/*
- * For MSI interrupts we have to use drivers/xen/event.s functions to
- * allocate an irq_desc and setup the right */
-
-
-static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
-{
- int irq, ret, i;
- struct msi_desc *msidesc;
- int *v;
-
- v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
- if (!v)
- return -ENOMEM;
-
- if (type == PCI_CAP_ID_MSIX)
- ret = xen_pci_frontend_enable_msix(dev, v, nvec);
- else
- ret = xen_pci_frontend_enable_msi(dev, v);
- if (ret)
- goto error;
- i = 0;
- list_for_each_entry(msidesc, &dev->msi_list, list) {
- irq = xen_bind_pirq_msi_to_irq(dev, msidesc, v[i], 0,
- (type == PCI_CAP_ID_MSIX) ?
- "pcifront-msi-x" :
- "pcifront-msi",
- DOMID_SELF);
- if (irq < 0)
- goto free;
- i++;
- }
- kfree(v);
- return 0;
-
-error:
- dev_err(&dev->dev, "Xen PCI frontend has not registered MSI/MSI-X support!\n");
-free:
- kfree(v);
- return ret;
-}
-
-static void xen_teardown_msi_irqs(struct pci_dev *dev)
-{
- struct msi_desc *msidesc;
-
- msidesc = list_entry(dev->msi_list.next, struct msi_desc, list);
- if (msidesc->msi_attrib.is_msix)
- xen_pci_frontend_disable_msix(dev);
- else
- xen_pci_frontend_disable_msi(dev);
-
- /* Free the IRQ's and the msidesc using the generic code. */
- default_teardown_msi_irqs(dev);
-}
-
-static void xen_teardown_msi_irq(unsigned int irq)
-{
- xen_destroy_irq(irq);
-}
-
#ifdef CONFIG_XEN_DOM0
static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
@@ -242,44 +338,28 @@ out:
return ret;
}
#endif
-#endif
-static int xen_pcifront_enable_irq(struct pci_dev *dev)
+static void xen_teardown_msi_irqs(struct pci_dev *dev)
{
- int rc;
- int share = 1;
- int pirq;
- u8 gsi;
+ struct msi_desc *msidesc;
- rc = pci_read_config_byte(dev, PCI_INTERRUPT_LINE, &gsi);
- if (rc < 0) {
- dev_warn(&dev->dev, "Xen PCI: failed to read interrupt line: %d\n",
- rc);
- return rc;
- }
+ msidesc = list_entry(dev->msi_list.next, struct msi_desc, list);
+ if (msidesc->msi_attrib.is_msix)
+ xen_pci_frontend_disable_msix(dev);
+ else
+ xen_pci_frontend_disable_msi(dev);
- rc = xen_allocate_pirq_gsi(gsi);
- if (rc < 0) {
- dev_warn(&dev->dev, "Xen PCI: failed to allocate a PIRQ for GSI%d: %d\n",
- gsi, rc);
- return rc;
- }
- pirq = rc;
+ /* Free the IRQ's and the msidesc using the generic code. */
+ default_teardown_msi_irqs(dev);
+}
- if (gsi < NR_IRQS_LEGACY)
- share = 0;
+static void xen_teardown_msi_irq(unsigned int irq)
+{
+ xen_destroy_irq(irq);
+}
- rc = xen_bind_pirq_gsi_to_irq(gsi, pirq, share, "pcifront");
- if (rc < 0) {
- dev_warn(&dev->dev, "Xen PCI: failed to bind GSI%d (PIRQ%d) to IRQ: %d\n",
- gsi, pirq, rc);
- return rc;
- }
+#endif
- dev->irq = rc;
- dev_info(&dev->dev, "Xen PCI mapped GSI%d to IRQ%d\n", gsi, dev->irq);
- return 0;
-}
int __init pci_xen_init(void)
{
@@ -327,77 +407,6 @@ int __init pci_xen_hvm_init(void)
}
#ifdef CONFIG_XEN_DOM0
-static int xen_register_pirq(u32 gsi, int triggering)
-{
- int rc, pirq, irq = -1;
- struct physdev_map_pirq map_irq;
- int shareable = 0;
- char *name;
-
- if (!xen_pv_domain())
- return -1;
-
- if (triggering == ACPI_EDGE_SENSITIVE) {
- shareable = 0;
- name = "ioapic-edge";
- } else {
- shareable = 1;
- name = "ioapic-level";
- }
-
- pirq = xen_allocate_pirq_gsi(gsi);
- if (pirq < 0)
- goto out;
-
- irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name);
- if (irq < 0)
- goto out;
-
- printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq);
-
- map_irq.domid = DOMID_SELF;
- map_irq.type = MAP_PIRQ_TYPE_GSI;
- map_irq.index = gsi;
- map_irq.pirq = pirq;
-
- rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
- if (rc) {
- printk(KERN_WARNING "xen map irq failed %d\n", rc);
- return -1;
- }
-
-out:
- return irq;
-}
-
-static int xen_register_gsi(u32 gsi, int triggering, int polarity)
-{
- int rc, irq;
- struct physdev_setup_gsi setup_gsi;
-
- if (!xen_pv_domain())
- return -1;
-
- printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n",
- gsi, triggering, polarity);
-
- irq = xen_register_pirq(gsi, triggering);
-
- setup_gsi.gsi = gsi;
- setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1);
- setup_gsi.polarity = (polarity == ACPI_ACTIVE_HIGH ? 0 : 1);
-
- rc = HYPERVISOR_physdev_op(PHYSDEVOP_setup_gsi, &setup_gsi);
- if (rc == -EEXIST)
- printk(KERN_INFO "Already setup the GSI :%d\n", gsi);
- else if (rc) {
- printk(KERN_ERR "Failed to setup GSI :%d, err_code:%d\n",
- gsi, rc);
- }
-
- return irq;
-}
-
static __init void xen_setup_acpi_sci(void)
{
int rc;
@@ -425,12 +434,6 @@ static __init void xen_setup_acpi_sci(void)
return;
}
-static int acpi_register_gsi_xen(struct device *dev, u32 gsi,
- int trigger, int polarity)
-{
- return xen_register_gsi(gsi, trigger, polarity);
-}
-
static int __init pci_xen_initial_domain(void)
{
#ifdef CONFIG_PCI_MSI
@@ -471,9 +474,7 @@ void __init xen_setup_pirqs(void)
trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE);
}
}
-#endif
-#ifdef CONFIG_XEN_DOM0
struct xen_device_domain_owner {
domid_t domain;
struct pci_dev *dev;
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 2/8] xen/pci: Update comments and fix empty spaces.
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 1/8] xen/pci: Shuffle code around Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 3/8] xen/pci: Provide #ifdef CONFIG_ACPI to easy code squashing Konrad Rzeszutek Wilk
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
The comment at the beginning of the file does not
make any sense anymore - update it.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index a2a8e2e..f44446b 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -1,8 +1,13 @@
/*
- * Xen PCI Frontend Stub - puts some "dummy" functions in to the Linux
- * x86 PCI core to support the Xen PCI Frontend
+ * Xen PCI - handle PCI (INTx) and MSI infrastructure calls for PV, HVM and
+ * initial domain support. We also handle the DSDT _PRT callbacks for GSI's
+ * used in HVM and initial domain mode (PV does not parse ACPI, so it has no
+ * concept of GSIs). Under PV we hook under the pnbbios API for IRQs and
+ * 0xcf8 PCI configuration read/write.
*
* Author: Ryan Wilson <hap9@epoch.ncsc.mil>
+ * Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
+ * Stefano Stabellini <stefano.stabellini@eu.citrix.com>
*/
#include <linux/module.h>
#include <linux/init.h>
@@ -19,7 +24,6 @@
#include <xen/events.h>
#include <asm/xen/pci.h>
-
static int xen_pcifront_enable_irq(struct pci_dev *dev)
{
int rc;
@@ -182,9 +186,6 @@ static int acpi_register_gsi_xen(struct device *dev, u32 gsi,
struct xen_pci_frontend_ops *xen_pci_frontend;
EXPORT_SYMBOL_GPL(xen_pci_frontend);
-/*
- * For MSI interrupts we have to use drivers/xen/event.s functions to
- * allocate an irq_desc and setup the right */
static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
{
int irq, ret, i;
@@ -360,7 +361,6 @@ static void xen_teardown_msi_irq(unsigned int irq)
#endif
-
int __init pci_xen_init(void)
{
if (!xen_pv_domain() || xen_initial_domain())
@@ -424,7 +424,7 @@ static __init void xen_setup_acpi_sci(void)
}
trigger = trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE;
polarity = polarity ? ACPI_ACTIVE_LOW : ACPI_ACTIVE_HIGH;
-
+
printk(KERN_INFO "xen: sci override: global_irq=%d trigger=%d "
"polarity=%d\n", gsi, trigger, polarity);
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 3/8] xen/pci: Provide #ifdef CONFIG_ACPI to easy code squashing.
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 1/8] xen/pci: Shuffle code around Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 2/8] xen/pci: Update comments and fix empty spaces Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 4/8] xen/pci: In xen_register_pirq bind the GSI to the IRQ after the hypercall Konrad Rzeszutek Wilk
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
. we guard those code segments to be dependent on CONFIG_XEN_DOM0
(and that config option depends on ACPI) so this patch is not
neccesary - but the next one will merge the HVM and initial domain
code as much as it can and we want to make sure the CONFIG_ACPI
dependency is preserved (HVM does not depend on CONFIG_XEN_DOM0).
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index f44446b..510dea5 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -101,6 +101,7 @@ static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
#endif
#ifdef CONFIG_XEN_DOM0
+#ifdef CONFIG_ACPI
static int xen_register_pirq(u32 gsi, int triggering)
{
int rc, pirq, irq = -1;
@@ -178,6 +179,7 @@ static int acpi_register_gsi_xen(struct device *dev, u32 gsi,
return xen_register_gsi(gsi, trigger, polarity);
}
#endif
+#endif
#if defined(CONFIG_PCI_MSI)
#include <linux/msi.h>
@@ -407,6 +409,7 @@ int __init pci_xen_hvm_init(void)
}
#ifdef CONFIG_XEN_DOM0
+#ifdef CONFIG_ACPI
static __init void xen_setup_acpi_sci(void)
{
int rc;
@@ -433,16 +436,17 @@ static __init void xen_setup_acpi_sci(void)
return;
}
-
+#endif
static int __init pci_xen_initial_domain(void)
{
#ifdef CONFIG_PCI_MSI
x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
#endif
+#ifdef CONFIG_ACPI
xen_setup_acpi_sci();
__acpi_register_gsi = acpi_register_gsi_xen;
-
+#endif
return 0;
}
@@ -462,7 +466,7 @@ void __init xen_setup_pirqs(void)
}
return;
}
-
+#ifdef CONFIG_ACPI
/* Pre-allocate legacy irqs */
for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
int trigger, polarity;
@@ -473,6 +477,7 @@ void __init xen_setup_pirqs(void)
xen_register_pirq(irq,
trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE);
}
+#endif
}
struct xen_device_domain_owner {
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/8] xen/pci: In xen_register_pirq bind the GSI to the IRQ after the hypercall.
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
` (2 preceding siblings ...)
2011-06-15 19:19 ` [PATCH 3/8] xen/pci: Provide #ifdef CONFIG_ACPI to easy code squashing Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 5/8] xen/pci: Use the xen_register_pirq from both HVM and initial domain case Konrad Rzeszutek Wilk
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
Not before.. also that code segment starts looking like the HVM case.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 510dea5..251480f 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -112,24 +112,11 @@ static int xen_register_pirq(u32 gsi, int triggering)
if (!xen_pv_domain())
return -1;
- if (triggering == ACPI_EDGE_SENSITIVE) {
- shareable = 0;
- name = "ioapic-edge";
- } else {
- shareable = 1;
- name = "ioapic-level";
- }
pirq = xen_allocate_pirq_gsi(gsi);
if (pirq < 0)
goto out;
- irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name);
- if (irq < 0)
- goto out;
-
- printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq);
-
map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_GSI;
map_irq.index = gsi;
@@ -141,6 +128,20 @@ static int xen_register_pirq(u32 gsi, int triggering)
return -1;
}
+ if (triggering == ACPI_EDGE_SENSITIVE) {
+ shareable = 0;
+ name = "ioapic-edge";
+ } else {
+ shareable = 1;
+ name = "ioapic-level";
+ }
+
+ irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name);
+ if (irq < 0)
+ goto out;
+
+ printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq);
+
out:
return irq;
}
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 5/8] xen/pci: Use the xen_register_pirq from both HVM and initial domain case
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
` (3 preceding siblings ...)
2011-06-15 19:19 ` [PATCH 4/8] xen/pci: In xen_register_pirq bind the GSI to the IRQ after the hypercall Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 6/8] xen/pci: Squash pci_xen_initial_domain and xen_setup_pirqs together Konrad Rzeszutek Wilk
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
. to cut down on the code duplicity.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 73 ++++++++++++++-------------------------------------
1 files changed, 20 insertions(+), 53 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 251480f..7c60a9b 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -62,61 +62,18 @@ static int xen_pcifront_enable_irq(struct pci_dev *dev)
}
#ifdef CONFIG_ACPI
-static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
- int trigger, int polarity)
+static int xen_register_pirq(u32 gsi, int triggering, bool alloc_pirq)
{
- int rc, irq;
+ int rc, pirq = -1, irq = -1;
struct physdev_map_pirq map_irq;
int shareable = 0;
char *name;
- if (!xen_hvm_domain())
- return -1;
-
- map_irq.domid = DOMID_SELF;
- map_irq.type = MAP_PIRQ_TYPE_GSI;
- map_irq.index = gsi;
- map_irq.pirq = -1;
-
- rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq);
- if (rc) {
- printk(KERN_WARNING "xen map irq failed %d\n", rc);
- return -1;
- }
-
- if (trigger == ACPI_EDGE_SENSITIVE) {
- shareable = 0;
- name = "ioapic-edge";
- } else {
- shareable = 1;
- name = "ioapic-level";
+ if (alloc_pirq) {
+ pirq = xen_allocate_pirq_gsi(gsi);
+ if (pirq < 0)
+ goto out;
}
-
- irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name);
-
- printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq);
-
- return irq;
-}
-#endif
-
-#ifdef CONFIG_XEN_DOM0
-#ifdef CONFIG_ACPI
-static int xen_register_pirq(u32 gsi, int triggering)
-{
- int rc, pirq, irq = -1;
- struct physdev_map_pirq map_irq;
- int shareable = 0;
- char *name;
-
- if (!xen_pv_domain())
- return -1;
-
-
- pirq = xen_allocate_pirq_gsi(gsi);
- if (pirq < 0)
- goto out;
-
map_irq.domid = DOMID_SELF;
map_irq.type = MAP_PIRQ_TYPE_GSI;
map_irq.index = gsi;
@@ -136,16 +93,26 @@ static int xen_register_pirq(u32 gsi, int triggering)
name = "ioapic-level";
}
- irq = xen_bind_pirq_gsi_to_irq(gsi, pirq, shareable, name);
+ irq = xen_bind_pirq_gsi_to_irq(gsi, map_irq.pirq, shareable, name);
if (irq < 0)
goto out;
- printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, irq);
+ printk(KERN_DEBUG "xen: --> pirq=%d -> irq=%d\n", pirq, map_irq.pirq);
out:
return irq;
}
+static int acpi_register_gsi_xen_hvm(struct device *dev, u32 gsi,
+ int trigger, int polarity)
+{
+ if (!xen_hvm_domain())
+ return -1;
+
+ return xen_register_pirq(gsi, trigger, false);
+}
+
+#ifdef CONFIG_XEN_DOM0
static int xen_register_gsi(u32 gsi, int triggering, int polarity)
{
int rc, irq;
@@ -157,7 +124,7 @@ static int xen_register_gsi(u32 gsi, int triggering, int polarity)
printk(KERN_DEBUG "xen: registering gsi %u triggering %d polarity %d\n",
gsi, triggering, polarity);
- irq = xen_register_pirq(gsi, triggering);
+ irq = xen_register_pirq(gsi, triggering, true);
setup_gsi.gsi = gsi;
setup_gsi.triggering = (triggering == ACPI_EDGE_SENSITIVE ? 0 : 1);
@@ -476,7 +443,7 @@ void __init xen_setup_pirqs(void)
continue;
xen_register_pirq(irq,
- trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE);
+ trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE, true);
}
#endif
}
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 6/8] xen/pci: Squash pci_xen_initial_domain and xen_setup_pirqs together.
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
` (4 preceding siblings ...)
2011-06-15 19:19 ` [PATCH 5/8] xen/pci: Use the xen_register_pirq from both HVM and initial domain case Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 7/8] xen/pci: Move the allocation of IRQs when there is no IOAPIC to the end Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 8/8] xen/pci: Remove unnecessary #ifdef CONFIG_ACPI Konrad Rzeszutek Wilk
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
Since they are only called once and the rest of the pci_xen_*
functions follow the same pattern of setup.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/include/asm/xen/pci.h | 5 +++--
arch/x86/pci/xen.c | 17 ++++++-----------
drivers/xen/events.c | 2 +-
3 files changed, 10 insertions(+), 14 deletions(-)
diff --git a/arch/x86/include/asm/xen/pci.h b/arch/x86/include/asm/xen/pci.h
index 4fbda9a..968d57d 100644
--- a/arch/x86/include/asm/xen/pci.h
+++ b/arch/x86/include/asm/xen/pci.h
@@ -14,13 +14,14 @@ static inline int pci_xen_hvm_init(void)
}
#endif
#if defined(CONFIG_XEN_DOM0)
-void __init xen_setup_pirqs(void);
+int __init pci_xen_initial_domain(void);
int xen_find_device_domain_owner(struct pci_dev *dev);
int xen_register_device_domain_owner(struct pci_dev *dev, uint16_t domain);
int xen_unregister_device_domain_owner(struct pci_dev *dev);
#else
-static inline void __init xen_setup_pirqs(void)
+static inline int __init pci_xen_initial_domain(void)
{
+ return -1;
}
static inline int xen_find_device_domain_owner(struct pci_dev *dev)
{
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 7c60a9b..7425d7d 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -405,8 +405,11 @@ static __init void xen_setup_acpi_sci(void)
return;
}
#endif
-static int __init pci_xen_initial_domain(void)
+
+int __init pci_xen_initial_domain(void)
{
+ int pirq, irq;
+
#ifdef CONFIG_PCI_MSI
x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
@@ -415,15 +418,6 @@ static int __init pci_xen_initial_domain(void)
xen_setup_acpi_sci();
__acpi_register_gsi = acpi_register_gsi_xen;
#endif
- return 0;
-}
-
-void __init xen_setup_pirqs(void)
-{
- int pirq, irq;
-
- pci_xen_initial_domain();
-
if (0 == nr_ioapics) {
for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
pirq = xen_allocate_pirq_gsi(irq);
@@ -432,7 +426,7 @@ void __init xen_setup_pirqs(void)
break;
irq = xen_bind_pirq_gsi_to_irq(irq, pirq, 0, "xt-pic");
}
- return;
+ return 0;
}
#ifdef CONFIG_ACPI
/* Pre-allocate legacy irqs */
@@ -446,6 +440,7 @@ void __init xen_setup_pirqs(void)
trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE, true);
}
#endif
+ return 0;
}
struct xen_device_domain_owner {
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index 3ff822b..ac0dc67 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -1693,6 +1693,6 @@ void __init xen_init_IRQ(void)
} else {
irq_ctx_init(smp_processor_id());
if (xen_initial_domain())
- xen_setup_pirqs();
+ pci_xen_initial_domain();
}
}
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 7/8] xen/pci: Move the allocation of IRQs when there is no IOAPIC to the end
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
` (5 preceding siblings ...)
2011-06-15 19:19 ` [PATCH 6/8] xen/pci: Squash pci_xen_initial_domain and xen_setup_pirqs together Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 8/8] xen/pci: Remove unnecessary #ifdef CONFIG_ACPI Konrad Rzeszutek Wilk
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
. and also move the probing of ACPI (or MP tables) to be done before
this. Which means that we can actually get the IRQ's polarity (and trigger)
from either one of those entries. Previously - if we did not have an IOAPIC
we would not been able to do this.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index 7425d7d..b53e1b7 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -417,18 +417,6 @@ int __init pci_xen_initial_domain(void)
#ifdef CONFIG_ACPI
xen_setup_acpi_sci();
__acpi_register_gsi = acpi_register_gsi_xen;
-#endif
- if (0 == nr_ioapics) {
- for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
- pirq = xen_allocate_pirq_gsi(irq);
- if (WARN(pirq < 0,
- "Could not allocate PIRQ for legacy interrupt\n"))
- break;
- irq = xen_bind_pirq_gsi_to_irq(irq, pirq, 0, "xt-pic");
- }
- return 0;
- }
-#ifdef CONFIG_ACPI
/* Pre-allocate legacy irqs */
for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
int trigger, polarity;
@@ -440,6 +428,15 @@ int __init pci_xen_initial_domain(void)
trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE, true);
}
#endif
+ if (0 == nr_ioapics) {
+ for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
+ pirq = xen_allocate_pirq_gsi(irq);
+ if (WARN(pirq < 0,
+ "Could not allocate PIRQ for legacy interrupt\n"))
+ break;
+ irq = xen_bind_pirq_gsi_to_irq(irq, pirq, 0, "xt-pic");
+ }
+ }
return 0;
}
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 8/8] xen/pci: Remove unnecessary #ifdef CONFIG_ACPI
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
` (6 preceding siblings ...)
2011-06-15 19:19 ` [PATCH 7/8] xen/pci: Move the allocation of IRQs when there is no IOAPIC to the end Konrad Rzeszutek Wilk
@ 2011-06-15 19:19 ` Konrad Rzeszutek Wilk
7 siblings, 0 replies; 9+ messages in thread
From: Konrad Rzeszutek Wilk @ 2011-06-15 19:19 UTC (permalink / raw)
To: xen-devel, linux-kernel, Jeremy Fitzhardinge, stefano.stabellini,
Ian.Campbell
Cc: Konrad Rzeszutek Wilk
As the code paths that are guarded by CONFIG_XEN_DOM0
already depend on CONFIG_ACPI so the extra #ifdef has
no point being here.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
arch/x86/pci/xen.c | 4 ----
1 files changed, 0 insertions(+), 4 deletions(-)
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c
index b53e1b7..e6ad37e 100644
--- a/arch/x86/pci/xen.c
+++ b/arch/x86/pci/xen.c
@@ -377,7 +377,6 @@ int __init pci_xen_hvm_init(void)
}
#ifdef CONFIG_XEN_DOM0
-#ifdef CONFIG_ACPI
static __init void xen_setup_acpi_sci(void)
{
int rc;
@@ -404,7 +403,6 @@ static __init void xen_setup_acpi_sci(void)
return;
}
-#endif
int __init pci_xen_initial_domain(void)
{
@@ -414,7 +412,6 @@ int __init pci_xen_initial_domain(void)
x86_msi.setup_msi_irqs = xen_initdom_setup_msi_irqs;
x86_msi.teardown_msi_irq = xen_teardown_msi_irq;
#endif
-#ifdef CONFIG_ACPI
xen_setup_acpi_sci();
__acpi_register_gsi = acpi_register_gsi_xen;
/* Pre-allocate legacy irqs */
@@ -427,7 +424,6 @@ int __init pci_xen_initial_domain(void)
xen_register_pirq(irq,
trigger ? ACPI_LEVEL_SENSITIVE : ACPI_EDGE_SENSITIVE, true);
}
-#endif
if (0 == nr_ioapics) {
for (irq = 0; irq < NR_IRQS_LEGACY; irq++) {
pirq = xen_allocate_pirq_gsi(irq);
--
1.7.4.1
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2011-06-15 19:21 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-15 19:19 [PATCH] cleanup in Xen PCI (arch/x86/pci/xen.c) code for 3.1 Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 1/8] xen/pci: Shuffle code around Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 2/8] xen/pci: Update comments and fix empty spaces Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 3/8] xen/pci: Provide #ifdef CONFIG_ACPI to easy code squashing Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 4/8] xen/pci: In xen_register_pirq bind the GSI to the IRQ after the hypercall Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 5/8] xen/pci: Use the xen_register_pirq from both HVM and initial domain case Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 6/8] xen/pci: Squash pci_xen_initial_domain and xen_setup_pirqs together Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 7/8] xen/pci: Move the allocation of IRQs when there is no IOAPIC to the end Konrad Rzeszutek Wilk
2011-06-15 19:19 ` [PATCH 8/8] xen/pci: Remove unnecessary #ifdef CONFIG_ACPI Konrad Rzeszutek Wilk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®