Skip to contentSkip to conversation

drm/amdgpu/display: make various arrays static, makes object smaller

PATCH In review Colin King 3 participants 4 messages Oct 7, 2019 – Oct 8, 2019

Subsystems (4)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/amdgpu/display: make various arrays static, makes object smaller

From: Colin Ian King <[email protected]>

Don't populate the arrays on the stack but instead make them static. Makes the object code smaller by 158 bytes.

Before:

   text	   data	    bss	    dec	    hex	filename
  32468	   2072	      0	  34540	   86ec	display/dc/bios/bios_parser.o
  22198	   1088	      0	  23286	   5af6	display/dc/bios/bios_parser2.o
  22278	   1076	      0	  23354	   5b3a	display/dc/dce/dce_mem_input.o

81180
After:

   text	   data	    bss	    dec	    hex	filename
  32341	   2136	      0	  34477	   86ad	display/dc/bios/bios_parser.o
  22070	   1184	      0	  23254	   5ad6	display/dc/bios/bios_parser2.o
  22119	   1172	      0	  23291	   5afb	display/dc/dce/dce_mem_input.o

(gcc version 9.2.1, amd64)

---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser.c  | 2 +-
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 2 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +1 -1
index 221e0f56389f..65ab225cf542 100644
@@ -2745,7 +2745,7 @@ static enum bp_result bios_get_board_layout_info(
 	struct bios_parser *bp;
 	enum bp_result record_result;
 
-	const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
+	static const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1,
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2,
 		0, 0
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +1 -1
index dff65c0fe82f..809c4a89b899 100644
@@ -1832,7 +1832,7 @@ static enum bp_result bios_get_board_layout_info(
 	struct bios_parser *bp;
 	enum bp_result record_result;
 
-	const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
+	static const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1,
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2,
 		0, 0
drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c +1 -1
index 8aa937f496c4..ed0031d5e021 100644
@@ -395,7 +395,7 @@ static void program_size_and_rotation(
 {
 	const struct rect *in_rect = &plane_size->surface_size;
 	struct rect hw_rect = plane_size->surface_size;
-	const uint32_t rotation_angles[ROTATION_ANGLE_COUNT] = {
+	static const uint32_t rotation_angles[ROTATION_ANGLE_COUNT] = {
 			[ROTATION_ANGLE_0] = 0,
 			[ROTATION_ANGLE_90] = 1,
 			[ROTATION_ANGLE_180] = 2,
Signature · 1 line
2.20.1
#1 lore raw
Quoted 32 lines · Colin King

From: Colin Ian King <[email protected]>

Don't populate the arrays on the stack but instead make them static. Makes the object code smaller by 158 bytes.

Before:

   text	   data	    bss	    dec	    hex	filename
  32468	   2072	      0	  34540	   86ec	display/dc/bios/bios_parser.o
  22198	   1088	      0	  23286	   5af6	display/dc/bios/bios_parser2.o
  22278	   1076	      0	  23354	   5b3a	display/dc/dce/dce_mem_input.o

81180
After:

   text	   data	    bss	    dec	    hex	filename
  32341	   2136	      0	  34477	   86ad	display/dc/bios/bios_parser.o
  22070	   1184	      0	  23254	   5ad6	display/dc/bios/bios_parser2.o
  22119	   1172	      0	  23291	   5afb	display/dc/dce/dce_mem_input.o

(gcc version 9.2.1, amd64)

---
 drivers/gpu/drm/amd/display/dc/bios/bios_parser.c  | 2 +-
 drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c | 2 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +0 -0
index 221e0f56389f..65ab225cf542 100644

drivers/gpu/drm/amd/display/dc/bios/bios_parser.c static enum bp_result bios_get_board_layout_info( · line 2748

Quoted 5 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +1 -1
@@ -2745,7 +2745,7 @@ static enum bp_result bios_get_board_layout_info(
 	struct bios_parser *bp;
 	enum bp_result record_result;
 
-	const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
+	static const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {

Won't this break the multi-GPU case where you'll have multiple driver instances with different layout?

Harry

Quoted 22 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +0 -0
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1,
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2,
 		0, 0
drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c +1 -1
index dff65c0fe82f..809c4a89b899 100644
@@ -1832,7 +1832,7 @@ static enum bp_result bios_get_board_layout_info(
 	struct bios_parser *bp;
 	enum bp_result record_result;
 
-	const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
+	static const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID1,
 		GENERICOBJECT_BRACKET_LAYOUT_ENUM_ID2,
 		0, 0
drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c +0 -0
index 8aa937f496c4..ed0031d5e021 100644

drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c static void program_size_and_rotation( · line 401

Quoted 8 lines
drivers/gpu/drm/amd/display/dc/dce/dce_mem_input.c +1 -1
@@ -395,7 +395,7 @@ static void program_size_and_rotation(
 {
 	const struct rect *in_rect = &plane_size->surface_size;
 	struct rect hw_rect = plane_size->surface_size;
-	const uint32_t rotation_angles[ROTATION_ANGLE_COUNT] = {
+	static const uint32_t rotation_angles[ROTATION_ANGLE_COUNT] = {
 			[ROTATION_ANGLE_0] = 0,
 			[ROTATION_ANGLE_90] = 1,
 			[ROTATION_ANGLE_180] = 2,

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw

On Tue, 2019-10-08 at 13:56 +0000, Harry Wentland wrote:
[]

Quoted 11 lines

drivers/gpu/drm/amd/display/dc/bios/bios_parser.c

Quoted 1 line
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +0 -0

[]

drivers/gpu/drm/amd/display/dc/bios/bios_parser.c static enum bp_result bios_get_board_layout_info( · line 2748

Quoted 6 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +1 -1
@@ -2745,7 +2745,7 @@ static enum bp_result bios_get_board_layout_info(
 	struct bios_parser *bp;
 	enum bp_result record_result;
 
-	const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
+	static const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {

Won't this break the multi-GPU case where you'll have multiple driver instances with different layout?

As the array is read-only, how could that happen?

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by
#3 lore raw
Quoted 8 lines · Joe Perches

On Tue, 2019-10-08 at 13:56 +0000, Harry Wentland wrote:
[]

Quoted 6 lines

drivers/gpu/drm/amd/display/dc/bios/bios_parser.c

Quoted 1 line
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +0 -0

[]

Quoted 4 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +0 -0
@@ -2745,7 +2745,7 @@ static enum bp_result bios_get_board_layout_info(
 	struct bios_parser *bp;
 	enum bp_result record_result;
 
Quoted 8 lines
Quoted 5 lines

drivers/gpu/drm/amd/display/dc/bios/bios_parser.c static enum bp_result bios_get_board_layout_info( · line 2748

Quoted 2 lines
drivers/gpu/drm/amd/display/dc/bios/bios_parser.c +1 -1
-	const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {
+	static const unsigned int slot_index_to_vbios_id[MAX_BOARD_SLOTS] = {

Won't this break the multi-GPU case where you'll have multiple driver instances with different layout?

As the array is read-only, how could that happen?

You're right.

Patch is

Harry

Quoted 1 line

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx