[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1283167276-7364-2-git-send-email-stefano.stabellini@eu.citrix.com>
Date: Mon, 30 Aug 2010 12:21:11 +0100
From: stefano.stabellini@...citrix.com
To: linux-kernel@...r.kernel.org
Cc: xen-devel@...ts.xensource.com, jeremy@...p.org,
konrad.wilk@...cle.com,
Stefano Stabellini <stefano.stabellini@...citrix.com>
Subject: [PATCH 2/7] xen: get the maximum number of pirqs from xen
From: Stefano Stabellini <stefano.stabellini@...citrix.com>
Use PHYSDEVOP_get_nr_pirqs to get the maximum number of pirqs from xen.
Signed-off-by: Stefano Stabellini <stefano.stabellini@...citrix.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
---
drivers/xen/events.c | 31 +++++++++++++++++++++++++++----
include/xen/interface/physdev.h | 6 ++++++
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/drivers/xen/events.c b/drivers/xen/events.c
index a5c30db..aca7230 100644
--- a/drivers/xen/events.c
+++ b/drivers/xen/events.c
@@ -102,6 +102,7 @@ struct irq_info
static struct irq_info *irq_info;
static int *pirq_to_irq;
+static int nr_pirqs;
static int *evtchn_to_irq;
struct cpu_evtchn_s {
@@ -377,10 +378,12 @@ static int get_nr_hw_irqs(void)
return ret;
}
+/* callers of this function should make sure that PHYSDEVOP_get_nr_pirqs
+ * succeeded otherwise nr_pirqs won't hold the right value */
static int find_unbound_pirq(void)
{
int i;
- for (i = 0; i < nr_irqs; i++) {
+ for (i = nr_pirqs-1; i >= 0; i--) {
if (pirq_to_irq[i] < 0)
return i;
}
@@ -596,6 +599,14 @@ int xen_map_pirq_gsi(unsigned pirq, unsigned gsi, int shareable, char *name)
spin_lock(&irq_mapping_update_lock);
+ if ((pirq > nr_pirqs) || (gsi > nr_irqs)) {
+ printk(KERN_WARN "%s: %s %s is incorrect!\n",
+ __function__,
+ pirq > nr_pirqs : "nr_pirqs" :"",
+ gsi > nr_irqs : "nr_irqs" : "");
+ goto out;
+ }
+
irq = find_irq_by_gsi(gsi);
if (irq != -1) {
printk(KERN_INFO "xen_map_pirq_gsi: returning irq %d for gsi %u\n",
@@ -1334,14 +1345,26 @@ void xen_callback_vector(void) {}
void __init xen_init_IRQ(void)
{
- int i;
+ int i, rc;
+ struct physdev_nr_pirqs op_nr_pirqs;
cpu_evtchn_mask_p = kcalloc(nr_cpu_ids, sizeof(struct cpu_evtchn_s),
GFP_KERNEL);
irq_info = kcalloc(nr_irqs, sizeof(*irq_info), GFP_KERNEL);
- pirq_to_irq = kcalloc(nr_irqs, sizeof(*pirq_to_irq), GFP_KERNEL);
- for (i = 0; i < nr_irqs; i++)
+ rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_nr_pirqs, &op_nr_pirqs);
+ if (rc < 0) {
+ nr_pirqs = nr_irqs;
+ if (rc != -ENOSYS)
+ printk(KERN_WARNING "PHYSDEVOP_get_nr_pirqs returned rc=%d\n", rc);
+ } else {
+ if (xen_pv_domain() && !xen_intial_domain())
+ nr_pirqs = max(op_nr_pirqs.nr_pirqs, nr_irqs);
+ else
+ nr_pirqs = op_nr_pirqs.nr_pirqs;
+ }
+ pirq_to_irq = kcalloc(nr_pirqs, sizeof(*pirq_to_irq), GFP_KERNEL);
+ for (i = 0; i < nr_pirqs; i++)
pirq_to_irq[i] = -1;
evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq),
diff --git a/include/xen/interface/physdev.h b/include/xen/interface/physdev.h
index cd69391..fbb5883 100644
--- a/include/xen/interface/physdev.h
+++ b/include/xen/interface/physdev.h
@@ -121,6 +121,12 @@ struct physdev_op {
} u;
};
+#define PHYSDEVOP_get_nr_pirqs 22
+struct physdev_nr_pirqs {
+ /* OUT */
+ uint32_t nr_pirqs;
+};
+
/*
* Notify that some PIRQ-bound event channels have been unmasked.
* ** This command is obsolete since interface version 0x00030202 and is **
--
1.5.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists