aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/apic/apic.c
diff options
context:
space:
mode:
authorSuresh Siddha <suresh.b.siddha@intel.com>2011-05-18 19:31:33 -0400
committerIngo Molnar <mingo@elte.hu>2011-05-20 07:40:52 -0400
commit31dce14a3269843f98ce1bc37d0c91b22f1991ee (patch)
tree66a02547580d22cc31648fd27169940b50c01ce4 /arch/x86/kernel/apic/apic.c
parent4c79185cdb1425fb74241d0be772ff1a9913091a (diff)
x86, ioapic: Use ioapic_saved_data while enabling intr-remapping
Code flow for enabling interrupt-remapping was allocating/freeing buffers for saving/restoring io-apic RTE's. ioapic suspend/resume code uses boot time allocated ioapic_saved_data that is a perfect match for reuse here. This will remove the unnecessary allocation/free of the temporary buffers during suspend/resume of interrupt-remapping enabled platforms aswell as paving the way for further code consolidation. Tested-by: Daniel J Blueman <daniel.blueman@gmail.com> Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com> Link: http://lkml.kernel.org/r/20110518233157.574469296@sbsiddha-MOBL3.sc.intel.com Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/kernel/apic/apic.c')
-rw-r--r--arch/x86/kernel/apic/apic.c48
1 files changed, 13 insertions, 35 deletions
diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index f92a8e5d1e21..b961af86bfea 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -1461,7 +1461,6 @@ int __init enable_IR(void)
1461void __init enable_IR_x2apic(void) 1461void __init enable_IR_x2apic(void)
1462{ 1462{
1463 unsigned long flags; 1463 unsigned long flags;
1464 struct IO_APIC_route_entry **ioapic_entries;
1465 int ret, x2apic_enabled = 0; 1464 int ret, x2apic_enabled = 0;
1466 int dmar_table_init_ret; 1465 int dmar_table_init_ret;
1467 1466
@@ -1469,13 +1468,7 @@ void __init enable_IR_x2apic(void)
1469 if (dmar_table_init_ret && !x2apic_supported()) 1468 if (dmar_table_init_ret && !x2apic_supported())
1470 return; 1469 return;
1471 1470
1472 ioapic_entries = alloc_ioapic_entries(); 1471 ret = save_ioapic_entries();
1473 if (!ioapic_entries) {
1474 pr_err("Allocate ioapic_entries failed\n");
1475 goto out;
1476 }
1477
1478 ret = save_IO_APIC_setup(ioapic_entries);
1479 if (ret) { 1472 if (ret) {
1480 pr_info("Saving IO-APIC state failed: %d\n", ret); 1473 pr_info("Saving IO-APIC state failed: %d\n", ret);
1481 goto out; 1474 goto out;
@@ -1483,7 +1476,7 @@ void __init enable_IR_x2apic(void)
1483 1476
1484 local_irq_save(flags); 1477 local_irq_save(flags);
1485 legacy_pic->mask_all(); 1478 legacy_pic->mask_all();
1486 mask_IO_APIC_setup(ioapic_entries); 1479 mask_ioapic_entries();
1487 1480
1488 if (dmar_table_init_ret) 1481 if (dmar_table_init_ret)
1489 ret = 0; 1482 ret = 0;
@@ -1514,14 +1507,11 @@ void __init enable_IR_x2apic(void)
1514 1507
1515nox2apic: 1508nox2apic:
1516 if (!ret) /* IR enabling failed */ 1509 if (!ret) /* IR enabling failed */
1517 restore_IO_APIC_setup(ioapic_entries); 1510 restore_ioapic_entries();
1518 legacy_pic->restore_mask(); 1511 legacy_pic->restore_mask();
1519 local_irq_restore(flags); 1512 local_irq_restore(flags);
1520 1513
1521out: 1514out:
1522 if (ioapic_entries)
1523 free_ioapic_entries(ioapic_entries);
1524
1525 if (x2apic_enabled) 1515 if (x2apic_enabled)
1526 return; 1516 return;
1527 1517
@@ -2095,28 +2085,20 @@ static void lapic_resume(void)
2095{ 2085{
2096 unsigned int l, h; 2086 unsigned int l, h;
2097 unsigned long flags; 2087 unsigned long flags;
2098 int maxlvt, ret; 2088 int maxlvt;
2099 struct IO_APIC_route_entry **ioapic_entries = NULL;
2100 2089
2101 if (!apic_pm_state.active) 2090 if (!apic_pm_state.active)
2102 return; 2091 return;
2103 2092
2104 local_irq_save(flags); 2093 local_irq_save(flags);
2105 if (intr_remapping_enabled) { 2094 if (intr_remapping_enabled) {
2106 ioapic_entries = alloc_ioapic_entries(); 2095 /*
2107 if (!ioapic_entries) { 2096 * IO-APIC and PIC have their own resume routines.
2108 WARN(1, "Alloc ioapic_entries in lapic resume failed."); 2097 * We just mask them here to make sure the interrupt
2109 goto restore; 2098 * subsystem is completely quiet while we enable x2apic
2110 } 2099 * and interrupt-remapping.
2111 2100 */
2112 ret = save_IO_APIC_setup(ioapic_entries); 2101 mask_ioapic_entries();
2113 if (ret) {
2114 WARN(1, "Saving IO-APIC state failed: %d\n", ret);
2115 free_ioapic_entries(ioapic_entries);
2116 goto restore;
2117 }
2118
2119 mask_IO_APIC_setup(ioapic_entries);
2120 legacy_pic->mask_all(); 2102 legacy_pic->mask_all();
2121 } 2103 }
2122 2104
@@ -2159,13 +2141,9 @@ static void lapic_resume(void)
2159 apic_write(APIC_ESR, 0); 2141 apic_write(APIC_ESR, 0);
2160 apic_read(APIC_ESR); 2142 apic_read(APIC_ESR);
2161 2143
2162 if (intr_remapping_enabled) { 2144 if (intr_remapping_enabled)
2163 reenable_intr_remapping(x2apic_mode); 2145 reenable_intr_remapping(x2apic_mode);
2164 legacy_pic->restore_mask(); 2146
2165 restore_IO_APIC_setup(ioapic_entries);
2166 free_ioapic_entries(ioapic_entries);
2167 }
2168restore:
2169 local_irq_restore(flags); 2147 local_irq_restore(flags);
2170} 2148}
2171 2149