media: staging: media: atomisp: fix stack overflow in init_pipe_defaults()
When building with clang, multiple copies of the structures to be
initialized are passed around on the stack and copied locally, using an
insane amount of stack space:
drivers/staging/media/atomisp/pci/sh_css.c:2371:1: error: stack frame size of 26864 bytes in function 'create_pipe' [-Werror,-Wframe-larger-than=]
Use constantly-allocated variables plus an explicit memcpy()
to avoid that.
Co-authored-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Fixes: 6dc9a2568f
("media: atomisp: convert default struct values to use compound-literals with designated initializers")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
5b552b198c
commit
89f3b3196e
|
@ -122,8 +122,7 @@ struct ia_css_frame_info {
|
||||||
struct ia_css_crop_info crop_info;
|
struct ia_css_crop_info crop_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_BINARY_DEFAULT_FRAME_INFO \
|
#define IA_CSS_BINARY_DEFAULT_FRAME_INFO { \
|
||||||
(struct ia_css_frame_info) { \
|
|
||||||
.format = IA_CSS_FRAME_FORMAT_NUM, \
|
.format = IA_CSS_FRAME_FORMAT_NUM, \
|
||||||
.raw_bayer_order = IA_CSS_BAYER_ORDER_NUM, \
|
.raw_bayer_order = IA_CSS_BAYER_ORDER_NUM, \
|
||||||
}
|
}
|
||||||
|
@ -185,8 +184,7 @@ struct ia_css_frame {
|
||||||
info.format */
|
info.format */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_FRAME \
|
#define DEFAULT_FRAME { \
|
||||||
(struct ia_css_frame) { \
|
|
||||||
.info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
.info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
||||||
.dynamic_queue_id = SH_CSS_INVALID_QUEUE_ID, \
|
.dynamic_queue_id = SH_CSS_INVALID_QUEUE_ID, \
|
||||||
.buf_type = IA_CSS_BUFFER_TYPE_INVALID, \
|
.buf_type = IA_CSS_BUFFER_TYPE_INVALID, \
|
||||||
|
|
|
@ -40,8 +40,7 @@ struct ia_css_preview_settings {
|
||||||
struct ia_css_pipe *acc_pipe;
|
struct ia_css_pipe *acc_pipe;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_DEFAULT_PREVIEW_SETTINGS \
|
#define IA_CSS_DEFAULT_PREVIEW_SETTINGS { \
|
||||||
(struct ia_css_preview_settings) { \
|
|
||||||
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
.preview_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.preview_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
.vf_pp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.vf_pp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
|
@ -65,8 +64,7 @@ struct ia_css_capture_settings {
|
||||||
unsigned int num_yuv_scaler;
|
unsigned int num_yuv_scaler;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_DEFAULT_CAPTURE_SETTINGS \
|
#define IA_CSS_DEFAULT_CAPTURE_SETTINGS { \
|
||||||
(struct ia_css_capture_settings) { \
|
|
||||||
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
.primary_binary = {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
|
.primary_binary = {IA_CSS_BINARY_DEFAULT_SETTINGS}, \
|
||||||
.pre_isp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.pre_isp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
|
@ -91,8 +89,7 @@ struct ia_css_video_settings {
|
||||||
unsigned int num_yuv_scaler;
|
unsigned int num_yuv_scaler;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_DEFAULT_VIDEO_SETTINGS \
|
#define IA_CSS_DEFAULT_VIDEO_SETTINGS { \
|
||||||
(struct ia_css_video_settings) { \
|
|
||||||
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
.video_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.video_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
.vf_pp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.vf_pp_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
|
@ -108,8 +105,7 @@ struct ia_css_yuvpp_settings {
|
||||||
unsigned int num_output;
|
unsigned int num_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_DEFAULT_YUVPP_SETTINGS \
|
#define IA_CSS_DEFAULT_YUVPP_SETTINGS { \
|
||||||
(struct ia_css_yuvpp_settings) { \
|
|
||||||
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
.copy_binary = IA_CSS_BINARY_DEFAULT_SETTINGS, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,8 +153,7 @@ struct ia_css_pipe {
|
||||||
unsigned int pipe_num;
|
unsigned int pipe_num;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_DEFAULT_PIPE \
|
#define IA_CSS_DEFAULT_PIPE { \
|
||||||
(struct ia_css_pipe) { \
|
|
||||||
.config = DEFAULT_PIPE_CONFIG, \
|
.config = DEFAULT_PIPE_CONFIG, \
|
||||||
.info = DEFAULT_PIPE_INFO, \
|
.info = DEFAULT_PIPE_INFO, \
|
||||||
.mode = IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
|
.mode = IA_CSS_PIPE_ID_ACC, /* (pipe_id) */ \
|
||||||
|
|
|
@ -149,8 +149,7 @@ struct ia_css_pipe_config {
|
||||||
/**
|
/**
|
||||||
* Default settings for newly created pipe configurations.
|
* Default settings for newly created pipe configurations.
|
||||||
*/
|
*/
|
||||||
#define DEFAULT_PIPE_CONFIG \
|
#define DEFAULT_PIPE_CONFIG { \
|
||||||
(struct ia_css_pipe_config) { \
|
|
||||||
.mode = IA_CSS_PIPE_MODE_PREVIEW, \
|
.mode = IA_CSS_PIPE_MODE_PREVIEW, \
|
||||||
.isp_pipe_version = 1, \
|
.isp_pipe_version = 1, \
|
||||||
.output_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
|
.output_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
|
||||||
|
@ -203,8 +202,7 @@ struct ia_css_pipe_info {
|
||||||
/**
|
/**
|
||||||
* Defaults for ia_css_pipe_info structs.
|
* Defaults for ia_css_pipe_info structs.
|
||||||
*/
|
*/
|
||||||
#define DEFAULT_PIPE_INFO \
|
#define DEFAULT_PIPE_INFO {\
|
||||||
(struct ia_css_pipe_info) { \
|
|
||||||
.output_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
|
.output_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
|
||||||
.vf_output_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
|
.vf_output_info = {IA_CSS_BINARY_DEFAULT_FRAME_INFO}, \
|
||||||
.raw_output_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
.raw_output_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
||||||
|
|
|
@ -392,8 +392,7 @@ struct ia_css_grid_info {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* defaults for ia_css_grid_info structs */
|
/* defaults for ia_css_grid_info structs */
|
||||||
#define DEFAULT_GRID_INFO \
|
#define DEFAULT_GRID_INFO { \
|
||||||
(struct ia_css_grid_info) { \
|
|
||||||
.dvs_grid = DEFAULT_DVS_GRID_INFO, \
|
.dvs_grid = DEFAULT_DVS_GRID_INFO, \
|
||||||
.vamem_type = IA_CSS_VAMEM_TYPE_1 \
|
.vamem_type = IA_CSS_VAMEM_TYPE_1 \
|
||||||
}
|
}
|
||||||
|
@ -485,8 +484,7 @@ struct ia_css_capture_config {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* default settings for ia_css_capture_config structs */
|
/* default settings for ia_css_capture_config structs */
|
||||||
#define DEFAULT_CAPTURE_CONFIG \
|
#define DEFAULT_CAPTURE_CONFIG { \
|
||||||
(struct ia_css_capture_config) { \
|
|
||||||
.mode = IA_CSS_CAPTURE_MODE_PRIMARY, \
|
.mode = IA_CSS_CAPTURE_MODE_PRIMARY, \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -197,12 +197,11 @@ struct ia_css_dvs_stat_grid_info {
|
||||||
|
|
||||||
/* DVS statistics generated by accelerator default grid info
|
/* DVS statistics generated by accelerator default grid info
|
||||||
*/
|
*/
|
||||||
#define DEFAULT_DVS_GRID_INFO \
|
#define DEFAULT_DVS_GRID_INFO { \
|
||||||
(union ia_css_dvs_grid_u) { \
|
.dvs_stat_grid_info = { \
|
||||||
.dvs_stat_grid_info = (struct ia_css_dvs_stat_grid_info) { \
|
|
||||||
.fe_roi_cfg = { \
|
.fe_roi_cfg = { \
|
||||||
[1] = (struct dvs_stat_public_dvs_level_fe_roi_cfg) { \
|
[1] = { \
|
||||||
.x_start = 4 \
|
.x_start = 4 \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -144,8 +144,7 @@ struct ia_css_binary {
|
||||||
struct ia_css_isp_param_css_segments css_params;
|
struct ia_css_isp_param_css_segments css_params;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IA_CSS_BINARY_DEFAULT_SETTINGS \
|
#define IA_CSS_BINARY_DEFAULT_SETTINGS { \
|
||||||
(struct ia_css_binary) { \
|
|
||||||
.input_format = ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY, \
|
.input_format = ATOMISP_INPUT_FORMAT_YUV420_8_LEGACY, \
|
||||||
.in_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
.in_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
||||||
.internal_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
.internal_frame_info = IA_CSS_BINARY_DEFAULT_FRAME_INFO, \
|
||||||
|
|
|
@ -57,8 +57,7 @@ struct ia_css_pipeline {
|
||||||
u32 pipe_qos_config;
|
u32 pipe_qos_config;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_PIPELINE \
|
#define DEFAULT_PIPELINE { \
|
||||||
(struct ia_css_pipeline) { \
|
|
||||||
.pipe_id = IA_CSS_PIPE_ID_PREVIEW, \
|
.pipe_id = IA_CSS_PIPE_ID_PREVIEW, \
|
||||||
.in_frame = DEFAULT_FRAME, \
|
.in_frame = DEFAULT_FRAME, \
|
||||||
.out_frame = {DEFAULT_FRAME}, \
|
.out_frame = {DEFAULT_FRAME}, \
|
||||||
|
|
|
@ -665,6 +665,8 @@ ERR:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct ia_css_frame ia_css_default_frame = DEFAULT_FRAME;
|
||||||
|
|
||||||
static void pipeline_init_defaults(
|
static void pipeline_init_defaults(
|
||||||
struct ia_css_pipeline *pipeline,
|
struct ia_css_pipeline *pipeline,
|
||||||
enum ia_css_pipe_id pipe_id,
|
enum ia_css_pipe_id pipe_id,
|
||||||
|
@ -677,10 +679,15 @@ static void pipeline_init_defaults(
|
||||||
pipeline->stages = NULL;
|
pipeline->stages = NULL;
|
||||||
pipeline->stop_requested = false;
|
pipeline->stop_requested = false;
|
||||||
pipeline->current_stage = NULL;
|
pipeline->current_stage = NULL;
|
||||||
pipeline->in_frame = DEFAULT_FRAME;
|
|
||||||
|
memcpy(&pipeline->in_frame, &ia_css_default_frame,
|
||||||
|
sizeof(ia_css_default_frame));
|
||||||
|
|
||||||
for (i = 0; i < IA_CSS_PIPE_MAX_OUTPUT_STAGE; i++) {
|
for (i = 0; i < IA_CSS_PIPE_MAX_OUTPUT_STAGE; i++) {
|
||||||
pipeline->out_frame[i] = DEFAULT_FRAME;
|
memcpy(&pipeline->out_frame[i], &ia_css_default_frame,
|
||||||
pipeline->vf_frame[i] = DEFAULT_FRAME;
|
sizeof(ia_css_default_frame));
|
||||||
|
memcpy(&pipeline->vf_frame[i], &ia_css_default_frame,
|
||||||
|
sizeof(ia_css_default_frame));
|
||||||
}
|
}
|
||||||
pipeline->num_execs = -1;
|
pipeline->num_execs = -1;
|
||||||
pipeline->acquire_isp_each_stage = true;
|
pipeline->acquire_isp_each_stage = true;
|
||||||
|
|
|
@ -2233,10 +2233,17 @@ ERR:
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct ia_css_pipe default_pipe = IA_CSS_DEFAULT_PIPE;
|
||||||
|
static const struct ia_css_preview_settings preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS;
|
||||||
|
static const struct ia_css_capture_settings capture = IA_CSS_DEFAULT_CAPTURE_SETTINGS;
|
||||||
|
static const struct ia_css_video_settings video = IA_CSS_DEFAULT_VIDEO_SETTINGS;
|
||||||
|
static const struct ia_css_yuvpp_settings yuvpp = IA_CSS_DEFAULT_YUVPP_SETTINGS;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
init_pipe_defaults(enum ia_css_pipe_mode mode,
|
init_pipe_defaults(enum ia_css_pipe_mode mode,
|
||||||
struct ia_css_pipe *pipe,
|
struct ia_css_pipe *pipe,
|
||||||
bool copy_pipe) {
|
bool copy_pipe) {
|
||||||
|
|
||||||
if (!pipe)
|
if (!pipe)
|
||||||
{
|
{
|
||||||
IA_CSS_ERROR("NULL pipe parameter");
|
IA_CSS_ERROR("NULL pipe parameter");
|
||||||
|
@ -2244,14 +2251,14 @@ init_pipe_defaults(enum ia_css_pipe_mode mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize pipe to pre-defined defaults */
|
/* Initialize pipe to pre-defined defaults */
|
||||||
*pipe = IA_CSS_DEFAULT_PIPE;
|
memcpy(pipe, &default_pipe, sizeof(default_pipe));
|
||||||
|
|
||||||
/* TODO: JB should not be needed, but temporary backward reference */
|
/* TODO: JB should not be needed, but temporary backward reference */
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
case IA_CSS_PIPE_MODE_PREVIEW:
|
case IA_CSS_PIPE_MODE_PREVIEW:
|
||||||
pipe->mode = IA_CSS_PIPE_ID_PREVIEW;
|
pipe->mode = IA_CSS_PIPE_ID_PREVIEW;
|
||||||
pipe->pipe_settings.preview = IA_CSS_DEFAULT_PREVIEW_SETTINGS;
|
memcpy(&pipe->pipe_settings.preview, &preview, sizeof(preview));
|
||||||
break;
|
break;
|
||||||
case IA_CSS_PIPE_MODE_CAPTURE:
|
case IA_CSS_PIPE_MODE_CAPTURE:
|
||||||
if (copy_pipe) {
|
if (copy_pipe) {
|
||||||
|
@ -2259,11 +2266,11 @@ init_pipe_defaults(enum ia_css_pipe_mode mode,
|
||||||
} else {
|
} else {
|
||||||
pipe->mode = IA_CSS_PIPE_ID_CAPTURE;
|
pipe->mode = IA_CSS_PIPE_ID_CAPTURE;
|
||||||
}
|
}
|
||||||
pipe->pipe_settings.capture = IA_CSS_DEFAULT_CAPTURE_SETTINGS;
|
memcpy(&pipe->pipe_settings.capture, &capture, sizeof(capture));
|
||||||
break;
|
break;
|
||||||
case IA_CSS_PIPE_MODE_VIDEO:
|
case IA_CSS_PIPE_MODE_VIDEO:
|
||||||
pipe->mode = IA_CSS_PIPE_ID_VIDEO;
|
pipe->mode = IA_CSS_PIPE_ID_VIDEO;
|
||||||
pipe->pipe_settings.video = IA_CSS_DEFAULT_VIDEO_SETTINGS;
|
memcpy(&pipe->pipe_settings.video, &video, sizeof(video));
|
||||||
break;
|
break;
|
||||||
case IA_CSS_PIPE_MODE_ACC:
|
case IA_CSS_PIPE_MODE_ACC:
|
||||||
pipe->mode = IA_CSS_PIPE_ID_ACC;
|
pipe->mode = IA_CSS_PIPE_ID_ACC;
|
||||||
|
@ -2273,7 +2280,7 @@ init_pipe_defaults(enum ia_css_pipe_mode mode,
|
||||||
break;
|
break;
|
||||||
case IA_CSS_PIPE_MODE_YUVPP:
|
case IA_CSS_PIPE_MODE_YUVPP:
|
||||||
pipe->mode = IA_CSS_PIPE_ID_YUVPP;
|
pipe->mode = IA_CSS_PIPE_ID_YUVPP;
|
||||||
pipe->pipe_settings.yuvpp = IA_CSS_DEFAULT_YUVPP_SETTINGS;
|
memcpy(&pipe->pipe_settings.yuvpp, &yuvpp, sizeof(yuvpp));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -8771,12 +8778,16 @@ sh_css_init_host_sp_control_vars(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* create the internal structures and fill in the configuration data
|
* create the internal structures and fill in the configuration data
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
ia_css_pipe_config ia_css_pipe_default_config = DEFAULT_PIPE_CONFIG;
|
||||||
|
|
||||||
void ia_css_pipe_config_defaults(struct ia_css_pipe_config *pipe_config)
|
void ia_css_pipe_config_defaults(struct ia_css_pipe_config *pipe_config)
|
||||||
{
|
{
|
||||||
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_pipe_config_defaults()\n");
|
ia_css_debug_dtrace(IA_CSS_DEBUG_TRACE, "ia_css_pipe_config_defaults()\n");
|
||||||
*pipe_config = DEFAULT_PIPE_CONFIG;
|
memcpy(pipe_config, &ia_css_pipe_default_config, sizeof(*pipe_config));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue