Skip to contentSkip to conversation

nVidia HPET force enable - merge requirements? (resend)

PATCH Applied Carlos Corbacho 2 participants 9 messages Oct 19, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

(Resend with CC's fixed)

Back in April, Mikko posted a patch to force enable the HPET on some nVidia chipsets:

v2:
http://lkml.org/lkml/2007/4/16/46

v3:
http://lkml.org/lkml/2007/4/17/354

What would need to be done to this patch to get it into x86 now (besides i386/ x86_64 -> x86 conversion), given that:

A) There is now a force_hpet boot parameter in the x86 tree (mm branch) (rather than relying on the solution in the earlier patches of a config option).

B) On the other hand, the force-quirk's are going into quirks.c, whilst Mikko's patch requires PCI scanning in early_quirks.c (could the PCI scanning be done in early_quirks.c and the actual HPET enabling handled in quirks.c later - or if not, could this early quirk play be made to obey the force_hpet boot option)?

-Carlos

Signature · 3 lines
E-Mail: [email protected]
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
#1 lore raw
Quoted 6 lines · Carlos Corbacho

Back in April, Mikko posted a patch to force enable the HPET on some nVidia chipsets:

A) There is now a force_hpet boot parameter in the x86 tree (mm branch) (rather than relying on the solution in the earlier patches of a config option).

There is still a config option for hpet. the hpet=force boot param is there to allow force enable hpet for not documented chip set features.

Quoted 5 lines

B) On the other hand, the force-quirk's are going into quirks.c, whilst Mikko's patch requires PCI scanning in early_quirks.c (could the PCI scanning be done in early_quirks.c and the actual HPET enabling handled in quirks.c later - or if not, could this early quirk play be made to obey the force_hpet boot option)?

It's not necessary to scan in early_quirks.c at all. The force hpet code handles the late DECLARE_PCI_FIXUP_HEADER() based detection just fine.

So if there are working quirks, please refactor them analogous to the existing ones in quirks.c.

All undocumented chipset poking needs to be protected by the hpet=force boot option, so the default is not to do scan for it.

Thanks,

tglx

#2 lore raw

Thomas,

Quoted 5 lines · On Friday 19 October 2007 07:50:08 Thomas Gleixner wrote:

So if there are working quirks, please refactor them analogous to the existing ones in quirks.c.

All undocumented chipset poking needs to be protected by the hpet=force boot option, so the default is not to do scan for it.

Would the following patch be more acceptable then? I've limited the device id's to just the nForce 4 chipset, because that's the only one I have here to test with at the moment - it appears to work fine:

hpet clockevent registered
hpet0: at MMIO 0xfefff000, IRQs 2, 8, 31
hpet0: 3 32-bit timers, 25000000 Hz
Time: hpet clocksource has been installed.
Switched to high resolution mode on CPU 0
Switched to high resolution mode on CPU 1

At the moment, I'm not clear on how to detect if the HPET has not been enabled by the BIOS (but given that this is hidden behind hpet=force, would this be acceptable, since the user would have to explicitly call hpet=force, and then it either works or doesn't?)

-Carlos

arch/x86/kernel/quirks.c +20 -0
index a4ce191..7c772bf 100644
@@ -321,6 +321,26 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
 			 vt8237_force_enable_hpet);
 
+static void nvidia_force_enable_hpet(struct pci_dev *dev)
+{
+	u32 uninitialized_var(val);
+
+	if (!hpet_force_user || hpet_address || force_hpet_address)
+		return;
+
+	pci_read_config_dword(dev, 0x44, &val);
+	force_hpet_address = val;
+	printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
+	       force_hpet_address);
+	cached_dev = dev;
+	return;
+}
+
+/* ISA Bridge */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
+			 nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
+			 nvidia_force_enable_hpet);
 
 void force_hpet_resume(void)
 {
#3 lore raw
Quoted 3 lines · Carlos Corbacho

Would the following patch be more acceptable then? I've limited the device id's to just the nForce 4 chipset, because that's the only one I have here to test with at the moment - it appears to work fine:

Yes, looks good. It is just missing the resume part, which is necessary to reenable the hpet after suspend/resume.

Quoted 11 lines

hpet clockevent registered
hpet0: at MMIO 0xfefff000, IRQs 2, 8, 31
hpet0: 3 32-bit timers, 25000000 Hz
Time: hpet clocksource has been installed.
Switched to high resolution mode on CPU 0
Switched to high resolution mode on CPU 1

At the moment, I'm not clear on how to detect if the HPET has not been enabled by the BIOS (but given that this is hidden behind hpet=force, would this be acceptable, since the user would have to explicitly call hpet=force, and then it either works or doesn't?)

Don't worry. If HPET is enabled in the BIOS, then we have an hpet_address already before we come into the force enable quirk. That's why we check for hpet_address in the quirk code.

tglx

#4 lore raw

PATCH 1/1 x86: Force enable HPET for CK804 (nForce 4) chipsets

From: Carlos Corbacho <[email protected]>

This patch adds a quirk from LinuxBIOS to force enable HPET on the nVidia CK804 (nForce 4) chipset.

This quirk can very likely support more than just nForce 4 (LinuxBIOS use the same code for nForce 5), and possibly nForce 3, but I don't have those chipsets, so cannot add and test them.

Tested on an Abit KN9 (CK804).

---
Thomas,

I've rewritten the code based on what LinuxBIOS does, since they have a better idea of how to drive the HPET than I do. I've tested this code, and it's also working fine here on my system.

 Documentation/kernel-parameters.txt |    3 +-
 arch/x86/kernel/quirks.c            |   36 ++++++++++++++++++++++++++++++++++-
 2 files changed, 37 insertions(+), 2 deletions(-)
Documentation/kernel-parameters.txt +2 -1
index 983f631..8abbfe6 100644
@@ -434,7 +434,8 @@ and is between 256 and 4096 characters. It is defined in the file
 	hpet=		[X86-32,HPET] option to control HPET usage
 			Format: { enable (default) | disable | force }
 			disable: disable HPET and use PIT instead
-			force: allow force enabled of undocumented chips (ICH4, VIA)
+			force: allow force enabled of undocumented chips (ICH4,
+			VIA, nVidia)
 
 	com20020=	[HW,NET] ARCnet - COM20020 chipset
 			Format:
arch/x86/kernel/quirks.c +35 -1
index a4ce191..cb21bcb 100644
@@ -60,7 +60,8 @@ static enum {
 	NONE_FORCE_HPET_RESUME,
 	OLD_ICH_FORCE_HPET_RESUME,
 	ICH_FORCE_HPET_RESUME,
-	VT8237_FORCE_HPET_RESUME
+	VT8237_FORCE_HPET_RESUME,
+	NVIDIA_FORCE_HPET_RESUME,
 } force_hpet_resume_type;
 
 static void __iomem *rcba_base;
@@ -321,6 +322,36 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
 			 vt8237_force_enable_hpet);
 
+/*
+ * Undocumented chipset feature taken from LinuxBIOS.
+ */
+static void nvidia_force_hpet_resume(void)
+{
+	pci_write_config_dword(cached_dev, 0x44, 0xfed00001);
+	printk(KERN_DEBUG "Force enabled HPET at resume\n");
+}
+
+static void nvidia_force_enable_hpet(struct pci_dev *dev)
+{
+	u32 uninitialized_var(val);
+
+	if (!hpet_force_user || hpet_address || force_hpet_address)
+		return;
+
+	pci_write_config_dword(dev, 0x44, 0xfed00001);
+	pci_read_config_dword(dev, 0x44, &val);
+	force_hpet_address = val & 0xfffffffe;
+	printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
+		force_hpet_address);
+	cached_dev = dev;
+	return;
+}
+
+/* ISA Bridges */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
+			nvidia_force_enable_hpet);
 
 void force_hpet_resume(void)
 {
@@ -334,6 +365,9 @@ void force_hpet_resume(void)
 	    case VT8237_FORCE_HPET_RESUME:
 		return vt8237_force_hpet_resume();
 
+	    case NVIDIA_FORCE_HPET_RESUME:
+		return nvidia_force_hpet_resume();
+
 	    default:
 		break;
 	}
Signature · 1 line
1.5.2.2
#5 lore raw

Re: [PATCH] x86: Force enable HPET for CK804 (nForce 4) chipsets

Quoted 5 lines · Carlos Corbacho

From: Carlos Corbacho <[email protected]>

This patch adds a quirk from LinuxBIOS to force enable HPET on the nVidia CK804 (nForce 4) chipset.

Quoted 7 lines

This quirk can very likely support more than just nForce 4 (LinuxBIOS use the same code for nForce 5), and possibly nForce 3, but I don't have those chipsets, so cannot add and test them.

Tested on an Abit KN9 (CK804).

Applied. Thanks,

tglx

#6 lore raw

PATCH 1/1 x86: Fix resume for nVidia and force_hpet

From: Carlos Corbacho <[email protected]>

Actually set force_hpet_resume_type.
---
Whoops, just noticed I forgot to re-add this to the patch before submitting it.

 arch/x86/kernel/quirks.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/quirks.c +1 -0
index cb21bcb..df01a1e 100644
@@ -344,6 +344,7 @@ static void nvidia_force_enable_hpet(struct pci_dev *dev)
 	printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
 		force_hpet_address);
 	cached_dev = dev;
+	force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
 	return;
 }
 
Signature · 1 line
1.5.2.2
#7 lore raw

Re: [PATCH] x86: Fix resume for nVidia and force_hpet

Quoted 14 lines · Carlos Corbacho

From: Carlos Corbacho <[email protected]>

Actually set force_hpet_resume_type.
---
Whoops, just noticed I forgot to re-add this to the patch before submitting it.

 arch/x86/kernel/quirks.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/x86/kernel/quirks.c +0 -0
index cb21bcb..df01a1e 100644

arch/x86/kernel/quirks.c static void nvidia_force_enable_hpet(struct pci_dev *dev) · line 349

Quoted 6 lines
arch/x86/kernel/quirks.c +1 -0
@@ -344,6 +344,7 @@ static void nvidia_force_enable_hpet(struct pci_dev *dev)
 	printk(KERN_DEBUG "Force enabled HPET at base address 0x%lx\n",
 		force_hpet_address);
 	cached_dev = dev;
+	force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
 	return;
 }

Yep, noticed it when I pushed it into the queue. Fixed it up already. Please be more careful next time.

Btw, I'm happy to take a follow up patch for platforms which you can not test and stick them into -mm for a while.

Thanks,

tglx

#8 lore raw

x86: Add HPET force support for MCP55 (nForce 5) chipsets

From: Carlos Corbacho <[email protected]>

Add support to force_hpet for all known MCP55 (nForce 5) chipset LPC bridges.
---
These are the untested nForce 5 chips (taken from Mikko's original patch, and checked against pci.ids).

 arch/x86/kernel/quirks.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
arch/x86/kernel/quirks.c +18 -0
index df01a1e..8f72148 100644
@@ -354,6 +354,24 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
 			nvidia_force_enable_hpet);
 
+/* LPC bridges */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0360,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0361,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0362,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0363,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0364,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0365,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0366,
+			nvidia_force_enable_hpet);
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0367,
+			nvidia_force_enable_hpet);
+
 void force_hpet_resume(void)
 {
 	switch (force_hpet_resume_type) {
Signature · 1 line
1.5.2.2