public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] riscv: alternative-macros.h cleanups
@ 2022-11-29 15:00 Andrew Jones
  2022-11-29 15:00 ` [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Andrew Jones
                   ` (6 more replies)
  0 siblings, 7 replies; 14+ messages in thread
From: Andrew Jones @ 2022-11-29 15:00 UTC (permalink / raw)
  To: linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Conor Dooley, Lad Prabhakar, prabhakar.csengg

This series is a collection of cleanups for alternative-macros.h with
the main motivation being that adding new ALTERNATIVE_3, ALTERNATIVE_4,
... will be possible without lots of bloat. For example, adding
ALTERNATIVE_3 should look something like the diff below and
ALTERNATIVE_4 the same. This has really only been compile tested, as
not all alternatives are used when quickly booting over QEMU, which
I also did.

Thanks,
drew

diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
index 7226e2462584..be9a09313499 100644
--- a/arch/riscv/include/asm/alternative-macros.h
+++ b/arch/riscv/include/asm/alternative-macros.h
@@ -50,8 +50,17 @@
 	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
 .endm
 
+.macro ALTERNATIVE_CFG_3 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,		\
+				new_c_2, vendor_id_2, errata_id_2, enable_2,		\
+				new_c_3, vendor_id_3, errata_id_3, enable_3
+	ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1,	\
+				  \new_c_2, \vendor_id_2, \errata_id_2, \enable_2
+	ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3
+.endm
+
 #define __ALTERNATIVE_CFG(...)		ALTERNATIVE_CFG __VA_ARGS__
 #define __ALTERNATIVE_CFG_2(...)	ALTERNATIVE_CFG_2 __VA_ARGS__
+#define __ALTERNATIVE_CFG_3(...)	ALTERNATIVE_CFG_3 __VA_ARGS__
 
 #else /* !__ASSEMBLY__ */
 
@@ -98,6 +107,13 @@
 	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1)	\
 	ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
 
+#define __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
+				   new_c_2, vendor_id_2, errata_id_2, enable_2,	\
+				   new_c_3, vendor_id_3, errata_id_3, enable_3)	\
+	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
+				   new_c_2, vendor_id_2, errata_id_2, enable_2)	\
+	ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3)
+
 #endif /* __ASSEMBLY__ */
 
 #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k)	\
@@ -108,6 +124,13 @@
 	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),	\
 				   new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
 
+#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1,	errata_id_1, CONFIG_k_1,		\
+				  new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2,		\
+				  new_c_3, vendor_id_3,	errata_id_3, CONFIG_k_3)		\
+	__ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),	\
+				   new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2),	\
+				   new_c_3, vendor_id_3, errata_id_3, IS_ENABLED(CONFIG_k_3))
+
 #else /* CONFIG_RISCV_ALTERNATIVE */
 #ifdef __ASSEMBLY__
 
@@ -121,6 +144,9 @@
 #define _ALTERNATIVE_CFG_2(old_c, ...)	\
 	ALTERNATIVE_CFG old_c
 
+#define _ALTERNATIVE_CFG_3(old_c, ...)	\
+	ALTERNATIVE_CFG old_c
+
 #else /* !__ASSEMBLY__ */
 
 #define __ALTERNATIVE_CFG(old_c)	\
@@ -132,6 +158,9 @@
 #define _ALTERNATIVE_CFG_2(old_c, ...)	\
 	__ALTERNATIVE_CFG(old_c)
 
+#define _ALTERNATIVE_CFG_3(old_c, ...)	\
+	__ALTERNATIVE_CFG(old_c)
+
 #endif /* __ASSEMBLY__ */
 #endif /* CONFIG_RISCV_ALTERNATIVE */
 
@@ -163,4 +192,11 @@
 	_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,	\
 					new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
 
+#define ALTERNATIVE_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,		\
+				   new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2,		\
+				   new_content_3, vendor_id_3, errata_id_3, CONFIG_k_3)		\
+	_ALTERNATIVE_CFG_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,	\
+					new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2,	\
+					new_content_3, vendor_id_3, errata_id_3, CONFIG_k_3)
+
 #endif

Andrew Jones (4):
  riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
  riscv: alternatives: Don't name unused macro parameters
  riscv: alternatives: Drop the underscores from the assembly macro
    names
  riscv: Don't duplicate _ALTERNATIVE_CFG* macros

 arch/riscv/include/asm/alternative-macros.h | 99 +++++++--------------
 1 file changed, 30 insertions(+), 69 deletions(-)

-- 
2.38.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
@ 2022-11-29 15:00 ` Andrew Jones
  2022-11-30  9:31   ` Heiko Stübner
  2022-12-10  4:20   ` patchwork-bot+linux-riscv
  2022-11-29 15:00 ` [PATCH v2 2/4] riscv: alternatives: Don't name unused macro parameters Andrew Jones
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 14+ messages in thread
From: Andrew Jones @ 2022-11-29 15:00 UTC (permalink / raw)
  To: linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Conor Dooley, Lad Prabhakar, prabhakar.csengg

Build __ALTERNATIVE_CFG_2 by adding on to __ALTERNATIVE_CFG rather
than duplicating it.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/include/asm/alternative-macros.h | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
index ec2f3f1b836f..c7036166af2c 100644
--- a/arch/riscv/include/asm/alternative-macros.h
+++ b/arch/riscv/include/asm/alternative-macros.h
@@ -49,14 +49,7 @@
 
 .macro __ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
 				  new_c_2, vendor_id_2, errata_id_2, enable_2
-886 :
-	.option push
-	.option norvc
-	.option norelax
-	\old_c
-	.option pop
-887 :
-	ALT_NEW_CONTENT \vendor_id_1, \errata_id_1, \enable_1, \new_c_1
+	__ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
 	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
 .endm
 
@@ -116,14 +109,7 @@
 					enable_1,			\
 				   new_c_2, vendor_id_2, errata_id_2,	\
 					enable_2)			\
-	"886 :\n"							\
-	".option push\n"						\
-	".option norvc\n"						\
-	".option norelax\n"						\
-	old_c "\n"							\
-	".option pop\n"							\
-	"887 :\n"							\
-	ALT_NEW_CONTENT(vendor_id_1, errata_id_1, enable_1, new_c_1)	\
+	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \
 	ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
 
 #define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-- 
2.38.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH v2 2/4] riscv: alternatives: Don't name unused macro parameters
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
  2022-11-29 15:00 ` [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Andrew Jones
@ 2022-11-29 15:00 ` Andrew Jones
  2022-11-30  9:37   ` Heiko Stübner
  2022-11-29 15:00 ` [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names Andrew Jones
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Andrew Jones @ 2022-11-29 15:00 UTC (permalink / raw)
  To: linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Conor Dooley, Lad Prabhakar, prabhakar.csengg

Without CONFIG_RISCV_ALTERNATIVE only the first parameter of the
ALTERNATIVE macros is needed. Use ... for the rest to cut down on
clutter. While there, fix a couple space vs. tab issues.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/include/asm/alternative-macros.h | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
index c7036166af2c..7cc2b587c5c4 100644
--- a/arch/riscv/include/asm/alternative-macros.h
+++ b/arch/riscv/include/asm/alternative-macros.h
@@ -130,28 +130,22 @@
 	\old_c
 .endm
 
-#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
+#define _ALTERNATIVE_CFG(old_c, ...)	\
 	__ALTERNATIVE_CFG old_c
 
-#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					CONFIG_k_1,			\
-				  new_c_2, vendor_id_2, errata_id_2,	\
-					CONFIG_k_2)			\
-       __ALTERNATIVE_CFG old_c
+#define _ALTERNATIVE_CFG_2(old_c, ...)	\
+	__ALTERNATIVE_CFG old_c
 
 #else /* !__ASSEMBLY__ */
 
-#define __ALTERNATIVE_CFG(old_c)  \
+#define __ALTERNATIVE_CFG(old_c)	\
 	old_c "\n"
 
-#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
+#define _ALTERNATIVE_CFG(old_c, ...)	\
 	__ALTERNATIVE_CFG(old_c)
 
-#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					CONFIG_k_1,			\
-				  new_c_2, vendor_id_2, errata_id_2,	\
-					CONFIG_k_2) \
-       __ALTERNATIVE_CFG(old_c)
+#define _ALTERNATIVE_CFG_2(old_c, ...)	\
+	__ALTERNATIVE_CFG(old_c)
 
 #endif /* __ASSEMBLY__ */
 #endif /* CONFIG_RISCV_ALTERNATIVE */
-- 
2.38.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
  2022-11-29 15:00 ` [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Andrew Jones
  2022-11-29 15:00 ` [PATCH v2 2/4] riscv: alternatives: Don't name unused macro parameters Andrew Jones
@ 2022-11-29 15:00 ` Andrew Jones
  2022-11-30 10:06   ` Heiko Stübner
  2022-11-29 15:00 ` [PATCH v2 4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros Andrew Jones
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Andrew Jones @ 2022-11-29 15:00 UTC (permalink / raw)
  To: linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Conor Dooley, Lad Prabhakar, prabhakar.csengg

The underscores aren't needed because there isn't anything already
named without them and the _CFG extension. This is a bit of a cleanup
by itself, but the real motivation is for a coming patch which would
otherwise need to add two more underscores to these macro names,
i.e. ____ALTERNATIVE_CFG, and that'd be gross.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/include/asm/alternative-macros.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
index 7cc2b587c5c4..9ea95331a280 100644
--- a/arch/riscv/include/asm/alternative-macros.h
+++ b/arch/riscv/include/asm/alternative-macros.h
@@ -33,7 +33,7 @@
 	.endif
 .endm
 
-.macro __ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
+.macro ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
 886 :
 	.option push
 	.option norvc
@@ -45,11 +45,11 @@
 .endm
 
 #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
-	__ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
+	ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
 
-.macro __ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
-				  new_c_2, vendor_id_2, errata_id_2, enable_2
-	__ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
+.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
+				new_c_2, vendor_id_2, errata_id_2, enable_2
+	ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
 	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
 .endm
 
@@ -57,9 +57,9 @@
 					CONFIG_k_1,			\
 				  new_c_2, vendor_id_2, errata_id_2,	\
 					CONFIG_k_2)			\
-	__ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
+	ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
 					IS_ENABLED(CONFIG_k_1),		\
-				   new_c_2, vendor_id_2, errata_id_2,	\
+				 new_c_2, vendor_id_2, errata_id_2,	\
 					IS_ENABLED(CONFIG_k_2)
 
 #else /* !__ASSEMBLY__ */
@@ -126,15 +126,15 @@
 #else /* CONFIG_RISCV_ALTERNATIVE */
 #ifdef __ASSEMBLY__
 
-.macro __ALTERNATIVE_CFG old_c
+.macro ALTERNATIVE_CFG old_c
 	\old_c
 .endm
 
 #define _ALTERNATIVE_CFG(old_c, ...)	\
-	__ALTERNATIVE_CFG old_c
+	ALTERNATIVE_CFG old_c
 
 #define _ALTERNATIVE_CFG_2(old_c, ...)	\
-	__ALTERNATIVE_CFG old_c
+	ALTERNATIVE_CFG old_c
 
 #else /* !__ASSEMBLY__ */
 
-- 
2.38.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* [PATCH v2 4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
                   ` (2 preceding siblings ...)
  2022-11-29 15:00 ` [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names Andrew Jones
@ 2022-11-29 15:00 ` Andrew Jones
  2022-11-30 10:07   ` Heiko Stübner
  2022-11-30 12:06 ` [PATCH v2 0/4] riscv: alternative-macros.h cleanups Lad, Prabhakar
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 14+ messages in thread
From: Andrew Jones @ 2022-11-29 15:00 UTC (permalink / raw)
  To: linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Heiko Stuebner,
	Conor Dooley, Lad Prabhakar, prabhakar.csengg

Reduce clutter by only defining the _ALTERNATIVE_CFG* macros once,
rather than once for assembly and once for C. To do that, we need to
add __ALTERNATIVE_CFG* macros to the assembly side, but those are
one-liners. Also take the opportunity to do a bit of reformatting,
taking full advantage of the fact checkpatch gives us 100 char lines.

Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
 arch/riscv/include/asm/alternative-macros.h | 53 +++++++--------------
 1 file changed, 17 insertions(+), 36 deletions(-)

diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
index 9ea95331a280..7226e2462584 100644
--- a/arch/riscv/include/asm/alternative-macros.h
+++ b/arch/riscv/include/asm/alternative-macros.h
@@ -44,23 +44,14 @@
 	ALT_NEW_CONTENT \vendor_id, \errata_id, \enable, \new_c
 .endm
 
-#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
-	ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
-
 .macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
 				new_c_2, vendor_id_2, errata_id_2, enable_2
 	ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
 	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
 .endm
 
-#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					CONFIG_k_1,			\
-				  new_c_2, vendor_id_2, errata_id_2,	\
-					CONFIG_k_2)			\
-	ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					IS_ENABLED(CONFIG_k_1),		\
-				 new_c_2, vendor_id_2, errata_id_2,	\
-					IS_ENABLED(CONFIG_k_2)
+#define __ALTERNATIVE_CFG(...)		ALTERNATIVE_CFG __VA_ARGS__
+#define __ALTERNATIVE_CFG_2(...)	ALTERNATIVE_CFG_2 __VA_ARGS__
 
 #else /* !__ASSEMBLY__ */
 
@@ -102,27 +93,21 @@
 	"887 :\n"							\
 	ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c)
 
-#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k)	\
-	__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
-
-#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					enable_1,			\
-				   new_c_2, vendor_id_2, errata_id_2,	\
-					enable_2)			\
-	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \
+#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
+				   new_c_2, vendor_id_2, errata_id_2, enable_2)	\
+	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1)	\
 	ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
 
-#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					CONFIG_k_1,			\
-				  new_c_2, vendor_id_2, errata_id_2,	\
-					CONFIG_k_2)			\
-	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
-					IS_ENABLED(CONFIG_k_1),		\
-				   new_c_2, vendor_id_2, errata_id_2,	\
-					IS_ENABLED(CONFIG_k_2))
-
 #endif /* __ASSEMBLY__ */
 
+#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k)	\
+	__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
+
+#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, CONFIG_k_1,		\
+				  new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2)		\
+	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),	\
+				   new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
+
 #else /* CONFIG_RISCV_ALTERNATIVE */
 #ifdef __ASSEMBLY__
 
@@ -173,13 +158,9 @@
  * on the following sample code and then replace ALTERNATIVE() with
  * ALTERNATIVE_2() to append its customized content.
  */
-#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1,		\
-					errata_id_1, CONFIG_k_1,	\
-				   new_content_2, vendor_id_2,		\
-					errata_id_2, CONFIG_k_2)	\
-	_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1,	\
-					    errata_id_1, CONFIG_k_1,	\
-					new_content_2, vendor_id_2,	\
-					    errata_id_2, CONFIG_k_2)
+#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,		\
+				   new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)		\
+	_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,	\
+					new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
 
 #endif
-- 
2.38.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
  2022-11-29 15:00 ` [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Andrew Jones
@ 2022-11-30  9:31   ` Heiko Stübner
  2022-12-10  4:20   ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 14+ messages in thread
From: Heiko Stübner @ 2022-11-30  9:31 UTC (permalink / raw)
  To: linux-riscv
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Conor Dooley,
	Lad Prabhakar, prabhakar.csengg, Andrew Jones

Am Dienstag, 29. November 2022, 16:00:50 CET schrieb Andrew Jones:
> Build __ALTERNATIVE_CFG_2 by adding on to __ALTERNATIVE_CFG rather
> than duplicating it.
> 
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>

Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>




_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 2/4] riscv: alternatives: Don't name unused macro parameters
  2022-11-29 15:00 ` [PATCH v2 2/4] riscv: alternatives: Don't name unused macro parameters Andrew Jones
@ 2022-11-30  9:37   ` Heiko Stübner
  0 siblings, 0 replies; 14+ messages in thread
From: Heiko Stübner @ 2022-11-30  9:37 UTC (permalink / raw)
  To: linux-riscv, Andrew Jones
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Conor Dooley,
	Lad Prabhakar, prabhakar.csengg

Am Dienstag, 29. November 2022, 16:00:51 CET schrieb Andrew Jones:
> Without CONFIG_RISCV_ALTERNATIVE only the first parameter of the
> ALTERNATIVE macros is needed. Use ... for the rest to cut down on
> clutter. While there, fix a couple space vs. tab issues.
> 
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>

Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>




_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names
  2022-11-29 15:00 ` [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names Andrew Jones
@ 2022-11-30 10:06   ` Heiko Stübner
  2022-11-30 11:27     ` Andrew Jones
  0 siblings, 1 reply; 14+ messages in thread
From: Heiko Stübner @ 2022-11-30 10:06 UTC (permalink / raw)
  To: linux-riscv, Andrew Jones
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Conor Dooley,
	Lad Prabhakar, prabhakar.csengg

Am Dienstag, 29. November 2022, 16:00:52 CET schrieb Andrew Jones:
> The underscores aren't needed because there isn't anything already
> named without them and the _CFG extension. This is a bit of a cleanup
> by itself, but the real motivation is for a coming patch which would
> otherwise need to add two more underscores to these macro names,
> i.e. ____ALTERNATIVE_CFG, and that'd be gross.
> 
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>

Hmm, I would assume the "_" are there to mark those as
"internal / don't use". So with removing the underscores
you loose that marking.

It works though, so
Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>

But I'll leave the judgement on its viability to others.

Heiko

> ---
>  arch/riscv/include/asm/alternative-macros.h | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
> index 7cc2b587c5c4..9ea95331a280 100644
> --- a/arch/riscv/include/asm/alternative-macros.h
> +++ b/arch/riscv/include/asm/alternative-macros.h
> @@ -33,7 +33,7 @@
>  	.endif
>  .endm
>  
> -.macro __ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
> +.macro ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
>  886 :
>  	.option push
>  	.option norvc
> @@ -45,11 +45,11 @@
>  .endm
>  
>  #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
> -	__ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
> +	ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
>  
> -.macro __ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
> -				  new_c_2, vendor_id_2, errata_id_2, enable_2
> -	__ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
> +.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
> +				new_c_2, vendor_id_2, errata_id_2, enable_2
> +	ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
>  	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
>  .endm
>  
> @@ -57,9 +57,9 @@
>  					CONFIG_k_1,			\
>  				  new_c_2, vendor_id_2, errata_id_2,	\
>  					CONFIG_k_2)			\
> -	__ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
> +	ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
>  					IS_ENABLED(CONFIG_k_1),		\
> -				   new_c_2, vendor_id_2, errata_id_2,	\
> +				 new_c_2, vendor_id_2, errata_id_2,	\
>  					IS_ENABLED(CONFIG_k_2)
>  
>  #else /* !__ASSEMBLY__ */
> @@ -126,15 +126,15 @@
>  #else /* CONFIG_RISCV_ALTERNATIVE */
>  #ifdef __ASSEMBLY__
>  
> -.macro __ALTERNATIVE_CFG old_c
> +.macro ALTERNATIVE_CFG old_c
>  	\old_c
>  .endm
>  
>  #define _ALTERNATIVE_CFG(old_c, ...)	\
> -	__ALTERNATIVE_CFG old_c
> +	ALTERNATIVE_CFG old_c
>  
>  #define _ALTERNATIVE_CFG_2(old_c, ...)	\
> -	__ALTERNATIVE_CFG old_c
> +	ALTERNATIVE_CFG old_c
>  
>  #else /* !__ASSEMBLY__ */
>  
> 





_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros
  2022-11-29 15:00 ` [PATCH v2 4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros Andrew Jones
@ 2022-11-30 10:07   ` Heiko Stübner
  0 siblings, 0 replies; 14+ messages in thread
From: Heiko Stübner @ 2022-11-30 10:07 UTC (permalink / raw)
  To: linux-riscv, Andrew Jones
  Cc: Paul Walmsley, Palmer Dabbelt, Albert Ou, Conor Dooley,
	Lad Prabhakar, prabhakar.csengg

Am Dienstag, 29. November 2022, 16:00:53 CET schrieb Andrew Jones:
> Reduce clutter by only defining the _ALTERNATIVE_CFG* macros once,
> rather than once for assembly and once for C. To do that, we need to
> add __ALTERNATIVE_CFG* macros to the assembly side, but those are
> one-liners. Also take the opportunity to do a bit of reformatting,
> taking full advantage of the fact checkpatch gives us 100 char lines.
> 
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>

As this depends on patch3,

Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>

But I'll leave the judgement on its viability to others.


Heiko

> ---
>  arch/riscv/include/asm/alternative-macros.h | 53 +++++++--------------
>  1 file changed, 17 insertions(+), 36 deletions(-)
> 
> diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
> index 9ea95331a280..7226e2462584 100644
> --- a/arch/riscv/include/asm/alternative-macros.h
> +++ b/arch/riscv/include/asm/alternative-macros.h
> @@ -44,23 +44,14 @@
>  	ALT_NEW_CONTENT \vendor_id, \errata_id, \enable, \new_c
>  .endm
>  
> -#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
> -	ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
> -
>  .macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
>  				new_c_2, vendor_id_2, errata_id_2, enable_2
>  	ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
>  	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
>  .endm
>  
> -#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
> -					CONFIG_k_1,			\
> -				  new_c_2, vendor_id_2, errata_id_2,	\
> -					CONFIG_k_2)			\
> -	ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
> -					IS_ENABLED(CONFIG_k_1),		\
> -				 new_c_2, vendor_id_2, errata_id_2,	\
> -					IS_ENABLED(CONFIG_k_2)
> +#define __ALTERNATIVE_CFG(...)		ALTERNATIVE_CFG __VA_ARGS__
> +#define __ALTERNATIVE_CFG_2(...)	ALTERNATIVE_CFG_2 __VA_ARGS__
>  
>  #else /* !__ASSEMBLY__ */
>  
> @@ -102,27 +93,21 @@
>  	"887 :\n"							\
>  	ALT_NEW_CONTENT(vendor_id, errata_id, enable, new_c)
>  
> -#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k)	\
> -	__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
> -
> -#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
> -					enable_1,			\
> -				   new_c_2, vendor_id_2, errata_id_2,	\
> -					enable_2)			\
> -	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1) \
> +#define __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
> +				   new_c_2, vendor_id_2, errata_id_2, enable_2)	\
> +	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1)	\
>  	ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
>  
> -#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
> -					CONFIG_k_1,			\
> -				  new_c_2, vendor_id_2, errata_id_2,	\
> -					CONFIG_k_2)			\
> -	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1,	\
> -					IS_ENABLED(CONFIG_k_1),		\
> -				   new_c_2, vendor_id_2, errata_id_2,	\
> -					IS_ENABLED(CONFIG_k_2))
> -
>  #endif /* __ASSEMBLY__ */
>  
> +#define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k)	\
> +	__ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k))
> +
> +#define _ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, CONFIG_k_1,		\
> +				  new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2)		\
> +	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),	\
> +				   new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
> +
>  #else /* CONFIG_RISCV_ALTERNATIVE */
>  #ifdef __ASSEMBLY__
>  
> @@ -173,13 +158,9 @@
>   * on the following sample code and then replace ALTERNATIVE() with
>   * ALTERNATIVE_2() to append its customized content.
>   */
> -#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1,		\
> -					errata_id_1, CONFIG_k_1,	\
> -				   new_content_2, vendor_id_2,		\
> -					errata_id_2, CONFIG_k_2)	\
> -	_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1,	\
> -					    errata_id_1, CONFIG_k_1,	\
> -					new_content_2, vendor_id_2,	\
> -					    errata_id_2, CONFIG_k_2)
> +#define ALTERNATIVE_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,		\
> +				   new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)		\
> +	_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,	\
> +					new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
>  
>  #endif
> 





_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names
  2022-11-30 10:06   ` Heiko Stübner
@ 2022-11-30 11:27     ` Andrew Jones
  0 siblings, 0 replies; 14+ messages in thread
From: Andrew Jones @ 2022-11-30 11:27 UTC (permalink / raw)
  To: Heiko Stübner
  Cc: linux-riscv, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Conor Dooley, Lad Prabhakar, prabhakar.csengg

On Wed, Nov 30, 2022 at 11:06:27AM +0100, Heiko Stübner wrote:
> Am Dienstag, 29. November 2022, 16:00:52 CET schrieb Andrew Jones:
> > The underscores aren't needed because there isn't anything already
> > named without them and the _CFG extension. This is a bit of a cleanup
> > by itself, but the real motivation is for a coming patch which would
> > otherwise need to add two more underscores to these macro names,
> > i.e. ____ALTERNATIVE_CFG, and that'd be gross.
> > 
> > Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> 
> Hmm, I would assume the "_" are there to mark those as
> "internal / don't use". So with removing the underscores
> you loose that marking.

Yeah, that's usually the case, but here we also have ALT_ENTRY and
ALT_NEW_CONTENT macros which are also internal, but don't have
leading-underscore names.

> 
> It works though, so
> Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu>

Thanks,
drew

> 
> But I'll leave the judgement on its viability to others.
> 
> Heiko
> 
> > ---
> >  arch/riscv/include/asm/alternative-macros.h | 20 ++++++++++----------
> >  1 file changed, 10 insertions(+), 10 deletions(-)
> > 
> > diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
> > index 7cc2b587c5c4..9ea95331a280 100644
> > --- a/arch/riscv/include/asm/alternative-macros.h
> > +++ b/arch/riscv/include/asm/alternative-macros.h
> > @@ -33,7 +33,7 @@
> >  	.endif
> >  .endm
> >  
> > -.macro __ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
> > +.macro ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, enable
> >  886 :
> >  	.option push
> >  	.option norvc
> > @@ -45,11 +45,11 @@
> >  .endm
> >  
> >  #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
> > -	__ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
> > +	ALTERNATIVE_CFG old_c, new_c, vendor_id, errata_id, IS_ENABLED(CONFIG_k)
> >  
> > -.macro __ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
> > -				  new_c_2, vendor_id_2, errata_id_2, enable_2
> > -	__ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
> > +.macro ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
> > +				new_c_2, vendor_id_2, errata_id_2, enable_2
> > +	ALTERNATIVE_CFG \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1
> >  	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
> >  .endm
> >  
> > @@ -57,9 +57,9 @@
> >  					CONFIG_k_1,			\
> >  				  new_c_2, vendor_id_2, errata_id_2,	\
> >  					CONFIG_k_2)			\
> > -	__ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
> > +	ALTERNATIVE_CFG_2 old_c, new_c_1, vendor_id_1, errata_id_1,	\
> >  					IS_ENABLED(CONFIG_k_1),		\
> > -				   new_c_2, vendor_id_2, errata_id_2,	\
> > +				 new_c_2, vendor_id_2, errata_id_2,	\
> >  					IS_ENABLED(CONFIG_k_2)
> >  
> >  #else /* !__ASSEMBLY__ */
> > @@ -126,15 +126,15 @@
> >  #else /* CONFIG_RISCV_ALTERNATIVE */
> >  #ifdef __ASSEMBLY__
> >  
> > -.macro __ALTERNATIVE_CFG old_c
> > +.macro ALTERNATIVE_CFG old_c
> >  	\old_c
> >  .endm
> >  
> >  #define _ALTERNATIVE_CFG(old_c, ...)	\
> > -	__ALTERNATIVE_CFG old_c
> > +	ALTERNATIVE_CFG old_c
> >  
> >  #define _ALTERNATIVE_CFG_2(old_c, ...)	\
> > -	__ALTERNATIVE_CFG old_c
> > +	ALTERNATIVE_CFG old_c
> >  
> >  #else /* !__ASSEMBLY__ */
> >  
> > 
> 
> 
> 
> 

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 0/4] riscv: alternative-macros.h cleanups
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
                   ` (3 preceding siblings ...)
  2022-11-29 15:00 ` [PATCH v2 4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros Andrew Jones
@ 2022-11-30 12:06 ` Lad, Prabhakar
  2022-12-07 17:57 ` Conor Dooley
  2022-12-10  2:15 ` Palmer Dabbelt
  6 siblings, 0 replies; 14+ messages in thread
From: Lad, Prabhakar @ 2022-11-30 12:06 UTC (permalink / raw)
  To: Andrew Jones
  Cc: linux-riscv, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Heiko Stuebner, Conor Dooley, Lad Prabhakar

Hi Andrew,

On Tue, Nov 29, 2022 at 3:00 PM Andrew Jones <ajones@ventanamicro.com> wrote:
>
> This series is a collection of cleanups for alternative-macros.h with
> the main motivation being that adding new ALTERNATIVE_3, ALTERNATIVE_4,
> ... will be possible without lots of bloat. For example, adding
> ALTERNATIVE_3 should look something like the diff below and
> ALTERNATIVE_4 the same. This has really only been compile tested, as
> not all alternatives are used when quickly booting over QEMU, which
> I also did.
>
> Thanks,
> drew
>
> diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
> index 7226e2462584..be9a09313499 100644
> --- a/arch/riscv/include/asm/alternative-macros.h
> +++ b/arch/riscv/include/asm/alternative-macros.h
> @@ -50,8 +50,17 @@
>         ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
>  .endm
>
> +.macro ALTERNATIVE_CFG_3 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,           \
> +                               new_c_2, vendor_id_2, errata_id_2, enable_2,            \
> +                               new_c_3, vendor_id_3, errata_id_3, enable_3
> +       ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1,      \
> +                                 \new_c_2, \vendor_id_2, \errata_id_2, \enable_2
> +       ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3
> +.endm
> +
>  #define __ALTERNATIVE_CFG(...)         ALTERNATIVE_CFG __VA_ARGS__
>  #define __ALTERNATIVE_CFG_2(...)       ALTERNATIVE_CFG_2 __VA_ARGS__
> +#define __ALTERNATIVE_CFG_3(...)       ALTERNATIVE_CFG_3 __VA_ARGS__
>
>  #else /* !__ASSEMBLY__ */
>
> @@ -98,6 +107,13 @@
>         __ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1)   \
>         ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
>
> +#define __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,        \
> +                                  new_c_2, vendor_id_2, errata_id_2, enable_2, \
> +                                  new_c_3, vendor_id_3, errata_id_3, enable_3) \
> +       __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1, \
> +                                  new_c_2, vendor_id_2, errata_id_2, enable_2) \
> +       ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3)
> +
>  #endif /* __ASSEMBLY__ */
>
>  #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k) \
> @@ -108,6 +124,13 @@
>         __ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),   \
>                                    new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
>
> +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1,        errata_id_1, CONFIG_k_1,                \
> +                                 new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2,                \
> +                                 new_c_3, vendor_id_3, errata_id_3, CONFIG_k_3)                \
> +       __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),   \
> +                                  new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2),   \
> +                                  new_c_3, vendor_id_3, errata_id_3, IS_ENABLED(CONFIG_k_3))
> +
>  #else /* CONFIG_RISCV_ALTERNATIVE */
>  #ifdef __ASSEMBLY__
>
> @@ -121,6 +144,9 @@
>  #define _ALTERNATIVE_CFG_2(old_c, ...) \
>         ALTERNATIVE_CFG old_c
>
> +#define _ALTERNATIVE_CFG_3(old_c, ...) \
> +       ALTERNATIVE_CFG old_c
> +
>  #else /* !__ASSEMBLY__ */
>
>  #define __ALTERNATIVE_CFG(old_c)       \
> @@ -132,6 +158,9 @@
>  #define _ALTERNATIVE_CFG_2(old_c, ...) \
>         __ALTERNATIVE_CFG(old_c)
>
> +#define _ALTERNATIVE_CFG_3(old_c, ...) \
> +       __ALTERNATIVE_CFG(old_c)
> +
>  #endif /* __ASSEMBLY__ */
>  #endif /* CONFIG_RISCV_ALTERNATIVE */
>
> @@ -163,4 +192,11 @@
>         _ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,    \
>                                         new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
>
> +#define ALTERNATIVE_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,                \
> +                                  new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2,         \
> +                                  new_content_3, vendor_id_3, errata_id_3, CONFIG_k_3)         \
> +       _ALTERNATIVE_CFG_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,    \
> +                                       new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2,    \
> +                                       new_content_3, vendor_id_3, errata_id_3, CONFIG_k_3)
> +
>  #endif
>
> Andrew Jones (4):
>   riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
>   riscv: alternatives: Don't name unused macro parameters
>   riscv: alternatives: Drop the underscores from the assembly macro
>     names
>   riscv: Don't duplicate _ALTERNATIVE_CFG* macros
>
For the whole series:

Tested-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

Cheers,
Prabhakar

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 0/4] riscv: alternative-macros.h cleanups
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
                   ` (4 preceding siblings ...)
  2022-11-30 12:06 ` [PATCH v2 0/4] riscv: alternative-macros.h cleanups Lad, Prabhakar
@ 2022-12-07 17:57 ` Conor Dooley
  2022-12-10  2:15 ` Palmer Dabbelt
  6 siblings, 0 replies; 14+ messages in thread
From: Conor Dooley @ 2022-12-07 17:57 UTC (permalink / raw)
  To: Andrew Jones
  Cc: linux-riscv, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Heiko Stuebner, Conor Dooley, Lad Prabhakar, prabhakar.csengg


[-- Attachment #1.1: Type: text/plain, Size: 5416 bytes --]

On Tue, Nov 29, 2022 at 04:00:49PM +0100, Andrew Jones wrote:
> This series is a collection of cleanups for alternative-macros.h with
> the main motivation being that adding new ALTERNATIVE_3, ALTERNATIVE_4,
> ... will be possible without lots of bloat. For example, adding
> ALTERNATIVE_3 should look something like the diff below and
> ALTERNATIVE_4 the same. This has really only been compile tested, as
> not all alternatives are used when quickly booting over QEMU, which
> I also did.
> 
> Thanks,
> drew

I was trying to find the cover from patchwork - but it really hates this
diff for some reason and treats it like another patch... I dunno how you
would work around that, maybe put a -- line above the patch?

Anyways, what was going to say was that it'd be nice if you had the
inter-version changelog somewhere - especially for something touching
this neck of the woods. b4 diff to the rescue though, it is just the
missing \s from v1.

I'm kinda with Heiko in the "I'll leave the judgement on its viability
to others" camp, but I'm in favour of simplifying the process of adding
alternatives so:
Acked-by: Conor Dooley <conor.dooley@microchip.com>

Thanks,
Conor.

> 
> diff --git a/arch/riscv/include/asm/alternative-macros.h b/arch/riscv/include/asm/alternative-macros.h
> index 7226e2462584..be9a09313499 100644
> --- a/arch/riscv/include/asm/alternative-macros.h
> +++ b/arch/riscv/include/asm/alternative-macros.h
> @@ -50,8 +50,17 @@
>  	ALT_NEW_CONTENT \vendor_id_2, \errata_id_2, \enable_2, \new_c_2
>  .endm
>  
> +.macro ALTERNATIVE_CFG_3 old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,		\
> +				new_c_2, vendor_id_2, errata_id_2, enable_2,		\
> +				new_c_3, vendor_id_3, errata_id_3, enable_3
> +	ALTERNATIVE_CFG_2 \old_c, \new_c_1, \vendor_id_1, \errata_id_1, \enable_1,	\
> +				  \new_c_2, \vendor_id_2, \errata_id_2, \enable_2
> +	ALT_NEW_CONTENT \vendor_id_3, \errata_id_3, \enable_3, \new_c_3
> +.endm
> +
>  #define __ALTERNATIVE_CFG(...)		ALTERNATIVE_CFG __VA_ARGS__
>  #define __ALTERNATIVE_CFG_2(...)	ALTERNATIVE_CFG_2 __VA_ARGS__
> +#define __ALTERNATIVE_CFG_3(...)	ALTERNATIVE_CFG_3 __VA_ARGS__
>  
>  #else /* !__ASSEMBLY__ */
>  
> @@ -98,6 +107,13 @@
>  	__ALTERNATIVE_CFG(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1)	\
>  	ALT_NEW_CONTENT(vendor_id_2, errata_id_2, enable_2, new_c_2)
>  
> +#define __ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
> +				   new_c_2, vendor_id_2, errata_id_2, enable_2,	\
> +				   new_c_3, vendor_id_3, errata_id_3, enable_3)	\
> +	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, enable_1,	\
> +				   new_c_2, vendor_id_2, errata_id_2, enable_2)	\
> +	ALT_NEW_CONTENT(vendor_id_3, errata_id_3, enable_3, new_c_3)
> +
>  #endif /* __ASSEMBLY__ */
>  
>  #define _ALTERNATIVE_CFG(old_c, new_c, vendor_id, errata_id, CONFIG_k)	\
> @@ -108,6 +124,13 @@
>  	__ALTERNATIVE_CFG_2(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),	\
>  				   new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2))
>  
> +#define _ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1,	errata_id_1, CONFIG_k_1,		\
> +				  new_c_2, vendor_id_2, errata_id_2, CONFIG_k_2,		\
> +				  new_c_3, vendor_id_3,	errata_id_3, CONFIG_k_3)		\
> +	__ALTERNATIVE_CFG_3(old_c, new_c_1, vendor_id_1, errata_id_1, IS_ENABLED(CONFIG_k_1),	\
> +				   new_c_2, vendor_id_2, errata_id_2, IS_ENABLED(CONFIG_k_2),	\
> +				   new_c_3, vendor_id_3, errata_id_3, IS_ENABLED(CONFIG_k_3))
> +
>  #else /* CONFIG_RISCV_ALTERNATIVE */
>  #ifdef __ASSEMBLY__
>  
> @@ -121,6 +144,9 @@
>  #define _ALTERNATIVE_CFG_2(old_c, ...)	\
>  	ALTERNATIVE_CFG old_c
>  
> +#define _ALTERNATIVE_CFG_3(old_c, ...)	\
> +	ALTERNATIVE_CFG old_c
> +
>  #else /* !__ASSEMBLY__ */
>  
>  #define __ALTERNATIVE_CFG(old_c)	\
> @@ -132,6 +158,9 @@
>  #define _ALTERNATIVE_CFG_2(old_c, ...)	\
>  	__ALTERNATIVE_CFG(old_c)
>  
> +#define _ALTERNATIVE_CFG_3(old_c, ...)	\
> +	__ALTERNATIVE_CFG(old_c)
> +
>  #endif /* __ASSEMBLY__ */
>  #endif /* CONFIG_RISCV_ALTERNATIVE */
>  
> @@ -163,4 +192,11 @@
>  	_ALTERNATIVE_CFG_2(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,	\
>  					new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2)
>  
> +#define ALTERNATIVE_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,		\
> +				   new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2,		\
> +				   new_content_3, vendor_id_3, errata_id_3, CONFIG_k_3)		\
> +	_ALTERNATIVE_CFG_3(old_content, new_content_1, vendor_id_1, errata_id_1, CONFIG_k_1,	\
> +					new_content_2, vendor_id_2, errata_id_2, CONFIG_k_2,	\
> +					new_content_3, vendor_id_3, errata_id_3, CONFIG_k_3)
> +
>  #endif
> 
> Andrew Jones (4):
>   riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
>   riscv: alternatives: Don't name unused macro parameters
>   riscv: alternatives: Drop the underscores from the assembly macro
>     names
>   riscv: Don't duplicate _ALTERNATIVE_CFG* macros
> 
>  arch/riscv/include/asm/alternative-macros.h | 99 +++++++--------------
>  1 file changed, 30 insertions(+), 69 deletions(-)
> 
> -- 
> 2.38.1
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
> 

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

[-- Attachment #2: Type: text/plain, Size: 161 bytes --]

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 0/4] riscv: alternative-macros.h cleanups
  2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
                   ` (5 preceding siblings ...)
  2022-12-07 17:57 ` Conor Dooley
@ 2022-12-10  2:15 ` Palmer Dabbelt
  6 siblings, 0 replies; 14+ messages in thread
From: Palmer Dabbelt @ 2022-12-10  2:15 UTC (permalink / raw)
  To: linux-riscv, Andrew Jones
  Cc: Lad Prabhakar, Albert Ou, Conor Dooley, prabhakar.csengg,
	Palmer Dabbelt, Heiko Stuebner, Paul Walmsley

On Tue, 29 Nov 2022 16:00:49 +0100, Andrew Jones wrote:
> This series is a collection of cleanups for alternative-macros.h with
> the main motivation being that adding new ALTERNATIVE_3, ALTERNATIVE_4,
> ... will be possible without lots of bloat. For example, adding
> ALTERNATIVE_3 should look something like the diff below and
> ALTERNATIVE_4 the same. This has really only been compile tested, as
> not all alternatives are used when quickly booting over QEMU, which
> I also did.
> 
> [...]

Applied, thanks!

[0/4] riscv: alternative-macros.h cleanups
      https://git.kernel.org/palmer/c/a0b4c0f7a0a2
[1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
      https://git.kernel.org/palmer/c/2ba8c7dc71c0
[2/4] riscv: alternatives: Don't name unused macro parameters
      https://git.kernel.org/palmer/c/7d52eace1bf5
[3/4] riscv: alternatives: Drop the underscores from the assembly macro names
      https://git.kernel.org/palmer/c/bb2efcde5946
[4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros
      https://git.kernel.org/palmer/c/26fb4b90b745

Best regards,
-- 
Palmer Dabbelt <palmer@rivosinc.com>

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
  2022-11-29 15:00 ` [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Andrew Jones
  2022-11-30  9:31   ` Heiko Stübner
@ 2022-12-10  4:20   ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 14+ messages in thread
From: patchwork-bot+linux-riscv @ 2022-12-10  4:20 UTC (permalink / raw)
  To: Andrew Jones
  Cc: linux-riscv, paul.walmsley, palmer, aou, heiko, conor.dooley,
	prabhakar.mahadev-lad.rj, prabhakar.csengg

Hello:

This series was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Tue, 29 Nov 2022 16:00:50 +0100 you wrote:
> Build __ALTERNATIVE_CFG_2 by adding on to __ALTERNATIVE_CFG rather
> than duplicating it.
> 
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> ---
>  arch/riscv/include/asm/alternative-macros.h | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)

Here is the summary with links:
  - [v2,1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2
    https://git.kernel.org/riscv/c/2ba8c7dc71c0
  - [v2,2/4] riscv: alternatives: Don't name unused macro parameters
    https://git.kernel.org/riscv/c/7d52eace1bf5
  - [v2,3/4] riscv: alternatives: Drop the underscores from the assembly macro names
    https://git.kernel.org/riscv/c/bb2efcde5946
  - [v2,4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros
    https://git.kernel.org/riscv/c/26fb4b90b745

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2022-12-10  4:20 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29 15:00 [PATCH v2 0/4] riscv: alternative-macros.h cleanups Andrew Jones
2022-11-29 15:00 ` [PATCH v2 1/4] riscv: Don't duplicate __ALTERNATIVE_CFG in __ALTERNATIVE_CFG_2 Andrew Jones
2022-11-30  9:31   ` Heiko Stübner
2022-12-10  4:20   ` patchwork-bot+linux-riscv
2022-11-29 15:00 ` [PATCH v2 2/4] riscv: alternatives: Don't name unused macro parameters Andrew Jones
2022-11-30  9:37   ` Heiko Stübner
2022-11-29 15:00 ` [PATCH v2 3/4] riscv: alternatives: Drop the underscores from the assembly macro names Andrew Jones
2022-11-30 10:06   ` Heiko Stübner
2022-11-30 11:27     ` Andrew Jones
2022-11-29 15:00 ` [PATCH v2 4/4] riscv: Don't duplicate _ALTERNATIVE_CFG* macros Andrew Jones
2022-11-30 10:07   ` Heiko Stübner
2022-11-30 12:06 ` [PATCH v2 0/4] riscv: alternative-macros.h cleanups Lad, Prabhakar
2022-12-07 17:57 ` Conor Dooley
2022-12-10  2:15 ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox