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

Previous thread: Re: [PATCH 0/4] Fix race between sk_filter reassign and sk_clone() by Olof Johansson on Thursday, October 18, 2007 - 10:29 pm. (4 messages)

Next thread: [M68KNOMMU]: improve mii_do_cmd code in FEC driver by Greg Ungerer on Thursday, October 18, 2007 - 11:46 pm. (1 message)
To: <linux-kernel@...>
Cc: Mikko Tiihonen <mikko.tiihonen@...>, Thomas Gleixner <tglx@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Thursday, October 18, 2007 - 11:23 pm

(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
--
E-Mail: cathectic@gmail.com
Web: strangeworlds.co.uk
GPG Key ID: 0x23EE722D
-

To: Carlos Corbacho <cathectic@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 2:50 am

There is still a config option for hpet. the hpet=force boot param is

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
-

To: Thomas Gleixner <tglx@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 11:29 am

Thomas,

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

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index a4ce191..7c772bf 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -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)
{
-

To: Carlos Corbacho <cathectic@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 12:19 pm

Yes, looks good. It is just missing the resume part, which is

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

-

To: Thomas Gleixner <tglx@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 1:51 pm

From: Carlos Corbacho <cathectic@gmail.com>

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).

Signed-off-by: Carlos Corbacho <cathectic@gmail.com>
---
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(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 983f631..8abbfe6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -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:
diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index a4ce191..cb21bcb 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -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_...

To: Carlos Corbacho <cathectic@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 1:58 pm

Applied. Thanks,

tglx
-

To: Thomas Gleixner <tglx@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 2:07 pm

From: Carlos Corbacho <cathectic@gmail.com>

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(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index cb21bcb..df01a1e 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -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;
}

--
1.5.2.2

-

To: Carlos Corbacho <cathectic@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Date: Friday, October 19, 2007 - 2:15 pm

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
-

To: Thomas Gleixner <tglx@...>, Venkatesh Pallipadi <venkatesh.pallipadi@...>
Cc: <linux-kernel@...>, Mikko Tiihonen <mikko.tiihonen@...>
Date: Friday, October 19, 2007 - 2:34 pm

From: Carlos Corbacho <cathectic@gmail.com>

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(-)

diff --git a/arch/x86/kernel/quirks.c b/arch/x86/kernel/quirks.c
index df01a1e..8f72148 100644
--- a/arch/x86/kernel/quirks.c
+++ b/arch/x86/kernel/quirks.c
@@ -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) {
--
1.5.2.2

-

Previous thread: Re: [PATCH 0/4] Fix race between sk_filter reassign and sk_clone() by Olof Johansson on Thursday, October 18, 2007 - 10:29 pm. (4 messages)

Next thread: [M68KNOMMU]: improve mii_do_cmd code in FEC driver by Greg Ungerer on Thursday, October 18, 2007 - 11:46 pm. (1 message)