acpi: reintroduce LNKS

Commit 4540409 (acpi: LNKS is not needed, 2012-08-07) removed LNKS because
it basically worked by chance: _CRS returns something else then one of the
possible resources from _PRS, _DIS would not really disable the interrupt,
and there was no _SRS method.  It just happened to work because all OSes
have some kind of special-casing for SCI.

Unfortunately, the code after the patch is also against the spec, and it
breaks FreeBSD because it treats IRQ 9 polarity as active low without
the Interrupt() entry.  Actually, numeric _PRT entries are handled the
same in Linux and FreeBSD (as active-low).  However, under Linux it just
happens to trigger another special casing of SCI which sets SCI up from
its override entry in the MADT, ignoring the DSDT completely.

This patch adds back the LNKS, but without using the PIIX register for
LNKA in its methods.

Tested-by: Luigi Rizzo <rizzo@iet.unipi.it>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/src/acpi-dsdt.dsl b/src/acpi-dsdt.dsl
index 8019b71..b58ef62 100644
--- a/src/acpi-dsdt.dsl
+++ b/src/acpi-dsdt.dsl
@@ -187,7 +187,7 @@
 
                 prt_slot0(0x0000),
                 /* Device 1 is power mgmt device, and can only use irq 9 */
-                Package() { 0x1ffff, 0,    0, 9 },
+                Package() { 0x1ffff, 0, LNKS, 0 },
                 Package() { 0x1ffff, 1, LNKB, 0 },
                 Package() { 0x1ffff, 2, LNKC, 0 },
                 Package() { 0x1ffff, 3, LNKD, 0 },
@@ -278,6 +278,22 @@
         define_link(LNKB, 1, PRQ1)
         define_link(LNKC, 2, PRQ2)
         define_link(LNKD, 3, PRQ3)
+
+        Device(LNKS) {
+            Name(_HID, EISAID("PNP0C0F"))
+            Name(_UID, 4)
+            Name(_PRS, ResourceTemplate() {
+                Interrupt(, Level, ActiveHigh, Shared) { 9 }
+            })
+
+            // The SCI cannot be disabled and is always attached to GSI 9,
+            // so these are no-ops.  We only need this link to override the
+            // polarity to active high and match the content of the MADT.
+            Method(_STA, 0, NotSerialized) { Return (0x0b) }
+            Method(_DIS, 0, NotSerialized) { }
+            Method(_CRS, 0, NotSerialized) { Return (_PRS) }
+            Method(_SRS, 1, NotSerialized) { }
+        }
     }
 
 #include "acpi-dsdt-cpu-hotplug.dsl"