Re: setup_ioapic_ids_from_mpc()

William Lee Irwin III
2003-01-19T13:20:54Z

>> 100% untested. I'll spin it sometime tomorrow.

On Sun, Jan 19, 2003 at 05:15:56AM -0800, William Lee Irwin III wrote:
> Take 2: I eyeballed a couple bogosities.

Take 3: flags undeclared, regval/reg aliasing might need barriers; speed
is not an issue at boot-time, so slap down the heaviest barrier imaginable.

===== arch/i386/kernel/io_apic.c 1.40 vs edited =====
--- 1.40/arch/i386/kernel/io_apic.c Tue Jan 14 03:02:28 2003
+++ edited/arch/i386/kernel/io_apic.c Sun Jan 19 05:27:35 2003
@@ -1132,7 +1132,44 @@
* by Matt Domsch <Matt_Domsch@dell.com> Tue Dec 21 12:25:05 CST 1999
*/

-static void __init setup_ioapic_ids_from_mpc (void)
+#ifdef CONFIG_X86_NUMAQ
+static void __init setup_ioapic_ids_from_mpc(void)
+{
+ int io_apic;
+
+ for (io_apic = 0; io_apic < nr_ioapics; ++io_apic) {
+ struct IO_APIC_reg_00 reg;
+ int node, local, global, *regval = (int *)&reg;
+ unsigned long flags;
+
+ global = mp_ioapics[apic].mpc_apicid;
+ local = 0;
+ for (node = 0; node < MAX_NUMNODES; ++node) {
+ if (mp_ioapic_id_map[node][0][0] == global)
+ local = mp_ioapic_id_map[node][0][1];
+ else if (mp_ioapic_id_map[node][1][0] == global)
+ local = mp_ioapic_id_map[node][1][1];
+ }
+
+ if (!local) {
+ printk("mystery IO-APIC, it will die\n");
+ continue;
+ }
+
+
+ spin_lock_irqsave(&ioapic_lock, flags);
+ *regval = io_apic_read(io_apic, 0);
+ mb(); /* b/c regval aliases &reg */
+ if (reg.ID != local) {
+ reg.ID = local;
+ mb(); /* b/c regval aliases &reg */
+ io_apic_write(io_apic, 0, *regval);
+ }
+ spin_unlock_irqrestore(&ioapic_lock, flags);
+ }
+}
+#else /* !CONFIG_X86_NUMAQ */
+static void __init setup_ioapic_ids_from_mpc(void)
{
struct IO_APIC_reg_00 reg_00;
unsigned long phys_id_present_map;
@@ -1225,6 +1262,7 @@