diff mbox series

[v2,1/4] common/board_f: remove XTRN_DECLARE_GLOBAL_DATA_PTR dead code

Message ID 20220913183129.14184-1-ovpanait@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [v2,1/4] common/board_f: remove XTRN_DECLARE_GLOBAL_DATA_PTR dead code | expand

Commit Message

Ovidiu Panait Sept. 13, 2022, 6:31 p.m. UTC
The XTRN_DECLARE_GLOBAL_DATA_PTR declarations in ppc code are permanently
commented out, so there are no users for this macro:
 #if 1
   #define DECLARE_GLOBAL_DATA_PTR   register volatile gd_t *gd asm ("r2")
 #else /* We could use plain global data, but the resulting code is bigger */
   #define XTRN_DECLARE_GLOBAL_DATA_PTR   extern
   #define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR \
                                       gd_t *gd
 #endif

Remove all references to this macro, but add a documentation note regarding
the possibility of using plain global data for the GD pointer.

Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
---

Changes in v2:
- update global data documentation with the info provided by Wolfgang

 arch/powerpc/include/asm/global_data.h |  6 ------
 common/board_f.c                       | 11 -----------
 doc/develop/global_data.rst            |  5 +++++
 3 files changed, 5 insertions(+), 17 deletions(-)

Comments

Simon Glass Sept. 14, 2022, 5:09 p.m. UTC | #1
On Tue, 13 Sept 2022 at 12:31, Ovidiu Panait <ovpanait@gmail.com> wrote:
>
> The XTRN_DECLARE_GLOBAL_DATA_PTR declarations in ppc code are permanently
> commented out, so there are no users for this macro:
>  #if 1
>    #define DECLARE_GLOBAL_DATA_PTR   register volatile gd_t *gd asm ("r2")
>  #else /* We could use plain global data, but the resulting code is bigger */
>    #define XTRN_DECLARE_GLOBAL_DATA_PTR   extern
>    #define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR \
>                                        gd_t *gd
>  #endif
>
> Remove all references to this macro, but add a documentation note regarding
> the possibility of using plain global data for the GD pointer.
>
> Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
> ---
>
> Changes in v2:
> - update global data documentation with the info provided by Wolfgang
>
>  arch/powerpc/include/asm/global_data.h |  6 ------
>  common/board_f.c                       | 11 -----------
>  doc/develop/global_data.rst            |  5 +++++
>  3 files changed, 5 insertions(+), 17 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Sept. 14, 2022, 6:49 p.m. UTC | #2
On Tue, Sep 13, 2022 at 09:31:26PM +0300, Ovidiu Panait wrote:

> The XTRN_DECLARE_GLOBAL_DATA_PTR declarations in ppc code are permanently
> commented out, so there are no users for this macro:
>  #if 1
>    #define DECLARE_GLOBAL_DATA_PTR   register volatile gd_t *gd asm ("r2")
>  #else /* We could use plain global data, but the resulting code is bigger */
>    #define XTRN_DECLARE_GLOBAL_DATA_PTR   extern
>    #define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR \
>                                        gd_t *gd
>  #endif
> 
> Remove all references to this macro, but add a documentation note regarding
> the possibility of using plain global data for the GD pointer.
> 
> Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini Oct. 7, 2022, 3:49 p.m. UTC | #3
On Tue, Sep 13, 2022 at 09:31:26PM +0300, Ovidiu Panait wrote:

> The XTRN_DECLARE_GLOBAL_DATA_PTR declarations in ppc code are permanently
> commented out, so there are no users for this macro:
>  #if 1
>    #define DECLARE_GLOBAL_DATA_PTR   register volatile gd_t *gd asm ("r2")
>  #else /* We could use plain global data, but the resulting code is bigger */
>    #define XTRN_DECLARE_GLOBAL_DATA_PTR   extern
>    #define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR \
>                                        gd_t *gd
>  #endif
> 
> Remove all references to this macro, but add a documentation note regarding
> the possibility of using plain global data for the GD pointer.
> 
> Signed-off-by: Ovidiu Panait <ovpanait@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/global_data.h b/arch/powerpc/include/asm/global_data.h
index 6709e692e6..6ed21c781f 100644
--- a/arch/powerpc/include/asm/global_data.h
+++ b/arch/powerpc/include/asm/global_data.h
@@ -92,12 +92,6 @@  struct arch_global_data {
 
 #include <asm-generic/global_data.h>
 
-#if 1
 #define DECLARE_GLOBAL_DATA_PTR     register volatile gd_t *gd asm ("r2")
-#else /* We could use plain global data, but the resulting code is bigger */
-#define XTRN_DECLARE_GLOBAL_DATA_PTR	extern
-#define DECLARE_GLOBAL_DATA_PTR     XTRN_DECLARE_GLOBAL_DATA_PTR \
-				    gd_t *gd
-#endif
 
 #endif /* __ASM_GBL_DATA_H */
diff --git a/common/board_f.c b/common/board_f.c
index 18e2246733..f4238d4c90 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -57,18 +57,7 @@ 
 #include <dm/root.h>
 #include <linux/errno.h>
 
-/*
- * Pointer to initial global data area
- *
- * Here we initialize it if needed.
- */
-#ifdef XTRN_DECLARE_GLOBAL_DATA_PTR
-#undef	XTRN_DECLARE_GLOBAL_DATA_PTR
-#define XTRN_DECLARE_GLOBAL_DATA_PTR	/* empty = allocate here */
-DECLARE_GLOBAL_DATA_PTR = (gd_t *)(CONFIG_SYS_INIT_GD_ADDR);
-#else
 DECLARE_GLOBAL_DATA_PTR;
-#endif
 
 /*
  * TODO(sjg@chromium.org): IMO this code should be
diff --git a/doc/develop/global_data.rst b/doc/develop/global_data.rst
index 2ac893de49..d143f27eed 100644
--- a/doc/develop/global_data.rst
+++ b/doc/develop/global_data.rst
@@ -36,6 +36,11 @@  On most architectures the global data pointer is stored in a register.
 
 The sandbox, x86_64, and Xtensa are notable exceptions.
 
+Current implementation uses a register for the GD pointer because this results
+in smaller code. However, using plain global data for the GD pointer would be
+possible too (and simpler, as it does not require the reservation of a specific
+register for it), but the resulting code is bigger.
+
 Clang for ARM does not support assigning a global register. When using Clang
 gd is defined as an inline function using assembly code. This adds a few bytes
 to the code size.