Re: [PATCH 3/8] media: iris: Add support for multiple TZ CP configs

Bryan O'Donoghue
2025-09-26T00:30:23Z

On 25/09/2025 00:14, Vikash Garodia wrote:
> vpu4 needs an additional configuration w.r.t CP regions. Make the CP

"with-respect-to" and please define CP once and then use the
abbreviation liberally.
> configuration as array such that the multiple configuration can be
> managed per platform.
>
> Co-developed-by: Vishnu Reddy <quic_bvisredd@quicinc.com>
> Signed-off-by: Vishnu Reddy <quic_bvisredd@quicinc.com>
> Signed-off-by: Vikash Garodia <vikash.garodia@oss.qualcomm.com>
> ---
> drivers/media/platform/qcom/iris/iris_firmware.c | 23 ++++++++++++---------
> .../platform/qcom/iris/iris_platform_common.h | 3 ++-
> .../media/platform/qcom/iris/iris_platform_gen2.c | 24 ++++++++++++++--------
> .../platform/qcom/iris/iris_platform_sm8250.c | 15 ++++++++------
> 4 files changed, 39 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c b/drivers/media/platform/qcom/iris/iris_firmware.c
> index 9ab499fad946446a87036720f49c9c8d311f3060..ad65c419e4416d0531d4c3deb04c22d44b29e500 100644
> --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> +++ b/drivers/media/platform/qcom/iris/iris_firmware.c
> @@ -70,9 +70,9 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)
>
> int iris_fw_load(struct iris_core *core)
> {
> - struct tz_cp_config *cp_config = core->iris_platform_data->tz_cp_config_data;
> + const struct tz_cp_config *cp_config;
> const char *fwpath = NULL;
> - int ret;
> + int i, ret;
>
> ret = of_property_read_string_index(core->dev->of_node, "firmware-name", 0,
> &fwpath);
> @@ -91,14 +91,17 @@ int iris_fw_load(struct iris_core *core)
> return ret;
> }
>
> - ret = qcom_scm_mem_protect_video_var(cp_config->cp_start,
> - cp_config->cp_size,
> - cp_config->cp_nonpixel_start,
> - cp_config->cp_nonpixel_size);
> - if (ret) {
> - dev_err(core->dev, "protect memory failed\n");
> - qcom_scm_pas_shutdown(core->iris_platform_data->pas_id);
> - return ret;
> + for (i = 0; i < core->iris_platform_data->tz_cp_config_data_size; i++) {
> + cp_config = &core->iris_platform_data->tz_cp_config_data[i];
> + ret = qcom_scm_mem_protect_video_var(cp_config->cp_start,
> + cp_config->cp_size,
> + cp_config->cp_nonpixel_start,
> + cp_config->cp_nonpixel_size);
> + if (ret) {
> + dev_err(core->dev, "protect memory failed\n");

I think this error message could be better ->
"qcom_scm_mem_protect_video_var()=%d" or err string.

Its not super-important just an observation.

> + qcom_scm_pas_shutdown(core->iris_platform_data->pas_id);
> + return ret;
> + }
> }
>
> return ret;
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_common.h b/drivers/media/platform/qcom/iris/iris_platform_common.h
> index df03de08c44839c1b6c137874eb7273c638d5f2c..ae49e95ba2252fc1442f7c81d8010dbfd86da0da 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_common.h
> +++ b/drivers/media/platform/qcom/iris/iris_platform_common.h
> @@ -220,7 +220,8 @@ struct iris_platform_data {
> u32 inst_fw_caps_dec_size;
> struct platform_inst_fw_cap *inst_fw_caps_enc;
> u32 inst_fw_caps_enc_size;
> - struct tz_cp_config *tz_cp_config_data;
> + const struct tz_cp_config *tz_cp_config_data;
> + u32 tz_cp_config_data_size;
> u32 core_arch;
> u32 hw_response_timeout;
> struct ubwc_config_data *ubwc_config;
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_gen2.c b/drivers/media/platform/qcom/iris/iris_platform_gen2.c
> index fea800811a389a58388175c733ad31c4d9c636b0..00c6b9021b98aac80612b1bb9734c8dac8146bd9 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_gen2.c
> +++ b/drivers/media/platform/qcom/iris/iris_platform_gen2.c
> @@ -648,11 +648,13 @@ static struct ubwc_config_data ubwc_config_sm8550 = {
> .bank_spreading = 1,
> };
>
> -static struct tz_cp_config tz_cp_config_sm8550 = {
> - .cp_start = 0,
> - .cp_size = 0x25800000,
> - .cp_nonpixel_start = 0x01000000,
> - .cp_nonpixel_size = 0x24800000,
> +static const struct tz_cp_config tz_cp_config_sm8550[] = {
> + {
> + .cp_start = 0,
> + .cp_size = 0x25800000,
> + .cp_nonpixel_start = 0x01000000,
> + .cp_nonpixel_size = 0x24800000,
> + },
> };
>
> static const u32 sm8550_vdec_input_config_params_default[] = {
> @@ -771,7 +773,8 @@ struct iris_platform_data sm8550_data = {
> .inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_sm8550_dec),
> .inst_fw_caps_enc = inst_fw_cap_sm8550_enc,
> .inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8550_enc),
> - .tz_cp_config_data = &tz_cp_config_sm8550,
> + .tz_cp_config_data = tz_cp_config_sm8550,
> + .tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_sm8550),
> .core_arch = VIDEO_ARCH_LX,
> .hw_response_timeout = HW_RESPONSE_TIMEOUT_VALUE,
> .ubwc_config = &ubwc_config_sm8550,
> @@ -864,7 +867,8 @@ struct iris_platform_data sm8650_data = {
> .inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_sm8550_dec),
> .inst_fw_caps_enc = inst_fw_cap_sm8550_enc,
> .inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8550_enc),
> - .tz_cp_config_data = &tz_cp_config_sm8550,
> + .tz_cp_config_data = tz_cp_config_sm8550,
> + .tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_sm8550),
> .core_arch = VIDEO_ARCH_LX,
> .hw_response_timeout = HW_RESPONSE_TIMEOUT_VALUE,
> .ubwc_config = &ubwc_config_sm8550,
> @@ -947,7 +951,8 @@ struct iris_platform_data sm8750_data = {
> .inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_sm8550_dec),
> .inst_fw_caps_enc = inst_fw_cap_sm8550_enc,
> .inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8550_enc),
> - .tz_cp_config_data = &tz_cp_config_sm8550,
> + .tz_cp_config_data = tz_cp_config_sm8550,
> + .tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_sm8550),
> .core_arch = VIDEO_ARCH_LX,
> .hw_response_timeout = HW_RESPONSE_TIMEOUT_VALUE,
> .ubwc_config = &ubwc_config_sm8550,
> @@ -1035,7 +1040,8 @@ struct iris_platform_data qcs8300_data = {
> .inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_qcs8300_dec),
> .inst_fw_caps_enc = inst_fw_cap_qcs8300_enc,
> .inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_qcs8300_enc),
> - .tz_cp_config_data = &tz_cp_config_sm8550,
> + .tz_cp_config_data = tz_cp_config_sm8550,
> + .tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_sm8550),
> .core_arch = VIDEO_ARCH_LX,
> .hw_response_timeout = HW_RESPONSE_TIMEOUT_VALUE,
> .ubwc_config = &ubwc_config_sm8550,
> diff --git a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c
> index 1b1b6aa751106ee0b0bc71bb0df2e78340190e66..8927c3ff59dab59c7d2cbcd92550f9ee3a2b5c1e 100644
> --- a/drivers/media/platform/qcom/iris/iris_platform_sm8250.c
> +++ b/drivers/media/platform/qcom/iris/iris_platform_sm8250.c
> @@ -278,11 +278,13 @@ static const char * const sm8250_opp_clk_table[] = {
> NULL,
> };
>
> -static struct tz_cp_config tz_cp_config_sm8250 = {
> - .cp_start = 0,
> - .cp_size = 0x25800000,
> - .cp_nonpixel_start = 0x01000000,
> - .cp_nonpixel_size = 0x24800000,
> +static const struct tz_cp_config tz_cp_config_sm8250[] = {
> + {
> + .cp_start = 0,
> + .cp_size = 0x25800000,
> + .cp_nonpixel_start = 0x01000000,
> + .cp_nonpixel_size = 0x24800000,
> + },
> };
>
> static const u32 sm8250_vdec_input_config_param_default[] = {
> @@ -348,7 +350,8 @@ struct iris_platform_data sm8250_data = {
> .inst_fw_caps_dec_size = ARRAY_SIZE(inst_fw_cap_sm8250_dec),
> .inst_fw_caps_enc = inst_fw_cap_sm8250_enc,
> .inst_fw_caps_enc_size = ARRAY_SIZE(inst_fw_cap_sm8250_enc),
> - .tz_cp_config_data = &tz_cp_config_sm8250,
> + .tz_cp_config_data = tz_cp_config_sm8250,
> + .tz_cp_config_data_size = ARRAY_SIZE(tz_cp_config_sm8250),
> .hw_response_timeout = HW_RESPONSE_TIMEOUT_VALUE,
> .num_vpp_pipe = 4,
> .max_session_count = 16,
>
> --
> 2.34.1
>
>

Please tidy up the commit log.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>