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