public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging/atomisp: reduce load_primary_binaries() stack usage
@ 2026-03-25 12:59 Arnd Bergmann
  2026-03-26 10:44 ` Andy Shevchenko
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-03-25 12:59 UTC (permalink / raw)
  To: Andy Shevchenko, Hans de Goede, Mauro Carvalho Chehab,
	Greg Kroah-Hartman, Alan Cox
  Cc: Arnd Bergmann, Sakari Ailus, Kees Cook, linux-media, linux-kernel,
	linux-staging

From: Arnd Bergmann <arnd@arndb.de>

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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/staging/media/atomisp/pci/sh_css.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/sh_css.c b/drivers/staging/media/atomisp/pci/sh_css.c
index 6cda5925fa45..584751516b69 100644
--- a/drivers/staging/media/atomisp/pci/sh_css.c
+++ b/drivers/staging/media/atomisp/pci/sh_css.c
@@ -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;
-- 
2.39.5


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

* Re: [PATCH] staging/atomisp: reduce load_primary_binaries() stack usage
  2026-03-25 12:59 [PATCH] staging/atomisp: reduce load_primary_binaries() stack usage Arnd Bergmann
@ 2026-03-26 10:44 ` Andy Shevchenko
  0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2026-03-26 10:44 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Andy Shevchenko, Hans de Goede, Mauro Carvalho Chehab,
	Greg Kroah-Hartman, Alan Cox, Arnd Bergmann, Sakari Ailus,
	Kees Cook, linux-media, linux-kernel, linux-staging

On Wed, Mar 25, 2026 at 01:59:43PM +0100, Arnd Bergmann wrote:

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

some

> 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,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>

*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.

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2026-03-26 10:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-25 12:59 [PATCH] staging/atomisp: reduce load_primary_binaries() stack usage Arnd Bergmann
2026-03-26 10:44 ` Andy Shevchenko

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