Skip to contentSkip to conversation

ARC: guard dsp early init against non ARCv2

PATCH In review Eugeniy Paltsev 4 participants 6 messages Apr 28, 2020 – Apr 29, 2020 Synopsys ARC architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARC: guard dsp early init against non ARCv2

As of today we guard early DSP init code with ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have CPU with DSP configured. However that's not enough as in ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC instructions presence.

So, let's guard DSP early init against non ARCv2.

---
 arch/arc/include/asm/dsp-impl.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arc/include/asm/dsp-impl.h +2 -0
index e1aa212ca6eb..e64d945ae7df 100644
@@ -15,12 +15,14 @@
 
 /* clobbers r5 register */
 .macro DSP_EARLY_INIT
+#if defined(CONFIG_ISA_ARCV2)
 	lr	r5, [ARC_AUX_DSP_BUILD]
 	bmsk	r5, r5, 7
 	breq    r5, 0, 1f
 	mov	r5, DSP_CTRL_DISABLED_ALL
 	sr	r5, [ARC_AUX_DSP_CTRL]
 1:
+#endif
 .endm
 
 /* clobbers r10, r11 registers pair */
Signature · 1 line
2.21.1
#1 lore raw
Quoted 18 lines · Eugeniy Paltsev

As of today we guard early DSP init code with ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have CPU with DSP configured. However that's not enough as in ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC instructions presence.

So, let's guard DSP early init against non ARCv2.

---
 arch/arc/include/asm/dsp-impl.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arc/include/asm/dsp-impl.h +0 -0
index e1aa212ca6eb..e64d945ae7df 100644

arch/arc/include/asm/dsp-impl.h line 18

Quoted 4 lines
arch/arc/include/asm/dsp-impl.h +1 -0
@@ -15,12 +15,14 @@
 
 /* clobbers r5 register */
 .macro DSP_EARLY_INIT
+#if defined(CONFIG_ISA_ARCV2)

ifdef is the canonical way for a single macro to check.

Also, this needs to be finer grained, i.e. CONFIG_ARC_DSP_KERNEL which is already tied to ARCV2 only configs.

Quoted 10 lines
arch/arc/include/asm/dsp-impl.h +1 -0
 	lr	r5, [ARC_AUX_DSP_BUILD]
 	bmsk	r5, r5, 7
 	breq    r5, 0, 1f
 	mov	r5, DSP_CTRL_DISABLED_ALL
 	sr	r5, [ARC_AUX_DSP_CTRL]
 1:
+#endif
 .endm
 
 /* clobbers r10, r11 registers pair */
#2 lore raw

Hi Vineet,

Quoted 26 lines

From: Vineet Gupta <[email protected]>
Sent: Tuesday, April 28, 2020 22:46
To: Eugeniy Paltsev; [email protected]
Cc: Alexey Brodkin; [email protected]
Subject: Re: [PATCH] ARC: guard dsp early init against non ARCv2

Quoted 19 lines · Eugeniy Paltsev

As of today we guard early DSP init code with ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have CPU with DSP configured. However that's not enough as in ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC instructions presence.

So, let's guard DSP early init against non ARCv2.

---
 arch/arc/include/asm/dsp-impl.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arc/include/asm/dsp-impl.h +0 -0
index e1aa212ca6eb..e64d945ae7df 100644
@@ -15,12 +15,14 @@
 
Quoted 8 lines

arch/arc/include/asm/dsp-impl.h line 18

Quoted 3 lines
arch/arc/include/asm/dsp-impl.h +1 -0
 /* clobbers r5 register */
 .macro DSP_EARLY_INIT
+#if defined(CONFIG_ISA_ARCV2)

ifdef is the canonical way for a single macro to check.

Also, this needs to be finer grained, i.e. CONFIG_ARC_DSP_KERNEL which is already tied to ARCV2 only configs.

We shouldn't limit the scope of this code part [dsp early init] to the cases were DSP support is enabled in kconfig - and that is the reason why this code initially was guarded with BCR check only.

So, I change the check to

#if defined(CONFIG_ARC_DSP_HANDLED) || defined(CONFIG_ARC_DSP_NONE)

which is actually the equivalent to

#if defined(CONFIG_ISA_ARCV2)

but I don't think it's worth thing to do.

Quoted 11 lines

arch/arc/include/asm/dsp-impl.h line 28

Quoted 11 lines
arch/arc/include/asm/dsp-impl.h +1 -0
      lr      r5, [ARC_AUX_DSP_BUILD]
      bmsk    r5, r5, 7
      breq    r5, 0, 1f
      mov     r5, DSP_CTRL_DISABLED_ALL
      sr      r5, [ARC_AUX_DSP_CTRL]
 1:
+#endif
 .endm
 
 /* clobbers r10, r11 registers pair */

---
Eugeniy Paltsev

#3 lore raw
Quoted 35 lines · Eugeniy Paltsev

Hi Vineet,

Quoted 26 lines

From: Vineet Gupta <[email protected]>
Sent: Tuesday, April 28, 2020 22:46
To: Eugeniy Paltsev; [email protected]
Cc: Alexey Brodkin; [email protected]
Subject: Re: [PATCH] ARC: guard dsp early init against non ARCv2

Quoted 19 lines · Eugeniy Paltsev

As of today we guard early DSP init code with ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have CPU with DSP configured. However that's not enough as in ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC instructions presence.

So, let's guard DSP early init against non ARCv2.

---
 arch/arc/include/asm/dsp-impl.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arc/include/asm/dsp-impl.h +0 -0
index e1aa212ca6eb..e64d945ae7df 100644
@@ -15,12 +15,14 @@
 
Quoted 7 lines

arch/arc/include/asm/dsp-impl.h line 18

Quoted 3 lines
arch/arc/include/asm/dsp-impl.h +1 -0
 /* clobbers r5 register */
 .macro DSP_EARLY_INIT
+#if defined(CONFIG_ISA_ARCV2)

ifdef is the canonical way for a single macro to check.

Also, this needs to be finer grained, i.e. CONFIG_ARC_DSP_KERNEL which is already tied to ARCV2 only configs.

Quoted 7 lines

We shouldn't limit the scope of this code part [dsp early init] to the cases were DSP support is enabled in kconfig - and that is the reason why this code initially was guarded with BCR check only.

So, I change the check to

#if defined(CONFIG_ARC_DSP_HANDLED) || defined(CONFIG_ARC_DSP_NONE)

You are right. It needs to be disabled if the hardware exists independent of Kconfig.

Quoted 5 lines

which is actually the equivalent to

#if defined(CONFIG_ISA_ARCV2)

but I don't think it's worth thing to do.

Agree.

-Vineet

#4 lore raw
In reply to Eugeniy Paltsev

From: Eugeniy Paltsev <[email protected]>
Date: Apr/28/2020, 19:50:24 (UTC+00:00)

Quoted 9 lines

As of today we guard early DSP init code with ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have CPU with DSP configured. However that's not enough as in ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC instructions presence.

So, let's guard DSP early init against non ARCv2.

Reported-by: Angelo Ribeiro
<[email protected]>

---
Thanks,
Jose Miguel Abreu

Tested-by
#5 lore raw

Hi Eugeniy,

Tested okay on a ARCv1.

Thanks
Angelo

From: Jose Abreu <[email protected]>
Date: Wed, Apr 29, 2020 at 07:19:55

Quoted 19 lines

From: Eugeniy Paltsev <[email protected]>
Date: Apr/28/2020, 19:50:24 (UTC+00:00)

Quoted 9 lines

As of today we guard early DSP init code with ARC_AUX_DSP_BUILD (0x7A) BCR check to verify that we have CPU with DSP configured. However that's not enough as in ARCv1 CPU the same BCR (0x7A) is used for checking MUL/MAC instructions presence.

So, let's guard DSP early init against non ARCv2.

Reported-by: Angelo Ribeiro
<[email protected]>

---
Thanks,
Jose Miguel Abreu