Code flow for enabling interrupt-remapping has its own routines for saving and
restoring io-apic RTE's. ioapic suspend/resume code flow also has similar
routines. Remove the duplicate code.
Signed-off-by: Suresh Siddha <[email protected]>
---
arch/x86/kernel/apic/io_apic.c | 36 +++++-------------------------------
1 file changed, 5 insertions(+), 31 deletions(-)
Index: linux-2.6-tip/arch/x86/kernel/apic/io_apic.c
===================================================================
--- linux-2.6-tip.orig/arch/x86/kernel/apic/io_apic.c
+++ linux-2.6-tip/arch/x86/kernel/apic/io_apic.c
@@ -2887,37 +2887,11 @@ static int __init io_apic_bug_finalize(v
late_initcall(io_apic_bug_finalize);
-static void suspend_ioapic(int ioapic_id)
+static void resume_ioapic_id(int ioapic_id)
{
- struct IO_APIC_route_entry *saved_data = ioapic_saved_data[ioapic_id];
- int i;
-
- if (!saved_data)
- return;
-
- for (i = 0; i < nr_ioapic_registers[ioapic_id]; i++)
- saved_data[i] = ioapic_read_entry(ioapic_id, i);
-}
-
-static int ioapic_suspend(void)
-{
- int ioapic_id;
-
- for (ioapic_id = 0; ioapic_id < nr_ioapics; ioapic_id++)
- suspend_ioapic(ioapic_id);
-
- return 0;
-}
-
-static void resume_ioapic(int ioapic_id)
-{
- struct IO_APIC_route_entry *saved_data = ioapic_saved_data[ioapic_id];
unsigned long flags;
union IO_APIC_reg_00 reg_00;
- int i;
- if (!saved_data)
- return;
raw_spin_lock_irqsave(&ioapic_lock, flags);
reg_00.raw = io_apic_read(ioapic_id, 0);
@@ -2926,8 +2900,6 @@ static void resume_ioapic(int ioapic_id)
io_apic_write(ioapic_id, 0, reg_00.raw);
}
raw_spin_unlock_irqrestore(&ioapic_lock, flags);
- for (i = 0; i < nr_ioapic_registers[ioapic_id]; i++)
- ioapic_write_entry(ioapic_id, i, saved_data[i]);
}
static void ioapic_resume(void)
@@ -2935,11 +2907,13 @@ static void ioapic_resume(void)
int ioapic_id;
for (ioapic_id = nr_ioapics - 1; ioapic_id >= 0; ioapic_id--)
- resume_ioapic(ioapic_id);
+ resume_ioapic_id(ioapic_id);
+
+ restore_ioapic_entries();
}
static struct syscore_ops ioapic_syscore_ops = {
- .suspend = ioapic_suspend,
+ .suspend = save_ioapic_entries,
.resume = ioapic_resume,
};
ok, this series looks better, but as this bug has demonstrated it we need to do
better to keep the ioapic code clean.
Firstly, please introduce a 'struct ioapic' structure that starts out with a
nr_registers field, and add an ioapics[] array and consolidate
nr_ioapic_registers into this.
The consolidate other ioapic driver state as well:
- add a *saved_registers field and consolidate ioapic_saved_data into it
- add a 'struct mpc_ioapic mp_config' entry and consolidate mp_ioapics[]
- add a 'struct mp_ioapic_gsi gsi_config' entry and consolidate mp_gsi_routing[]
- add a 'int pin_programmed' field and consolidate mp_ioapic_routing[] into it
ioapics[] itself should be static to io_apic.c.
Please create a separate patch for each change: that way it's bisectable and
reviewable.
These changes alone will make the IO-APIC code a *lot* more readable, more
extensible - and hopefully much less prone to suspend/resume bugs as well.
Feel free to do this on top of your current queue to keep your patch-shuffling
overhead low.
Thanks,
Ingo