All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] add Centaur Family >= 7 CPUs support
@ 2020-09-08 10:57 Tony W Wang-oc
  2020-09-08 10:57 ` [PATCH v1 1/2] x86/cpu: replace two-condition switch-case with if statement Tony W Wang-oc
  2020-09-08 10:57 ` [PATCH v1 2/2] x86/cpu: add Centaur Family >=7 CPUs initialization support Tony W Wang-oc
  0 siblings, 2 replies; 5+ messages in thread
From: Tony W Wang-oc @ 2020-09-08 10:57 UTC (permalink / raw)
  To: tglx, mingo, bp, x86, hpa, sean.j.christopherson, liam.merwick,
	mlevitsk, linux-kernel
  Cc: TimGuo-oc, CooperYan, QiyuanWang, HerryYang, CobeChen

New Centaur CPUs have Family >= 7. So, add specific initialization
for these CPUs in centaur.c

In order to handle Family >= 7, also use if instead two-condition
switch-case in centaur.c

Tony W Wang-oc (2):
  x86/cpu: replace two-condition switch-case with if statement
  x86/cpu: add Centaur Family >=7 CPUs initialization support

 arch/x86/kernel/cpu/centaur.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

-- 
2.7.4


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

* [PATCH v1 1/2] x86/cpu: replace two-condition switch-case with if statement
  2020-09-08 10:57 [PATCH v1 0/2] add Centaur Family >= 7 CPUs support Tony W Wang-oc
@ 2020-09-08 10:57 ` Tony W Wang-oc
  2020-09-11  9:47   ` [tip: x86/cpu] x86/cpu/centaur: Replace two-condition switch-case with an " tip-bot2 for Tony W Wang-oc
  2020-09-08 10:57 ` [PATCH v1 2/2] x86/cpu: add Centaur Family >=7 CPUs initialization support Tony W Wang-oc
  1 sibling, 1 reply; 5+ messages in thread
From: Tony W Wang-oc @ 2020-09-08 10:57 UTC (permalink / raw)
  To: tglx, mingo, bp, x86, hpa, sean.j.christopherson, liam.merwick,
	mlevitsk, linux-kernel
  Cc: TimGuo-oc, CooperYan, QiyuanWang, HerryYang, CobeChen

Use if-case instead two-condition switch-case.

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
---
 arch/x86/kernel/cpu/centaur.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index c5cf336..5f811586 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -90,18 +90,14 @@ enum {
 
 static void early_init_centaur(struct cpuinfo_x86 *c)
 {
-	switch (c->x86) {
 #ifdef CONFIG_X86_32
-	case 5:
-		/* Emulate MTRRs using Centaur's MCR. */
+	/* Emulate MTRRs using Centaur's MCR. */
+	if (c->x86 == 5)
 		set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
-		break;
 #endif
-	case 6:
-		if (c->x86_model >= 0xf)
-			set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-		break;
-	}
+	if (c->x86 == 6 && c->x86_model >= 0xf)
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
+
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_SYSENTER32);
 #endif
@@ -145,9 +141,8 @@ static void init_centaur(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
 	}
 
-	switch (c->x86) {
 #ifdef CONFIG_X86_32
-	case 5:
+	if (c->x86 == 5) {
 		switch (c->x86_model) {
 		case 4:
 			name = "C6";
@@ -207,12 +202,10 @@ static void init_centaur(struct cpuinfo_x86 *c)
 			c->x86_cache_size = (cc>>24)+(dd>>24);
 		}
 		sprintf(c->x86_model_id, "WinChip %s", name);
-		break;
+	}
 #endif
-	case 6:
+	if (c->x86 == 6)
 		init_c3(c);
-		break;
-	}
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
 #endif
-- 
2.7.4


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

* [PATCH v1 2/2] x86/cpu: add Centaur Family >=7 CPUs initialization support
  2020-09-08 10:57 [PATCH v1 0/2] add Centaur Family >= 7 CPUs support Tony W Wang-oc
  2020-09-08 10:57 ` [PATCH v1 1/2] x86/cpu: replace two-condition switch-case with if statement Tony W Wang-oc
@ 2020-09-08 10:57 ` Tony W Wang-oc
  2020-09-11  9:47   ` [tip: x86/cpu] x86/cpu/centaur: Add Centaur family " tip-bot2 for Tony W Wang-oc
  1 sibling, 1 reply; 5+ messages in thread
From: Tony W Wang-oc @ 2020-09-08 10:57 UTC (permalink / raw)
  To: tglx, mingo, bp, x86, hpa, sean.j.christopherson, liam.merwick,
	mlevitsk, linux-kernel
  Cc: TimGuo-oc, CooperYan, QiyuanWang, HerryYang, CobeChen

add Centaur Family >=7 CPUs specific initialization support in centaur.c

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
---
 arch/x86/kernel/cpu/centaur.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index 5f811586..345f7d9 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -65,6 +65,9 @@ static void init_c3(struct cpuinfo_x86 *c)
 		c->x86_cache_alignment = c->x86_clflush_size * 2;
 		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 	}
+
+	if (c->x86 >= 7)
+		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 }
 
 enum {
@@ -95,7 +98,8 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
 	if (c->x86 == 5)
 		set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
 #endif
-	if (c->x86 == 6 && c->x86_model >= 0xf)
+	if ((c->x86 == 6 && c->x86_model >= 0xf) ||
+	    (c->x86 >= 7))
 		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 
 #ifdef CONFIG_X86_64
@@ -204,7 +208,7 @@ static void init_centaur(struct cpuinfo_x86 *c)
 		sprintf(c->x86_model_id, "WinChip %s", name);
 	}
 #endif
-	if (c->x86 == 6)
+	if (c->x86 == 6 || c->x86 >= 7)
 		init_c3(c);
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
-- 
2.7.4


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

* [tip: x86/cpu] x86/cpu/centaur: Replace two-condition switch-case with an if statement
  2020-09-08 10:57 ` [PATCH v1 1/2] x86/cpu: replace two-condition switch-case with if statement Tony W Wang-oc
@ 2020-09-11  9:47   ` tip-bot2 for Tony W Wang-oc
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Tony W Wang-oc @ 2020-09-11  9:47 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Tony W Wang-oc, Borislav Petkov, x86, LKML

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     8687bdc04128b2bd16faaae11db10128ad0da7b8
Gitweb:        https://git.kernel.org/tip/8687bdc04128b2bd16faaae11db10128ad0da7b8
Author:        Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
AuthorDate:    Tue, 08 Sep 2020 18:57:45 +08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 11 Sep 2020 10:50:01 +02:00

x86/cpu/centaur: Replace two-condition switch-case with an if statement

Use a normal if statements instead of a two-condition switch-case.

 [ bp: Massage commit message. ]

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/1599562666-31351-2-git-send-email-TonyWWang-oc@zhaoxin.com
---
 arch/x86/kernel/cpu/centaur.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index c5cf336..5f81158 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -90,18 +90,14 @@ enum {
 
 static void early_init_centaur(struct cpuinfo_x86 *c)
 {
-	switch (c->x86) {
 #ifdef CONFIG_X86_32
-	case 5:
-		/* Emulate MTRRs using Centaur's MCR. */
+	/* Emulate MTRRs using Centaur's MCR. */
+	if (c->x86 == 5)
 		set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
-		break;
 #endif
-	case 6:
-		if (c->x86_model >= 0xf)
-			set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
-		break;
-	}
+	if (c->x86 == 6 && c->x86_model >= 0xf)
+		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
+
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_SYSENTER32);
 #endif
@@ -145,9 +141,8 @@ static void init_centaur(struct cpuinfo_x86 *c)
 			set_cpu_cap(c, X86_FEATURE_ARCH_PERFMON);
 	}
 
-	switch (c->x86) {
 #ifdef CONFIG_X86_32
-	case 5:
+	if (c->x86 == 5) {
 		switch (c->x86_model) {
 		case 4:
 			name = "C6";
@@ -207,12 +202,10 @@ static void init_centaur(struct cpuinfo_x86 *c)
 			c->x86_cache_size = (cc>>24)+(dd>>24);
 		}
 		sprintf(c->x86_model_id, "WinChip %s", name);
-		break;
+	}
 #endif
-	case 6:
+	if (c->x86 == 6)
 		init_c3(c);
-		break;
-	}
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
 #endif

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

* [tip: x86/cpu] x86/cpu/centaur: Add Centaur family >=7 CPUs initialization support
  2020-09-08 10:57 ` [PATCH v1 2/2] x86/cpu: add Centaur Family >=7 CPUs initialization support Tony W Wang-oc
@ 2020-09-11  9:47   ` tip-bot2 for Tony W Wang-oc
  0 siblings, 0 replies; 5+ messages in thread
From: tip-bot2 for Tony W Wang-oc @ 2020-09-11  9:47 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: Tony W Wang-oc, Borislav Petkov, x86, LKML

The following commit has been merged into the x86/cpu branch of tip:

Commit-ID:     33b4711df4c1b3aec7c267c60fc24abccfadd40c
Gitweb:        https://git.kernel.org/tip/33b4711df4c1b3aec7c267c60fc24abccfadd40c
Author:        Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
AuthorDate:    Tue, 08 Sep 2020 18:57:46 +08:00
Committer:     Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 11 Sep 2020 10:53:19 +02:00

x86/cpu/centaur: Add Centaur family >=7 CPUs initialization support

Add Centaur family >=7 CPUs specific initialization support.

Signed-off-by: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/1599562666-31351-3-git-send-email-TonyWWang-oc@zhaoxin.com
---
 arch/x86/kernel/cpu/centaur.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/cpu/centaur.c b/arch/x86/kernel/cpu/centaur.c
index 5f81158..345f7d9 100644
--- a/arch/x86/kernel/cpu/centaur.c
+++ b/arch/x86/kernel/cpu/centaur.c
@@ -65,6 +65,9 @@ static void init_c3(struct cpuinfo_x86 *c)
 		c->x86_cache_alignment = c->x86_clflush_size * 2;
 		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 	}
+
+	if (c->x86 >= 7)
+		set_cpu_cap(c, X86_FEATURE_REP_GOOD);
 }
 
 enum {
@@ -95,7 +98,8 @@ static void early_init_centaur(struct cpuinfo_x86 *c)
 	if (c->x86 == 5)
 		set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
 #endif
-	if (c->x86 == 6 && c->x86_model >= 0xf)
+	if ((c->x86 == 6 && c->x86_model >= 0xf) ||
+	    (c->x86 >= 7))
 		set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
 
 #ifdef CONFIG_X86_64
@@ -204,7 +208,7 @@ static void init_centaur(struct cpuinfo_x86 *c)
 		sprintf(c->x86_model_id, "WinChip %s", name);
 	}
 #endif
-	if (c->x86 == 6)
+	if (c->x86 == 6 || c->x86 >= 7)
 		init_c3(c);
 #ifdef CONFIG_X86_64
 	set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);

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

end of thread, other threads:[~2020-09-11  9:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-08 10:57 [PATCH v1 0/2] add Centaur Family >= 7 CPUs support Tony W Wang-oc
2020-09-08 10:57 ` [PATCH v1 1/2] x86/cpu: replace two-condition switch-case with if statement Tony W Wang-oc
2020-09-11  9:47   ` [tip: x86/cpu] x86/cpu/centaur: Replace two-condition switch-case with an " tip-bot2 for Tony W Wang-oc
2020-09-08 10:57 ` [PATCH v1 2/2] x86/cpu: add Centaur Family >=7 CPUs initialization support Tony W Wang-oc
2020-09-11  9:47   ` [tip: x86/cpu] x86/cpu/centaur: Add Centaur family " tip-bot2 for Tony W Wang-oc

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.