pcbios: irq routing fixes.
cover pcbios: irq routing fixes.
Hi,
This patch series brings a bunch of IRQ routing fixes for the pcbios living at git://git.qemu.org/pcbios.git
They are cherry-picked from the kvm tree.
please apply,
Gerd
PATCH 1/6 kvm: bios: advertise pci irqs as active high
From: Avi Kivity <[email protected]>
now that kvm emulates the ioapic polarity correctly, we must describe the polarity correctly in the acpi tables. otherwise pci interrupts won't be delivered correctly.
--- acpi-dsdt.dsl | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
acpi-dsdt.dsl +8 -8
@@ -441,7 +441,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 1) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)
@@ -461,7 +461,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)
@@ -488,7 +488,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 2) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)
@@ -508,7 +508,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)
@@ -535,7 +535,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 3) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)
@@ -555,7 +555,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)
@@ -582,7 +582,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 4) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)
@@ -602,7 +602,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)
Signature · 1 line
1.6.2.5
Re: [Qemu-devel] [PATCH 1/6] kvm: bios: advertise pci irqs as active high
Quoted 3 lines · Gerd Hoffmann
From: Avi Kivity <[email protected]>
now that kvm emulates the ioapic polarity correctly, we must describe
kvm yes, but qemu doesn't. It make sense to fix qemu polarity handling in the same series. Otherwise this patch does nothing.
Quoted 89 lines
the polarity correctly in the acpi tables. otherwise pci interrupts won't be delivered correctly.
Signed-off-by Avi Kivity <[email protected]>Signed-off-by Gerd Hoffmann <[email protected]>--- acpi-dsdt.dsl | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)acpi-dsdt.dsl +8
-8@@ -441,7 +441,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 1) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)@@ -461,7 +461,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)@@ -488,7 +488,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 2) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)@@ -508,7 +508,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)@@ -535,7 +535,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 3) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)@@ -555,7 +555,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)@@ -582,7 +582,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 4) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {3,4,5,6,7,9,10,11,12} }) Method (_STA, 0, NotSerialized)@@ -602,7 +602,7 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveLow, Shared) + IRQ (Level, ActiveHigh, Shared) {1} }) CreateWordField (PRR0, 0x01, TMP)Signature · 1 line
1.6.2.5
--
Gleb.
Re: [Qemu-devel] [PATCH 1/6] kvm: bios: advertise pci irqs as active high
Quoted 6 lines · Gleb Natapov
Quoted 3 lines · Gerd Hoffmann
From: Avi Kivity<[email protected]>
now that kvm emulates the ioapic polarity correctly, we must describe
kvm yes, but qemu doesn't. It make sense to fix qemu polarity handling in the same series.
Same series doesn't work. These patches are for the pcbios git tree.
Of course it makes sense to get more features and fixes from kvm merged upstream. Feel free to join the party to speed this up ;)
Quoted 1 line
Otherwise this patch does nothing.
It doesn't hurt though and reduces the differences between qemu and kvm, which is a good thing. Also note that the other patches which fix real bugs depend on this one.
cheers,
Gerd
Re: [Qemu-devel] [PATCH 1/6] kvm: bios: advertise pci irqs as active high
Quoted 10 lines · Gerd Hoffmann
Quoted 6 lines · Gleb Natapov
Quoted 3 lines · Gerd Hoffmann
From: Avi Kivity<[email protected]>
now that kvm emulates the ioapic polarity correctly, we must describe
kvm yes, but qemu doesn't. It make sense to fix qemu polarity handling in the same series.
Same series doesn't work. These patches are for the pcbios git tree.
We already have pcbios git tree. Cool.
Quoted 3 lines
Of course it makes sense to get more features and fixes from kvm merged upstream. Feel free to join the party to speed this up ;)
kvm implements polarity in in-kernel ioapic, not in qemu one. It should be very simple though. I though may be while you are at it... :)
Quoted 6 lines
Quoted 1 line
Otherwise this patch does nothing.
It doesn't hurt though and reduces the differences between qemu and kvm, which is a good thing. Also note that the other patches which fix real bugs depend on this one.
Can you elaborate which one fixes what bugs? I am not at all against those patches going into qemu, just curious. AFAIK current bios works with qemu as is.
--
Gleb.
Re: [Qemu-devel] [PATCH 1/6] kvm: bios: advertise pci irqs as active high
Quoted 11 lines · Gleb Natapov
Quoted 9 lines · Gerd Hoffmann
Quoted 6 lines · Gleb Natapov
Quoted 3 lines · Gerd Hoffmann
From: Avi Kivity<[email protected]>
now that kvm emulates the ioapic polarity correctly, we must describe
kvm yes, but qemu doesn't. It make sense to fix qemu polarity handling in the same series.
Same series doesn't work. These patches are for the pcbios git tree.
We already have pcbios git tree. Cool.
Have a look at http://git.qemu.org/. Not yet live. As far I know the plan is to (a) switch from savannah to qemu.org as master tree, (b) import the bios trees as git submodules and (c) hook them into the qemu build process.
Quoted 4 lines
Quoted 3 lines
Of course it makes sense to get more features and fixes from kvm merged upstream. Feel free to join the party to speed this up ;)
kvm implements polarity in in-kernel ioapic, not in qemu one.
Ah, ok. upstream qemu probably wants to use the in-kernel ioapic too some day, then we'll need the fixes anyway. But even without that it is saner to have correct ACPI entries IMHO.
Quoted 6 lines
Quoted 3 lines
kvm, which is a good thing. Also note that the other patches which fix real bugs depend on this one.
Can you elaborate which one fixes what bugs? I am not at all against those patches going into qemu, just curious. AFAIK current bios works with qemu as is.
The patch descriptions are pretty clear ...
Patch 4/6 (disallow sharing acpi irq #9) actually fixes some acpi hickups. I've noticed the 'system_powerdown' monitor command started working correctly recently for me, and I think this is this patch (didn't double-check though).
cheers,
Gerd
PATCH 2/6 kvm: bios: restrict pci interrupts to irq 5/9/10/11
In reply to Gerd HoffmannFrom: Avi Kivity <[email protected]>
we need to specify the pci interrupts as active high; this reduces the number of override entries we have to add.
--- acpi-dsdt.dsl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
acpi-dsdt.dsl +4 -4
@@ -442,7 +442,7 @@ DefinitionBlock ( Name(_UID, 1) Name(_PRS, ResourceTemplate(){ IRQ (Level, ActiveHigh, Shared) - {3,4,5,6,7,9,10,11,12} + { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized) {
@@ -489,7 +489,7 @@ DefinitionBlock ( Name(_UID, 2) Name(_PRS, ResourceTemplate(){ IRQ (Level, ActiveHigh, Shared) - {3,4,5,6,7,9,10,11,12} + { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized) {
@@ -536,7 +536,7 @@ DefinitionBlock ( Name(_UID, 3) Name(_PRS, ResourceTemplate(){ IRQ (Level, ActiveHigh, Shared) - {3,4,5,6,7,9,10,11,12} + { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized) {
@@ -583,7 +583,7 @@ DefinitionBlock ( Name(_UID, 4) Name(_PRS, ResourceTemplate(){ IRQ (Level, ActiveHigh, Shared) - {3,4,5,6,7,9,10,11,12} + { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized) {
Signature · 1 line
1.6.2.5
PATCH 3/6 kvm: bios: use extended interrupt descriptor for pci irqs
In reply to Gerd HoffmannFrom: Avi Kivity <[email protected]>
this is necessary to allow freebsd to boot; freebsd chokes if a regular interrupt descriptor specifies an active high pic irq.
--- acpi-dsdt.dsl | 56 ++++++++++++++++++++++++-------------------------------- 1 files changed, 24 insertions(+), 32 deletions(-)
acpi-dsdt.dsl +24 -32
@@ -441,7 +441,7 @@ DefinitionBlock ( Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 1) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized)
@@ -461,14 +461,14 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) {1} }) - CreateWordField (PRR0, 0x01, TMP) + CreateDWordField (PRR0, 0x05, TMP) Store (PRQ0, Local0) If (LLess (Local0, 0x80)) { - ShiftLeft (One, Local0, TMP) + Store (Local0, TMP) } Else {
@@ -478,17 +478,15 @@ DefinitionBlock ( } Method (_SRS, 1, NotSerialized) { - CreateWordField (Arg0, 0x01, TMP) - FindSetRightBit (TMP, Local0) - Decrement (Local0) - Store (Local0, PRQ0) + CreateDWordField (Arg0, 0x05, TMP) + Store (TMP, PRQ0) } } Device(LNKB){ Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 2) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized)
@@ -508,14 +506,14 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) {1} }) - CreateWordField (PRR0, 0x01, TMP) + CreateDWordField (PRR0, 0x05, TMP) Store (PRQ1, Local0) If (LLess (Local0, 0x80)) { - ShiftLeft (One, Local0, TMP) + Store (Local0, TMP) } Else {
@@ -525,17 +523,15 @@ DefinitionBlock ( } Method (_SRS, 1, NotSerialized) { - CreateWordField (Arg0, 0x01, TMP) - FindSetRightBit (TMP, Local0) - Decrement (Local0) - Store (Local0, PRQ1) + CreateDWordField (Arg0, 0x05, TMP) + Store (TMP, PRQ1) } } Device(LNKC){ Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 3) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized)
@@ -555,14 +551,14 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) {1} }) - CreateWordField (PRR0, 0x01, TMP) + CreateDWordField (PRR0, 0x05, TMP) Store (PRQ2, Local0) If (LLess (Local0, 0x80)) { - ShiftLeft (One, Local0, TMP) + Store (Local0, TMP) } Else {
@@ -572,17 +568,15 @@ DefinitionBlock ( } Method (_SRS, 1, NotSerialized) { - CreateWordField (Arg0, 0x01, TMP) - FindSetRightBit (TMP, Local0) - Decrement (Local0) - Store (Local0, PRQ2) + CreateDWordField (Arg0, 0x05, TMP) + Store (TMP, PRQ2) } } Device(LNKD){ Name(_HID, EISAID("PNP0C0F")) // PCI interrupt link Name(_UID, 4) Name(_PRS, ResourceTemplate(){ - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) { 5, 9, 10, 11 } }) Method (_STA, 0, NotSerialized)
@@ -602,14 +596,14 @@ DefinitionBlock ( { Name (PRR0, ResourceTemplate () { - IRQ (Level, ActiveHigh, Shared) + Interrupt (, Level, ActiveHigh, Shared) {1} }) - CreateWordField (PRR0, 0x01, TMP) + CreateDWordField (PRR0, 0x05, TMP) Store (PRQ3, Local0) If (LLess (Local0, 0x80)) { - ShiftLeft (One, Local0, TMP) + Store (Local0, TMP) } Else {
@@ -619,10 +613,8 @@ DefinitionBlock ( } Method (_SRS, 1, NotSerialized) { - CreateWordField (Arg0, 0x01, TMP) - FindSetRightBit (TMP, Local0) - Decrement (Local0) - Store (Local0, PRQ3) + CreateDWordField (Arg0, 0x05, TMP) + Store (TMP, PRQ3) } } }
Signature · 1 line
1.6.2.5
PATCH 4/6 kvm: bios: remove irq 9 from the pci interrupt link resources
In reply to Gerd HoffmannFrom: Avi Kivity <[email protected]>
qemu can't share isa irqs (which is how the acpi sci interrupt is implemented) with the pci irqs, so remove the sci interrupt from the pci link interrupt candidate list.
--- acpi-dsdt.dsl | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-)
acpi-dsdt.dsl +4 -4
@@ -442,7 +442,7 @@ DefinitionBlock ( Name(_UID, 1) Name(_PRS, ResourceTemplate(){ Interrupt (, Level, ActiveHigh, Shared) - { 5, 9, 10, 11 } + { 5, 10, 11 } }) Method (_STA, 0, NotSerialized) {
@@ -487,7 +487,7 @@ DefinitionBlock ( Name(_UID, 2) Name(_PRS, ResourceTemplate(){ Interrupt (, Level, ActiveHigh, Shared) - { 5, 9, 10, 11 } + { 5, 10, 11 } }) Method (_STA, 0, NotSerialized) {
@@ -532,7 +532,7 @@ DefinitionBlock ( Name(_UID, 3) Name(_PRS, ResourceTemplate(){ Interrupt (, Level, ActiveHigh, Shared) - { 5, 9, 10, 11 } + { 5, 10, 11 } }) Method (_STA, 0, NotSerialized) {
@@ -577,7 +577,7 @@ DefinitionBlock ( Name(_UID, 4) Name(_PRS, ResourceTemplate(){ Interrupt (, Level, ActiveHigh, Shared) - { 5, 9, 10, 11 } + { 5, 10, 11 } }) Method (_STA, 0, NotSerialized) {
Signature · 1 line
1.6.2.5
PATCH 5/6 kvm: bios: correct default pci irq links
In reply to Gerd HoffmannFrom: Avi Kivity <[email protected]>
the hardware uses irqs 10 and 11, so change the bios to reflect that.
--- rombios32.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
rombios32.c +1 -1
@@ -716,7 +716,7 @@ static uint32_t pci_bios_io_addr;static uint32_t pci_bios_mem_addr;static uint32_t pci_bios_bigmem_addr;/* host irqs corresponding to PCI irqs A-D */ -static uint8_t pci_irqs[4 ] = {11 ,9 ,11 ,9 }; +static uint8_t pci_irqs[4 ] = {10 ,10 ,11 ,11 };static PCIDevice i440_pcidev;static void pci_config_writel (PCIDevice *d,uint32_t addr,uint32_t val)
Signature · 1 line
1.6.2.5
PATCH 6/6 add interrupt override entries for IRQs 5, 9, 10, 11 to the MADT
In reply to Gerd Hoffmannso the OS knows that they're active high, level triggered. This allows for proper ACPI event reporting such as the (emulated) power button and should also fix the ACPI timer.
by Avi Kivity, adapted for upstream qemu by Gerd Hoffmann
--- rombios32.c | 20 +++++++++++++++++++- 1 files changed, 19 insertions(+), 1 deletions(-)
rombios32.c +19 -1
@@ -57,6 +57,9 @@ typedef unsigned long long uint64_t;#define APIC_ID 0x020#define APIC_LVT3 0x370 +/* IRQs 5,9,10,11 */ +#define PCI_ISA_IRQ_MASK 0x0e20U +#define APIC_ENABLED 0x0100#define AP_BOOT_ADDR 0x9f000
@@ -1730,7 +1733,7 @@ void acpi_bios_init(void) madt_size = sizeof(*madt) + sizeof(struct madt_processor_apic) * max_cpus +#ifdef BX_QEMU -sizeof (struct madt_io_apic ) +sizeof (struct madt_int_override ); +sizeof (struct madt_io_apic ) +sizeof (struct madt_int_override ) *5 ;#else sizeof (struct madt_io_apic );#endif
@@ -1828,6 +1831,21 @@ void acpi_bios_init(void) int_override->source =cpu_to_le32 (0 ); int_override->gsi =cpu_to_le32 (2 ); int_override->flags =cpu_to_le32 (0 ); + int_override++; + +for ( i =0 ; i <16 ; i++ ) { +if (!(PCI_ISA_IRQ_MASK & (1U << i))) { +/* No need for a INT source override structure. */ +continue ; + } +memset (int_override,0 ,sizeof (*int_override)); + int_override->type =APIC_XRUPT_OVERRIDE ; + int_override->length =sizeof (*int_override); + int_override->source = i; + int_override->gsi = i; + int_override->flags =0xd ;/* active high, level triggered */ + int_override++; + }#endif acpi_build_table_header((struct acpi_table_header *)madt,
Signature · 1 line
1.6.2.5