x86, HPET: mark HPET PCI BARs as IORESOURCE_PCI_FIXED
PATCH 1/1 x86, HPET: mark HPET PCI BARs as IORESOURCE_PCI_FIXED
We often discover the HPET early, via the static ACPI HPET table, before enumerating PCI devices. If the HPET is implemented as a PCI function, we will discover it again during PCI device enumeration. We must make sure we never move the PCI function out from under the driver.
Doing this for *any* PCI BAR that matches a previously discovered HPET should be more generic than the previous ATI-specific quirk.
This is for a regression from 2.6.34, but the reporter has been unable to test it yet.
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=18482
---
arch/x86/kernel/quirks.c | 19 +++++++++++++++++++ arch/x86/pci/fixup.c | 28 ---------------------------- 2 files changed, 19 insertions(+), 28 deletions(-)
arch/x86/kernel/quirks.c +19 -0
@@ -507,6 +507,25 @@ static void force_disable_hpet_msi(struct pci_dev *unused)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_ATI ,PCI_DEVICE_ID_ATI_SBX00_SMBUS , force_disable_hpet_msi); +static void mark_pci_hpet_fixed (struct pci_dev *dev) +{ +int i; + +if (!hpet_address) +return ; + +for (i =0 ; i <6 ; i++) { +struct resource *res = &dev->resource[i]; + +if (resource_type (res) ==IORESOURCE_MEM && + res->start == hpet_address) { +dev_info (&dev->dev,"BAR %d: %pR is an HPET we found earlier; making it immovable\n" , + i, res); + res->flags |=IORESOURCE_PCI_FIXED ; + } + } +} +DECLARE_PCI_FIXUP_HEADER (PCI_ANY_ID ,PCI_ANY_ID , mark_pci_hpet_fixed);#endif #if defined(CONFIG_PCI ) && defined(CONFIG_NUMA )
arch/x86/pci/fixup.c +0 -28
@@ -493,31 +493,3 @@ static void __devinit pci_siemens_interrupt_controller(struct pci_dev *dev) }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_SIEMENS ,0x0015 , pci_siemens_interrupt_controller); - -/* -* SB600: Disable BAR1 on device 14.0 to avoid HPET resources from -* confusing the PCI engine: -*/ -static void sb600_disable_hpet_bar (struct pci_dev *dev) -{ -u8 val; - -/* -* The SB600 and SB700 both share the same device -* ID, but the PM register 0x55 does something different -* for the SB700, so make sure we are dealing with the -* SB600 before touching the bit: -*/ - -pci_read_config_byte (dev,0x08 , &val); - -if (val <0x2F ) { -outb (0x55 ,0xCD6 ); - val =inb (0xCD7 ); - -/* Set bit 7 in PM register 0x55 */ -outb (0x55 ,0xCD6 ); -outb (val |0x80 ,0xCD7 ); - } -} -DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_ATI ,0x4385 , sb600_disable_hpet_bar);
Sorry for the duplicate; I tried to include Frédéric's proper name, but stg mail got horribly confused and made a mess of the cc: list. This one should be better.
Sorry Yinghai, I forgot to copy you on the initial post. Any comments on this? If not, we should try to get it into linux-next soon.
Quoted 90 lines · Bjorn Helgaas
We often discover the HPET early, via the static ACPI HPET table, before enumerating PCI devices. If the HPET is implemented as a PCI function, we will discover it again during PCI device enumeration. We must make sure we never move the PCI function out from under the driver.
Doing this for *any* PCI BAR that matches a previously discovered HPET should be more generic than the previous ATI-specific quirk.
This is for a regression from 2.6.34, but the reporter has been unable to test it yet.
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=18482
Reported-by Simon Arlott <[email protected]>Signed-off-by Bjorn Helgaas <[email protected]>---
arch/x86/kernel/quirks.c | 19 +++++++++++++++++++ arch/x86/pci/fixup.c | 28 ---------------------------- 2 files changed, 19 insertions(+), 28 deletions(-)arch/x86/kernel/quirks.c +19
-0@@ -507,6 +507,25 @@ static void force_disable_hpet_msi(struct pci_dev *unused)DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_ATI ,PCI_DEVICE_ID_ATI_SBX00_SMBUS , force_disable_hpet_msi); +static void mark_pci_hpet_fixed (struct pci_dev *dev) +{ +int i; + +if (!hpet_address) +return ; + +for (i =0 ; i <6 ; i++) { +struct resource *res = &dev->resource[i]; + +if (resource_type (res) ==IORESOURCE_MEM && + res->start == hpet_address) { +dev_info (&dev->dev,"BAR %d: %pR is an HPET we found earlier; making it immovable\n" , + i, res); + res->flags |=IORESOURCE_PCI_FIXED ; + } + } +} +DECLARE_PCI_FIXUP_HEADER (PCI_ANY_ID ,PCI_ANY_ID , mark_pci_hpet_fixed);#endif #if defined(CONFIG_PCI ) && defined(CONFIG_NUMA )arch/x86/pci/fixup.c +0
-28@@ -493,31 +493,3 @@ static void __devinit pci_siemens_interrupt_controller(struct pci_dev *dev) }DECLARE_PCI_FIXUP_HEADER (PCI_VENDOR_ID_SIEMENS ,0x0015 , pci_siemens_interrupt_controller); - -/* -* SB600: Disable BAR1 on device 14.0 to avoid HPET resources from -* confusing the PCI engine: -*/ -static void sb600_disable_hpet_bar (struct pci_dev *dev) -{ -u8 val; - -/* -* The SB600 and SB700 both share the same device -* ID, but the PM register 0x55 does something different -* for the SB700, so make sure we are dealing with the -* SB600 before touching the bit: -*/ - -pci_read_config_byte (dev,0x08 , &val); - -if (val <0x2F ) { -outb (0x55 ,0xCD6 ); - val =inb (0xCD7 ); - -/* Set bit 7 in PM register 0x55 */ -outb (0x55 ,0xCD6 ); -outb (val |0x80 ,0xCD7 ); - } -} -DECLARE_PCI_FIXUP_EARLY (PCI_VENDOR_ID_ATI ,0x4385 , sb600_disable_hpet_bar);
Quoted 3 lines · Bjorn Helgaas
Sorry Yinghai, I forgot to copy you on the initial post. Any comments on this? If not, we should try to get it into linux-next soon.
should be good.
only one thing, that will punish all other vendors... and run that quirk for every pci device.
please check if you can have +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_ANY_ID, mark_pci_hpet_fixed);
AND _AMD maybe, if AMD dump _ATI brand later.
Thanks
Yinghai
H. Peter Anvin
reviewerQuoted 7 lines · Yinghai Lu
Quoted 3 lines · Bjorn Helgaas
Sorry Yinghai, I forgot to copy you on the initial post. Any comments on this? If not, we should try to get it into linux-next soon.
should be good.
Quoted 8 lines
only one thing, that will punish all other vendors... and run that quirk for every pci device.
please check if you can have +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI,
PCI_ANY_ID,mark_pci_hpet_fixed);AND
_AMDmaybe, if AMD dump_ATIbrand later.
No, because the problem is known to happen on multiple vendors.
-hpa
Quoted 11 lines · H. Peter Anvin
Quoted 10 lines · Yinghai Lu
Quoted 3 lines · Bjorn Helgaas
Sorry Yinghai, I forgot to copy you on the initial post. Any comments on this? If not, we should try to get it into linux-next soon.
should be good.
only one thing, that will punish all other vendors... and run that quirk for every pci device.
Quoted 8 lines
Quoted 5 lines
please check if you can have +DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI,
PCI_ANY_ID,mark_pci_hpet_fixed);AND
_AMDmaybe, if AMD dump_ATIbrand later.No, because the problem is known to happen on multiple vendors.
Do you have URL to them?
INTEL ?
ServerWorks?
Via?
Yinghai
H. Peter Anvin
reviewerQuoted 9 lines · Yinghai Lu
Quoted 3 lines
No, because the problem is known to happen on multiple vendors.
Do you have URL to them?
INTEL ?
ServerWorks?
Via?
It'll happen on any platform where the HPET is a BAR. There is no point in enumerating it by vendor, since there is a static test for it.
-hpa