All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2 v2] x86/tsc: Update tsc crystal_khz whitelist
@ 2016-09-19 12:51 Prarit Bhargava
  2016-09-19 12:51 ` [PATCH 1/2 v2] x86,tsc: Use cpu id defines from intel-family.h Prarit Bhargava
  2016-09-19 12:51 ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Prarit Bhargava
  0 siblings, 2 replies; 6+ messages in thread
From: Prarit Bhargava @ 2016-09-19 12:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, Rafael Aquini, Peter Zijlstra (Intel),
	Andy Lutomirski, Len Brown, lenb

native_calibrate_tsc() contains a whitelist of models that have a known
TSC frequency that differs from the CPU frequency.  This patchset
switches the code from using magic numbers to using the defines in
asm/intel-family.h and adds new processors to the whitelist.

v2: peterz, fixed typo in patch 0002.  There was some question if the value
was supposed to be 25000 or 24000.  Experimenting on an 0x55 processor shows
that 25000 is correct.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Rafael Aquini <aquini@redhat.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Len Brown <len.brown@intel.com>
Cc: lenb@kernel.org


Prarit Bhargava (2):
  x86,tsc: Use cpu id defines from intel-family.h
  x86/tsc: Add additional Intel CPU models to crystal_khz whitelist

 arch/x86/kernel/tsc.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

-- 
1.7.9.3

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2 v2] x86,tsc: Use cpu id defines from intel-family.h
  2016-09-19 12:51 [PATCH 0/2 v2] x86/tsc: Update tsc crystal_khz whitelist Prarit Bhargava
@ 2016-09-19 12:51 ` Prarit Bhargava
  2016-09-19 23:06   ` [tip:x86/timers] x86/tsc: Use cpu id defines instead of hex constants tip-bot for Prarit Bhargava
  2016-09-19 12:51 ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Prarit Bhargava
  1 sibling, 1 reply; 6+ messages in thread
From: Prarit Bhargava @ 2016-09-19 12:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, Rafael Aquini, Peter Zijlstra (Intel),
	Andy Lutomirski, Len Brown, lenb

asm/intel-family.h contains defines for cpu ids which should be
used in the native_calibrate_tsc() function.

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Rafael Aquini <aquini@redhat.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Len Brown <len.brown@intel.com>
Cc: lenb@kernel.org
---
 arch/x86/kernel/tsc.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 78b9cb5a26af..2344758ba8a3 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -23,6 +23,7 @@
 #include <asm/x86_init.h>
 #include <asm/geode.h>
 #include <asm/apic.h>
+#include <asm/intel-family.h>
 
 unsigned int __read_mostly cpu_khz;	/* TSC clocks / usec, not used here */
 EXPORT_SYMBOL(cpu_khz);
@@ -686,11 +687,11 @@ unsigned long native_calibrate_tsc(void)
 
 	if (crystal_khz == 0) {
 		switch (boot_cpu_data.x86_model) {
-		case 0x4E:	/* SKL */
-		case 0x5E:	/* SKL */
+		case INTEL_FAM6_SKYLAKE_MOBILE:
+		case INTEL_FAM6_SKYLAKE_DESKTOP:
 			crystal_khz = 24000;	/* 24.0 MHz */
 			break;
-		case 0x5C:	/* BXT */
+		case INTEL_FAM6_ATOM_GOLDMONT:
 			crystal_khz = 19200;	/* 19.2 MHz */
 			break;
 		}
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist
  2016-09-19 12:51 [PATCH 0/2 v2] x86/tsc: Update tsc crystal_khz whitelist Prarit Bhargava
  2016-09-19 12:51 ` [PATCH 1/2 v2] x86,tsc: Use cpu id defines from intel-family.h Prarit Bhargava
@ 2016-09-19 12:51 ` Prarit Bhargava
  2016-09-19 23:07   ` [tip:x86/timers] x86/tsc: Add additional Intel CPU models to the crystal quirk list tip-bot for Prarit Bhargava
  2016-09-28 15:00   ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Len Brown
  1 sibling, 2 replies; 6+ messages in thread
From: Prarit Bhargava @ 2016-09-19 12:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: Prarit Bhargava, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	x86, Rafael Aquini, Peter Zijlstra (Intel),
	Andy Lutomirski, Len Brown, lenb

In commit aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via
CPUID"), the kernel added support for Intel processors which had
a different CPU base-frequency and TSC frequency.

The turbostat utility has been updated with KBL and SKX processors,
and they should also be added to the crystal_khz white list.

For example, on INTEL_FAM6_KABYLAKE_MOBILE native_calibrate_tsc() returns 0 MHz
for tsc_khz and after this patch native_calibrate_tsc() returns 1608 MHz.

v2: peterz, fix typo for SKX should be 25000

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: x86@kernel.org
Cc: Rafael Aquini <aquini@redhat.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Len Brown <len.brown@intel.com>
Cc: lenb@kernel.org
---
 arch/x86/kernel/tsc.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 2344758ba8a3..cd0c9ece25de 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -689,11 +689,18 @@ unsigned long native_calibrate_tsc(void)
 		switch (boot_cpu_data.x86_model) {
 		case INTEL_FAM6_SKYLAKE_MOBILE:
 		case INTEL_FAM6_SKYLAKE_DESKTOP:
+		case INTEL_FAM6_KABYLAKE_MOBILE:
+		case INTEL_FAM6_KABYLAKE_DESKTOP:
 			crystal_khz = 24000;	/* 24.0 MHz */
 			break;
+		case INTEL_FAM6_SKYLAKE_X:
+			crystal_khz = 25000;	/* 25.0 MHz */
+			break;
 		case INTEL_FAM6_ATOM_GOLDMONT:
 			crystal_khz = 19200;	/* 19.2 MHz */
 			break;
+		default:
+			crystal_khz = 0;
 		}
 	}
 
-- 
1.7.9.3

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:x86/timers] x86/tsc: Use cpu id defines instead of hex constants
  2016-09-19 12:51 ` [PATCH 1/2 v2] x86,tsc: Use cpu id defines from intel-family.h Prarit Bhargava
@ 2016-09-19 23:06   ` tip-bot for Prarit Bhargava
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot for Prarit Bhargava @ 2016-09-19 23:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: luto, linux-kernel, peterz, prarit, len.brown, aquini, hpa, mingo, tglx

Commit-ID:  655e52d2b62458032fc67ff7daaa664af6f36fb5
Gitweb:     http://git.kernel.org/tip/655e52d2b62458032fc67ff7daaa664af6f36fb5
Author:     Prarit Bhargava <prarit@redhat.com>
AuthorDate: Mon, 19 Sep 2016 08:51:40 -0400
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 20 Sep 2016 01:00:32 +0200

x86/tsc: Use cpu id defines instead of hex constants

asm/intel-family.h contains defines for cpu ids which should be used
instead of hex constants. Convert the switch case in native_calibrate_tsc()
to use the defines before adding more cpu models.

[ tglx: Massaged changelog ]

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael Aquini <aquini@redhat.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Link: http://lkml.kernel.org/r/1474289501-31717-2-git-send-email-prarit@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/tsc.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 78b9cb5..2344758 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -23,6 +23,7 @@
 #include <asm/x86_init.h>
 #include <asm/geode.h>
 #include <asm/apic.h>
+#include <asm/intel-family.h>
 
 unsigned int __read_mostly cpu_khz;	/* TSC clocks / usec, not used here */
 EXPORT_SYMBOL(cpu_khz);
@@ -686,11 +687,11 @@ unsigned long native_calibrate_tsc(void)
 
 	if (crystal_khz == 0) {
 		switch (boot_cpu_data.x86_model) {
-		case 0x4E:	/* SKL */
-		case 0x5E:	/* SKL */
+		case INTEL_FAM6_SKYLAKE_MOBILE:
+		case INTEL_FAM6_SKYLAKE_DESKTOP:
 			crystal_khz = 24000;	/* 24.0 MHz */
 			break;
-		case 0x5C:	/* BXT */
+		case INTEL_FAM6_ATOM_GOLDMONT:
 			crystal_khz = 19200;	/* 19.2 MHz */
 			break;
 		}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip:x86/timers] x86/tsc: Add additional Intel CPU models to the crystal quirk list
  2016-09-19 12:51 ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Prarit Bhargava
@ 2016-09-19 23:07   ` tip-bot for Prarit Bhargava
  2016-09-28 15:00   ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Len Brown
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot for Prarit Bhargava @ 2016-09-19 23:07 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: prarit, luto, hpa, mingo, linux-kernel, peterz, aquini, len.brown, tglx

Commit-ID:  6baf3d61821f5b38f27b4e9f044ad4d1e8f3d14f
Gitweb:     http://git.kernel.org/tip/6baf3d61821f5b38f27b4e9f044ad4d1e8f3d14f
Author:     Prarit Bhargava <prarit@redhat.com>
AuthorDate: Mon, 19 Sep 2016 08:51:41 -0400
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 20 Sep 2016 01:00:32 +0200

x86/tsc: Add additional Intel CPU models to the crystal quirk list

commit aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via
CPUID") added code to retrieve the crystal and TSC frequency from CPUID
leaves. If the crystal freqency is enumerated as 0,the resulting TSC
frequency is 0 as well. For CPUs with a known fixed crystal frequency a
quirk list is available to set the frequency,

Kabylake and SkylakeX CPUs are missing in the list of CPUs which need this
quirk. Add them so the TSC frequency can be calculated correctly.

[ tglx: Removed the silly default case as the switch() is only invoked when
  	cpu_khz is 0. Massaged changelog. ]

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
Cc: Len Brown <len.brown@intel.com>
Cc: Rafael Aquini <aquini@redhat.com>
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>
Link: http://lkml.kernel.org/r/1474289501-31717-3-git-send-email-prarit@redhat.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/x86/kernel/tsc.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 2344758..46b2f41 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -689,8 +689,13 @@ unsigned long native_calibrate_tsc(void)
 		switch (boot_cpu_data.x86_model) {
 		case INTEL_FAM6_SKYLAKE_MOBILE:
 		case INTEL_FAM6_SKYLAKE_DESKTOP:
+		case INTEL_FAM6_KABYLAKE_MOBILE:
+		case INTEL_FAM6_KABYLAKE_DESKTOP:
 			crystal_khz = 24000;	/* 24.0 MHz */
 			break;
+		case INTEL_FAM6_SKYLAKE_X:
+			crystal_khz = 25000;	/* 25.0 MHz */
+			break;
 		case INTEL_FAM6_ATOM_GOLDMONT:
 			crystal_khz = 19200;	/* 19.2 MHz */
 			break;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist
  2016-09-19 12:51 ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Prarit Bhargava
  2016-09-19 23:07   ` [tip:x86/timers] x86/tsc: Add additional Intel CPU models to the crystal quirk list tip-bot for Prarit Bhargava
@ 2016-09-28 15:00   ` Len Brown
  1 sibling, 0 replies; 6+ messages in thread
From: Len Brown @ 2016-09-28 15:00 UTC (permalink / raw)
  To: Prarit Bhargava
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
	X86 ML, Rafael Aquini, Peter Zijlstra (Intel),
	Andy Lutomirski, Len Brown

On Mon, Sep 19, 2016 at 8:51 AM, Prarit Bhargava <prarit@redhat.com> wrote:
> In commit aa297292d708 ("x86/tsc: Enumerate SKL cpu_khz and tsc_khz via
> CPUID"), the kernel added support for Intel processors which had
> a different CPU base-frequency and TSC frequency.
>
> The turbostat utility has been updated with KBL and SKX processors,
> and they should also be added to the crystal_khz white list.
>
> For example, on INTEL_FAM6_KABYLAKE_MOBILE native_calibrate_tsc() returns 0 MHz
> for tsc_khz and after this patch native_calibrate_tsc() returns 1608 MHz.
>
> v2: peterz, fix typo for SKX should be 25000
>
> Signed-off-by: Prarit Bhargava <prarit@redhat.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: x86@kernel.org
> Cc: Rafael Aquini <aquini@redhat.com>
> Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Len Brown <len.brown@intel.com>
> Cc: lenb@kernel.org
> ---
>  arch/x86/kernel/tsc.c |    7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
> index 2344758ba8a3..cd0c9ece25de 100644
> --- a/arch/x86/kernel/tsc.c
> +++ b/arch/x86/kernel/tsc.c
> @@ -689,11 +689,18 @@ unsigned long native_calibrate_tsc(void)
>                 switch (boot_cpu_data.x86_model) {
>                 case INTEL_FAM6_SKYLAKE_MOBILE:
>                 case INTEL_FAM6_SKYLAKE_DESKTOP:
> +               case INTEL_FAM6_KABYLAKE_MOBILE:
> +               case INTEL_FAM6_KABYLAKE_DESKTOP:
>                         crystal_khz = 24000;    /* 24.0 MHz */
>                         break;
> +               case INTEL_FAM6_SKYLAKE_X:
> +                       crystal_khz = 25000;    /* 25.0 MHz */
> +                       break;
>                 case INTEL_FAM6_ATOM_GOLDMONT:
>                         crystal_khz = 19200;    /* 19.2 MHz */
>                         break;
> +               default:
> +                       crystal_khz = 0;
>                 }


Correct.

Reviewed-by: Len Brown <len.brown@intel.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-28 15:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19 12:51 [PATCH 0/2 v2] x86/tsc: Update tsc crystal_khz whitelist Prarit Bhargava
2016-09-19 12:51 ` [PATCH 1/2 v2] x86,tsc: Use cpu id defines from intel-family.h Prarit Bhargava
2016-09-19 23:06   ` [tip:x86/timers] x86/tsc: Use cpu id defines instead of hex constants tip-bot for Prarit Bhargava
2016-09-19 12:51 ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Prarit Bhargava
2016-09-19 23:07   ` [tip:x86/timers] x86/tsc: Add additional Intel CPU models to the crystal quirk list tip-bot for Prarit Bhargava
2016-09-28 15:00   ` [PATCH 2/2 v2] x86/tsc: Add additional Intel CPU models to crystal_khz whitelist Len Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.