diff options
Diffstat (limited to 'drivers/xen')
-rw-r--r-- | drivers/xen/events.c | 59 |
1 files changed, 25 insertions, 34 deletions
diff --git a/drivers/xen/events.c b/drivers/xen/events.c index 002283e01749..6782251e4029 100644 --- a/drivers/xen/events.c +++ b/drivers/xen/events.c | |||
@@ -107,8 +107,6 @@ struct irq_info | |||
107 | #define PIRQ_NEEDS_EOI (1 << 0) | 107 | #define PIRQ_NEEDS_EOI (1 << 0) |
108 | #define PIRQ_SHAREABLE (1 << 1) | 108 | #define PIRQ_SHAREABLE (1 << 1) |
109 | 109 | ||
110 | static int *pirq_to_irq; | ||
111 | |||
112 | static int *evtchn_to_irq; | 110 | static int *evtchn_to_irq; |
113 | 111 | ||
114 | static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], | 112 | static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], |
@@ -196,8 +194,6 @@ static void xen_irq_info_pirq_init(unsigned irq, | |||
196 | info->u.pirq.gsi = gsi; | 194 | info->u.pirq.gsi = gsi; |
197 | info->u.pirq.vector = vector; | 195 | info->u.pirq.vector = vector; |
198 | info->u.pirq.flags = flags; | 196 | info->u.pirq.flags = flags; |
199 | |||
200 | pirq_to_irq[pirq] = irq; | ||
201 | } | 197 | } |
202 | 198 | ||
203 | /* | 199 | /* |
@@ -247,16 +243,6 @@ static unsigned pirq_from_irq(unsigned irq) | |||
247 | return info->u.pirq.pirq; | 243 | return info->u.pirq.pirq; |
248 | } | 244 | } |
249 | 245 | ||
250 | static unsigned gsi_from_irq(unsigned irq) | ||
251 | { | ||
252 | struct irq_info *info = info_for_irq(irq); | ||
253 | |||
254 | BUG_ON(info == NULL); | ||
255 | BUG_ON(info->type != IRQT_PIRQ); | ||
256 | |||
257 | return info->u.pirq.gsi; | ||
258 | } | ||
259 | |||
260 | static enum xen_irq_type type_from_irq(unsigned irq) | 246 | static enum xen_irq_type type_from_irq(unsigned irq) |
261 | { | 247 | { |
262 | return info_for_irq(irq)->type; | 248 | return info_for_irq(irq)->type; |
@@ -653,12 +639,6 @@ int xen_bind_pirq_gsi_to_irq(unsigned gsi, | |||
653 | 639 | ||
654 | spin_lock(&irq_mapping_update_lock); | 640 | spin_lock(&irq_mapping_update_lock); |
655 | 641 | ||
656 | if (pirq > nr_irqs) { | ||
657 | printk(KERN_WARNING "xen_map_pirq_gsi: pirq %d > nr_irqs %d!\n", | ||
658 | pirq, nr_irqs); | ||
659 | goto out; | ||
660 | } | ||
661 | |||
662 | irq = find_irq_by_gsi(gsi); | 642 | irq = find_irq_by_gsi(gsi); |
663 | if (irq != -1) { | 643 | if (irq != -1) { |
664 | printk(KERN_INFO "xen_map_pirq_gsi: returning irq %d for gsi %u\n", | 644 | printk(KERN_INFO "xen_map_pirq_gsi: returning irq %d for gsi %u\n", |
@@ -758,7 +738,6 @@ int xen_destroy_irq(int irq) | |||
758 | goto out; | 738 | goto out; |
759 | } | 739 | } |
760 | } | 740 | } |
761 | pirq_to_irq[info->u.pirq.pirq] = -1; | ||
762 | 741 | ||
763 | xen_free_irq(irq); | 742 | xen_free_irq(irq); |
764 | 743 | ||
@@ -769,7 +748,24 @@ out: | |||
769 | 748 | ||
770 | int xen_irq_from_pirq(unsigned pirq) | 749 | int xen_irq_from_pirq(unsigned pirq) |
771 | { | 750 | { |
772 | return pirq_to_irq[pirq]; | 751 | int irq; |
752 | |||
753 | struct irq_info *info; | ||
754 | |||
755 | spin_lock(&irq_mapping_update_lock); | ||
756 | |||
757 | list_for_each_entry(info, &xen_irq_list_head, list) { | ||
758 | if (info == NULL || info->type != IRQT_PIRQ) | ||
759 | continue; | ||
760 | irq = info->irq; | ||
761 | if (info->u.pirq.pirq == pirq) | ||
762 | goto out; | ||
763 | } | ||
764 | irq = -1; | ||
765 | out: | ||
766 | spin_lock(&irq_mapping_update_lock); | ||
767 | |||
768 | return irq; | ||
773 | } | 769 | } |
774 | 770 | ||
775 | int bind_evtchn_to_irq(unsigned int evtchn) | 771 | int bind_evtchn_to_irq(unsigned int evtchn) |
@@ -1269,15 +1265,18 @@ static void restore_pirqs(void) | |||
1269 | { | 1265 | { |
1270 | int pirq, rc, irq, gsi; | 1266 | int pirq, rc, irq, gsi; |
1271 | struct physdev_map_pirq map_irq; | 1267 | struct physdev_map_pirq map_irq; |
1268 | struct irq_info *info; | ||
1272 | 1269 | ||
1273 | for (pirq = 0; pirq < nr_irqs; pirq++) { | 1270 | list_for_each_entry(info, &xen_irq_list_head, list) { |
1274 | irq = pirq_to_irq[pirq]; | 1271 | if (info->type != IRQT_PIRQ) |
1275 | if (irq == -1) | ||
1276 | continue; | 1272 | continue; |
1277 | 1273 | ||
1274 | pirq = info->u.pirq.pirq; | ||
1275 | gsi = info->u.pirq.gsi; | ||
1276 | irq = info->irq; | ||
1277 | |||
1278 | /* save/restore of PT devices doesn't work, so at this point the | 1278 | /* save/restore of PT devices doesn't work, so at this point the |
1279 | * only devices present are GSI based emulated devices */ | 1279 | * only devices present are GSI based emulated devices */ |
1280 | gsi = gsi_from_irq(irq); | ||
1281 | if (!gsi) | 1280 | if (!gsi) |
1282 | continue; | 1281 | continue; |
1283 | 1282 | ||
@@ -1291,7 +1290,6 @@ static void restore_pirqs(void) | |||
1291 | printk(KERN_WARNING "xen map irq failed gsi=%d irq=%d pirq=%d rc=%d\n", | 1290 | printk(KERN_WARNING "xen map irq failed gsi=%d irq=%d pirq=%d rc=%d\n", |
1292 | gsi, irq, pirq, rc); | 1291 | gsi, irq, pirq, rc); |
1293 | xen_free_irq(irq); | 1292 | xen_free_irq(irq); |
1294 | pirq_to_irq[pirq] = -1; | ||
1295 | continue; | 1293 | continue; |
1296 | } | 1294 | } |
1297 | 1295 | ||
@@ -1512,13 +1510,6 @@ void __init xen_init_IRQ(void) | |||
1512 | { | 1510 | { |
1513 | int i; | 1511 | int i; |
1514 | 1512 | ||
1515 | /* We are using nr_irqs as the maximum number of pirq available but | ||
1516 | * that number is actually chosen by Xen and we don't know exactly | ||
1517 | * what it is. Be careful choosing high pirq numbers. */ | ||
1518 | pirq_to_irq = kcalloc(nr_irqs, sizeof(*pirq_to_irq), GFP_KERNEL); | ||
1519 | for (i = 0; i < nr_irqs; i++) | ||
1520 | pirq_to_irq[i] = -1; | ||
1521 | |||
1522 | evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq), | 1513 | evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq), |
1523 | GFP_KERNEL); | 1514 | GFP_KERNEL); |
1524 | for (i = 0; i < NR_EVENT_CHANNELS; i++) | 1515 | for (i = 0; i < NR_EVENT_CHANNELS; i++) |