Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Local APIC related interfaces to support IOAPIC, MSI, HT_IRQ etc. |
| 3 | * |
| 4 | * Copyright (C) 1997, 1998, 1999, 2000, 2009 Ingo Molnar, Hajnalka Szabo |
| 5 | * Moved from arch/x86/kernel/apic/io_apic.c. |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 6 | * Jiang Liu <jiang.liu@linux.intel.com> |
| 7 | * Enable support of hierarchical irqdomains |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/compiler.h> |
| 16 | #include <linux/irqdomain.h> |
| 17 | #include <linux/slab.h> |
| 18 | #include <asm/hw_irq.h> |
| 19 | #include <asm/apic.h> |
| 20 | #include <asm/i8259.h> |
| 21 | #include <asm/desc.h> |
| 22 | #include <asm/irq_remapping.h> |
| 23 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 24 | struct irq_domain *x86_vector_domain; |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 25 | static DEFINE_RAW_SPINLOCK(vector_lock); |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 26 | static struct irq_chip lapic_controller; |
Jiang Liu | 1331532 | 2015-04-13 14:11:56 +0800 | [diff] [blame^] | 27 | #ifdef CONFIG_X86_IO_APIC |
| 28 | static struct irq_cfg *legacy_irq_cfgs[NR_IRQS_LEGACY]; |
| 29 | #endif |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 30 | |
| 31 | void lock_vector_lock(void) |
| 32 | { |
| 33 | /* Used to the online set of cpus does not change |
| 34 | * during assign_irq_vector. |
| 35 | */ |
| 36 | raw_spin_lock(&vector_lock); |
| 37 | } |
| 38 | |
| 39 | void unlock_vector_lock(void) |
| 40 | { |
| 41 | raw_spin_unlock(&vector_lock); |
| 42 | } |
| 43 | |
| 44 | struct irq_cfg *irq_cfg(unsigned int irq) |
| 45 | { |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 46 | return irqd_cfg(irq_get_irq_data(irq)); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 47 | } |
| 48 | |
| 49 | struct irq_cfg *irqd_cfg(struct irq_data *irq_data) |
| 50 | { |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 51 | if (!irq_data) |
| 52 | return NULL; |
| 53 | |
| 54 | while (irq_data->parent_data) |
| 55 | irq_data = irq_data->parent_data; |
| 56 | |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 57 | return irq_data->chip_data; |
| 58 | } |
| 59 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 60 | static struct irq_cfg *alloc_irq_cfg(int node) |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 61 | { |
| 62 | struct irq_cfg *cfg; |
| 63 | |
| 64 | cfg = kzalloc_node(sizeof(*cfg), GFP_KERNEL, node); |
| 65 | if (!cfg) |
| 66 | return NULL; |
| 67 | if (!zalloc_cpumask_var_node(&cfg->domain, GFP_KERNEL, node)) |
| 68 | goto out_cfg; |
| 69 | if (!zalloc_cpumask_var_node(&cfg->old_domain, GFP_KERNEL, node)) |
| 70 | goto out_domain; |
| 71 | #ifdef CONFIG_X86_IO_APIC |
| 72 | INIT_LIST_HEAD(&cfg->irq_2_pin); |
| 73 | #endif |
| 74 | return cfg; |
| 75 | out_domain: |
| 76 | free_cpumask_var(cfg->domain); |
| 77 | out_cfg: |
| 78 | kfree(cfg); |
| 79 | return NULL; |
| 80 | } |
| 81 | |
| 82 | struct irq_cfg *alloc_irq_and_cfg_at(unsigned int at, int node) |
| 83 | { |
| 84 | int res = irq_alloc_desc_at(at, node); |
| 85 | struct irq_cfg *cfg; |
| 86 | |
| 87 | if (res < 0) { |
| 88 | if (res != -EEXIST) |
| 89 | return NULL; |
| 90 | cfg = irq_cfg(at); |
| 91 | if (cfg) |
| 92 | return cfg; |
| 93 | } |
| 94 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 95 | cfg = alloc_irq_cfg(node); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 96 | if (cfg) |
| 97 | irq_set_chip_data(at, cfg); |
| 98 | else |
| 99 | irq_free_desc(at); |
| 100 | return cfg; |
| 101 | } |
| 102 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 103 | static void free_irq_cfg(struct irq_cfg *cfg) |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 104 | { |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 105 | if (cfg) { |
| 106 | free_cpumask_var(cfg->domain); |
| 107 | free_cpumask_var(cfg->old_domain); |
| 108 | kfree(cfg); |
| 109 | } |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | static int |
| 113 | __assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask) |
| 114 | { |
| 115 | /* |
| 116 | * NOTE! The local APIC isn't very good at handling |
| 117 | * multiple interrupts at the same interrupt level. |
| 118 | * As the interrupt level is determined by taking the |
| 119 | * vector number and shifting that right by 4, we |
| 120 | * want to spread these out a bit so that they don't |
| 121 | * all fall in the same interrupt level. |
| 122 | * |
| 123 | * Also, we've got to be careful not to trash gate |
| 124 | * 0x80, because int 0x80 is hm, kind of importantish. ;) |
| 125 | */ |
| 126 | static int current_vector = FIRST_EXTERNAL_VECTOR + VECTOR_OFFSET_START; |
| 127 | static int current_offset = VECTOR_OFFSET_START % 16; |
| 128 | int cpu, err; |
| 129 | cpumask_var_t tmp_mask; |
| 130 | |
| 131 | if (cfg->move_in_progress) |
| 132 | return -EBUSY; |
| 133 | |
| 134 | if (!alloc_cpumask_var(&tmp_mask, GFP_ATOMIC)) |
| 135 | return -ENOMEM; |
| 136 | |
| 137 | /* Only try and allocate irqs on cpus that are present */ |
| 138 | err = -ENOSPC; |
| 139 | cpumask_clear(cfg->old_domain); |
| 140 | cpu = cpumask_first_and(mask, cpu_online_mask); |
| 141 | while (cpu < nr_cpu_ids) { |
| 142 | int new_cpu, vector, offset; |
| 143 | |
| 144 | apic->vector_allocation_domain(cpu, tmp_mask, mask); |
| 145 | |
| 146 | if (cpumask_subset(tmp_mask, cfg->domain)) { |
| 147 | err = 0; |
| 148 | if (cpumask_equal(tmp_mask, cfg->domain)) |
| 149 | break; |
| 150 | /* |
| 151 | * New cpumask using the vector is a proper subset of |
| 152 | * the current in use mask. So cleanup the vector |
| 153 | * allocation for the members that are not used anymore. |
| 154 | */ |
| 155 | cpumask_andnot(cfg->old_domain, cfg->domain, tmp_mask); |
| 156 | cfg->move_in_progress = |
| 157 | cpumask_intersects(cfg->old_domain, cpu_online_mask); |
| 158 | cpumask_and(cfg->domain, cfg->domain, tmp_mask); |
| 159 | break; |
| 160 | } |
| 161 | |
| 162 | vector = current_vector; |
| 163 | offset = current_offset; |
| 164 | next: |
| 165 | vector += 16; |
| 166 | if (vector >= first_system_vector) { |
| 167 | offset = (offset + 1) % 16; |
| 168 | vector = FIRST_EXTERNAL_VECTOR + offset; |
| 169 | } |
| 170 | |
| 171 | if (unlikely(current_vector == vector)) { |
| 172 | cpumask_or(cfg->old_domain, cfg->old_domain, tmp_mask); |
| 173 | cpumask_andnot(tmp_mask, mask, cfg->old_domain); |
| 174 | cpu = cpumask_first_and(tmp_mask, cpu_online_mask); |
| 175 | continue; |
| 176 | } |
| 177 | |
| 178 | if (test_bit(vector, used_vectors)) |
| 179 | goto next; |
| 180 | |
| 181 | for_each_cpu_and(new_cpu, tmp_mask, cpu_online_mask) { |
| 182 | if (per_cpu(vector_irq, new_cpu)[vector] > |
| 183 | VECTOR_UNDEFINED) |
| 184 | goto next; |
| 185 | } |
| 186 | /* Found one! */ |
| 187 | current_vector = vector; |
| 188 | current_offset = offset; |
| 189 | if (cfg->vector) { |
| 190 | cpumask_copy(cfg->old_domain, cfg->domain); |
| 191 | cfg->move_in_progress = |
| 192 | cpumask_intersects(cfg->old_domain, cpu_online_mask); |
| 193 | } |
| 194 | for_each_cpu_and(new_cpu, tmp_mask, cpu_online_mask) |
| 195 | per_cpu(vector_irq, new_cpu)[vector] = irq; |
| 196 | cfg->vector = vector; |
| 197 | cpumask_copy(cfg->domain, tmp_mask); |
| 198 | err = 0; |
| 199 | break; |
| 200 | } |
| 201 | free_cpumask_var(tmp_mask); |
| 202 | |
Jiang Liu | 5f0052f | 2015-04-13 14:11:23 +0800 | [diff] [blame] | 203 | if (!err) { |
| 204 | /* cache destination APIC IDs into cfg->dest_apicid */ |
| 205 | err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, |
| 206 | &cfg->dest_apicid); |
| 207 | } |
| 208 | |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 209 | return err; |
| 210 | } |
| 211 | |
| 212 | int assign_irq_vector(int irq, struct irq_cfg *cfg, const struct cpumask *mask) |
| 213 | { |
| 214 | int err; |
| 215 | unsigned long flags; |
| 216 | |
| 217 | raw_spin_lock_irqsave(&vector_lock, flags); |
| 218 | err = __assign_irq_vector(irq, cfg, mask); |
| 219 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
| 220 | return err; |
| 221 | } |
| 222 | |
| 223 | void clear_irq_vector(int irq, struct irq_cfg *cfg) |
| 224 | { |
| 225 | int cpu, vector; |
| 226 | unsigned long flags; |
| 227 | |
| 228 | raw_spin_lock_irqsave(&vector_lock, flags); |
| 229 | BUG_ON(!cfg->vector); |
| 230 | |
| 231 | vector = cfg->vector; |
| 232 | for_each_cpu_and(cpu, cfg->domain, cpu_online_mask) |
| 233 | per_cpu(vector_irq, cpu)[vector] = VECTOR_UNDEFINED; |
| 234 | |
| 235 | cfg->vector = 0; |
| 236 | cpumask_clear(cfg->domain); |
| 237 | |
| 238 | if (likely(!cfg->move_in_progress)) { |
| 239 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
| 240 | return; |
| 241 | } |
| 242 | |
| 243 | for_each_cpu_and(cpu, cfg->old_domain, cpu_online_mask) { |
| 244 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; |
| 245 | vector++) { |
| 246 | if (per_cpu(vector_irq, cpu)[vector] != irq) |
| 247 | continue; |
| 248 | per_cpu(vector_irq, cpu)[vector] = VECTOR_UNDEFINED; |
| 249 | break; |
| 250 | } |
| 251 | } |
| 252 | cfg->move_in_progress = 0; |
| 253 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
| 254 | } |
| 255 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 256 | void init_irq_alloc_info(struct irq_alloc_info *info, |
| 257 | const struct cpumask *mask) |
| 258 | { |
| 259 | memset(info, 0, sizeof(*info)); |
| 260 | info->mask = mask; |
| 261 | } |
| 262 | |
| 263 | void copy_irq_alloc_info(struct irq_alloc_info *dst, struct irq_alloc_info *src) |
| 264 | { |
| 265 | if (src) |
| 266 | *dst = *src; |
| 267 | else |
| 268 | memset(dst, 0, sizeof(*dst)); |
| 269 | } |
| 270 | |
| 271 | static inline const struct cpumask * |
| 272 | irq_alloc_info_get_mask(struct irq_alloc_info *info) |
| 273 | { |
| 274 | return (!info || !info->mask) ? apic->target_cpus() : info->mask; |
| 275 | } |
| 276 | |
| 277 | static void x86_vector_free_irqs(struct irq_domain *domain, |
| 278 | unsigned int virq, unsigned int nr_irqs) |
| 279 | { |
| 280 | struct irq_data *irq_data; |
| 281 | int i; |
| 282 | |
| 283 | for (i = 0; i < nr_irqs; i++) { |
| 284 | irq_data = irq_domain_get_irq_data(x86_vector_domain, virq + i); |
| 285 | if (irq_data && irq_data->chip_data) { |
| 286 | free_remapped_irq(virq); |
| 287 | clear_irq_vector(virq + i, irq_data->chip_data); |
| 288 | free_irq_cfg(irq_data->chip_data); |
Jiang Liu | 1331532 | 2015-04-13 14:11:56 +0800 | [diff] [blame^] | 289 | #ifdef CONFIG_X86_IO_APIC |
| 290 | if (virq + i < nr_legacy_irqs()) |
| 291 | legacy_irq_cfgs[virq + i] = NULL; |
| 292 | #endif |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 293 | irq_domain_reset_irq_data(irq_data); |
| 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
| 298 | static int x86_vector_alloc_irqs(struct irq_domain *domain, unsigned int virq, |
| 299 | unsigned int nr_irqs, void *arg) |
| 300 | { |
| 301 | struct irq_alloc_info *info = arg; |
| 302 | const struct cpumask *mask; |
| 303 | struct irq_data *irq_data; |
| 304 | struct irq_cfg *cfg; |
| 305 | int i, err; |
| 306 | |
| 307 | if (disable_apic) |
| 308 | return -ENXIO; |
| 309 | |
| 310 | /* Currently vector allocator can't guarantee contiguous allocations */ |
| 311 | if ((info->flags & X86_IRQ_ALLOC_CONTIGUOUS_VECTORS) && nr_irqs > 1) |
| 312 | return -ENOSYS; |
| 313 | |
| 314 | mask = irq_alloc_info_get_mask(info); |
| 315 | for (i = 0; i < nr_irqs; i++) { |
| 316 | irq_data = irq_domain_get_irq_data(domain, virq + i); |
| 317 | BUG_ON(!irq_data); |
Jiang Liu | 1331532 | 2015-04-13 14:11:56 +0800 | [diff] [blame^] | 318 | #ifdef CONFIG_X86_IO_APIC |
| 319 | if (virq + i < nr_legacy_irqs() && legacy_irq_cfgs[virq + i]) |
| 320 | cfg = legacy_irq_cfgs[virq + i]; |
| 321 | else |
| 322 | #endif |
| 323 | cfg = alloc_irq_cfg(irq_data->node); |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 324 | if (!cfg) { |
| 325 | err = -ENOMEM; |
| 326 | goto error; |
| 327 | } |
| 328 | |
| 329 | irq_data->chip = &lapic_controller; |
| 330 | irq_data->chip_data = cfg; |
| 331 | irq_data->hwirq = virq + i; |
| 332 | err = assign_irq_vector(virq, cfg, mask); |
| 333 | if (err) |
| 334 | goto error; |
| 335 | } |
| 336 | |
| 337 | return 0; |
| 338 | |
| 339 | error: |
| 340 | x86_vector_free_irqs(domain, virq, i + 1); |
| 341 | return err; |
| 342 | } |
| 343 | |
| 344 | static struct irq_domain_ops x86_vector_domain_ops = { |
| 345 | .alloc = x86_vector_alloc_irqs, |
| 346 | .free = x86_vector_free_irqs, |
| 347 | }; |
| 348 | |
Jiang Liu | 11d686e | 2014-10-27 16:12:05 +0800 | [diff] [blame] | 349 | int __init arch_probe_nr_irqs(void) |
| 350 | { |
| 351 | int nr; |
| 352 | |
| 353 | if (nr_irqs > (NR_VECTORS * nr_cpu_ids)) |
| 354 | nr_irqs = NR_VECTORS * nr_cpu_ids; |
| 355 | |
| 356 | nr = (gsi_top + nr_legacy_irqs()) + 8 * nr_cpu_ids; |
| 357 | #if defined(CONFIG_PCI_MSI) || defined(CONFIG_HT_IRQ) |
| 358 | /* |
| 359 | * for MSI and HT dyn irq |
| 360 | */ |
| 361 | if (gsi_top <= NR_IRQS_LEGACY) |
| 362 | nr += 8 * nr_cpu_ids; |
| 363 | else |
| 364 | nr += gsi_top * 16; |
| 365 | #endif |
| 366 | if (nr < nr_irqs) |
| 367 | nr_irqs = nr; |
| 368 | |
| 369 | return nr_legacy_irqs(); |
| 370 | } |
| 371 | |
Jiang Liu | 1331532 | 2015-04-13 14:11:56 +0800 | [diff] [blame^] | 372 | #ifdef CONFIG_X86_IO_APIC |
| 373 | static void init_legacy_irqs(void) |
| 374 | { |
| 375 | int i, node = cpu_to_node(0); |
| 376 | struct irq_cfg *cfg; |
| 377 | |
| 378 | /* |
| 379 | * For legacy IRQ's, start with assigning irq0 to irq15 to |
| 380 | * IRQ0_VECTOR to IRQ15_VECTOR for all cpu's. |
| 381 | */ |
| 382 | for (i = 0; i < nr_legacy_irqs(); i++) { |
| 383 | cfg = legacy_irq_cfgs[i] = alloc_irq_cfg(node); |
| 384 | BUG_ON(!cfg); |
| 385 | /* |
| 386 | * For legacy IRQ's, start with assigning irq0 to irq15 to |
| 387 | * IRQ0_VECTOR to IRQ15_VECTOR for all cpu's. |
| 388 | */ |
| 389 | cfg->vector = IRQ0_VECTOR + i; |
| 390 | cpumask_setall(cfg->domain); |
| 391 | irq_set_chip_data(i, cfg); |
| 392 | } |
| 393 | } |
| 394 | #else |
| 395 | static void init_legacy_irqs(void) { } |
| 396 | #endif |
| 397 | |
Jiang Liu | 11d686e | 2014-10-27 16:12:05 +0800 | [diff] [blame] | 398 | int __init arch_early_irq_init(void) |
| 399 | { |
Jiang Liu | 1331532 | 2015-04-13 14:11:56 +0800 | [diff] [blame^] | 400 | init_legacy_irqs(); |
| 401 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 402 | x86_vector_domain = irq_domain_add_tree(NULL, &x86_vector_domain_ops, |
| 403 | NULL); |
| 404 | BUG_ON(x86_vector_domain == NULL); |
| 405 | irq_set_default_host(x86_vector_domain); |
| 406 | |
Jiang Liu | 52f518a | 2015-04-13 14:11:35 +0800 | [diff] [blame] | 407 | arch_init_msi_domain(x86_vector_domain); |
Jiang Liu | 49e07d8 | 2015-04-13 14:11:43 +0800 | [diff] [blame] | 408 | arch_init_htirq_domain(x86_vector_domain); |
Jiang Liu | 52f518a | 2015-04-13 14:11:35 +0800 | [diff] [blame] | 409 | |
Jiang Liu | 11d686e | 2014-10-27 16:12:05 +0800 | [diff] [blame] | 410 | return arch_early_ioapic_init(); |
| 411 | } |
| 412 | |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 413 | static void __setup_vector_irq(int cpu) |
| 414 | { |
| 415 | /* Initialize vector_irq on a new cpu */ |
| 416 | int irq, vector; |
| 417 | struct irq_cfg *cfg; |
| 418 | |
| 419 | /* |
| 420 | * vector_lock will make sure that we don't run into irq vector |
| 421 | * assignments that might be happening on another cpu in parallel, |
| 422 | * while we setup our initial vector to irq mappings. |
| 423 | */ |
| 424 | raw_spin_lock(&vector_lock); |
| 425 | /* Mark the inuse vectors */ |
| 426 | for_each_active_irq(irq) { |
| 427 | cfg = irq_cfg(irq); |
| 428 | if (!cfg) |
| 429 | continue; |
| 430 | |
| 431 | if (!cpumask_test_cpu(cpu, cfg->domain)) |
| 432 | continue; |
| 433 | vector = cfg->vector; |
| 434 | per_cpu(vector_irq, cpu)[vector] = irq; |
| 435 | } |
| 436 | /* Mark the free vectors */ |
| 437 | for (vector = 0; vector < NR_VECTORS; ++vector) { |
| 438 | irq = per_cpu(vector_irq, cpu)[vector]; |
| 439 | if (irq <= VECTOR_UNDEFINED) |
| 440 | continue; |
| 441 | |
| 442 | cfg = irq_cfg(irq); |
| 443 | if (!cpumask_test_cpu(cpu, cfg->domain)) |
| 444 | per_cpu(vector_irq, cpu)[vector] = VECTOR_UNDEFINED; |
| 445 | } |
| 446 | raw_spin_unlock(&vector_lock); |
| 447 | } |
| 448 | |
| 449 | /* |
| 450 | * Setup the vector to irq mappings. |
| 451 | */ |
| 452 | void setup_vector_irq(int cpu) |
| 453 | { |
| 454 | int irq; |
| 455 | |
| 456 | /* |
| 457 | * On most of the platforms, legacy PIC delivers the interrupts on the |
| 458 | * boot cpu. But there are certain platforms where PIC interrupts are |
| 459 | * delivered to multiple cpu's. If the legacy IRQ is handled by the |
| 460 | * legacy PIC, for the new cpu that is coming online, setup the static |
| 461 | * legacy vector to irq mapping: |
| 462 | */ |
| 463 | for (irq = 0; irq < nr_legacy_irqs(); irq++) |
| 464 | per_cpu(vector_irq, cpu)[IRQ0_VECTOR + irq] = irq; |
| 465 | |
| 466 | __setup_vector_irq(cpu); |
| 467 | } |
| 468 | |
| 469 | int apic_retrigger_irq(struct irq_data *data) |
| 470 | { |
Jiang Liu | a978609 | 2014-10-27 16:12:07 +0800 | [diff] [blame] | 471 | struct irq_cfg *cfg = irqd_cfg(data); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 472 | unsigned long flags; |
| 473 | int cpu; |
| 474 | |
| 475 | raw_spin_lock_irqsave(&vector_lock, flags); |
| 476 | cpu = cpumask_first_and(cfg->domain, cpu_online_mask); |
| 477 | apic->send_IPI_mask(cpumask_of(cpu), cfg->vector); |
| 478 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
| 479 | |
| 480 | return 1; |
| 481 | } |
| 482 | |
| 483 | void apic_ack_edge(struct irq_data *data) |
| 484 | { |
Jiang Liu | a978609 | 2014-10-27 16:12:07 +0800 | [diff] [blame] | 485 | irq_complete_move(irqd_cfg(data)); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 486 | irq_move_irq(data); |
| 487 | ack_APIC_irq(); |
| 488 | } |
| 489 | |
| 490 | /* |
| 491 | * Either sets data->affinity to a valid value, and returns |
| 492 | * ->cpu_mask_to_apicid of that in dest_id, or returns -1 and |
| 493 | * leaves data->affinity untouched. |
| 494 | */ |
| 495 | int apic_set_affinity(struct irq_data *data, const struct cpumask *mask, |
| 496 | unsigned int *dest_id) |
| 497 | { |
Jiang Liu | a978609 | 2014-10-27 16:12:07 +0800 | [diff] [blame] | 498 | struct irq_cfg *cfg = irqd_cfg(data); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 499 | unsigned int irq = data->irq; |
| 500 | int err; |
| 501 | |
| 502 | if (!config_enabled(CONFIG_SMP)) |
| 503 | return -EPERM; |
| 504 | |
| 505 | if (!cpumask_intersects(mask, cpu_online_mask)) |
| 506 | return -EINVAL; |
| 507 | |
| 508 | err = assign_irq_vector(irq, cfg, mask); |
| 509 | if (err) |
| 510 | return err; |
| 511 | |
| 512 | err = apic->cpu_mask_to_apicid_and(mask, cfg->domain, dest_id); |
| 513 | if (err) { |
| 514 | if (assign_irq_vector(irq, cfg, data->affinity)) |
| 515 | pr_err("Failed to recover vector for irq %d\n", irq); |
| 516 | return err; |
| 517 | } |
| 518 | |
| 519 | cpumask_copy(data->affinity, mask); |
| 520 | |
| 521 | return 0; |
| 522 | } |
| 523 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 524 | static int vector_set_affinity(struct irq_data *irq_data, |
| 525 | const struct cpumask *dest, bool force) |
| 526 | { |
| 527 | struct irq_cfg *cfg = irq_data->chip_data; |
| 528 | int err, irq = irq_data->irq; |
| 529 | |
| 530 | if (!config_enabled(CONFIG_SMP)) |
| 531 | return -EPERM; |
| 532 | |
| 533 | if (!cpumask_intersects(dest, cpu_online_mask)) |
| 534 | return -EINVAL; |
| 535 | |
| 536 | err = assign_irq_vector(irq, cfg, dest); |
| 537 | if (err) { |
| 538 | struct irq_data *top = irq_get_irq_data(irq); |
| 539 | |
| 540 | if (assign_irq_vector(irq, cfg, top->affinity)) |
| 541 | pr_err("Failed to recover vector for irq %d\n", irq); |
| 542 | return err; |
| 543 | } |
| 544 | |
| 545 | return IRQ_SET_MASK_OK; |
| 546 | } |
| 547 | |
| 548 | static struct irq_chip lapic_controller = { |
| 549 | .irq_ack = apic_ack_edge, |
| 550 | .irq_set_affinity = vector_set_affinity, |
| 551 | .irq_retrigger = apic_retrigger_irq, |
| 552 | }; |
| 553 | |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 554 | #ifdef CONFIG_SMP |
| 555 | void send_cleanup_vector(struct irq_cfg *cfg) |
| 556 | { |
| 557 | cpumask_var_t cleanup_mask; |
| 558 | |
| 559 | if (unlikely(!alloc_cpumask_var(&cleanup_mask, GFP_ATOMIC))) { |
| 560 | unsigned int i; |
| 561 | |
| 562 | for_each_cpu_and(i, cfg->old_domain, cpu_online_mask) |
| 563 | apic->send_IPI_mask(cpumask_of(i), |
| 564 | IRQ_MOVE_CLEANUP_VECTOR); |
| 565 | } else { |
| 566 | cpumask_and(cleanup_mask, cfg->old_domain, cpu_online_mask); |
| 567 | apic->send_IPI_mask(cleanup_mask, IRQ_MOVE_CLEANUP_VECTOR); |
| 568 | free_cpumask_var(cleanup_mask); |
| 569 | } |
| 570 | cfg->move_in_progress = 0; |
| 571 | } |
| 572 | |
| 573 | asmlinkage __visible void smp_irq_move_cleanup_interrupt(void) |
| 574 | { |
| 575 | unsigned vector, me; |
| 576 | |
| 577 | ack_APIC_irq(); |
| 578 | irq_enter(); |
| 579 | exit_idle(); |
| 580 | |
| 581 | me = smp_processor_id(); |
| 582 | for (vector = FIRST_EXTERNAL_VECTOR; vector < NR_VECTORS; vector++) { |
| 583 | int irq; |
| 584 | unsigned int irr; |
| 585 | struct irq_desc *desc; |
| 586 | struct irq_cfg *cfg; |
| 587 | |
| 588 | irq = __this_cpu_read(vector_irq[vector]); |
| 589 | |
| 590 | if (irq <= VECTOR_UNDEFINED) |
| 591 | continue; |
| 592 | |
| 593 | desc = irq_to_desc(irq); |
| 594 | if (!desc) |
| 595 | continue; |
| 596 | |
| 597 | cfg = irq_cfg(irq); |
| 598 | if (!cfg) |
| 599 | continue; |
| 600 | |
| 601 | raw_spin_lock(&desc->lock); |
| 602 | |
| 603 | /* |
| 604 | * Check if the irq migration is in progress. If so, we |
| 605 | * haven't received the cleanup request yet for this irq. |
| 606 | */ |
| 607 | if (cfg->move_in_progress) |
| 608 | goto unlock; |
| 609 | |
| 610 | if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain)) |
| 611 | goto unlock; |
| 612 | |
| 613 | irr = apic_read(APIC_IRR + (vector / 32 * 0x10)); |
| 614 | /* |
| 615 | * Check if the vector that needs to be cleanedup is |
| 616 | * registered at the cpu's IRR. If so, then this is not |
| 617 | * the best time to clean it up. Lets clean it up in the |
| 618 | * next attempt by sending another IRQ_MOVE_CLEANUP_VECTOR |
| 619 | * to myself. |
| 620 | */ |
| 621 | if (irr & (1 << (vector % 32))) { |
| 622 | apic->send_IPI_self(IRQ_MOVE_CLEANUP_VECTOR); |
| 623 | goto unlock; |
| 624 | } |
| 625 | __this_cpu_write(vector_irq[vector], VECTOR_UNDEFINED); |
| 626 | unlock: |
| 627 | raw_spin_unlock(&desc->lock); |
| 628 | } |
| 629 | |
| 630 | irq_exit(); |
| 631 | } |
| 632 | |
| 633 | static void __irq_complete_move(struct irq_cfg *cfg, unsigned vector) |
| 634 | { |
| 635 | unsigned me; |
| 636 | |
| 637 | if (likely(!cfg->move_in_progress)) |
| 638 | return; |
| 639 | |
| 640 | me = smp_processor_id(); |
| 641 | |
| 642 | if (vector == cfg->vector && cpumask_test_cpu(me, cfg->domain)) |
| 643 | send_cleanup_vector(cfg); |
| 644 | } |
| 645 | |
| 646 | void irq_complete_move(struct irq_cfg *cfg) |
| 647 | { |
| 648 | __irq_complete_move(cfg, ~get_irq_regs()->orig_ax); |
| 649 | } |
| 650 | |
| 651 | void irq_force_complete_move(int irq) |
| 652 | { |
| 653 | struct irq_cfg *cfg = irq_cfg(irq); |
| 654 | |
| 655 | if (!cfg) |
| 656 | return; |
| 657 | |
| 658 | __irq_complete_move(cfg, cfg->vector); |
| 659 | } |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 660 | #endif |
| 661 | |
| 662 | /* |
| 663 | * Dynamic irq allocate and deallocation. Should be replaced by irq domains! |
| 664 | */ |
| 665 | int arch_setup_hwirq(unsigned int irq, int node) |
| 666 | { |
| 667 | struct irq_cfg *cfg; |
| 668 | unsigned long flags; |
| 669 | int ret; |
| 670 | |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 671 | cfg = alloc_irq_cfg(node); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 672 | if (!cfg) |
| 673 | return -ENOMEM; |
| 674 | |
| 675 | raw_spin_lock_irqsave(&vector_lock, flags); |
| 676 | ret = __assign_irq_vector(irq, cfg, apic->target_cpus()); |
| 677 | raw_spin_unlock_irqrestore(&vector_lock, flags); |
| 678 | |
| 679 | if (!ret) |
| 680 | irq_set_chip_data(irq, cfg); |
| 681 | else |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 682 | free_irq_cfg(cfg); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 683 | return ret; |
| 684 | } |
| 685 | |
| 686 | void arch_teardown_hwirq(unsigned int irq) |
| 687 | { |
| 688 | struct irq_cfg *cfg = irq_cfg(irq); |
| 689 | |
| 690 | free_remapped_irq(irq); |
| 691 | clear_irq_vector(irq, cfg); |
Jiang Liu | b5dc8e6 | 2015-04-13 14:11:24 +0800 | [diff] [blame] | 692 | irq_set_chip_data(irq, NULL); |
| 693 | free_irq_cfg(cfg); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 694 | } |
| 695 | |
| 696 | static void __init print_APIC_field(int base) |
| 697 | { |
| 698 | int i; |
| 699 | |
| 700 | printk(KERN_DEBUG); |
| 701 | |
| 702 | for (i = 0; i < 8; i++) |
| 703 | pr_cont("%08x", apic_read(base + i*0x10)); |
| 704 | |
| 705 | pr_cont("\n"); |
| 706 | } |
| 707 | |
| 708 | static void __init print_local_APIC(void *dummy) |
| 709 | { |
| 710 | unsigned int i, v, ver, maxlvt; |
| 711 | u64 icr; |
| 712 | |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 713 | pr_debug("printing local APIC contents on CPU#%d/%d:\n", |
| 714 | smp_processor_id(), hard_smp_processor_id()); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 715 | v = apic_read(APIC_ID); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 716 | pr_info("... APIC ID: %08x (%01x)\n", v, read_apic_id()); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 717 | v = apic_read(APIC_LVR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 718 | pr_info("... APIC VERSION: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 719 | ver = GET_APIC_VERSION(v); |
| 720 | maxlvt = lapic_get_maxlvt(); |
| 721 | |
| 722 | v = apic_read(APIC_TASKPRI); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 723 | pr_debug("... APIC TASKPRI: %08x (%02x)\n", v, v & APIC_TPRI_MASK); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 724 | |
| 725 | /* !82489DX */ |
| 726 | if (APIC_INTEGRATED(ver)) { |
| 727 | if (!APIC_XAPIC(ver)) { |
| 728 | v = apic_read(APIC_ARBPRI); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 729 | pr_debug("... APIC ARBPRI: %08x (%02x)\n", |
| 730 | v, v & APIC_ARBPRI_MASK); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 731 | } |
| 732 | v = apic_read(APIC_PROCPRI); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 733 | pr_debug("... APIC PROCPRI: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 734 | } |
| 735 | |
| 736 | /* |
| 737 | * Remote read supported only in the 82489DX and local APIC for |
| 738 | * Pentium processors. |
| 739 | */ |
| 740 | if (!APIC_INTEGRATED(ver) || maxlvt == 3) { |
| 741 | v = apic_read(APIC_RRR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 742 | pr_debug("... APIC RRR: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 743 | } |
| 744 | |
| 745 | v = apic_read(APIC_LDR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 746 | pr_debug("... APIC LDR: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 747 | if (!x2apic_enabled()) { |
| 748 | v = apic_read(APIC_DFR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 749 | pr_debug("... APIC DFR: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 750 | } |
| 751 | v = apic_read(APIC_SPIV); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 752 | pr_debug("... APIC SPIV: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 753 | |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 754 | pr_debug("... APIC ISR field:\n"); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 755 | print_APIC_field(APIC_ISR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 756 | pr_debug("... APIC TMR field:\n"); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 757 | print_APIC_field(APIC_TMR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 758 | pr_debug("... APIC IRR field:\n"); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 759 | print_APIC_field(APIC_IRR); |
| 760 | |
| 761 | /* !82489DX */ |
| 762 | if (APIC_INTEGRATED(ver)) { |
| 763 | /* Due to the Pentium erratum 3AP. */ |
| 764 | if (maxlvt > 3) |
| 765 | apic_write(APIC_ESR, 0); |
| 766 | |
| 767 | v = apic_read(APIC_ESR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 768 | pr_debug("... APIC ESR: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 769 | } |
| 770 | |
| 771 | icr = apic_icr_read(); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 772 | pr_debug("... APIC ICR: %08x\n", (u32)icr); |
| 773 | pr_debug("... APIC ICR2: %08x\n", (u32)(icr >> 32)); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 774 | |
| 775 | v = apic_read(APIC_LVTT); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 776 | pr_debug("... APIC LVTT: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 777 | |
| 778 | if (maxlvt > 3) { |
| 779 | /* PC is LVT#4. */ |
| 780 | v = apic_read(APIC_LVTPC); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 781 | pr_debug("... APIC LVTPC: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 782 | } |
| 783 | v = apic_read(APIC_LVT0); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 784 | pr_debug("... APIC LVT0: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 785 | v = apic_read(APIC_LVT1); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 786 | pr_debug("... APIC LVT1: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 787 | |
| 788 | if (maxlvt > 2) { |
| 789 | /* ERR is LVT#3. */ |
| 790 | v = apic_read(APIC_LVTERR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 791 | pr_debug("... APIC LVTERR: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | v = apic_read(APIC_TMICT); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 795 | pr_debug("... APIC TMICT: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 796 | v = apic_read(APIC_TMCCT); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 797 | pr_debug("... APIC TMCCT: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 798 | v = apic_read(APIC_TDCR); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 799 | pr_debug("... APIC TDCR: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 800 | |
| 801 | if (boot_cpu_has(X86_FEATURE_EXTAPIC)) { |
| 802 | v = apic_read(APIC_EFEAT); |
| 803 | maxlvt = (v >> 16) & 0xff; |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 804 | pr_debug("... APIC EFEAT: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 805 | v = apic_read(APIC_ECTRL); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 806 | pr_debug("... APIC ECTRL: %08x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 807 | for (i = 0; i < maxlvt; i++) { |
| 808 | v = apic_read(APIC_EILVTn(i)); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 809 | pr_debug("... APIC EILVT%d: %08x\n", i, v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 810 | } |
| 811 | } |
| 812 | pr_cont("\n"); |
| 813 | } |
| 814 | |
| 815 | static void __init print_local_APICs(int maxcpu) |
| 816 | { |
| 817 | int cpu; |
| 818 | |
| 819 | if (!maxcpu) |
| 820 | return; |
| 821 | |
| 822 | preempt_disable(); |
| 823 | for_each_online_cpu(cpu) { |
| 824 | if (cpu >= maxcpu) |
| 825 | break; |
| 826 | smp_call_function_single(cpu, print_local_APIC, NULL, 1); |
| 827 | } |
| 828 | preempt_enable(); |
| 829 | } |
| 830 | |
| 831 | static void __init print_PIC(void) |
| 832 | { |
| 833 | unsigned int v; |
| 834 | unsigned long flags; |
| 835 | |
| 836 | if (!nr_legacy_irqs()) |
| 837 | return; |
| 838 | |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 839 | pr_debug("\nprinting PIC contents\n"); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 840 | |
| 841 | raw_spin_lock_irqsave(&i8259A_lock, flags); |
| 842 | |
| 843 | v = inb(0xa1) << 8 | inb(0x21); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 844 | pr_debug("... PIC IMR: %04x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 845 | |
| 846 | v = inb(0xa0) << 8 | inb(0x20); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 847 | pr_debug("... PIC IRR: %04x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 848 | |
| 849 | outb(0x0b, 0xa0); |
| 850 | outb(0x0b, 0x20); |
| 851 | v = inb(0xa0) << 8 | inb(0x20); |
| 852 | outb(0x0a, 0xa0); |
| 853 | outb(0x0a, 0x20); |
| 854 | |
| 855 | raw_spin_unlock_irqrestore(&i8259A_lock, flags); |
| 856 | |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 857 | pr_debug("... PIC ISR: %04x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 858 | |
| 859 | v = inb(0x4d1) << 8 | inb(0x4d0); |
Jiang Liu | 849d356 | 2014-10-27 16:12:01 +0800 | [diff] [blame] | 860 | pr_debug("... PIC ELCR: %04x\n", v); |
Jiang Liu | 74afab7 | 2014-10-27 16:12:00 +0800 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | static int show_lapic __initdata = 1; |
| 864 | static __init int setup_show_lapic(char *arg) |
| 865 | { |
| 866 | int num = -1; |
| 867 | |
| 868 | if (strcmp(arg, "all") == 0) { |
| 869 | show_lapic = CONFIG_NR_CPUS; |
| 870 | } else { |
| 871 | get_option(&arg, &num); |
| 872 | if (num >= 0) |
| 873 | show_lapic = num; |
| 874 | } |
| 875 | |
| 876 | return 1; |
| 877 | } |
| 878 | __setup("show_lapic=", setup_show_lapic); |
| 879 | |
| 880 | static int __init print_ICs(void) |
| 881 | { |
| 882 | if (apic_verbosity == APIC_QUIET) |
| 883 | return 0; |
| 884 | |
| 885 | print_PIC(); |
| 886 | |
| 887 | /* don't print out if apic is not there */ |
| 888 | if (!cpu_has_apic && !apic_from_smp_config()) |
| 889 | return 0; |
| 890 | |
| 891 | print_local_APICs(show_lapic); |
| 892 | print_IO_APICs(); |
| 893 | |
| 894 | return 0; |
| 895 | } |
| 896 | |
| 897 | late_initcall(print_ICs); |