acpi/fadt: Make sure that SCI IRQ is valid
[dragonfly.git] / sys / platform / pc64 / acpica5 / acpi_fadt.c
index c160a90..6918f25 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/kernel.h>
 #include <sys/machintr.h>
 #include <sys/systm.h>
+#include <sys/thread2.h>
 
 #include "acpi_sdt.h"
 #include "acpi_sdt_var.h"
@@ -181,12 +182,22 @@ acpi_sci_config(void)
 {
        const struct acpi_sci_mode *mode;
 
+       KKASSERT(mycpuid == 0);
+
+       if (machintr_legacy_intr_find(acpi_sci_irq,
+           INTR_TRIGGER_CONFORM, INTR_POLARITY_CONFORM) < 0) {
+               kprintf("ACPI FADT: SCI irq %d is invalid, disable\n",
+                   acpi_sci_irq);
+               acpi_sci_irq = -1;
+               return;
+       }
+
        if (acpi_sci_irq < 0)
                return;
 
        if (acpi_sci_trig != INTR_TRIGGER_CONFORM) {
                KKASSERT(acpi_sci_pola != INTR_POLARITY_CONFORM);
-               machintr_intr_config(acpi_sci_irq,
+               machintr_legacy_intr_config(acpi_sci_irq,
                    acpi_sci_trig, acpi_sci_pola);
                return;
        }
@@ -201,21 +212,21 @@ acpi_sci_config(void)
                    intr_str_trigger(mode->sci_trig),
                    intr_str_polarity(mode->sci_pola));
 
-               last_cnt = get_interrupt_counter(acpi_sci_irq);
+               last_cnt = get_interrupt_counter(acpi_sci_irq, 0);
 
-               machintr_intr_config(acpi_sci_irq,
+               machintr_legacy_intr_config(acpi_sci_irq,
                    mode->sci_trig, mode->sci_pola);
 
                sci_desc = register_int(acpi_sci_irq,
                    acpi_sci_dummy_intr, NULL, "sci", NULL,
                    INTR_EXCL | INTR_CLOCK |
-                   INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY);
+                   INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY, 0);
 
                DELAY(100 * 1000);
 
-               unregister_int(sci_desc);
+               unregister_int(sci_desc, 0);
 
-               if (get_interrupt_counter(acpi_sci_irq) - last_cnt < 20) {
+               if (get_interrupt_counter(acpi_sci_irq, 0) - last_cnt < 20) {
                        acpi_sci_trig = mode->sci_trig;
                        acpi_sci_pola = mode->sci_pola;
 
@@ -249,3 +260,9 @@ acpi_sci_pci_shariable(void)
        else
                return 0;
 }
+
+int
+acpi_sci_irqno(void)
+{
+       return acpi_sci_irq;
+}