Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Xen event channels |
| 3 | * |
| 4 | * Xen models interrupts with abstract event channels. Because each |
| 5 | * domain gets 1024 event channels, but NR_IRQ is not that large, we |
| 6 | * must dynamically map irqs<->event channels. The event channels |
| 7 | * interface with the rest of the kernel by defining a xen interrupt |
| 8 | * chip. When an event is recieved, it is mapped to an irq and sent |
| 9 | * through the normal interrupt processing path. |
| 10 | * |
| 11 | * There are four kinds of events which can be mapped to an event |
| 12 | * channel: |
| 13 | * |
| 14 | * 1. Inter-domain notifications. This includes all the virtual |
| 15 | * device events, since they're driven by front-ends in another domain |
| 16 | * (typically dom0). |
| 17 | * 2. VIRQs, typically used for timers. These are per-cpu events. |
| 18 | * 3. IPIs. |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 19 | * 4. PIRQs - Hardware interrupts. |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 20 | * |
| 21 | * Jeremy Fitzhardinge <jeremy@xensource.com>, XenSource Inc, 2007 |
| 22 | */ |
| 23 | |
| 24 | #include <linux/linkage.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/irq.h> |
| 27 | #include <linux/module.h> |
| 28 | #include <linux/string.h> |
Christophe Saout | 28e0886 | 2009-01-11 11:46:23 -0800 | [diff] [blame] | 29 | #include <linux/bootmem.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 30 | #include <linux/slab.h> |
Jeremy Fitzhardinge | b21ddbf | 2010-06-07 16:28:49 -0400 | [diff] [blame] | 31 | #include <linux/irqnr.h> |
Qing He | f731e3ef | 2010-10-11 15:30:09 +0100 | [diff] [blame] | 32 | #include <linux/pci.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 33 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 34 | #include <asm/desc.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 35 | #include <asm/ptrace.h> |
| 36 | #include <asm/irq.h> |
Jeremy Fitzhardinge | 792dc4f | 2009-02-06 14:09:43 -0800 | [diff] [blame] | 37 | #include <asm/idle.h> |
Konrad Rzeszutek Wilk | 0794bfc | 2010-10-18 10:41:08 -0400 | [diff] [blame] | 38 | #include <asm/io_apic.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 39 | #include <asm/sync_bitops.h> |
Stefano Stabellini | 42a1de5 | 2010-06-24 16:42:04 +0100 | [diff] [blame] | 40 | #include <asm/xen/pci.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 41 | #include <asm/xen/hypercall.h> |
Adrian Bunk | 8d1b875 | 2007-07-20 00:31:44 -0700 | [diff] [blame] | 42 | #include <asm/xen/hypervisor.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 43 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 44 | #include <xen/xen.h> |
| 45 | #include <xen/hvm.h> |
Isaku Yamahata | e04d0d0 | 2008-04-02 10:53:55 -0700 | [diff] [blame] | 46 | #include <xen/xen-ops.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 47 | #include <xen/events.h> |
| 48 | #include <xen/interface/xen.h> |
| 49 | #include <xen/interface/event_channel.h> |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 50 | #include <xen/interface/hvm/hvm_op.h> |
| 51 | #include <xen/interface/hvm/params.h> |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 52 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 53 | /* |
| 54 | * This lock protects updates to the following mapping and reference-count |
| 55 | * arrays. The lock does not need to be acquired to read the mapping tables. |
| 56 | */ |
| 57 | static DEFINE_SPINLOCK(irq_mapping_update_lock); |
| 58 | |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 59 | static LIST_HEAD(xen_irq_list_head); |
| 60 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 61 | /* IRQ <-> VIRQ mapping. */ |
Tejun Heo | 204fba4 | 2009-06-24 15:13:45 +0900 | [diff] [blame] | 62 | static DEFINE_PER_CPU(int [NR_VIRQS], virq_to_irq) = {[0 ... NR_VIRQS-1] = -1}; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 63 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 64 | /* IRQ <-> IPI mapping */ |
Tejun Heo | 204fba4 | 2009-06-24 15:13:45 +0900 | [diff] [blame] | 65 | static DEFINE_PER_CPU(int [XEN_NR_IPIS], ipi_to_irq) = {[0 ... XEN_NR_IPIS-1] = -1}; |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 66 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 67 | /* Interrupt types. */ |
| 68 | enum xen_irq_type { |
Jeremy Fitzhardinge | d77bbd4 | 2009-02-06 14:09:45 -0800 | [diff] [blame] | 69 | IRQT_UNBOUND = 0, |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 70 | IRQT_PIRQ, |
| 71 | IRQT_VIRQ, |
| 72 | IRQT_IPI, |
| 73 | IRQT_EVTCHN |
| 74 | }; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 75 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 76 | /* |
| 77 | * Packed IRQ information: |
| 78 | * type - enum xen_irq_type |
| 79 | * event channel - irq->event channel mapping |
| 80 | * cpu - cpu this event channel is bound to |
| 81 | * index - type-specific information: |
Stefano Stabellini | 42a1de5 | 2010-06-24 16:42:04 +0100 | [diff] [blame] | 82 | * PIRQ - vector, with MSB being "needs EIO", or physical IRQ of the HVM |
| 83 | * guest, or GSI (real passthrough IRQ) of the device. |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 84 | * VIRQ - virq number |
| 85 | * IPI - IPI vector |
| 86 | * EVTCHN - |
| 87 | */ |
| 88 | struct irq_info |
| 89 | { |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 90 | struct list_head list; |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 91 | enum xen_irq_type type; /* type */ |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 92 | unsigned irq; |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 93 | unsigned short evtchn; /* event channel */ |
| 94 | unsigned short cpu; /* cpu bound */ |
| 95 | |
| 96 | union { |
| 97 | unsigned short virq; |
| 98 | enum ipi_vector ipi; |
| 99 | struct { |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 100 | unsigned short pirq; |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 101 | unsigned short gsi; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 102 | unsigned char vector; |
| 103 | unsigned char flags; |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 104 | } pirq; |
| 105 | } u; |
| 106 | }; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 107 | #define PIRQ_NEEDS_EOI (1 << 0) |
Konrad Rzeszutek Wilk | 15ebbb8 | 2010-10-04 13:43:27 -0400 | [diff] [blame] | 108 | #define PIRQ_SHAREABLE (1 << 1) |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 109 | |
Jeremy Fitzhardinge | b21ddbf | 2010-06-07 16:28:49 -0400 | [diff] [blame] | 110 | static struct irq_info *irq_info; |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 111 | static int *pirq_to_irq; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 112 | |
Jeremy Fitzhardinge | b21ddbf | 2010-06-07 16:28:49 -0400 | [diff] [blame] | 113 | static int *evtchn_to_irq; |
Jeremy Fitzhardinge | 3b32f57 | 2009-08-13 12:50:37 -0700 | [diff] [blame] | 114 | |
Ian Campbell | cb60d11 | 2011-03-10 16:08:08 +0000 | [diff] [blame] | 115 | static DEFINE_PER_CPU(unsigned long [NR_EVENT_CHANNELS/BITS_PER_LONG], |
| 116 | cpu_evtchn_mask); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 117 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 118 | /* Xen will never allocate port zero for any purpose. */ |
| 119 | #define VALID_EVTCHN(chn) ((chn) != 0) |
| 120 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 121 | static struct irq_chip xen_dynamic_chip; |
Jeremy Fitzhardinge | aaca496 | 2010-08-20 18:57:53 -0700 | [diff] [blame] | 122 | static struct irq_chip xen_percpu_chip; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 123 | static struct irq_chip xen_pirq_chip; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 124 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 125 | /* Get info for IRQ */ |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 126 | static struct irq_info *info_for_irq(unsigned irq) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 127 | { |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 128 | return &irq_info[irq]; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 131 | /* Constructors for packed IRQ information. */ |
| 132 | static void xen_irq_info_common_init(struct irq_info *info, |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 133 | unsigned irq, |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 134 | enum xen_irq_type type, |
| 135 | unsigned short evtchn, |
| 136 | unsigned short cpu) |
| 137 | { |
| 138 | |
| 139 | BUG_ON(info->type != IRQT_UNBOUND && info->type != type); |
| 140 | |
| 141 | info->type = type; |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 142 | info->irq = irq; |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 143 | info->evtchn = evtchn; |
| 144 | info->cpu = cpu; |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 145 | |
| 146 | evtchn_to_irq[evtchn] = irq; |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | static void xen_irq_info_evtchn_init(unsigned irq, |
| 150 | unsigned short evtchn) |
| 151 | { |
| 152 | struct irq_info *info = info_for_irq(irq); |
| 153 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 154 | xen_irq_info_common_init(info, irq, IRQT_EVTCHN, evtchn, 0); |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 155 | } |
| 156 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 157 | static void xen_irq_info_ipi_init(unsigned cpu, |
| 158 | unsigned irq, |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 159 | unsigned short evtchn, |
| 160 | enum ipi_vector ipi) |
| 161 | { |
| 162 | struct irq_info *info = info_for_irq(irq); |
| 163 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 164 | xen_irq_info_common_init(info, irq, IRQT_IPI, evtchn, 0); |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 165 | |
| 166 | info->u.ipi = ipi; |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 167 | |
| 168 | per_cpu(ipi_to_irq, cpu)[ipi] = irq; |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 169 | } |
| 170 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 171 | static void xen_irq_info_virq_init(unsigned cpu, |
| 172 | unsigned irq, |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 173 | unsigned short evtchn, |
| 174 | unsigned short virq) |
| 175 | { |
| 176 | struct irq_info *info = info_for_irq(irq); |
| 177 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 178 | xen_irq_info_common_init(info, irq, IRQT_VIRQ, evtchn, 0); |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 179 | |
| 180 | info->u.virq = virq; |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 181 | |
| 182 | per_cpu(virq_to_irq, cpu)[virq] = irq; |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 183 | } |
| 184 | |
| 185 | static void xen_irq_info_pirq_init(unsigned irq, |
| 186 | unsigned short evtchn, |
| 187 | unsigned short pirq, |
| 188 | unsigned short gsi, |
| 189 | unsigned short vector, |
| 190 | unsigned char flags) |
| 191 | { |
| 192 | struct irq_info *info = info_for_irq(irq); |
| 193 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 194 | xen_irq_info_common_init(info, irq, IRQT_PIRQ, evtchn, 0); |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 195 | |
| 196 | info->u.pirq.pirq = pirq; |
| 197 | info->u.pirq.gsi = gsi; |
| 198 | info->u.pirq.vector = vector; |
| 199 | info->u.pirq.flags = flags; |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 200 | |
| 201 | pirq_to_irq[pirq] = irq; |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | /* |
| 205 | * Accessors for packed IRQ information. |
| 206 | */ |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 207 | static unsigned int evtchn_from_irq(unsigned irq) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 208 | { |
Joe Jin | 110e7c7 | 2011-01-07 14:50:12 +0800 | [diff] [blame] | 209 | if (unlikely(WARN(irq < 0 || irq >= nr_irqs, "Invalid irq %d!\n", irq))) |
| 210 | return 0; |
| 211 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 212 | return info_for_irq(irq)->evtchn; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 213 | } |
| 214 | |
Ian Campbell | d4c0453 | 2009-02-06 19:20:31 -0800 | [diff] [blame] | 215 | unsigned irq_from_evtchn(unsigned int evtchn) |
| 216 | { |
| 217 | return evtchn_to_irq[evtchn]; |
| 218 | } |
| 219 | EXPORT_SYMBOL_GPL(irq_from_evtchn); |
| 220 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 221 | static enum ipi_vector ipi_from_irq(unsigned irq) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 222 | { |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 223 | struct irq_info *info = info_for_irq(irq); |
| 224 | |
| 225 | BUG_ON(info == NULL); |
| 226 | BUG_ON(info->type != IRQT_IPI); |
| 227 | |
| 228 | return info->u.ipi; |
| 229 | } |
| 230 | |
| 231 | static unsigned virq_from_irq(unsigned irq) |
| 232 | { |
| 233 | struct irq_info *info = info_for_irq(irq); |
| 234 | |
| 235 | BUG_ON(info == NULL); |
| 236 | BUG_ON(info->type != IRQT_VIRQ); |
| 237 | |
| 238 | return info->u.virq; |
| 239 | } |
| 240 | |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 241 | static unsigned pirq_from_irq(unsigned irq) |
| 242 | { |
| 243 | struct irq_info *info = info_for_irq(irq); |
| 244 | |
| 245 | BUG_ON(info == NULL); |
| 246 | BUG_ON(info->type != IRQT_PIRQ); |
| 247 | |
| 248 | return info->u.pirq.pirq; |
| 249 | } |
| 250 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 251 | static unsigned gsi_from_irq(unsigned irq) |
| 252 | { |
| 253 | struct irq_info *info = info_for_irq(irq); |
| 254 | |
| 255 | BUG_ON(info == NULL); |
| 256 | BUG_ON(info->type != IRQT_PIRQ); |
| 257 | |
| 258 | return info->u.pirq.gsi; |
| 259 | } |
| 260 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 261 | static enum xen_irq_type type_from_irq(unsigned irq) |
| 262 | { |
| 263 | return info_for_irq(irq)->type; |
| 264 | } |
| 265 | |
| 266 | static unsigned cpu_from_irq(unsigned irq) |
| 267 | { |
| 268 | return info_for_irq(irq)->cpu; |
| 269 | } |
| 270 | |
| 271 | static unsigned int cpu_from_evtchn(unsigned int evtchn) |
| 272 | { |
| 273 | int irq = evtchn_to_irq[evtchn]; |
| 274 | unsigned ret = 0; |
| 275 | |
| 276 | if (irq != -1) |
| 277 | ret = cpu_from_irq(irq); |
| 278 | |
| 279 | return ret; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 282 | static bool pirq_needs_eoi(unsigned irq) |
| 283 | { |
| 284 | struct irq_info *info = info_for_irq(irq); |
| 285 | |
| 286 | BUG_ON(info->type != IRQT_PIRQ); |
| 287 | |
| 288 | return info->u.pirq.flags & PIRQ_NEEDS_EOI; |
| 289 | } |
| 290 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 291 | static inline unsigned long active_evtchns(unsigned int cpu, |
| 292 | struct shared_info *sh, |
| 293 | unsigned int idx) |
| 294 | { |
| 295 | return (sh->evtchn_pending[idx] & |
Ian Campbell | cb60d11 | 2011-03-10 16:08:08 +0000 | [diff] [blame] | 296 | per_cpu(cpu_evtchn_mask, cpu)[idx] & |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 297 | ~sh->evtchn_mask[idx]); |
| 298 | } |
| 299 | |
| 300 | static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu) |
| 301 | { |
| 302 | int irq = evtchn_to_irq[chn]; |
| 303 | |
| 304 | BUG_ON(irq == -1); |
| 305 | #ifdef CONFIG_SMP |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 306 | cpumask_copy(irq_to_desc(irq)->irq_data.affinity, cpumask_of(cpu)); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 307 | #endif |
| 308 | |
Ian Campbell | cb60d11 | 2011-03-10 16:08:08 +0000 | [diff] [blame] | 309 | clear_bit(chn, per_cpu(cpu_evtchn_mask, cpu_from_irq(irq))); |
| 310 | set_bit(chn, per_cpu(cpu_evtchn_mask, cpu)); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 311 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 312 | irq_info[irq].cpu = cpu; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 313 | } |
| 314 | |
| 315 | static void init_evtchn_cpu_bindings(void) |
| 316 | { |
Jan Beulich | 1c6969e | 2010-11-16 14:55:33 -0800 | [diff] [blame] | 317 | int i; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 318 | #ifdef CONFIG_SMP |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 319 | struct irq_info *info; |
Thomas Gleixner | 10e5808 | 2008-10-16 14:19:04 +0200 | [diff] [blame] | 320 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 321 | /* By default all event channels notify CPU#0. */ |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 322 | list_for_each_entry(info, &xen_irq_list_head, list) { |
| 323 | struct irq_desc *desc = irq_to_desc(info->irq); |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 324 | cpumask_copy(desc->irq_data.affinity, cpumask_of(0)); |
Yinghai Lu | 0b8f1ef | 2008-12-05 18:58:31 -0800 | [diff] [blame] | 325 | } |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 326 | #endif |
| 327 | |
Jan Beulich | 1c6969e | 2010-11-16 14:55:33 -0800 | [diff] [blame] | 328 | for_each_possible_cpu(i) |
Ian Campbell | cb60d11 | 2011-03-10 16:08:08 +0000 | [diff] [blame] | 329 | memset(per_cpu(cpu_evtchn_mask, i), |
| 330 | (i == 0) ? ~0 : 0, sizeof(*per_cpu(cpu_evtchn_mask, i))); |
Jan Beulich | 1c6969e | 2010-11-16 14:55:33 -0800 | [diff] [blame] | 331 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 332 | } |
| 333 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 334 | static inline void clear_evtchn(int port) |
| 335 | { |
| 336 | struct shared_info *s = HYPERVISOR_shared_info; |
| 337 | sync_clear_bit(port, &s->evtchn_pending[0]); |
| 338 | } |
| 339 | |
| 340 | static inline void set_evtchn(int port) |
| 341 | { |
| 342 | struct shared_info *s = HYPERVISOR_shared_info; |
| 343 | sync_set_bit(port, &s->evtchn_pending[0]); |
| 344 | } |
| 345 | |
Jeremy Fitzhardinge | 168d2f4 | 2008-08-20 17:02:18 -0700 | [diff] [blame] | 346 | static inline int test_evtchn(int port) |
| 347 | { |
| 348 | struct shared_info *s = HYPERVISOR_shared_info; |
| 349 | return sync_test_bit(port, &s->evtchn_pending[0]); |
| 350 | } |
| 351 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 352 | |
| 353 | /** |
| 354 | * notify_remote_via_irq - send event to remote end of event channel via irq |
| 355 | * @irq: irq of event channel to send event to |
| 356 | * |
| 357 | * Unlike notify_remote_via_evtchn(), this is safe to use across |
| 358 | * save/restore. Notifications on a broken connection are silently |
| 359 | * dropped. |
| 360 | */ |
| 361 | void notify_remote_via_irq(int irq) |
| 362 | { |
| 363 | int evtchn = evtchn_from_irq(irq); |
| 364 | |
| 365 | if (VALID_EVTCHN(evtchn)) |
| 366 | notify_remote_via_evtchn(evtchn); |
| 367 | } |
| 368 | EXPORT_SYMBOL_GPL(notify_remote_via_irq); |
| 369 | |
| 370 | static void mask_evtchn(int port) |
| 371 | { |
| 372 | struct shared_info *s = HYPERVISOR_shared_info; |
| 373 | sync_set_bit(port, &s->evtchn_mask[0]); |
| 374 | } |
| 375 | |
| 376 | static void unmask_evtchn(int port) |
| 377 | { |
| 378 | struct shared_info *s = HYPERVISOR_shared_info; |
| 379 | unsigned int cpu = get_cpu(); |
| 380 | |
| 381 | BUG_ON(!irqs_disabled()); |
| 382 | |
| 383 | /* Slow path (hypercall) if this is a non-local port. */ |
| 384 | if (unlikely(cpu != cpu_from_evtchn(port))) { |
| 385 | struct evtchn_unmask unmask = { .port = port }; |
| 386 | (void)HYPERVISOR_event_channel_op(EVTCHNOP_unmask, &unmask); |
| 387 | } else { |
Christoph Lameter | 780f36d | 2010-12-06 11:16:29 -0600 | [diff] [blame] | 388 | struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 389 | |
| 390 | sync_clear_bit(port, &s->evtchn_mask[0]); |
| 391 | |
| 392 | /* |
| 393 | * The following is basically the equivalent of |
| 394 | * 'hw_resend_irq'. Just like a real IO-APIC we 'lose |
| 395 | * the interrupt edge' if the channel is masked. |
| 396 | */ |
| 397 | if (sync_test_bit(port, &s->evtchn_pending[0]) && |
| 398 | !sync_test_and_set_bit(port / BITS_PER_LONG, |
| 399 | &vcpu_info->evtchn_pending_sel)) |
| 400 | vcpu_info->evtchn_upcall_pending = 1; |
| 401 | } |
| 402 | |
| 403 | put_cpu(); |
| 404 | } |
| 405 | |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 406 | static void xen_irq_init(unsigned irq) |
| 407 | { |
| 408 | struct irq_info *info; |
| 409 | struct irq_desc *desc = irq_to_desc(irq); |
| 410 | |
| 411 | /* By default all event channels notify CPU#0. */ |
| 412 | cpumask_copy(desc->irq_data.affinity, cpumask_of(0)); |
| 413 | |
| 414 | info = &irq_info[irq]; |
| 415 | |
| 416 | info->type = IRQT_UNBOUND; |
| 417 | |
| 418 | list_add_tail(&info->list, &xen_irq_list_head); |
| 419 | } |
| 420 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 421 | static int xen_allocate_irq_dynamic(void) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 422 | { |
Ian Campbell | 8991150 | 2011-03-03 11:57:44 -0500 | [diff] [blame] | 423 | int first = 0; |
| 424 | int irq; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 425 | |
Ian Campbell | 8991150 | 2011-03-03 11:57:44 -0500 | [diff] [blame] | 426 | #ifdef CONFIG_X86_IO_APIC |
| 427 | /* |
| 428 | * For an HVM guest or domain 0 which see "real" (emulated or |
| 429 | * actual repectively) GSIs we allocate dynamic IRQs |
| 430 | * e.g. those corresponding to event channels or MSIs |
| 431 | * etc. from the range above those "real" GSIs to avoid |
| 432 | * collisions. |
Konrad Rzeszutek Wilk | d1b758e | 2010-12-09 14:53:29 -0500 | [diff] [blame] | 433 | */ |
Ian Campbell | 8991150 | 2011-03-03 11:57:44 -0500 | [diff] [blame] | 434 | if (xen_initial_domain() || xen_hvm_domain()) |
| 435 | first = get_nr_irqs_gsi(); |
| 436 | #endif |
| 437 | |
| 438 | retry: |
| 439 | irq = irq_alloc_desc_from(first, -1); |
| 440 | |
| 441 | if (irq == -ENOMEM && first > NR_IRQS_LEGACY) { |
| 442 | printk(KERN_ERR "Out of dynamic IRQ space and eating into GSI space. You should increase nr_irqs\n"); |
| 443 | first = max(NR_IRQS_LEGACY, first - NR_IRQS_LEGACY); |
| 444 | goto retry; |
Stefano Stabellini | 99ad198 | 2010-05-14 12:41:20 +0100 | [diff] [blame] | 445 | } |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 446 | |
Ian Campbell | 8991150 | 2011-03-03 11:57:44 -0500 | [diff] [blame] | 447 | if (irq < 0) |
| 448 | panic("No available IRQ to bind to: increase nr_irqs!\n"); |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 449 | |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 450 | xen_irq_init(irq); |
| 451 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 452 | return irq; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 453 | } |
| 454 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 455 | static int xen_allocate_irq_gsi(unsigned gsi) |
| 456 | { |
| 457 | int irq; |
| 458 | |
Ian Campbell | 8991150 | 2011-03-03 11:57:44 -0500 | [diff] [blame] | 459 | /* |
| 460 | * A PV guest has no concept of a GSI (since it has no ACPI |
| 461 | * nor access to/knowledge of the physical APICs). Therefore |
| 462 | * all IRQs are dynamically allocated from the entire IRQ |
| 463 | * space. |
| 464 | */ |
| 465 | if (xen_pv_domain() && !xen_initial_domain()) |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 466 | return xen_allocate_irq_dynamic(); |
| 467 | |
| 468 | /* Legacy IRQ descriptors are already allocated by the arch. */ |
| 469 | if (gsi < NR_IRQS_LEGACY) |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 470 | irq = gsi; |
| 471 | else |
| 472 | irq = irq_alloc_desc_at(gsi, -1); |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 473 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 474 | if (irq < 0) |
| 475 | panic("Unable to allocate to IRQ%d (%d)\n", gsi, irq); |
| 476 | |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 477 | xen_irq_init(irq); |
| 478 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 479 | return irq; |
| 480 | } |
| 481 | |
| 482 | static void xen_free_irq(unsigned irq) |
| 483 | { |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 484 | struct irq_info *info = &irq_info[irq]; |
| 485 | |
| 486 | info->type = IRQT_UNBOUND; |
| 487 | |
| 488 | list_del(&info->list); |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 489 | |
Ian Campbell | 7214610 | 2011-02-03 09:49:35 +0000 | [diff] [blame] | 490 | /* Legacy IRQ descriptors are managed by the arch. */ |
| 491 | if (irq < NR_IRQS_LEGACY) |
| 492 | return; |
| 493 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 494 | irq_free_desc(irq); |
| 495 | } |
| 496 | |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 497 | static void pirq_unmask_notify(int irq) |
| 498 | { |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 499 | struct physdev_eoi eoi = { .irq = pirq_from_irq(irq) }; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 500 | |
| 501 | if (unlikely(pirq_needs_eoi(irq))) { |
| 502 | int rc = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); |
| 503 | WARN_ON(rc); |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | static void pirq_query_unmask(int irq) |
| 508 | { |
| 509 | struct physdev_irq_status_query irq_status; |
| 510 | struct irq_info *info = info_for_irq(irq); |
| 511 | |
| 512 | BUG_ON(info->type != IRQT_PIRQ); |
| 513 | |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 514 | irq_status.irq = pirq_from_irq(irq); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 515 | if (HYPERVISOR_physdev_op(PHYSDEVOP_irq_status_query, &irq_status)) |
| 516 | irq_status.flags = 0; |
| 517 | |
| 518 | info->u.pirq.flags &= ~PIRQ_NEEDS_EOI; |
| 519 | if (irq_status.flags & XENIRQSTAT_needs_eoi) |
| 520 | info->u.pirq.flags |= PIRQ_NEEDS_EOI; |
| 521 | } |
| 522 | |
| 523 | static bool probing_irq(int irq) |
| 524 | { |
| 525 | struct irq_desc *desc = irq_to_desc(irq); |
| 526 | |
| 527 | return desc && desc->action == NULL; |
| 528 | } |
| 529 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 530 | static unsigned int __startup_pirq(unsigned int irq) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 531 | { |
| 532 | struct evtchn_bind_pirq bind_pirq; |
| 533 | struct irq_info *info = info_for_irq(irq); |
| 534 | int evtchn = evtchn_from_irq(irq); |
Konrad Rzeszutek Wilk | 15ebbb8 | 2010-10-04 13:43:27 -0400 | [diff] [blame] | 535 | int rc; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 536 | |
| 537 | BUG_ON(info->type != IRQT_PIRQ); |
| 538 | |
| 539 | if (VALID_EVTCHN(evtchn)) |
| 540 | goto out; |
| 541 | |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 542 | bind_pirq.pirq = pirq_from_irq(irq); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 543 | /* NB. We are happy to share unless we are probing. */ |
Konrad Rzeszutek Wilk | 15ebbb8 | 2010-10-04 13:43:27 -0400 | [diff] [blame] | 544 | bind_pirq.flags = info->u.pirq.flags & PIRQ_SHAREABLE ? |
| 545 | BIND_PIRQ__WILL_SHARE : 0; |
| 546 | rc = HYPERVISOR_event_channel_op(EVTCHNOP_bind_pirq, &bind_pirq); |
| 547 | if (rc != 0) { |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 548 | if (!probing_irq(irq)) |
| 549 | printk(KERN_INFO "Failed to obtain physical IRQ %d\n", |
| 550 | irq); |
| 551 | return 0; |
| 552 | } |
| 553 | evtchn = bind_pirq.port; |
| 554 | |
| 555 | pirq_query_unmask(irq); |
| 556 | |
| 557 | evtchn_to_irq[evtchn] = irq; |
| 558 | bind_evtchn_to_cpu(evtchn, 0); |
| 559 | info->evtchn = evtchn; |
| 560 | |
| 561 | out: |
| 562 | unmask_evtchn(evtchn); |
| 563 | pirq_unmask_notify(irq); |
| 564 | |
| 565 | return 0; |
| 566 | } |
| 567 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 568 | static unsigned int startup_pirq(struct irq_data *data) |
| 569 | { |
| 570 | return __startup_pirq(data->irq); |
| 571 | } |
| 572 | |
| 573 | static void shutdown_pirq(struct irq_data *data) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 574 | { |
| 575 | struct evtchn_close close; |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 576 | unsigned int irq = data->irq; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 577 | struct irq_info *info = info_for_irq(irq); |
| 578 | int evtchn = evtchn_from_irq(irq); |
| 579 | |
| 580 | BUG_ON(info->type != IRQT_PIRQ); |
| 581 | |
| 582 | if (!VALID_EVTCHN(evtchn)) |
| 583 | return; |
| 584 | |
| 585 | mask_evtchn(evtchn); |
| 586 | |
| 587 | close.port = evtchn; |
| 588 | if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0) |
| 589 | BUG(); |
| 590 | |
| 591 | bind_evtchn_to_cpu(evtchn, 0); |
| 592 | evtchn_to_irq[evtchn] = -1; |
| 593 | info->evtchn = 0; |
| 594 | } |
| 595 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 596 | static void enable_pirq(struct irq_data *data) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 597 | { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 598 | startup_pirq(data); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 599 | } |
| 600 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 601 | static void disable_pirq(struct irq_data *data) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 602 | { |
| 603 | } |
| 604 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 605 | static void ack_pirq(struct irq_data *data) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 606 | { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 607 | int evtchn = evtchn_from_irq(data->irq); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 608 | |
Ian Campbell | aa673c1 | 2011-02-07 11:08:39 +0000 | [diff] [blame] | 609 | move_native_irq(data->irq); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 610 | |
| 611 | if (VALID_EVTCHN(evtchn)) { |
| 612 | mask_evtchn(evtchn); |
| 613 | clear_evtchn(evtchn); |
| 614 | } |
| 615 | } |
| 616 | |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 617 | static int find_irq_by_gsi(unsigned gsi) |
| 618 | { |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 619 | struct irq_info *info; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 620 | |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 621 | list_for_each_entry(info, &xen_irq_list_head, list) { |
| 622 | if (info->type != IRQT_PIRQ) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 623 | continue; |
| 624 | |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 625 | if (info->u.pirq.gsi == gsi) |
| 626 | return info->irq; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 627 | } |
| 628 | |
| 629 | return -1; |
| 630 | } |
| 631 | |
Ian Campbell | f4d0635 | 2011-03-10 16:08:07 +0000 | [diff] [blame] | 632 | int xen_allocate_pirq_gsi(unsigned gsi) |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 633 | { |
Ian Campbell | f4d0635 | 2011-03-10 16:08:07 +0000 | [diff] [blame] | 634 | return gsi; |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 635 | } |
| 636 | |
Ian Campbell | 653378a | 2011-03-10 16:08:04 +0000 | [diff] [blame] | 637 | /* |
| 638 | * Do not make any assumptions regarding the relationship between the |
| 639 | * IRQ number returned here and the Xen pirq argument. |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 640 | * |
| 641 | * Note: We don't assign an event channel until the irq actually started |
| 642 | * up. Return an existing irq if we've already got one for the gsi. |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 643 | */ |
Ian Campbell | f4d0635 | 2011-03-10 16:08:07 +0000 | [diff] [blame] | 644 | int xen_bind_pirq_gsi_to_irq(unsigned gsi, |
| 645 | unsigned pirq, int shareable, char *name) |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 646 | { |
Ian Campbell | a0e1811 | 2011-03-10 16:08:03 +0000 | [diff] [blame] | 647 | int irq = -1; |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 648 | struct physdev_irq irq_op; |
| 649 | |
| 650 | spin_lock(&irq_mapping_update_lock); |
| 651 | |
Stefano Stabellini | e5fc734 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 652 | if ((pirq > nr_irqs) || (gsi > nr_irqs)) { |
Stefano Stabellini | 01557ba | 2010-08-20 14:46:52 +0100 | [diff] [blame] | 653 | printk(KERN_WARNING "xen_map_pirq_gsi: %s %s is incorrect!\n", |
Stefano Stabellini | e5fc734 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 654 | pirq > nr_irqs ? "pirq" :"", |
| 655 | gsi > nr_irqs ? "gsi" : ""); |
Stefano Stabellini | 01557ba | 2010-08-20 14:46:52 +0100 | [diff] [blame] | 656 | goto out; |
| 657 | } |
| 658 | |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 659 | irq = find_irq_by_gsi(gsi); |
| 660 | if (irq != -1) { |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 661 | printk(KERN_INFO "xen_map_pirq_gsi: returning irq %d for gsi %u\n", |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 662 | irq, gsi); |
| 663 | goto out; /* XXX need refcount? */ |
| 664 | } |
| 665 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 666 | irq = xen_allocate_irq_gsi(gsi); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 667 | |
| 668 | set_irq_chip_and_handler_name(irq, &xen_pirq_chip, |
Gerd Hoffmann | 1a60d05 | 2010-10-04 13:42:27 -0400 | [diff] [blame] | 669 | handle_level_irq, name); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 670 | |
| 671 | irq_op.irq = irq; |
Alex Nixon | b5401a9 | 2010-03-18 16:31:34 -0400 | [diff] [blame] | 672 | irq_op.vector = 0; |
| 673 | |
| 674 | /* Only the privileged domain can do this. For non-priv, the pcifront |
| 675 | * driver provides a PCI bus that does the call to do exactly |
| 676 | * this in the priv domain. */ |
| 677 | if (xen_initial_domain() && |
| 678 | HYPERVISOR_physdev_op(PHYSDEVOP_alloc_irq_vector, &irq_op)) { |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 679 | xen_free_irq(irq); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 680 | irq = -ENOSPC; |
| 681 | goto out; |
| 682 | } |
| 683 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 684 | xen_irq_info_pirq_init(irq, 0, pirq, gsi, irq_op.vector, |
| 685 | shareable ? PIRQ_SHAREABLE : 0); |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 686 | |
| 687 | out: |
| 688 | spin_unlock(&irq_mapping_update_lock); |
| 689 | |
| 690 | return irq; |
| 691 | } |
| 692 | |
Qing He | f731e3ef | 2010-10-11 15:30:09 +0100 | [diff] [blame] | 693 | #ifdef CONFIG_PCI_MSI |
Ian Campbell | bf480d9 | 2011-02-18 16:43:32 +0000 | [diff] [blame] | 694 | int xen_allocate_pirq_msi(struct pci_dev *dev, struct msi_desc *msidesc) |
Ian Campbell | cbf6aa8 | 2011-01-11 17:20:14 +0000 | [diff] [blame] | 695 | { |
Ian Campbell | 5cad61a | 2011-02-18 16:43:31 +0000 | [diff] [blame] | 696 | int rc; |
Ian Campbell | cbf6aa8 | 2011-01-11 17:20:14 +0000 | [diff] [blame] | 697 | struct physdev_get_free_pirq op_get_free_pirq; |
Ian Campbell | 5cad61a | 2011-02-18 16:43:31 +0000 | [diff] [blame] | 698 | |
Ian Campbell | bf480d9 | 2011-02-18 16:43:32 +0000 | [diff] [blame] | 699 | op_get_free_pirq.type = MAP_PIRQ_TYPE_MSI; |
Ian Campbell | cbf6aa8 | 2011-01-11 17:20:14 +0000 | [diff] [blame] | 700 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_get_free_pirq, &op_get_free_pirq); |
Ian Campbell | cbf6aa8 | 2011-01-11 17:20:14 +0000 | [diff] [blame] | 701 | |
Ian Campbell | 5cad61a | 2011-02-18 16:43:31 +0000 | [diff] [blame] | 702 | WARN_ONCE(rc == -ENOSYS, |
| 703 | "hypervisor does not support the PHYSDEVOP_get_free_pirq interface\n"); |
| 704 | |
| 705 | return rc ? -1 : op_get_free_pirq.pirq; |
Ian Campbell | cbf6aa8 | 2011-01-11 17:20:14 +0000 | [diff] [blame] | 706 | } |
| 707 | |
Ian Campbell | bf480d9 | 2011-02-18 16:43:32 +0000 | [diff] [blame] | 708 | int xen_bind_pirq_msi_to_irq(struct pci_dev *dev, struct msi_desc *msidesc, |
Ian Campbell | ca1d8fe | 2011-02-18 16:43:36 +0000 | [diff] [blame] | 709 | int pirq, int vector, const char *name) |
Stefano Stabellini | 809f926 | 2010-07-01 17:10:39 +0100 | [diff] [blame] | 710 | { |
Ian Campbell | bf480d9 | 2011-02-18 16:43:32 +0000 | [diff] [blame] | 711 | int irq, ret; |
Ian Campbell | 4b41df7 | 2011-02-18 16:43:29 +0000 | [diff] [blame] | 712 | |
Stefano Stabellini | 809f926 | 2010-07-01 17:10:39 +0100 | [diff] [blame] | 713 | spin_lock(&irq_mapping_update_lock); |
| 714 | |
Ian Campbell | 4b41df7 | 2011-02-18 16:43:29 +0000 | [diff] [blame] | 715 | irq = xen_allocate_irq_dynamic(); |
| 716 | if (irq == -1) |
Ian Campbell | bb5d079 | 2011-02-18 16:43:28 +0000 | [diff] [blame] | 717 | goto out; |
Stefano Stabellini | 809f926 | 2010-07-01 17:10:39 +0100 | [diff] [blame] | 718 | |
Ian Campbell | 4b41df7 | 2011-02-18 16:43:29 +0000 | [diff] [blame] | 719 | set_irq_chip_and_handler_name(irq, &xen_pirq_chip, |
Stefano Stabellini | 809f926 | 2010-07-01 17:10:39 +0100 | [diff] [blame] | 720 | handle_level_irq, name); |
| 721 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 722 | xen_irq_info_pirq_init(irq, 0, pirq, 0, vector, 0); |
Ian Campbell | bf480d9 | 2011-02-18 16:43:32 +0000 | [diff] [blame] | 723 | ret = set_irq_msi(irq, msidesc); |
| 724 | if (ret < 0) |
| 725 | goto error_irq; |
Stefano Stabellini | 809f926 | 2010-07-01 17:10:39 +0100 | [diff] [blame] | 726 | out: |
| 727 | spin_unlock(&irq_mapping_update_lock); |
Ian Campbell | 4b41df7 | 2011-02-18 16:43:29 +0000 | [diff] [blame] | 728 | return irq; |
Ian Campbell | bf480d9 | 2011-02-18 16:43:32 +0000 | [diff] [blame] | 729 | error_irq: |
| 730 | spin_unlock(&irq_mapping_update_lock); |
| 731 | xen_free_irq(irq); |
| 732 | return -1; |
Stefano Stabellini | 809f926 | 2010-07-01 17:10:39 +0100 | [diff] [blame] | 733 | } |
Qing He | f731e3ef | 2010-10-11 15:30:09 +0100 | [diff] [blame] | 734 | #endif |
| 735 | |
Alex Nixon | b5401a9 | 2010-03-18 16:31:34 -0400 | [diff] [blame] | 736 | int xen_destroy_irq(int irq) |
| 737 | { |
| 738 | struct irq_desc *desc; |
Jeremy Fitzhardinge | 38aa66f | 2010-09-02 14:51:39 +0100 | [diff] [blame] | 739 | struct physdev_unmap_pirq unmap_irq; |
| 740 | struct irq_info *info = info_for_irq(irq); |
Alex Nixon | b5401a9 | 2010-03-18 16:31:34 -0400 | [diff] [blame] | 741 | int rc = -ENOENT; |
| 742 | |
| 743 | spin_lock(&irq_mapping_update_lock); |
| 744 | |
| 745 | desc = irq_to_desc(irq); |
| 746 | if (!desc) |
| 747 | goto out; |
| 748 | |
Jeremy Fitzhardinge | 38aa66f | 2010-09-02 14:51:39 +0100 | [diff] [blame] | 749 | if (xen_initial_domain()) { |
Konrad Rzeszutek Wilk | 1233471 | 2010-11-19 11:27:09 -0500 | [diff] [blame] | 750 | unmap_irq.pirq = info->u.pirq.pirq; |
Jeremy Fitzhardinge | 38aa66f | 2010-09-02 14:51:39 +0100 | [diff] [blame] | 751 | unmap_irq.domid = DOMID_SELF; |
| 752 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_unmap_pirq, &unmap_irq); |
| 753 | if (rc) { |
| 754 | printk(KERN_WARNING "unmap irq failed %d\n", rc); |
| 755 | goto out; |
| 756 | } |
| 757 | } |
Konrad Rzeszutek Wilk | 1aa0b51 | 2011-02-17 11:23:58 -0500 | [diff] [blame] | 758 | pirq_to_irq[info->u.pirq.pirq] = -1; |
| 759 | |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 760 | xen_free_irq(irq); |
Alex Nixon | b5401a9 | 2010-03-18 16:31:34 -0400 | [diff] [blame] | 761 | |
| 762 | out: |
| 763 | spin_unlock(&irq_mapping_update_lock); |
| 764 | return rc; |
| 765 | } |
| 766 | |
Stefano Stabellini | af42b8d | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 767 | int xen_irq_from_pirq(unsigned pirq) |
| 768 | { |
| 769 | return pirq_to_irq[pirq]; |
| 770 | } |
| 771 | |
Jeremy Fitzhardinge | b536b4b | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 772 | int bind_evtchn_to_irq(unsigned int evtchn) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 773 | { |
| 774 | int irq; |
| 775 | |
| 776 | spin_lock(&irq_mapping_update_lock); |
| 777 | |
| 778 | irq = evtchn_to_irq[evtchn]; |
| 779 | |
| 780 | if (irq == -1) { |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 781 | irq = xen_allocate_irq_dynamic(); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 782 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 783 | set_irq_chip_and_handler_name(irq, &xen_dynamic_chip, |
Jeremy Fitzhardinge | 3588fe2 | 2010-08-27 17:30:24 -0700 | [diff] [blame] | 784 | handle_fasteoi_irq, "event"); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 785 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 786 | xen_irq_info_evtchn_init(irq, evtchn); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 787 | } |
| 788 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 789 | spin_unlock(&irq_mapping_update_lock); |
| 790 | |
| 791 | return irq; |
| 792 | } |
Jeremy Fitzhardinge | b536b4b | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 793 | EXPORT_SYMBOL_GPL(bind_evtchn_to_irq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 794 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 795 | static int bind_ipi_to_irq(unsigned int ipi, unsigned int cpu) |
| 796 | { |
| 797 | struct evtchn_bind_ipi bind_ipi; |
| 798 | int evtchn, irq; |
| 799 | |
| 800 | spin_lock(&irq_mapping_update_lock); |
| 801 | |
| 802 | irq = per_cpu(ipi_to_irq, cpu)[ipi]; |
Ian Campbell | 90af951 | 2009-02-06 16:55:58 -0800 | [diff] [blame] | 803 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 804 | if (irq == -1) { |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 805 | irq = xen_allocate_irq_dynamic(); |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 806 | if (irq < 0) |
| 807 | goto out; |
| 808 | |
Jeremy Fitzhardinge | aaca496 | 2010-08-20 18:57:53 -0700 | [diff] [blame] | 809 | set_irq_chip_and_handler_name(irq, &xen_percpu_chip, |
| 810 | handle_percpu_irq, "ipi"); |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 811 | |
| 812 | bind_ipi.vcpu = cpu; |
| 813 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, |
| 814 | &bind_ipi) != 0) |
| 815 | BUG(); |
| 816 | evtchn = bind_ipi.port; |
| 817 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 818 | xen_irq_info_ipi_init(cpu, irq, evtchn, ipi); |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 819 | |
| 820 | bind_evtchn_to_cpu(evtchn, cpu); |
| 821 | } |
| 822 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 823 | out: |
| 824 | spin_unlock(&irq_mapping_update_lock); |
| 825 | return irq; |
| 826 | } |
| 827 | |
| 828 | |
Jeremy Fitzhardinge | 4fe7d5a | 2010-09-02 16:17:06 +0100 | [diff] [blame] | 829 | int bind_virq_to_irq(unsigned int virq, unsigned int cpu) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 830 | { |
| 831 | struct evtchn_bind_virq bind_virq; |
| 832 | int evtchn, irq; |
| 833 | |
| 834 | spin_lock(&irq_mapping_update_lock); |
| 835 | |
| 836 | irq = per_cpu(virq_to_irq, cpu)[virq]; |
| 837 | |
| 838 | if (irq == -1) { |
Ian Campbell | c9df1ce | 2011-01-11 17:20:15 +0000 | [diff] [blame] | 839 | irq = xen_allocate_irq_dynamic(); |
Jeremy Fitzhardinge | a52521f | 2010-09-22 15:28:52 -0700 | [diff] [blame] | 840 | |
| 841 | set_irq_chip_and_handler_name(irq, &xen_percpu_chip, |
| 842 | handle_percpu_irq, "virq"); |
| 843 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 844 | bind_virq.virq = virq; |
| 845 | bind_virq.vcpu = cpu; |
| 846 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, |
| 847 | &bind_virq) != 0) |
| 848 | BUG(); |
| 849 | evtchn = bind_virq.port; |
| 850 | |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 851 | xen_irq_info_virq_init(cpu, irq, evtchn, virq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 852 | |
| 853 | bind_evtchn_to_cpu(evtchn, cpu); |
| 854 | } |
| 855 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 856 | spin_unlock(&irq_mapping_update_lock); |
| 857 | |
| 858 | return irq; |
| 859 | } |
| 860 | |
| 861 | static void unbind_from_irq(unsigned int irq) |
| 862 | { |
| 863 | struct evtchn_close close; |
| 864 | int evtchn = evtchn_from_irq(irq); |
| 865 | |
| 866 | spin_lock(&irq_mapping_update_lock); |
| 867 | |
Jeremy Fitzhardinge | d77bbd4 | 2009-02-06 14:09:45 -0800 | [diff] [blame] | 868 | if (VALID_EVTCHN(evtchn)) { |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 869 | close.port = evtchn; |
| 870 | if (HYPERVISOR_event_channel_op(EVTCHNOP_close, &close) != 0) |
| 871 | BUG(); |
| 872 | |
| 873 | switch (type_from_irq(irq)) { |
| 874 | case IRQT_VIRQ: |
| 875 | per_cpu(virq_to_irq, cpu_from_evtchn(evtchn)) |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 876 | [virq_from_irq(irq)] = -1; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 877 | break; |
Alex Nixon | d68d82a | 2008-08-22 11:52:15 +0100 | [diff] [blame] | 878 | case IRQT_IPI: |
| 879 | per_cpu(ipi_to_irq, cpu_from_evtchn(evtchn)) |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 880 | [ipi_from_irq(irq)] = -1; |
Alex Nixon | d68d82a | 2008-08-22 11:52:15 +0100 | [diff] [blame] | 881 | break; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 882 | default: |
| 883 | break; |
| 884 | } |
| 885 | |
| 886 | /* Closed ports are implicitly re-bound to VCPU0. */ |
| 887 | bind_evtchn_to_cpu(evtchn, 0); |
| 888 | |
| 889 | evtchn_to_irq[evtchn] = -1; |
Ian Campbell | fed5ea8 | 2009-12-01 16:15:30 +0000 | [diff] [blame] | 890 | } |
| 891 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 892 | BUG_ON(irq_info[irq].type == IRQT_UNBOUND); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 893 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 894 | xen_free_irq(irq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 895 | |
| 896 | spin_unlock(&irq_mapping_update_lock); |
| 897 | } |
| 898 | |
| 899 | int bind_evtchn_to_irqhandler(unsigned int evtchn, |
Jeff Garzik | 7c23997 | 2007-10-19 03:12:20 -0400 | [diff] [blame] | 900 | irq_handler_t handler, |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 901 | unsigned long irqflags, |
| 902 | const char *devname, void *dev_id) |
| 903 | { |
| 904 | unsigned int irq; |
| 905 | int retval; |
| 906 | |
| 907 | irq = bind_evtchn_to_irq(evtchn); |
| 908 | retval = request_irq(irq, handler, irqflags, devname, dev_id); |
| 909 | if (retval != 0) { |
| 910 | unbind_from_irq(irq); |
| 911 | return retval; |
| 912 | } |
| 913 | |
| 914 | return irq; |
| 915 | } |
| 916 | EXPORT_SYMBOL_GPL(bind_evtchn_to_irqhandler); |
| 917 | |
| 918 | int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, |
Jeff Garzik | 7c23997 | 2007-10-19 03:12:20 -0400 | [diff] [blame] | 919 | irq_handler_t handler, |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 920 | unsigned long irqflags, const char *devname, void *dev_id) |
| 921 | { |
| 922 | unsigned int irq; |
| 923 | int retval; |
| 924 | |
| 925 | irq = bind_virq_to_irq(virq, cpu); |
| 926 | retval = request_irq(irq, handler, irqflags, devname, dev_id); |
| 927 | if (retval != 0) { |
| 928 | unbind_from_irq(irq); |
| 929 | return retval; |
| 930 | } |
| 931 | |
| 932 | return irq; |
| 933 | } |
| 934 | EXPORT_SYMBOL_GPL(bind_virq_to_irqhandler); |
| 935 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 936 | int bind_ipi_to_irqhandler(enum ipi_vector ipi, |
| 937 | unsigned int cpu, |
| 938 | irq_handler_t handler, |
| 939 | unsigned long irqflags, |
| 940 | const char *devname, |
| 941 | void *dev_id) |
| 942 | { |
| 943 | int irq, retval; |
| 944 | |
| 945 | irq = bind_ipi_to_irq(ipi, cpu); |
| 946 | if (irq < 0) |
| 947 | return irq; |
| 948 | |
Thomas Gleixner | 676dc3c | 2011-02-05 20:08:59 +0000 | [diff] [blame] | 949 | irqflags |= IRQF_NO_SUSPEND | IRQF_FORCE_RESUME; |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 950 | retval = request_irq(irq, handler, irqflags, devname, dev_id); |
| 951 | if (retval != 0) { |
| 952 | unbind_from_irq(irq); |
| 953 | return retval; |
| 954 | } |
| 955 | |
| 956 | return irq; |
| 957 | } |
| 958 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 959 | void unbind_from_irqhandler(unsigned int irq, void *dev_id) |
| 960 | { |
| 961 | free_irq(irq, dev_id); |
| 962 | unbind_from_irq(irq); |
| 963 | } |
| 964 | EXPORT_SYMBOL_GPL(unbind_from_irqhandler); |
| 965 | |
Jeremy Fitzhardinge | f87e4ca | 2007-07-17 18:37:06 -0700 | [diff] [blame] | 966 | void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector) |
| 967 | { |
| 968 | int irq = per_cpu(ipi_to_irq, cpu)[vector]; |
| 969 | BUG_ON(irq < 0); |
| 970 | notify_remote_via_irq(irq); |
| 971 | } |
| 972 | |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 973 | irqreturn_t xen_debug_interrupt(int irq, void *dev_id) |
| 974 | { |
| 975 | struct shared_info *sh = HYPERVISOR_shared_info; |
| 976 | int cpu = smp_processor_id(); |
Ian Campbell | cb60d11 | 2011-03-10 16:08:08 +0000 | [diff] [blame] | 977 | unsigned long *cpu_evtchn = per_cpu(cpu_evtchn_mask, cpu); |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 978 | int i; |
| 979 | unsigned long flags; |
| 980 | static DEFINE_SPINLOCK(debug_lock); |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 981 | struct vcpu_info *v; |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 982 | |
| 983 | spin_lock_irqsave(&debug_lock, flags); |
| 984 | |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 985 | printk("\nvcpu %d\n ", cpu); |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 986 | |
| 987 | for_each_online_cpu(i) { |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 988 | int pending; |
| 989 | v = per_cpu(xen_vcpu, i); |
| 990 | pending = (get_irq_regs() && i == cpu) |
| 991 | ? xen_irqs_disabled(get_irq_regs()) |
| 992 | : v->evtchn_upcall_mask; |
| 993 | printk("%d: masked=%d pending=%d event_sel %0*lx\n ", i, |
| 994 | pending, v->evtchn_upcall_pending, |
| 995 | (int)(sizeof(v->evtchn_pending_sel)*2), |
| 996 | v->evtchn_pending_sel); |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 997 | } |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 998 | v = per_cpu(xen_vcpu, cpu); |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 999 | |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 1000 | printk("\npending:\n "); |
| 1001 | for (i = ARRAY_SIZE(sh->evtchn_pending)-1; i >= 0; i--) |
| 1002 | printk("%0*lx%s", (int)sizeof(sh->evtchn_pending[0])*2, |
| 1003 | sh->evtchn_pending[i], |
| 1004 | i % 8 == 0 ? "\n " : " "); |
| 1005 | printk("\nglobal mask:\n "); |
| 1006 | for (i = ARRAY_SIZE(sh->evtchn_mask)-1; i >= 0; i--) |
| 1007 | printk("%0*lx%s", |
| 1008 | (int)(sizeof(sh->evtchn_mask[0])*2), |
| 1009 | sh->evtchn_mask[i], |
| 1010 | i % 8 == 0 ? "\n " : " "); |
| 1011 | |
| 1012 | printk("\nglobally unmasked:\n "); |
| 1013 | for (i = ARRAY_SIZE(sh->evtchn_mask)-1; i >= 0; i--) |
| 1014 | printk("%0*lx%s", (int)(sizeof(sh->evtchn_mask[0])*2), |
| 1015 | sh->evtchn_pending[i] & ~sh->evtchn_mask[i], |
| 1016 | i % 8 == 0 ? "\n " : " "); |
| 1017 | |
| 1018 | printk("\nlocal cpu%d mask:\n ", cpu); |
| 1019 | for (i = (NR_EVENT_CHANNELS/BITS_PER_LONG)-1; i >= 0; i--) |
| 1020 | printk("%0*lx%s", (int)(sizeof(cpu_evtchn[0])*2), |
| 1021 | cpu_evtchn[i], |
| 1022 | i % 8 == 0 ? "\n " : " "); |
| 1023 | |
| 1024 | printk("\nlocally unmasked:\n "); |
| 1025 | for (i = ARRAY_SIZE(sh->evtchn_mask)-1; i >= 0; i--) { |
| 1026 | unsigned long pending = sh->evtchn_pending[i] |
| 1027 | & ~sh->evtchn_mask[i] |
| 1028 | & cpu_evtchn[i]; |
| 1029 | printk("%0*lx%s", (int)(sizeof(sh->evtchn_mask[0])*2), |
| 1030 | pending, i % 8 == 0 ? "\n " : " "); |
| 1031 | } |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 1032 | |
| 1033 | printk("\npending list:\n"); |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 1034 | for (i = 0; i < NR_EVENT_CHANNELS; i++) { |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 1035 | if (sync_test_bit(i, sh->evtchn_pending)) { |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 1036 | int word_idx = i / BITS_PER_LONG; |
| 1037 | printk(" %d: event %d -> irq %d%s%s%s\n", |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 1038 | cpu_from_evtchn(i), i, |
Ian Campbell | cb52e6d | 2010-10-15 11:52:46 +0100 | [diff] [blame] | 1039 | evtchn_to_irq[i], |
| 1040 | sync_test_bit(word_idx, &v->evtchn_pending_sel) |
| 1041 | ? "" : " l2-clear", |
| 1042 | !sync_test_bit(i, sh->evtchn_mask) |
| 1043 | ? "" : " globally-masked", |
| 1044 | sync_test_bit(i, cpu_evtchn) |
| 1045 | ? "" : " locally-masked"); |
Jeremy Fitzhardinge | ee523ca | 2008-03-17 16:37:18 -0700 | [diff] [blame] | 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | spin_unlock_irqrestore(&debug_lock, flags); |
| 1050 | |
| 1051 | return IRQ_HANDLED; |
| 1052 | } |
| 1053 | |
Tejun Heo | 245b2e7 | 2009-06-24 15:13:48 +0900 | [diff] [blame] | 1054 | static DEFINE_PER_CPU(unsigned, xed_nesting_count); |
| 1055 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1056 | /* |
| 1057 | * Search the CPUs pending events bitmasks. For each one found, map |
| 1058 | * the event number to an irq, and feed it into do_IRQ() for |
| 1059 | * handling. |
| 1060 | * |
| 1061 | * Xen uses a two-level bitmap to speed searching. The first level is |
| 1062 | * a bitset of words which contain pending event bits. The second |
| 1063 | * level is a bitset of pending events themselves. |
| 1064 | */ |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1065 | static void __xen_evtchn_do_upcall(void) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1066 | { |
| 1067 | int cpu = get_cpu(); |
| 1068 | struct shared_info *s = HYPERVISOR_shared_info; |
Christoph Lameter | 780f36d | 2010-12-06 11:16:29 -0600 | [diff] [blame] | 1069 | struct vcpu_info *vcpu_info = __this_cpu_read(xen_vcpu); |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1070 | unsigned count; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1071 | |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1072 | do { |
| 1073 | unsigned long pending_words; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1074 | |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1075 | vcpu_info->evtchn_upcall_pending = 0; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1076 | |
Christoph Lameter | b2e4ae6 | 2010-12-06 11:40:07 -0600 | [diff] [blame] | 1077 | if (__this_cpu_inc_return(xed_nesting_count) - 1) |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1078 | goto out; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1079 | |
Isaku Yamahata | e849c3e | 2008-04-02 10:53:56 -0700 | [diff] [blame] | 1080 | #ifndef CONFIG_X86 /* No need for a barrier -- XCHG is a barrier on x86. */ |
| 1081 | /* Clear master flag /before/ clearing selector flag. */ |
Isaku Yamahata | 6673cf6 | 2008-06-16 14:58:13 -0700 | [diff] [blame] | 1082 | wmb(); |
Isaku Yamahata | e849c3e | 2008-04-02 10:53:56 -0700 | [diff] [blame] | 1083 | #endif |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1084 | pending_words = xchg(&vcpu_info->evtchn_pending_sel, 0); |
| 1085 | while (pending_words != 0) { |
| 1086 | unsigned long pending_bits; |
| 1087 | int word_idx = __ffs(pending_words); |
| 1088 | pending_words &= ~(1UL << word_idx); |
| 1089 | |
| 1090 | while ((pending_bits = active_evtchns(cpu, s, word_idx)) != 0) { |
| 1091 | int bit_idx = __ffs(pending_bits); |
| 1092 | int port = (word_idx * BITS_PER_LONG) + bit_idx; |
| 1093 | int irq = evtchn_to_irq[port]; |
Eric W. Biederman | ca4dbc6 | 2010-02-17 18:49:54 -0800 | [diff] [blame] | 1094 | struct irq_desc *desc; |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1095 | |
Jeremy Fitzhardinge | 3588fe2 | 2010-08-27 17:30:24 -0700 | [diff] [blame] | 1096 | mask_evtchn(port); |
| 1097 | clear_evtchn(port); |
| 1098 | |
Eric W. Biederman | ca4dbc6 | 2010-02-17 18:49:54 -0800 | [diff] [blame] | 1099 | if (irq != -1) { |
| 1100 | desc = irq_to_desc(irq); |
| 1101 | if (desc) |
| 1102 | generic_handle_irq_desc(irq, desc); |
| 1103 | } |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1104 | } |
| 1105 | } |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1106 | |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1107 | BUG_ON(!irqs_disabled()); |
| 1108 | |
Christoph Lameter | 780f36d | 2010-12-06 11:16:29 -0600 | [diff] [blame] | 1109 | count = __this_cpu_read(xed_nesting_count); |
| 1110 | __this_cpu_write(xed_nesting_count, 0); |
Stefano Stabellini | 183d03c | 2010-05-17 17:08:21 +0100 | [diff] [blame] | 1111 | } while (count != 1 || vcpu_info->evtchn_upcall_pending); |
Jeremy Fitzhardinge | 229664b | 2008-03-17 16:37:20 -0700 | [diff] [blame] | 1112 | |
| 1113 | out: |
Jeremy Fitzhardinge | 3445a8f | 2009-02-06 14:09:46 -0800 | [diff] [blame] | 1114 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1115 | put_cpu(); |
| 1116 | } |
| 1117 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1118 | void xen_evtchn_do_upcall(struct pt_regs *regs) |
| 1119 | { |
| 1120 | struct pt_regs *old_regs = set_irq_regs(regs); |
| 1121 | |
| 1122 | exit_idle(); |
| 1123 | irq_enter(); |
| 1124 | |
| 1125 | __xen_evtchn_do_upcall(); |
| 1126 | |
| 1127 | irq_exit(); |
| 1128 | set_irq_regs(old_regs); |
| 1129 | } |
| 1130 | |
| 1131 | void xen_hvm_evtchn_do_upcall(void) |
| 1132 | { |
| 1133 | __xen_evtchn_do_upcall(); |
| 1134 | } |
Stefano Stabellini | 183d03c | 2010-05-17 17:08:21 +0100 | [diff] [blame] | 1135 | EXPORT_SYMBOL_GPL(xen_hvm_evtchn_do_upcall); |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1136 | |
Jeremy Fitzhardinge | eb1e305 | 2008-05-26 23:31:23 +0100 | [diff] [blame] | 1137 | /* Rebind a new event channel to an existing irq. */ |
| 1138 | void rebind_evtchn_irq(int evtchn, int irq) |
| 1139 | { |
Jeremy Fitzhardinge | d77bbd4 | 2009-02-06 14:09:45 -0800 | [diff] [blame] | 1140 | struct irq_info *info = info_for_irq(irq); |
| 1141 | |
Jeremy Fitzhardinge | eb1e305 | 2008-05-26 23:31:23 +0100 | [diff] [blame] | 1142 | /* Make sure the irq is masked, since the new event channel |
| 1143 | will also be masked. */ |
| 1144 | disable_irq(irq); |
| 1145 | |
| 1146 | spin_lock(&irq_mapping_update_lock); |
| 1147 | |
| 1148 | /* After resume the irq<->evtchn mappings are all cleared out */ |
| 1149 | BUG_ON(evtchn_to_irq[evtchn] != -1); |
| 1150 | /* Expect irq to have been bound before, |
Jeremy Fitzhardinge | d77bbd4 | 2009-02-06 14:09:45 -0800 | [diff] [blame] | 1151 | so there should be a proper type */ |
| 1152 | BUG_ON(info->type == IRQT_UNBOUND); |
Jeremy Fitzhardinge | eb1e305 | 2008-05-26 23:31:23 +0100 | [diff] [blame] | 1153 | |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 1154 | xen_irq_info_evtchn_init(irq, evtchn); |
Jeremy Fitzhardinge | eb1e305 | 2008-05-26 23:31:23 +0100 | [diff] [blame] | 1155 | |
| 1156 | spin_unlock(&irq_mapping_update_lock); |
| 1157 | |
| 1158 | /* new event channels are always bound to cpu 0 */ |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 1159 | irq_set_affinity(irq, cpumask_of(0)); |
Jeremy Fitzhardinge | eb1e305 | 2008-05-26 23:31:23 +0100 | [diff] [blame] | 1160 | |
| 1161 | /* Unmask the event channel. */ |
| 1162 | enable_irq(irq); |
| 1163 | } |
| 1164 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1165 | /* Rebind an evtchn so that it gets delivered to a specific cpu */ |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 1166 | static int rebind_irq_to_cpu(unsigned irq, unsigned tcpu) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1167 | { |
| 1168 | struct evtchn_bind_vcpu bind_vcpu; |
| 1169 | int evtchn = evtchn_from_irq(irq); |
| 1170 | |
Ian Campbell | be49472 | 2011-03-10 16:08:02 +0000 | [diff] [blame] | 1171 | if (!VALID_EVTCHN(evtchn)) |
| 1172 | return -1; |
| 1173 | |
| 1174 | /* |
| 1175 | * Events delivered via platform PCI interrupts are always |
| 1176 | * routed to vcpu 0 and hence cannot be rebound. |
| 1177 | */ |
| 1178 | if (xen_hvm_domain() && !xen_have_vector_callback) |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 1179 | return -1; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1180 | |
| 1181 | /* Send future instances of this interrupt to other vcpu. */ |
| 1182 | bind_vcpu.port = evtchn; |
| 1183 | bind_vcpu.vcpu = tcpu; |
| 1184 | |
| 1185 | /* |
| 1186 | * If this fails, it usually just indicates that we're dealing with a |
| 1187 | * virq or IPI channel, which don't actually need to be rebound. Ignore |
| 1188 | * it, but don't do the xenlinux-level rebind in that case. |
| 1189 | */ |
| 1190 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) |
| 1191 | bind_evtchn_to_cpu(evtchn, tcpu); |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 1192 | |
| 1193 | return 0; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1194 | } |
| 1195 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1196 | static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest, |
| 1197 | bool force) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1198 | { |
Rusty Russell | 0de2652 | 2008-12-13 21:20:26 +1030 | [diff] [blame] | 1199 | unsigned tcpu = cpumask_first(dest); |
Yinghai Lu | d5dedd4 | 2009-04-27 17:59:21 -0700 | [diff] [blame] | 1200 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1201 | return rebind_irq_to_cpu(data->irq, tcpu); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1202 | } |
| 1203 | |
Isaku Yamahata | 642e0c8 | 2008-04-02 10:53:57 -0700 | [diff] [blame] | 1204 | int resend_irq_on_evtchn(unsigned int irq) |
| 1205 | { |
| 1206 | int masked, evtchn = evtchn_from_irq(irq); |
| 1207 | struct shared_info *s = HYPERVISOR_shared_info; |
| 1208 | |
| 1209 | if (!VALID_EVTCHN(evtchn)) |
| 1210 | return 1; |
| 1211 | |
| 1212 | masked = sync_test_and_set_bit(evtchn, s->evtchn_mask); |
| 1213 | sync_set_bit(evtchn, s->evtchn_pending); |
| 1214 | if (!masked) |
| 1215 | unmask_evtchn(evtchn); |
| 1216 | |
| 1217 | return 1; |
| 1218 | } |
| 1219 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1220 | static void enable_dynirq(struct irq_data *data) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1221 | { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1222 | int evtchn = evtchn_from_irq(data->irq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1223 | |
| 1224 | if (VALID_EVTCHN(evtchn)) |
| 1225 | unmask_evtchn(evtchn); |
| 1226 | } |
| 1227 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1228 | static void disable_dynirq(struct irq_data *data) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1229 | { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1230 | int evtchn = evtchn_from_irq(data->irq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1231 | |
| 1232 | if (VALID_EVTCHN(evtchn)) |
| 1233 | mask_evtchn(evtchn); |
| 1234 | } |
| 1235 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1236 | static void ack_dynirq(struct irq_data *data) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1237 | { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1238 | int evtchn = evtchn_from_irq(data->irq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1239 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1240 | move_masked_irq(data->irq); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1241 | |
| 1242 | if (VALID_EVTCHN(evtchn)) |
Jeremy Fitzhardinge | 3588fe2 | 2010-08-27 17:30:24 -0700 | [diff] [blame] | 1243 | unmask_evtchn(evtchn); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1244 | } |
| 1245 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1246 | static int retrigger_dynirq(struct irq_data *data) |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1247 | { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1248 | int evtchn = evtchn_from_irq(data->irq); |
Jeremy Fitzhardinge | ee8fa1c | 2008-03-17 16:37:19 -0700 | [diff] [blame] | 1249 | struct shared_info *sh = HYPERVISOR_shared_info; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1250 | int ret = 0; |
| 1251 | |
| 1252 | if (VALID_EVTCHN(evtchn)) { |
Jeremy Fitzhardinge | ee8fa1c | 2008-03-17 16:37:19 -0700 | [diff] [blame] | 1253 | int masked; |
| 1254 | |
| 1255 | masked = sync_test_and_set_bit(evtchn, sh->evtchn_mask); |
| 1256 | sync_set_bit(evtchn, sh->evtchn_pending); |
| 1257 | if (!masked) |
| 1258 | unmask_evtchn(evtchn); |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1259 | ret = 1; |
| 1260 | } |
| 1261 | |
| 1262 | return ret; |
| 1263 | } |
| 1264 | |
Ian Campbell | 0a85226 | 2011-03-10 16:08:06 +0000 | [diff] [blame] | 1265 | static void restore_pirqs(void) |
Stefano Stabellini | 9a069c3 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 1266 | { |
| 1267 | int pirq, rc, irq, gsi; |
| 1268 | struct physdev_map_pirq map_irq; |
| 1269 | |
| 1270 | for (pirq = 0; pirq < nr_irqs; pirq++) { |
| 1271 | irq = pirq_to_irq[pirq]; |
| 1272 | if (irq == -1) |
| 1273 | continue; |
| 1274 | |
| 1275 | /* save/restore of PT devices doesn't work, so at this point the |
| 1276 | * only devices present are GSI based emulated devices */ |
| 1277 | gsi = gsi_from_irq(irq); |
| 1278 | if (!gsi) |
| 1279 | continue; |
| 1280 | |
| 1281 | map_irq.domid = DOMID_SELF; |
| 1282 | map_irq.type = MAP_PIRQ_TYPE_GSI; |
| 1283 | map_irq.index = gsi; |
| 1284 | map_irq.pirq = pirq; |
| 1285 | |
| 1286 | rc = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); |
| 1287 | if (rc) { |
| 1288 | printk(KERN_WARNING "xen map irq failed gsi=%d irq=%d pirq=%d rc=%d\n", |
| 1289 | gsi, irq, pirq, rc); |
Ian Campbell | 9158c35 | 2011-03-10 16:08:09 +0000 | [diff] [blame] | 1290 | xen_free_irq(irq); |
Stefano Stabellini | 9a069c3 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 1291 | pirq_to_irq[pirq] = -1; |
| 1292 | continue; |
| 1293 | } |
| 1294 | |
| 1295 | printk(KERN_DEBUG "xen: --> irq=%d, pirq=%d\n", irq, map_irq.pirq); |
| 1296 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1297 | __startup_pirq(irq); |
Stefano Stabellini | 9a069c3 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 1298 | } |
| 1299 | } |
| 1300 | |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1301 | static void restore_cpu_virqs(unsigned int cpu) |
| 1302 | { |
| 1303 | struct evtchn_bind_virq bind_virq; |
| 1304 | int virq, irq, evtchn; |
| 1305 | |
| 1306 | for (virq = 0; virq < NR_VIRQS; virq++) { |
| 1307 | if ((irq = per_cpu(virq_to_irq, cpu)[virq]) == -1) |
| 1308 | continue; |
| 1309 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 1310 | BUG_ON(virq_from_irq(irq) != virq); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1311 | |
| 1312 | /* Get a new binding from Xen. */ |
| 1313 | bind_virq.virq = virq; |
| 1314 | bind_virq.vcpu = cpu; |
| 1315 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_virq, |
| 1316 | &bind_virq) != 0) |
| 1317 | BUG(); |
| 1318 | evtchn = bind_virq.port; |
| 1319 | |
| 1320 | /* Record the new mapping. */ |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 1321 | xen_irq_info_virq_init(cpu, irq, evtchn, virq); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1322 | bind_evtchn_to_cpu(evtchn, cpu); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1323 | } |
| 1324 | } |
| 1325 | |
| 1326 | static void restore_cpu_ipis(unsigned int cpu) |
| 1327 | { |
| 1328 | struct evtchn_bind_ipi bind_ipi; |
| 1329 | int ipi, irq, evtchn; |
| 1330 | |
| 1331 | for (ipi = 0; ipi < XEN_NR_IPIS; ipi++) { |
| 1332 | if ((irq = per_cpu(ipi_to_irq, cpu)[ipi]) == -1) |
| 1333 | continue; |
| 1334 | |
Jeremy Fitzhardinge | ced40d0 | 2009-02-06 14:09:44 -0800 | [diff] [blame] | 1335 | BUG_ON(ipi_from_irq(irq) != ipi); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1336 | |
| 1337 | /* Get a new binding from Xen. */ |
| 1338 | bind_ipi.vcpu = cpu; |
| 1339 | if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_ipi, |
| 1340 | &bind_ipi) != 0) |
| 1341 | BUG(); |
| 1342 | evtchn = bind_ipi.port; |
| 1343 | |
| 1344 | /* Record the new mapping. */ |
Ian Campbell | 3d4cfa3 | 2011-03-10 16:08:10 +0000 | [diff] [blame] | 1345 | xen_irq_info_ipi_init(cpu, irq, evtchn, ipi); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1346 | bind_evtchn_to_cpu(evtchn, cpu); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1347 | } |
| 1348 | } |
| 1349 | |
Jeremy Fitzhardinge | 2d9e1e2 | 2008-07-07 12:07:53 -0700 | [diff] [blame] | 1350 | /* Clear an irq's pending state, in preparation for polling on it */ |
| 1351 | void xen_clear_irq_pending(int irq) |
| 1352 | { |
| 1353 | int evtchn = evtchn_from_irq(irq); |
| 1354 | |
| 1355 | if (VALID_EVTCHN(evtchn)) |
| 1356 | clear_evtchn(evtchn); |
| 1357 | } |
Konrad Rzeszutek Wilk | d9a8814 | 2009-11-05 16:33:09 -0500 | [diff] [blame] | 1358 | EXPORT_SYMBOL(xen_clear_irq_pending); |
Jeremy Fitzhardinge | 168d2f4 | 2008-08-20 17:02:18 -0700 | [diff] [blame] | 1359 | void xen_set_irq_pending(int irq) |
| 1360 | { |
| 1361 | int evtchn = evtchn_from_irq(irq); |
| 1362 | |
| 1363 | if (VALID_EVTCHN(evtchn)) |
| 1364 | set_evtchn(evtchn); |
| 1365 | } |
| 1366 | |
| 1367 | bool xen_test_irq_pending(int irq) |
| 1368 | { |
| 1369 | int evtchn = evtchn_from_irq(irq); |
| 1370 | bool ret = false; |
| 1371 | |
| 1372 | if (VALID_EVTCHN(evtchn)) |
| 1373 | ret = test_evtchn(evtchn); |
| 1374 | |
| 1375 | return ret; |
| 1376 | } |
| 1377 | |
Konrad Rzeszutek Wilk | d9a8814 | 2009-11-05 16:33:09 -0500 | [diff] [blame] | 1378 | /* Poll waiting for an irq to become pending with timeout. In the usual case, |
| 1379 | * the irq will be disabled so it won't deliver an interrupt. */ |
| 1380 | void xen_poll_irq_timeout(int irq, u64 timeout) |
Jeremy Fitzhardinge | 2d9e1e2 | 2008-07-07 12:07:53 -0700 | [diff] [blame] | 1381 | { |
| 1382 | evtchn_port_t evtchn = evtchn_from_irq(irq); |
| 1383 | |
| 1384 | if (VALID_EVTCHN(evtchn)) { |
| 1385 | struct sched_poll poll; |
| 1386 | |
| 1387 | poll.nr_ports = 1; |
Konrad Rzeszutek Wilk | d9a8814 | 2009-11-05 16:33:09 -0500 | [diff] [blame] | 1388 | poll.timeout = timeout; |
Isaku Yamahata | ff3c536 | 2008-10-14 17:50:44 -0700 | [diff] [blame] | 1389 | set_xen_guest_handle(poll.ports, &evtchn); |
Jeremy Fitzhardinge | 2d9e1e2 | 2008-07-07 12:07:53 -0700 | [diff] [blame] | 1390 | |
| 1391 | if (HYPERVISOR_sched_op(SCHEDOP_poll, &poll) != 0) |
| 1392 | BUG(); |
| 1393 | } |
| 1394 | } |
Konrad Rzeszutek Wilk | d9a8814 | 2009-11-05 16:33:09 -0500 | [diff] [blame] | 1395 | EXPORT_SYMBOL(xen_poll_irq_timeout); |
| 1396 | /* Poll waiting for an irq to become pending. In the usual case, the |
| 1397 | * irq will be disabled so it won't deliver an interrupt. */ |
| 1398 | void xen_poll_irq(int irq) |
| 1399 | { |
| 1400 | xen_poll_irq_timeout(irq, 0 /* no timeout */); |
| 1401 | } |
Jeremy Fitzhardinge | 2d9e1e2 | 2008-07-07 12:07:53 -0700 | [diff] [blame] | 1402 | |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1403 | void xen_irq_resume(void) |
| 1404 | { |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 1405 | unsigned int cpu, evtchn; |
| 1406 | struct irq_info *info; |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1407 | |
| 1408 | init_evtchn_cpu_bindings(); |
| 1409 | |
| 1410 | /* New event-channel space is not 'live' yet. */ |
| 1411 | for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++) |
| 1412 | mask_evtchn(evtchn); |
| 1413 | |
| 1414 | /* No IRQ <-> event-channel mappings. */ |
Ian Campbell | 6cb6537 | 2011-03-10 16:08:11 +0000 | [diff] [blame^] | 1415 | list_for_each_entry(info, &xen_irq_list_head, list) |
| 1416 | info->evtchn = 0; /* zap event-channel binding */ |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1417 | |
| 1418 | for (evtchn = 0; evtchn < NR_EVENT_CHANNELS; evtchn++) |
| 1419 | evtchn_to_irq[evtchn] = -1; |
| 1420 | |
| 1421 | for_each_possible_cpu(cpu) { |
| 1422 | restore_cpu_virqs(cpu); |
| 1423 | restore_cpu_ipis(cpu); |
| 1424 | } |
Ian Campbell | 6903591 | 2010-11-01 16:30:09 +0000 | [diff] [blame] | 1425 | |
Ian Campbell | 0a85226 | 2011-03-10 16:08:06 +0000 | [diff] [blame] | 1426 | restore_pirqs(); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1427 | } |
| 1428 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1429 | static struct irq_chip xen_dynamic_chip __read_mostly = { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1430 | .name = "xen-dyn", |
Jeremy Fitzhardinge | 54a353a | 2009-02-06 14:09:42 -0800 | [diff] [blame] | 1431 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1432 | .irq_disable = disable_dynirq, |
| 1433 | .irq_mask = disable_dynirq, |
| 1434 | .irq_unmask = enable_dynirq, |
Jeremy Fitzhardinge | 54a353a | 2009-02-06 14:09:42 -0800 | [diff] [blame] | 1435 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1436 | .irq_eoi = ack_dynirq, |
| 1437 | .irq_set_affinity = set_affinity_irq, |
| 1438 | .irq_retrigger = retrigger_dynirq, |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1439 | }; |
| 1440 | |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1441 | static struct irq_chip xen_pirq_chip __read_mostly = { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1442 | .name = "xen-pirq", |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1443 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1444 | .irq_startup = startup_pirq, |
| 1445 | .irq_shutdown = shutdown_pirq, |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1446 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1447 | .irq_enable = enable_pirq, |
| 1448 | .irq_unmask = enable_pirq, |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1449 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1450 | .irq_disable = disable_pirq, |
| 1451 | .irq_mask = disable_pirq, |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1452 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1453 | .irq_ack = ack_pirq, |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1454 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1455 | .irq_set_affinity = set_affinity_irq, |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1456 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1457 | .irq_retrigger = retrigger_dynirq, |
Jeremy Fitzhardinge | d46a78b | 2010-10-01 12:20:09 -0400 | [diff] [blame] | 1458 | }; |
| 1459 | |
Jeremy Fitzhardinge | aaca496 | 2010-08-20 18:57:53 -0700 | [diff] [blame] | 1460 | static struct irq_chip xen_percpu_chip __read_mostly = { |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1461 | .name = "xen-percpu", |
Jeremy Fitzhardinge | aaca496 | 2010-08-20 18:57:53 -0700 | [diff] [blame] | 1462 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1463 | .irq_disable = disable_dynirq, |
| 1464 | .irq_mask = disable_dynirq, |
| 1465 | .irq_unmask = enable_dynirq, |
Jeremy Fitzhardinge | aaca496 | 2010-08-20 18:57:53 -0700 | [diff] [blame] | 1466 | |
Thomas Gleixner | c9e265e | 2011-02-05 20:08:54 +0000 | [diff] [blame] | 1467 | .irq_ack = ack_dynirq, |
Jeremy Fitzhardinge | aaca496 | 2010-08-20 18:57:53 -0700 | [diff] [blame] | 1468 | }; |
| 1469 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1470 | int xen_set_callback_via(uint64_t via) |
| 1471 | { |
| 1472 | struct xen_hvm_param a; |
| 1473 | a.domid = DOMID_SELF; |
| 1474 | a.index = HVM_PARAM_CALLBACK_IRQ; |
| 1475 | a.value = via; |
| 1476 | return HYPERVISOR_hvm_op(HVMOP_set_param, &a); |
| 1477 | } |
| 1478 | EXPORT_SYMBOL_GPL(xen_set_callback_via); |
| 1479 | |
Stefano Stabellini | ca65f9f | 2010-07-29 14:37:48 +0100 | [diff] [blame] | 1480 | #ifdef CONFIG_XEN_PVHVM |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1481 | /* Vector callbacks are better than PCI interrupts to receive event |
| 1482 | * channel notifications because we can receive vector callbacks on any |
| 1483 | * vcpu and we don't need PCI support or APIC interactions. */ |
| 1484 | void xen_callback_vector(void) |
| 1485 | { |
| 1486 | int rc; |
| 1487 | uint64_t callback_via; |
| 1488 | if (xen_have_vector_callback) { |
| 1489 | callback_via = HVM_CALLBACK_VECTOR(XEN_HVM_EVTCHN_CALLBACK); |
| 1490 | rc = xen_set_callback_via(callback_via); |
| 1491 | if (rc) { |
| 1492 | printk(KERN_ERR "Request for Xen HVM callback vector" |
| 1493 | " failed.\n"); |
| 1494 | xen_have_vector_callback = 0; |
| 1495 | return; |
| 1496 | } |
| 1497 | printk(KERN_INFO "Xen HVM callback vector for event delivery is " |
| 1498 | "enabled\n"); |
| 1499 | /* in the restore case the vector has already been allocated */ |
| 1500 | if (!test_bit(XEN_HVM_EVTCHN_CALLBACK, used_vectors)) |
| 1501 | alloc_intr_gate(XEN_HVM_EVTCHN_CALLBACK, xen_hvm_callback_vector); |
| 1502 | } |
| 1503 | } |
Stefano Stabellini | ca65f9f | 2010-07-29 14:37:48 +0100 | [diff] [blame] | 1504 | #else |
| 1505 | void xen_callback_vector(void) {} |
| 1506 | #endif |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1507 | |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1508 | void __init xen_init_IRQ(void) |
| 1509 | { |
Stefano Stabellini | e5fc734 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 1510 | int i; |
Mike Travis | c7a3589 | 2009-01-10 21:58:11 -0800 | [diff] [blame] | 1511 | |
Jeremy Fitzhardinge | b21ddbf | 2010-06-07 16:28:49 -0400 | [diff] [blame] | 1512 | irq_info = kcalloc(nr_irqs, sizeof(*irq_info), GFP_KERNEL); |
| 1513 | |
Stefano Stabellini | e5fc734 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 1514 | /* We are using nr_irqs as the maximum number of pirq available but |
| 1515 | * that number is actually chosen by Xen and we don't know exactly |
| 1516 | * what it is. Be careful choosing high pirq numbers. */ |
| 1517 | pirq_to_irq = kcalloc(nr_irqs, sizeof(*pirq_to_irq), GFP_KERNEL); |
| 1518 | for (i = 0; i < nr_irqs; i++) |
Stefano Stabellini | 7a043f1 | 2010-07-01 17:08:14 +0100 | [diff] [blame] | 1519 | pirq_to_irq[i] = -1; |
| 1520 | |
Jeremy Fitzhardinge | b21ddbf | 2010-06-07 16:28:49 -0400 | [diff] [blame] | 1521 | evtchn_to_irq = kcalloc(NR_EVENT_CHANNELS, sizeof(*evtchn_to_irq), |
| 1522 | GFP_KERNEL); |
| 1523 | for (i = 0; i < NR_EVENT_CHANNELS; i++) |
| 1524 | evtchn_to_irq[i] = -1; |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1525 | |
| 1526 | init_evtchn_cpu_bindings(); |
| 1527 | |
| 1528 | /* No event channels are 'live' right now. */ |
| 1529 | for (i = 0; i < NR_EVENT_CHANNELS; i++) |
| 1530 | mask_evtchn(i); |
| 1531 | |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1532 | if (xen_hvm_domain()) { |
| 1533 | xen_callback_vector(); |
| 1534 | native_init_IRQ(); |
Stefano Stabellini | 3942b74 | 2010-06-24 17:50:18 +0100 | [diff] [blame] | 1535 | /* pci_xen_hvm_init must be called after native_init_IRQ so that |
| 1536 | * __acpi_register_gsi can point at the right function */ |
| 1537 | pci_xen_hvm_init(); |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1538 | } else { |
| 1539 | irq_ctx_init(smp_processor_id()); |
Jeremy Fitzhardinge | 38aa66f | 2010-09-02 14:51:39 +0100 | [diff] [blame] | 1540 | if (xen_initial_domain()) |
| 1541 | xen_setup_pirqs(); |
Sheng Yang | 38e20b0 | 2010-05-14 12:40:51 +0100 | [diff] [blame] | 1542 | } |
Jeremy Fitzhardinge | e46cdb6 | 2007-07-17 18:37:05 -0700 | [diff] [blame] | 1543 | } |