From: Yinghai Lu <yhlu.kernel.send@gmail.com>
To: Ingo Molnar <mingo@elte.hu>,
"Eric W. Biederman" <ebiederm@xmission.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] x86: update mptable
Date: Tue, 6 May 2008 10:38:57 -0700 [thread overview]
Message-ID: <200805061038.58023.yhlu.kernel@gmail.com> (raw)
In-Reply-To: <200805041823.57198.yhlu.kernel@gmail.com>
make mptable to be consistent to acpi routing, so we could
1. kexec kernel with acpi=off
2. workaround BIOS that acpi routing is working, but mptable is not right.
so can use kernel/kexec to start other os that doesn't have good acpi support
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Index: linux-2.6/drivers/acpi/pci_irq.c
===================================================================
--- linux-2.6.orig/drivers/acpi/pci_irq.c
+++ linux-2.6/drivers/acpi/pci_irq.c
@@ -474,6 +474,8 @@ acpi_pci_irq_derive(struct pci_dev *dev,
return irq;
}
+int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, u32 gsi, int triggering, int polarity);
+
/*
* acpi_pci_irq_enable
* success: return 0
@@ -570,6 +572,8 @@ int acpi_pci_irq_enable(struct pci_dev *
(triggering == ACPI_LEVEL_SENSITIVE) ? "level" : "edge",
(polarity == ACPI_ACTIVE_LOW) ? "low" : "high", dev->irq);
+ mp_config_acpi_gsi(dev->bus->number, dev->devfn, dev->pin, irq, triggering, polarity);
+
return 0;
}
Index: linux-2.6/arch/x86/kernel/mpparse.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/mpparse.c
+++ linux-2.6/arch/x86/kernel/mpparse.c
@@ -180,14 +180,26 @@ static void __init MP_ioapic_info(struct
nr_ioapics++;
}
-static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
+static void __init print_MP_intsrc_info(struct mpc_config_intsrc *m)
{
- mp_irqs[mp_irq_entries] = *m;
printk(KERN_INFO "Int: type %d, pol %d, trig %d, bus %02x,"
" IRQ %02x, APIC ID %x, APIC INT %02x\n",
m->mpc_irqtype, m->mpc_irqflag & 3,
(m->mpc_irqflag >> 2) & 3, m->mpc_srcbus,
m->mpc_srcbusirq, m->mpc_dstapic, m->mpc_dstirq);
+}
+
+static void __init MP_intsrc_info(struct mpc_config_intsrc *m)
+{
+ int i;
+
+ print_MP_intsrc_info(m);
+
+ for (i = 0; i < mp_irq_entries; i++)
+ if (!memcmp(m, &mp_irqs[i], sizeof(*m)))
+ return;
+
+ mp_irqs[mp_irq_entries] = *m;
if (++mp_irq_entries == MAX_IRQ_SOURCES)
panic("Max # of irq sources exceeded!!\n");
}
@@ -281,12 +293,9 @@ static inline void mps_oem_check(struct
* Read/parse the MPC
*/
-static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
+static int __init smp_check_mpc(struct mp_config_table *mpc, char *oem,
+ char *str)
{
- char str[16];
- char oem[10];
- int count = sizeof(*mpc);
- unsigned char *mpt = ((unsigned char *)mpc) + count;
if (memcmp(mpc->mpc_signature, MPC_SIGNATURE, 4)) {
printk(KERN_ERR "MPTABLE: bad signature [%c%c%c%c]!\n",
@@ -314,13 +323,28 @@ static int __init smp_read_mpc(struct mp
memcpy(str, mpc->mpc_productid, 12);
str[12] = 0;
-#ifdef CONFIG_X86_32
- mps_oem_check(mpc, oem, str);
-#endif
printk(KERN_INFO "MPTABLE: Product ID: %s\n", str);
printk(KERN_INFO "MPTABLE: APIC at: 0x%X\n", mpc->mpc_lapic);
+ return 1;
+}
+
+static int __init smp_read_mpc(struct mp_config_table *mpc, unsigned early)
+{
+ char str[16];
+ char oem[10];
+
+ int count = sizeof(*mpc);
+ unsigned char *mpt = ((unsigned char *)mpc) + count;
+
+ if (!smp_check_mpc(mpc, oem, str))
+ return 0;
+
+#ifdef CONFIG_X86_32
+ mps_oem_check(mpc, oem, str);
+#endif
+
/* save the local APIC address, it might be non-default */
if (!acpi_lapic)
mp_lapic_addr = mpc->mpc_lapic;
@@ -1082,5 +1106,225 @@ int mp_register_gsi(u32 gsi, int trigger
return gsi;
}
+int mp_config_acpi_gsi(unsigned char number, unsigned int devfn, u8 pin, u32 gsi, int triggering, int polarity)
+{
+ struct mpc_config_intsrc intsrc;
+ int ioapic;
+
+ /* print the entry should happen on mptable identically */
+ intsrc.mpc_type = MP_INTSRC;
+ intsrc.mpc_irqtype = mp_INT;
+ intsrc.mpc_irqflag = (triggering == ACPI_EDGE_SENSITIVE ? 4 : 0x0c) |
+ (polarity == ACPI_ACTIVE_HIGH ? 1 : 3);
+ intsrc.mpc_srcbus = number;
+ intsrc.mpc_srcbusirq = (((devfn >> 3) & 0x1f) << 2) | ((pin - 1) & 3);
+ ioapic = mp_find_ioapic(gsi);
+ intsrc.mpc_dstapic = mp_ioapic_routing[ioapic].apic_id;
+ intsrc.mpc_dstirq = gsi - mp_ioapic_routing[ioapic].gsi_base;
+
+ MP_intsrc_info(&intsrc);
+
+ return 0;
+}
#endif /* CONFIG_X86_IO_APIC */
#endif /* CONFIG_ACPI */
+
+static u8 __initdata irq_used[MAX_IRQ_SOURCES];
+
+static int __init get_MP_intsrc_index(struct mpc_config_intsrc *m)
+{
+ int i;
+
+ if (m->mpc_irqtype != mp_INT)
+ return 0;
+
+ if (m->mpc_irqflag != 0x0f)
+ return 0;
+
+ /* not legacy */
+
+ for (i = 0; i < mp_irq_entries; i++) {
+ if (mp_irqs[i].mpc_irqtype != mp_INT)
+ continue;
+
+ if (mp_irqs[i].mpc_irqflag != 0x0f)
+ continue;
+
+ if (mp_irqs[i].mpc_srcbus != m->mpc_srcbus)
+ continue;
+ if (mp_irqs[i].mpc_srcbusirq != m->mpc_srcbusirq)
+ continue;
+ if (irq_used[i]) {
+ /* already claimed */
+ return -2;
+ }
+ irq_used[i] = 1;
+ return i;
+ }
+
+ /* not found */
+ return -1;
+}
+
+#define SPARE_SLOT_NUM 20
+
+static struct mpc_config_intsrc __initdata *m_spare[SPARE_SLOT_NUM];
+
+static int __init replace_intsrc_all(struct mp_config_table *mpc)
+{
+ int i;
+ int nr_m_spare = 0;
+
+ int count = sizeof(*mpc);
+ unsigned char *mpt = ((unsigned char *)mpc) + count;
+
+ printk("mpc_length %x\n", mpc->mpc_length);
+ while (count < mpc->mpc_length) {
+ switch (*mpt) {
+ case MP_PROCESSOR:
+ {
+ struct mpc_config_processor *m =
+ (struct mpc_config_processor *)mpt;
+ mpt += sizeof(*m);
+ count += sizeof(*m);
+ break;
+ }
+ case MP_BUS:
+ {
+ struct mpc_config_bus *m =
+ (struct mpc_config_bus *)mpt;
+ mpt += sizeof(*m);
+ count += sizeof(*m);
+ break;
+ }
+ case MP_IOAPIC:
+ {
+ mpt += sizeof(struct mpc_config_ioapic);
+ count += sizeof(struct mpc_config_ioapic);
+ break;
+ }
+ case MP_INTSRC:
+ {
+#ifdef CONFIG_X86_IO_APIC
+ struct mpc_config_intsrc *m =
+ (struct mpc_config_intsrc *)mpt;
+
+ /* we can not fill blank, so just duplicate last one if needed */
+ printk("OLD ");
+ print_MP_intsrc_info(m);
+ i = get_MP_intsrc_index(m);
+ if (i > 0) {
+ memcpy(m, &mp_irqs[i], sizeof(*m));
+ printk("NEW ");
+ print_MP_intsrc_info(&mp_irqs[i]);
+ } else if (!i) {
+ /* legacy, do nothing */
+ } else if (nr_m_spare < SPARE_SLOT_NUM) {
+ /* -1, -2 */
+ /* not found, or duplicated ==> invalid entry, we need to use the slot later*/
+ m_spare[nr_m_spare] = m;
+ nr_m_spare++;
+ }
+#endif
+ mpt += sizeof(struct mpc_config_intsrc);
+ count += sizeof(struct mpc_config_intsrc);
+ break;
+ }
+ case MP_LINTSRC:
+ {
+ struct mpc_config_lintsrc *m =
+ (struct mpc_config_lintsrc *)mpt;
+ mpt += sizeof(*m);
+ count += sizeof(*m);
+ break;
+ }
+ default:
+ /* wrong mptable */
+ printk(KERN_ERR "Your mptable is wrong, contact your HW vendor!\n");
+ printk(KERN_ERR "type %x\n", *mpt);
+ print_hex_dump(KERN_ERR, " ", DUMP_PREFIX_ADDRESS, 16,
+ 1, mpc, mpc->mpc_length, 1);
+ goto out;
+ }
+ }
+
+#ifdef CONFIG_X86_IO_APIC
+ for (i = 0; i < mp_irq_entries; i++) {
+ if (irq_used[i])
+ continue;
+
+ if (mp_irqs[i].mpc_irqtype != mp_INT)
+ continue;
+
+ if (mp_irqs[i].mpc_irqflag != 0x0f)
+ continue;
+
+ if (nr_m_spare > 0) {
+ printk("*NEW* found ");
+ nr_m_spare--;
+ memcpy(m_spare[nr_m_spare], &mp_irqs[i], sizeof(mp_irqs[i]));
+ m_spare[nr_m_spare] = NULL;
+ } else {
+ struct mpc_config_intsrc *m =
+ (struct mpc_config_intsrc *)mpt;
+ count += sizeof(struct mpc_config_intsrc);
+ mpc->mpc_length = count;
+ printk("No spare slots, try to append...take your risk, new mpc_length %x\n", count);
+ memcpy(m, &mp_irqs[i], sizeof(mp_irqs[i]));
+ mpt += sizeof(struct mpc_config_intsrc);
+ }
+ print_MP_intsrc_info(&mp_irqs[i]);
+ }
+#endif
+out:
+ /* update checksum */
+ mpc->mpc_checksum = 0;
+ mpc->mpc_checksum -= mpf_checksum((unsigned char *)mpc, mpc->mpc_length);
+
+ return 0;
+}
+
+int __initdata enable_update_mptable;
+
+static int __init update_mptable_setup(char *str)
+{
+ enable_update_mptable = 1;
+ return 0;
+}
+early_param("update_mptable", update_mptable_setup);
+
+static int __init update_mp_table(void)
+{
+ char str[16];
+ char oem[10];
+ struct intel_mp_floating *mpf;
+
+ if (!enable_update_mptable)
+ return 0;
+
+ mpf = mpf_found;
+ if (!mpf)
+ return 0;
+
+ /*
+ * Now see if we need to go further.
+ */
+ if (mpf->mpf_feature1 != 0)
+ return 0;
+
+ if (!mpf->mpf_physptr)
+ return 0;
+
+ if (!smp_check_mpc(phys_to_virt(mpf->mpf_physptr), oem, str))
+ return 0;
+
+ printk(KERN_INFO "mpf_physptr: %x\n", mpf->mpf_physptr);
+
+ /* only replace the one with mp_INT, MP_IRQ_TRIGGER_LEVEL|MP_IRQ_POLARITY_LOW,
+ already in mp_irqs , stored by ... and mp_config_acpi_gsi ... need pci=routeirq */
+ replace_intsrc_all(phys_to_virt(mpf->mpf_physptr));
+
+ return 0;
+}
+
+late_initcall(update_mp_table);
next parent reply other threads:[~2008-05-06 17:45 UTC|newest]
Thread overview: 65+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200805041823.57198.yhlu.kernel@gmail.com>
2008-05-06 17:38 ` Yinghai Lu [this message]
2008-05-06 17:41 ` [PATCH] x86: fixed mtrr change WP to WB Yinghai Lu
2008-05-06 17:48 ` H. Peter Anvin
2008-05-06 18:24 ` Yinghai Lu
2008-05-06 18:31 ` H. Peter Anvin
2008-05-06 18:34 ` Yinghai Lu
2008-05-06 18:43 ` H. Peter Anvin
2008-05-06 19:05 ` Yinghai Lu
2008-05-06 19:08 ` H. Peter Anvin
2008-05-06 19:15 ` Yinghai Lu
2008-05-07 7:48 ` [PATCH] x86: update mptable v2 Yinghai Lu
2008-05-17 2:32 ` [PATCH] x86: update mptable v3 Yinghai Lu
2008-05-19 15:46 ` Ingo Molnar
2008-05-19 19:35 ` [PATCH] x86: update mptable v4 Yinghai Lu
2008-05-19 19:52 ` [PATCH] x86: update mptable v5 Yinghai Lu
2008-05-25 23:00 ` [PATCH] x86: update mptable v6 Yinghai Lu
2008-06-01 20:17 ` [PATCH] x86: update mptable v7 Yinghai Lu
2008-06-09 2:53 ` [PATCH] x86: update mptable v7 - fix Yinghai Lu
2008-06-09 10:13 ` Ingo Molnar
2008-06-09 17:51 ` Yinghai Lu
2008-06-09 18:11 ` Maciej W. Rozycki
2008-06-09 19:09 ` Ingo Molnar
2008-06-09 19:38 ` Yinghai Lu
2008-06-09 19:46 ` H. Peter Anvin
2008-06-09 19:49 ` Maciej W. Rozycki
2008-06-18 21:32 ` [PATCH] x86: update mptable fix with no ioapic Yinghai Lu
2008-06-19 0:29 ` [PATCH] x86: update mptable fix with no ioapic v2 Yinghai Lu
2008-06-19 7:18 ` [PATCH] x86: let MPS support selectable Yinghai Lu
2008-06-19 12:13 ` Ingo Molnar
2008-06-19 12:49 ` Ingo Molnar
2008-06-19 15:10 ` Maciej W. Rozycki
2008-06-19 17:39 ` Yinghai Lu
2008-06-19 18:03 ` Len Brown
2008-06-19 18:48 ` Maciej W. Rozycki
2008-06-26 9:31 ` Ingo Molnar
[not found] ` <200806191213.10312.yhlu.kernel@gmail.com>
2008-06-19 19:15 ` [PATCH] x86: fix compiling when CONFIG_X86_MPPARSE is not set Yinghai Lu
2008-06-20 14:42 ` [PATCH] x86: check command line " Yinghai Lu
2008-06-20 15:01 ` Ingo Molnar
2008-06-20 15:04 ` Yinghai Lu
2008-06-20 15:36 ` Maciej W. Rozycki
2008-06-20 23:11 ` [PATCH] x86: check command line when CONFIG_X86_MPPARSE is not set v2 Yinghai Lu
2008-06-21 8:14 ` [PATCH] x86: clean up init_amd() Yinghai Lu
2008-06-24 12:12 ` [PATCH] x86: check command line when CONFIG_X86_MPPARSE is not set Pavel Machek
2008-06-26 8:23 ` Yinghai Lu
[not found] ` <200806200733.31477.yhlu.kernel@gmail.com>
2008-06-20 15:03 ` [PATCH] x86: simplify x86_mpparse dependency check Ingo Molnar
2008-06-20 15:31 ` Maciej W. Rozycki
2008-06-19 12:13 ` [PATCH] x86: update mptable fix with no ioapic v2 Ingo Molnar
2008-06-18 22:18 ` [PATCH] x86: update mptable v7 Len Brown
2008-06-18 22:32 ` Yinghai Lu
2008-06-19 0:33 ` Len Brown
2008-06-19 0:49 ` Yinghai Lu
2008-06-19 4:32 ` Eric W. Biederman
2008-06-19 5:09 ` H. Peter Anvin
2008-06-19 5:11 ` Yinghai Lu
2008-06-19 5:27 ` Len Brown
2008-06-19 6:37 ` Eric W. Biederman
2008-06-19 7:31 ` Yinghai Lu
2008-06-19 18:16 ` Len Brown
2008-06-20 6:47 ` Ingo Molnar
2008-06-20 7:20 ` Yinghai Lu
2008-06-20 9:12 ` Andi Kleen
2008-06-19 5:20 ` Len Brown
2008-06-19 6:26 ` Yinghai Lu
2008-06-19 6:28 ` H. Peter Anvin
2008-06-19 6:35 ` Yinghai Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200805061038.58023.yhlu.kernel@gmail.com \
--to=yhlu.kernel.send@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=yhlu.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.