Bug 15701

Summary: Linux should ignore Producer/Consumer bit in _CRS Address Space descriptors
Product: ACPI Reporter: Bjorn Helgaas (bjorn.helgaas)
Component: Config-OtherAssignee: Bjorn Helgaas (bjorn.helgaas)
Status: CLOSED CODE_FIX    
Severity: normal CC: lenb, rui.zhang
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.34-rc3 Subsystem:
Regression: No Bisected commit-id:
Attachments: test DSDT
Windows Server 2008 R2 summary
Windows memory map
HPET resources
PCI host bridge resources
PCI host bridge resources, part 2
PCI NIC resources

Description Bjorn Helgaas 2010-04-05 23:32:13 UTC
In the ACPI PCI host bridge driver, the arch-specific code parses _CRS resources to learn the windows forwarded to the PCI bus.  Both ia64 and x86 follow section 6.4.3.5 of ACPI spec 4.0, which says that Bit[0] of Byte 4 in QWord, DWord, Word, and Extended Address Space Descriptors is a "Consumer/Producer" bit.  This bit is set if the device consumes the resource, and clear if the device produces and consumes it, i.e., if the device forwards the resource to a downstream bus.

However, it is rumored that BIOSes have not used the Consumer/Producer bit consistently, and the bit was documented as "Ignored" in ACPI 2.0c.  The bit was added back in 3.0, but this apparently was a mistake.

I experimented with Windows Server 2008 R2 in a qemu environment, running SeaBIOS, where I could modify the _CRS description and see how Windows handled it.

The PCI host bridge windows should be described as ResourceProducer, and the HPET registers should be described as ResourceConsumer.  As shown here, I modified the SeaBIOS DSDT to reverse both flags, so the bridge window is a Consumer and the HPET registers are a Producer:

        Device(PCI0) {
            Name (_HID, EisaId ("PNP0A03"))
            Name (_CRS, ResourceTemplate ()
            {
                ...
                DWordMemory (ResourceConsumer, PosDecode, MinFixed, MaxFixed, NonCacheable, ReadWrite,
                    0x00000000,         // Address Space Granularity
                    0xE0000000,         // Address Range Minimum
                    0xFEBFFFFF,         // Address Range Maximum
                    0x00000000,         // Address Translation Offset
                    0x1EC00000,         // Address Length
                    ,, , AddressRangeMemory, TypeStatic)
            })
        }
        Device(HPET) {
            Name(_HID,  EISAID("PNP0103"))
            Name(_CRS, ResourceTemplate() {
                DWordMemory(
                    ResourceProducer, PosDecode, MinFixed, MaxFixed,
                    NonCacheable, ReadWrite,
                    0x00000000,
                    0xFED00000,
                    0xFED003FF,
                    0x00000000,
                    0x00000400 /* 1K memory: FED00000 - FED003FF */
                )
            })
        }

The attachments of Windows Device Manager screenshots show that Windows interpreted the bridge ResourceConsumer as a window and the HPET ResourceProducer as normal registers.  PCI devices, e.g., the NIC and VGA, inside the ResourceConsumer range worked normally.
Comment 1 Bjorn Helgaas 2010-04-05 23:33:43 UTC
Created attachment 25873 [details]
test DSDT

modified SeaBIOS DSDT
Comment 2 Bjorn Helgaas 2010-04-05 23:34:54 UTC
Created attachment 25874 [details]
Windows Server 2008 R2 summary
Comment 3 Bjorn Helgaas 2010-04-05 23:35:39 UTC
Created attachment 25875 [details]
Windows memory map
Comment 4 Bjorn Helgaas 2010-04-05 23:36:49 UTC
Created attachment 25876 [details]
HPET resources

These are incorrectly described as ResourceProducer in the DSDT, but seem to still work fine.
Comment 5 Bjorn Helgaas 2010-04-05 23:38:15 UTC
Created attachment 25877 [details]
PCI host bridge resources

Note the 0xcf8-0xcff region doesn't appear at all, even though it is correctly described as a ResourceConsumer in the DSDT.
Comment 6 Bjorn Helgaas 2010-04-05 23:39:40 UTC
Created attachment 25878 [details]
PCI host bridge resources, part 2

The window from 0xE0000000-0xFEBFFFFF is incorrectly described as a ResourceConsumer in the DSDT.
Comment 7 Bjorn Helgaas 2010-04-05 23:41:36 UTC
Created attachment 25879 [details]
PCI NIC resources

PCI NIC resources, inside the window incorrectly described as a ResourceConsumer.
Comment 8 Zhang Rui 2010-06-24 08:28:32 UTC
hmm, bjorn, any update of this bug?
Comment 9 Bjorn Helgaas 2010-07-08 22:19:46 UTC
This patch makes the x86 PCI host bridge driver ignore the Producer/Consumer bit:

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;
h=73a0e614580fb650846be1e9315f6b7b6069b9cc

This patch appeared in v2.6.34-rc6.