Skip to content

Commit 42debda

Browse files
authored
Merge pull request #98 from nakato/sl4-int-override
Override irq7 for SL4A over probing Legacy PIC
2 parents 150c447 + b5b37b1 commit 42debda

2 files changed

Lines changed: 22 additions & 46 deletions

File tree

arch/x86/kernel/acpi/boot.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/efi-bgrt.h>
2222
#include <linux/serial_core.h>
2323
#include <linux/pgtable.h>
24+
#include <linux/dmi.h>
2425

2526
#include <asm/e820/api.h>
2627
#include <asm/irqdomain.h>
@@ -1155,6 +1156,17 @@ static void __init mp_config_acpi_legacy_irqs(void)
11551156
}
11561157
}
11571158

1159+
static const struct dmi_system_id surface_quirk[] __initconst = {
1160+
{
1161+
.ident = "Microsoft Surface Laptop 4 (AMD)",
1162+
.matches = {
1163+
DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
1164+
DMI_MATCH(DMI_PRODUCT_SKU, "Surface_Laptop_4_1952:1953")
1165+
},
1166+
},
1167+
{}
1168+
};
1169+
11581170
/*
11591171
* Parse IOAPIC related entries in MADT
11601172
* returns 0 on success, < 0 on error
@@ -1212,6 +1224,11 @@ static int __init acpi_parse_madt_ioapic_entries(void)
12121224
acpi_sci_ioapic_setup(acpi_gbl_FADT.sci_interrupt, 0, 0,
12131225
acpi_gbl_FADT.sci_interrupt);
12141226

1227+
if (dmi_check_system(surface_quirk)) {
1228+
pr_warn("Surface hack: Override irq 7\n");
1229+
mp_override_legacy_irq(7, 3, 3, 7);
1230+
}
1231+
12151232
/* Fill in identity legacy mappings where no override */
12161233
mp_config_acpi_legacy_irqs();
12171234

arch/x86/kernel/i8259.c

Lines changed: 5 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
3-
#define pr_fmt(fmt) "i8259: " fmt
4-
52
#include <linux/linkage.h>
63
#include <linux/errno.h>
74
#include <linux/signal.h>
@@ -19,7 +16,6 @@
1916
#include <linux/io.h>
2017
#include <linux/delay.h>
2118
#include <linux/pgtable.h>
22-
#include <linux/dmi.h>
2319

2420
#include <linux/atomic.h>
2521
#include <asm/timer.h>
@@ -302,39 +298,11 @@ static void unmask_8259A(void)
302298
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
303299
}
304300

305-
/*
306-
* DMI table to identify devices with quirky probe behavior. See comment in
307-
* probe_8259A() for more details.
308-
*/
309-
static const struct dmi_system_id retry_probe_quirk_table[] = {
310-
{
311-
.ident = "Microsoft Surface Laptop 4 (AMD)",
312-
.matches = {
313-
DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
314-
DMI_MATCH(DMI_PRODUCT_SKU, "Surface_Laptop_4_1952:1953")
315-
},
316-
},
317-
{}
318-
};
319-
320301
static int probe_8259A(void)
321302
{
322303
unsigned long flags;
323304
unsigned char probe_val = ~(1 << PIC_CASCADE_IR);
324305
unsigned char new_val;
325-
unsigned int i, imax = 1;
326-
327-
/*
328-
* Some systems have a legacy PIC that doesn't immediately respond
329-
* after boot. We know it's there, we know it should respond and is
330-
* required for proper interrupt handling later on, so let's try a
331-
* couple of times.
332-
*/
333-
if (dmi_check_system(retry_probe_quirk_table)) {
334-
pr_warn("system with broken legacy PIC detected, re-trying multiple times if necessary\n");
335-
imax = 10;
336-
}
337-
338306
/*
339307
* Check to see if we have a PIC.
340308
* Mask all except the cascade and read
@@ -344,24 +312,15 @@ static int probe_8259A(void)
344312
*/
345313
raw_spin_lock_irqsave(&i8259A_lock, flags);
346314

347-
for (i = 0; i < imax; i++) {
348-
outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
349-
outb(probe_val, PIC_MASTER_IMR);
350-
new_val = inb(PIC_MASTER_IMR);
351-
if (new_val == probe_val)
352-
break;
353-
}
354-
355-
if (i == imax) {
356-
pr_info("using NULL legacy PIC\n");
315+
outb(0xff, PIC_SLAVE_IMR); /* mask all of 8259A-2 */
316+
outb(probe_val, PIC_MASTER_IMR);
317+
new_val = inb(PIC_MASTER_IMR);
318+
if (new_val != probe_val) {
319+
printk(KERN_INFO "Using NULL legacy PIC\n");
357320
legacy_pic = &null_legacy_pic;
358321
}
359322

360323
raw_spin_unlock_irqrestore(&i8259A_lock, flags);
361-
362-
if (imax > 1 && i < imax)
363-
pr_info("got legacy PIC after %d tries\n", i + 1);
364-
365324
return nr_legacy_irqs();
366325
}
367326

0 commit comments

Comments
 (0)