Skip to contentSkip to conversation

staging/atomisp: reduce load_primary_binaries() stack usage

PATCH In review Arnd Bergmann 3 participants 3 messages Mar 25 – May 20

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging/atomisp: reduce load_primary_binaries() stack usage

From: Arnd Bergmann <[email protected]>

The load_primary_binaries() function is overly complex and has som large variables on the stack, which can cause warnings depending on CONFIG_FRAME_WARN setting:

drivers/staging/media/atomisp/pci/sh_css.c: In function 'load_primary_binaries':
drivers/staging/media/atomisp/pci/sh_css.c:5260:1: error: the frame size of 1560 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

Half of the stack usage is for the prim_descr[] array, but only one member of the array is used at any given time.

Reduce the stack usage by turning the array into a single structure.

Fixes a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2")
---
 drivers/staging/media/atomisp/pci/sh_css.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/media/atomisp/pci/sh_css.c +3 -3
index 6cda5925fa45..584751516b69 100644
@@ -5020,7 +5020,6 @@ static int load_primary_binaries(
 	struct ia_css_capture_settings *mycs;
 	unsigned int i;
 	bool need_extra_yuv_scaler = false;
-	struct ia_css_binary_descr prim_descr[MAX_NUM_PRIMARY_STAGES];
 
 	IA_CSS_ENTER_PRIVATE("");
 	assert(pipe);
@@ -5189,15 +5188,16 @@ static int load_primary_binaries(
 
 	/* Primary */
 	for (i = 0; i < mycs->num_primary_stage; i++) {
+		struct ia_css_binary_descr prim_descr;
 		struct ia_css_frame_info *local_vf_info = NULL;
 
 		if (pipe->enable_viewfinder[IA_CSS_PIPE_OUTPUT_STAGE_0] &&
 		    (i == mycs->num_primary_stage - 1))
 			local_vf_info = &vf_info;
-		ia_css_pipe_get_primary_binarydesc(pipe, &prim_descr[i],
+		ia_css_pipe_get_primary_binarydesc(pipe, &prim_descr,
 						   &prim_in_info, &prim_out_info,
 						   local_vf_info, i);
-		err = ia_css_binary_find(&prim_descr[i], &mycs->primary_binary[i]);
+		err = ia_css_binary_find(&prim_descr, &mycs->primary_binary[i]);
 		if (err) {
 			IA_CSS_LEAVE_ERR_PRIVATE(err);
 			return err;
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 1 line · Arnd Bergmann

The load_primary_binaries() function is overly complex and has som large

some

Quoted 10 lines

variables on the stack, which can cause warnings depending on CONFIG_FRAME_WARN setting:

drivers/staging/media/atomisp/pci/sh_css.c: In function 'load_primary_binaries':
drivers/staging/media/atomisp/pci/sh_css.c:5260:1: error: the frame size of 1560 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

Half of the stack usage is for the prim_descr[] array, but only one member of the array is used at any given time.

Reduce the stack usage by turning the array into a single structure.

Makes sense,

*I think the original idea was to construct some chains out of the firmware blobs and provide run-time combinations of them, but IIRC that was never implemented.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
reviewer
#2 lore raw
Quoted 15 lines · Andy Shevchenko
Quoted 1 line · Arnd Bergmann

The load_primary_binaries() function is overly complex and has som large

some

Quoted 9 lines

variables on the stack, which can cause warnings depending on CONFIG_FRAME_WARN setting:

drivers/staging/media/atomisp/pci/sh_css.c: In function 'load_primary_binaries':
drivers/staging/media/atomisp/pci/sh_css.c:5260:1: error: the frame size of 1560 bytes is larger than 1536 bytes [-Werror=frame-larger-than=]

Half of the stack usage is for the prim_descr[] array, but only one member of the array is used at any given time.

Quoted 8 lines
Quoted 1 line

Reduce the stack usage by turning the array into a single structure.

Makes sense,

*I think the original idea was to construct some chains out of the firmware blobs and provide run-time combinations of them, but IIRC that was never implemented.

Thanks.

I'll add Cc: stable to make CI happy and this can't hurt in the stable trees anyway.

Signature · 1 line
Sakari Ailus