Skip to contentSkip to conversation

sparc64: correctly recognise M7 cpu type

PATCH Superseded Allen Pais 3 participants 9 messages Aug 22, 2014 – Aug 24, 2014 SPARC + UltraSPARC (sparc/sparc64)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Allen Pais

author
#0 lore raw

PATCH 1/3 sparc64: correctly recognise M7 cpu type

The following patch adds support for correctly
recognising M7 cpu type.

---
 arch/sparc/include/asm/spitfire.h |  1 +
 arch/sparc/kernel/cpu.c           |  6 ++++++
 arch/sparc/kernel/head_64.S       | 14 ++++++++++++++
 3 files changed, 21 insertions(+)
arch/sparc/include/asm/spitfire.h +1 -0
index 3fc58691..9aec17b 100644
@@ -45,6 +45,7 @@
 #define SUN4V_CHIP_NIAGARA3	0x03
 #define SUN4V_CHIP_NIAGARA4	0x04
 #define SUN4V_CHIP_NIAGARA5	0x05
+#define SUN4V_CHIP_SPARC_M7	0x08
 #define SUN4V_CHIP_SPARC64X	0x8a
 #define SUN4V_CHIP_UNKNOWN	0xff
 
arch/sparc/kernel/cpu.c +6 -0
index 82a3a71..55dfb62 100644
@@ -494,6 +494,12 @@ static void __init sun4v_cpu_probe(void)
 		sparc_pmu_type = "niagara5";
 		break;
 
+	case SUN4V_CHIP_SPARC_M7:
+		sparc_cpu_type = "SPARC-M7";
+		sparc_fpu_type = "SPARC-M7 integrated FPU";
+		sparc_pmu_type = "sparc-m7";
+		break;
+
 	case SUN4V_CHIP_SPARC64X:
 		sparc_cpu_type = "SPARC64-X";
 		sparc_fpu_type = "SPARC64-X integrated FPU";
arch/sparc/kernel/head_64.S +14 -0
index 452f04f..577abba0 100644
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop
 
@@ -430,6 +432,14 @@ sun4v_chip_type:
 	ba,pt	%xcc, 49f
 	 nop
 
+71:
+	ldub	[%g1 + 7], %g2
+	cmp	%g2, '7'
+	be,pt	%xcc, 5f
+	 mov	SUN4V_CHIP_SPARC_M7, %g4
+	ba,pt	%xcc, 49f
+	 nop
+
 91:	sethi	%hi(prom_cpu_compatible), %g1
 	or	%g1, %lo(prom_cpu_compatible), %g1
 	ldub	[%g1 + 17], %g2
@@ -586,6 +596,10 @@ niagara_tlb_fixup:
 	be,pt	%xcc, niagara4_patch
 	 nop
 
+	cmp	%g1, SUN4V_CHIP_SPARC_M7
+	be,pt	%xcc, niagara4_patch
+	 nop
+
 	call	generic_patch_copyops
 	 nop
 	call	generic_patch_bzero
Signature · 1 line
1.8.4.2
maintainer
#1 lore raw

From: Allen Pais <[email protected]>
Date: Fri, 22 Aug 2014 11:22:51 +0530

Quoted 4 lines

The following patch adds support for correctly
recognising M7 cpu type.

I don't think this is correct.

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 420

Quoted 8 lines
arch/sparc/kernel/head_64.S +2 -0
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop

This code block is supposed to fallthrough when %g2 is 'M' so that we accept all of "{T,M}345..." but your change is breaking that such that we will now only accept "M" as a prefix for "7".

That's a regression.

All you have to do is add the new comparison against '7' in the "70:" label code block, and you're done.

maintainer
#2 lore raw
In reply to Allen Pais

From: Allen Pais <[email protected]>
Date: Sun, 24 Aug 2014 11:37:09 +0530

Quoted 27 lines
Quoted 16 lines

I don't think this is correct.

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 420

Quoted 8 lines
arch/sparc/kernel/head_64.S +2 -0
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop

This code block is supposed to fallthrough when %g2 is 'M' so that we accept all of "{T,M}345..." but your change is breaking that such that we will now only accept "M" as a prefix for "7".

Quoted 4 lines

That's a regression.

All you have to do is add the new comparison against '7' in the "70:" label code block, and you're done.

The idea was to also have M5 and M6-32 cpu types supported too with M7.

+71:

arch/sparc/kernel/head_64.S +3 -0
+	ldub	[%g1 + 7], %g2
+	cmp	%g1, '5'
+	be,pt	%xcc, 5f

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 442

Quoted 10 lines
arch/sparc/kernel/head_64.S +10 -0
+	 mov	SUN4V_CHIP_SPARC_M5, %g4
+	cmp	%g1, '6'
+	be,pt	%xcc, 5f
+	 mov	SUN4V_CHIP_SPARC_M6, %g4
+       cmp     %g2, '7'
+       be,pt   %xcc, 5f
+        mov    SUN4V_CHIP_SPARC_M7, %g4
+       ba,pt   %xcc, 49f
+        nop
+

Again, why are you bothing with a special code path at all? You don't need to.

Just add the M7 test to the "70:" label code block, and you're done.

author
#3 lore raw
In reply to Allen Pais
Quoted 16 lines

I don't think this is correct.

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 420

Quoted 8 lines
arch/sparc/kernel/head_64.S +2 -0
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop

This code block is supposed to fallthrough when %g2 is 'M' so that we accept all of "{T,M}345..." but your change is breaking that such that we will now only accept "M" as a prefix for "7".

Quoted 4 lines

That's a regression.

All you have to do is add the new comparison against '7' in the "70:" label code block, and you're done.

The idea was to also have M5 and M6-32 cpu types supported too with M7.

+71:
+ ldub [%g1 + 7], %g2
+ cmp %g1, '5'
+ be,pt %xcc, 5f
+ mov SUN4V_CHIP_SPARC_M5, %g4
+ cmp %g1, '6'
+ be,pt %xcc, 5f
+ mov SUN4V_CHIP_SPARC_M6, %g4

+       cmp     %g2, '7'
+       be,pt   %xcc, 5f
+        mov    SUN4V_CHIP_SPARC_M7, %g4
+       ba,pt   %xcc, 49f

+ nop
+

I haven't tested it yet on M5, I should have perhaps sent all them together.
lemme know what you think.

- Allen

author
#4 lore raw
In reply to Allen Pais

David,

Quoted 14 lines

Review sun4v_chip_type: · line 420

Quoted 9 lines
(quoted diff) +2 -0
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop

This code block is supposed to fallthrough when %g2 is 'M' so that we accept all of "{T,M}345..." but your change is breaking that such that we will now only accept "M" as a prefix for "7".

Quoted 5 lines

That's a regression.

All you have to do is add the new comparison against '7' in the "70:" label code block, and you're done.

When we are on this topic, here's a patch that attempts to simplify
cpu detection.

Here's a quick diff.

arch/sparc/kernel/cpu.c +30 -0
index 5c51258..c06e27e 100644
@@ -460,6 +460,36 @@ static int __init cpu_type_probe(void)
 #endif /* CONFIG_SPARC32 */
 
 #ifdef CONFIG_SPARC64
+
+static struct sun4v_chip_names {
+       const char *name;
+       unsigned long chip;
+} sun4v_names[] __initdata = {
+       {"SUNW,UltraSPARC-T1", SUN4V_CHIP_NIAGARA1},
+       {"SUNW,UltraSPARC-T2", SUN4V_CHIP_NIAGARA2},
+       {"SUNW,UltraSPARC-T2+", SUN4V_CHIP_NIAGARA2},
+       {"SUNW,UltraSPARC-T3", SUN4V_CHIP_NIAGARA3},
+       {"SPARC-T4", SUN4V_CHIP_NIAGARA4},
+       {"SPARC64-X", SUN4V_CHIP_SPARC64X},
+       {"SPARC-T5", SUN4V_CHIP_NIAGARA5},
+       {"SPARC-M7", SUN4V_CHIP_SPARC_M7},
+};
+
+unsigned long __init determine_sun4v_cpu(void)
+{
+       unsigned int nr_chips = ARRAY_SIZE(sun4v_names);
+       unsigned long chip_type = SUN4V_CHIP_UNKNOWN;
+       unsigned int i;
+
+       for (i = 0; i < nr_chips; i++) {
+               if (strcmp(prom_cpu_compatible, sun4v_names[i].name) = 0) {
+                       chip_type = sun4v_names[i].chip;
+                       break;
+               }
+       }
+       return chip_type;
+}
+
 static void __init sun4v_cpu_probe(void)
 {
        switch (sun4v_chip_type) {
arch/sparc/kernel/head_64.S +2 -89

105 lines not on this page · raw message

- Allen

maintainer
#5 lore raw
In reply to Allen Pais

From: Allen Pais <[email protected]>
Date: Sun, 24 Aug 2014 11:49:29 +0530

Quoted 17 lines

David,

Quoted 16 lines

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 420

Quoted 9 lines
arch/sparc/kernel/head_64.S +2 -0
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop

This code block is supposed to fallthrough when %g2 is 'M' so that we accept all of "{T,M}345..." but your change is breaking that such that we will now only accept "M" as a prefix for "7".

That's a regression.

Quoted 8 lines
Quoted 3 lines

All you have to do is add the new comparison against '7' in the "70:" label code block, and you're done.

When we are on this topic, here's a patch that attempts to simplify
cpu detection.

Here's a quick diff.

You can't call C code until you've cleared the BSS, you can't clear the BSS until you hook up the proper optimized routines, you can't hook up the proper optimized routined until you know the cpu type.

I would have done this years ago otherwise.

author
#6 lore raw
In reply to Allen Pais

David,

Quoted 20 lines
Quoted 6 lines

The idea was to also have M5 and M6-32 cpu types supported too with M7.

+71:

arch/sparc/kernel/head_64.S +3 -0
+	ldub	[%g1 + 7], %g2
+	cmp	%g1, '5'
+	be,pt	%xcc, 5f

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 442

Quoted 10 lines
arch/sparc/kernel/head_64.S +10 -0
+	 mov	SUN4V_CHIP_SPARC_M5, %g4
+	cmp	%g1, '6'
+	be,pt	%xcc, 5f
+	 mov	SUN4V_CHIP_SPARC_M6, %g4
+       cmp     %g2, '7'
+       be,pt   %xcc, 5f
+        mov    SUN4V_CHIP_SPARC_M7, %g4
+       ba,pt   %xcc, 49f
+        nop
+

Again, why are you bothing with a special code path at all? You don't need to.

Quoted 2 lines

Just add the M7 test to the "70:" label code block, and you're done.

I was a little confused when you initially mentioned about using "70:" label
code block, now I see the point. I'll re-do the patch and test it.

- Allen

#7 lore raw
In reply to Allen Pais

Hi,
David Miller wrote: [Sun Aug 24 2014, 02:43:11AM EDT]

Quoted 24 lines

From: Allen Pais <[email protected]>
Date: Sun, 24 Aug 2014 11:49:29 +0530

Quoted 21 lines

David,

Quoted 19 lines

arch/sparc/kernel/head_64.S sun4v_chip_type: · line 420

Quoted 9 lines
arch/sparc/kernel/head_64.S +2 -0
@@ -414,6 +414,8 @@ sun4v_chip_type:
 	cmp	%g2, 'T'
 	be,pt	%xcc, 70f
 	 cmp	%g2, 'M'
+	be,pt	%xcc, 71f
+	 nop
 	bne,pn	%xcc, 49f
 	 nop

This code block is supposed to fallthrough when %g2 is 'M' so that we accept all of "{T,M}345..." but your change is breaking that such that we will now only accept "M" as a prefix for "7".

That's a regression.

All you have to do is add the new comparison against '7' in the "70:" label code block, and you're done.

Quoted 8 lines
Quoted 4 lines

When we are on this topic, here's a patch that attempts to simplify
cpu detection.

Here's a quick diff.

You can't call C code until you've cleared the BSS, you can't clear the BSS until you hook up the proper optimized routines, you can't hook up the proper optimized routined until you know the cpu type.

I'm aware of BSS and cpu initialization routines. Many issues are subtle until paging_init finishes.

What BSS does this code touch or reference? None that I'm aware of.

The code is executing on OBP stack and the kernel has been remapped and doesn't require PIC address manipulation any longer. Your only assumptions should be OBP handling register window events and accessing compile time initialized data. BSS is taboo for the reason you state.

One obviously has to be VERY careful. The "VERY" part is true of all code here. Should there be fear of strcmp then implement it in simple "C" and name it "boot_strcmp".

Perhaps I've missed an issue.

thanx,

bob

Quoted 6 lines

I would have done this years ago otherwise.
--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#8 lore raw
In reply to Allen Pais

From: Bob Picco <[email protected]>
Date: Sun, 24 Aug 2014 08:35:06 -0400

Quoted 1 line

What BSS does this code touch or reference? None that I'm aware of.

You cannot control what code the compiler emits, it is therefore not safe to call C code.

Please just drop this for now, thank you.