video: driver: modify max mapped output count

adjust MAX_MAP_OUTPUT_COUNT based on resolution
to enhance performance and reduce memory pressure.
- For 8K session: count = 20
- For 4K session: count = 32
- For 1080p session: count = 48
- For all remaining sessions: count = 64

reduce MAX_DPB_COUNT to 32.
reduce DEFAULT_MAX_HOST_BUF_COUNT to 64.

Change-Id: I0e6d25121947524b843e9cce96b75871aba174af
Signed-off-by: Darshana Patil <darshana@codeaurora.org>
This commit is contained in:
Darshana Patil
2021-05-21 10:42:31 -07:00
parent 702fe54c21
commit e5ec6843e8
6 changed files with 80 additions and 38 deletions

View File

@@ -533,34 +533,6 @@ static int __boot_firmware_iris2(struct msm_vidc_core *vidc_core)
return rc;
}
bool res_is_greater_than(u32 width, u32 height,
u32 ref_width, u32 ref_height)
{
u32 num_mbs = NUM_MBS_PER_FRAME(height, width);
u32 max_side = max(ref_width, ref_height);
if (num_mbs > NUM_MBS_PER_FRAME(ref_height, ref_width) ||
width > max_side ||
height > max_side)
return true;
else
return false;
}
bool res_is_less_than_or_equal_to(u32 width, u32 height,
u32 ref_width, u32 ref_height)
{
u32 num_mbs = NUM_MBS_PER_FRAME(height, width);
u32 max_side = max(ref_width, ref_height);
if (num_mbs <= NUM_MBS_PER_FRAME(ref_height, ref_width) &&
width <= max_side &&
height <= max_side)
return true;
else
return false;
}
int msm_vidc_decide_work_mode_iris2(struct msm_vidc_inst* inst)
{
u32 work_mode;

View File

@@ -405,5 +405,9 @@ int msm_vidc_flush_ts(struct msm_vidc_inst *inst);
const char *buf_name(enum msm_vidc_buffer_type type);
void msm_vidc_free_capabililty_list(struct msm_vidc_inst *inst,
enum msm_vidc_ctrl_list_type list_type);
bool res_is_greater_than(u32 width, u32 height,
u32 ref_width, u32 ref_height);
bool res_is_less_than_or_equal_to(u32 width, u32 height,
u32 ref_width, u32 ref_height);
#endif // _MSM_VIDC_DRIVER_H_

View File

@@ -153,5 +153,6 @@ struct msm_vidc_inst {
bool vb2q_init;
u32 max_input_data_size;
u32 dpb_list_payload[MAX_DPB_LIST_ARRAY_SIZE];
u32 max_map_output_count;
};
#endif // _MSM_VIDC_INST_H_

View File

@@ -43,7 +43,7 @@
#define MAX_CAP_CHILDREN 16
#define DEFAULT_BITSTREM_ALIGNMENT 16
#define H265_BITSTREM_ALIGNMENT 32
#define DEFAULT_MAX_HOST_BUF_COUNT 128
#define DEFAULT_MAX_HOST_BUF_COUNT 64
#define DEFAULT_MAX_HOST_BURST_BUF_COUNT 256
#define BIT_DEPTH_8 (8 << 16 | 8)
#define BIT_DEPTH_10 (10 << 16 | 10)
@@ -119,14 +119,8 @@
#define HW_RESPONSE_TIMEOUT_VALUE (1000)
#define SW_PC_DELAY_VALUE (HW_RESPONSE_TIMEOUT_VALUE + 500)
#define FW_UNLOAD_DELAY_VALUE (SW_PC_DELAY_VALUE + 1500)
/*
* MAX_MAPPED_OUTPUT_COUNT: maximum mappings which can
* be present in output map list with refcount 1. These
* mappings exist due to delayed unmap feature. Current
* threshold is kept as 50 to handle vpp usecases
* which might have many output buffers.
*/
#define MAX_MAPPED_OUTPUT_COUNT 64
#define MAX_MAP_OUTPUT_COUNT 64
#define MAX_DPB_COUNT 32
/*
* max dpb count in firmware = 16

View File

@@ -1625,6 +1625,44 @@ static int msm_vdec_subscribe_output_port_settings_change(struct msm_vidc_inst *
return rc;
}
static int msm_vdec_update_max_map_output_count(struct msm_vidc_inst *inst)
{
int rc = 0;
struct v4l2_format *f;
u32 width, height, count;
if (!inst) {
d_vpr_e("%s: invalid params\n", __func__);
return -EINVAL;
}
f = &inst->fmts[OUTPUT_PORT];
width = f->fmt.pix_mp.width;
height = f->fmt.pix_mp.height;
/*
* adjust max map output count based on resolution
* to enhance performance.
* For 8K session: count = 20
* For 4K session: count = 32
* For 1080p session: count = 48
* For all remaining sessions: count = 64
*/
if (res_is_greater_than(width, height, 4096, 2160))
count = 20;
else if (res_is_greater_than(width, height, 1920, 1080))
count = 32;
else if (res_is_greater_than(width, height, 1280, 720))
count = 48;
else
count = 64;
inst->max_map_output_count = count;
i_vpr_h(inst, "%s: count: %d\n", __func__, inst->max_map_output_count);
return rc;
}
int msm_vdec_streamon_output(struct msm_vidc_inst *inst)
{
int rc = 0;
@@ -1642,6 +1680,10 @@ int msm_vdec_streamon_output(struct msm_vidc_inst *inst)
return -EINVAL;
}
rc = msm_vdec_update_max_map_output_count(inst);
if (rc)
return rc;
rc = msm_vdec_set_output_properties(inst);
if (rc)
goto error;
@@ -1884,7 +1926,7 @@ static int msm_vidc_unmap_excessive_mappings(struct msm_vidc_inst *inst)
refcount_one_bufs_count++;
}
if (refcount_one_bufs_count <= MAX_MAPPED_OUTPUT_COUNT)
if (refcount_one_bufs_count <= inst->max_map_output_count)
return 0;
/* unmap these buffers as they are stale entries */
@@ -2528,6 +2570,7 @@ int msm_vdec_inst_init(struct msm_vidc_inst *inst)
inst->buffers.output.min_count +
inst->buffers.output.extra_count;
inst->buffers.output.size = f->fmt.pix_mp.plane_fmt[0].sizeimage;
inst->max_map_output_count = MAX_MAP_OUTPUT_COUNT;
f = &inst->fmts[OUTPUT_META_PORT];
f->type = OUTPUT_META_PLANE;

View File

@@ -1027,6 +1027,34 @@ struct msm_vidc_allocations *msm_vidc_get_allocations(
}
}
bool res_is_greater_than(u32 width, u32 height,
u32 ref_width, u32 ref_height)
{
u32 num_mbs = NUM_MBS_PER_FRAME(height, width);
u32 max_side = max(ref_width, ref_height);
if (num_mbs > NUM_MBS_PER_FRAME(ref_height, ref_width) ||
width > max_side ||
height > max_side)
return true;
else
return false;
}
bool res_is_less_than_or_equal_to(u32 width, u32 height,
u32 ref_width, u32 ref_height)
{
u32 num_mbs = NUM_MBS_PER_FRAME(height, width);
u32 max_side = max(ref_width, ref_height);
if (num_mbs <= NUM_MBS_PER_FRAME(ref_height, ref_width) &&
width <= max_side &&
height <= max_side)
return true;
else
return false;
}
int msm_vidc_change_core_state(struct msm_vidc_core *core,
enum msm_vidc_core_state request_state, const char *func)
{