diff options
author | Jiang Liu <jiang.liu@linux.intel.com> | 2014-06-09 04:19:45 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2014-06-21 17:05:41 -0400 |
commit | 18e485518656205bbffce5e01f07830a6c3f557d (patch) | |
tree | dcbba2daaa381470b66c17839f808c4795c6b7cf /arch/x86/kernel | |
parent | 79598505aee61bc943955de3653be054c2f7393f (diff) |
x86, irq: Introduce some helper utilities to improve readability
It also fixes an off by one bug in
if ((ioapic_idx > 0) && (irq > NR_IRQS_LEGACY))
It should be
if ((ioapic_idx > 0) && (irq >= NR_IRQS_LEGACY))
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1402302011-23642-17-git-send-email-jiang.liu@linux.intel.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/apic/io_apic.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 09e5c7b4df5a..424f795a1c78 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c | |||
@@ -117,6 +117,24 @@ struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int ioapic_idx) | |||
117 | return &ioapics[ioapic_idx].gsi_config; | 117 | return &ioapics[ioapic_idx].gsi_config; |
118 | } | 118 | } |
119 | 119 | ||
120 | static inline int mp_ioapic_pin_count(int ioapic) | ||
121 | { | ||
122 | struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(ioapic); | ||
123 | |||
124 | return gsi_cfg->gsi_end - gsi_cfg->gsi_base + 1; | ||
125 | } | ||
126 | |||
127 | u32 mp_pin_to_gsi(int ioapic, int pin) | ||
128 | { | ||
129 | return mp_ioapic_gsi_routing(ioapic)->gsi_base + pin; | ||
130 | } | ||
131 | |||
132 | /* Initialize all legacy IRQs and all pins on the first IOAPIC at boot */ | ||
133 | static inline int mp_init_irq_at_boot(int ioapic, int irq) | ||
134 | { | ||
135 | return ioapic == 0 || (irq >= 0 && irq < NR_IRQS_LEGACY); | ||
136 | } | ||
137 | |||
120 | int nr_ioapics; | 138 | int nr_ioapics; |
121 | 139 | ||
122 | /* The one past the highest gsi number used */ | 140 | /* The one past the highest gsi number used */ |
@@ -1367,8 +1385,7 @@ static void __init __io_apic_setup_irqs(unsigned int ioapic_idx) | |||
1367 | continue; | 1385 | continue; |
1368 | 1386 | ||
1369 | irq = pin_2_irq(idx, ioapic_idx, pin); | 1387 | irq = pin_2_irq(idx, ioapic_idx, pin); |
1370 | 1388 | if (!mp_init_irq_at_boot(ioapic_idx, irq)) | |
1371 | if ((ioapic_idx > 0) && (irq > NR_IRQS_LEGACY)) | ||
1372 | continue; | 1389 | continue; |
1373 | 1390 | ||
1374 | /* | 1391 | /* |
@@ -1419,9 +1436,7 @@ void setup_IO_APIC_irq_extra(u32 gsi) | |||
1419 | return; | 1436 | return; |
1420 | 1437 | ||
1421 | irq = pin_2_irq(idx, ioapic_idx, pin); | 1438 | irq = pin_2_irq(idx, ioapic_idx, pin); |
1422 | 1439 | if (mp_init_irq_at_boot(ioapic_idx, irq)) | |
1423 | /* Only handle the non legacy irqs on secondary ioapics */ | ||
1424 | if (ioapic_idx == 0 || irq < NR_IRQS_LEGACY) | ||
1425 | return; | 1440 | return; |
1426 | 1441 | ||
1427 | set_io_apic_irq_attr(&attr, ioapic_idx, pin, irq_trigger(idx), | 1442 | set_io_apic_irq_attr(&attr, ioapic_idx, pin, irq_trigger(idx), |
@@ -3528,9 +3543,9 @@ void __init setup_ioapic_dest(void) | |||
3528 | irq_entry = find_irq_entry(ioapic, pin, mp_INT); | 3543 | irq_entry = find_irq_entry(ioapic, pin, mp_INT); |
3529 | if (irq_entry == -1) | 3544 | if (irq_entry == -1) |
3530 | continue; | 3545 | continue; |
3531 | irq = pin_2_irq(irq_entry, ioapic, pin); | ||
3532 | 3546 | ||
3533 | if ((ioapic > 0) && (irq > NR_IRQS_LEGACY)) | 3547 | irq = pin_2_irq(irq_entry, ioapic, pin); |
3548 | if (!mp_init_irq_at_boot(ioapic, irq)) | ||
3534 | continue; | 3549 | continue; |
3535 | 3550 | ||
3536 | idata = irq_get_irq_data(irq); | 3551 | idata = irq_get_irq_data(irq); |