From: sashiko-bot@kernel.org
To: "Vishnu Reddy" <busanna.reddy@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v9 10/14] media: iris: Add support to select core for dual core platforms
Date: Wed, 15 Jul 2026 14:42:07 +0000 [thread overview]
Message-ID: <20260715144207.C76D11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260715-glymur-v9-10-8cf2cbe12a07@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Dynamic core reassignment mid-session corrupts hardware state and bypasses capacity limits.
- [High] Misattribution of unassigned sessions incorrectly inflates Core 1 clock frequencies, leading to hardware underclocking.
--
--- Patch [10]: [PATCH v9 10/14] media: iris: Add support to select core for dual core platforms ---
commit 9f55933e77ce82b0c6d889a73f17c3f4e9da2a7a
Author: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
Subject: media: iris: Add support to select core for dual core platforms
This commit adds support for dual video codec cores, selecting a core based
on MBPF and MBPS load and scaling limits and clock frequencies accordingly.
> diff --git a/drivers/media/platform/qcom/iris/iris_vb2.c b/drivers/media/platform/qcom/iris/iris_vb2.c
> index a2ea2d67f60d0..dbb89396e6514 100644
> --- a/drivers/media/platform/qcom/iris/iris_vb2.c
> +++ b/drivers/media/platform/qcom/iris/iris_vb2.c
> @@ -176,6 +176,10 @@ int iris_vb2_start_streaming(struct vb2_queue *q, unsigned int count)
> if (ret)
> goto error;
>
> + ret = iris_set_core_id(inst);
[Severity: High]
Does setting the core ID happen too late in the streaming initialization?
Looking at iris_vb2_start_streaming(), iris_scale_power() is called before
iris_check_session_supported() and iris_set_core_id():
iris_scale_power(inst);
ret = iris_check_session_supported(inst);
...
ret = iris_set_core_id(inst);
This means frequency calculations will run while the new session's core_id
is still unassigned (0), which appears to cause issues in the frequency
calculation logic below.
> + if (ret)
> + goto error;
> +
> if (V4L2_TYPE_IS_OUTPUT(q->type)) {
[ ... ]
> diff --git a/drivers/media/platform/qcom/iris/iris_vpu3x.c b/drivers/media/platform/qcom/iris/iris_vpu3x.c
> index 7d5007abaded8..97563bf899392 100644
> --- a/drivers/media/platform/qcom/iris/iris_vpu3x.c
> +++ b/drivers/media/platform/qcom/iris/iris_vpu3x.c
[ ... ]
> @@ -338,6 +338,67 @@ static void iris_vpu36_program_bootup_registers(struct iris_core *core)
> writel(0x0, core->reg_base + CPU_CS_SCIACMDARG3);
> }
>
> +static int iris_vpu36_check_core_load(struct iris_inst *inst, bool mbpf)
> +{
> + const struct iris_platform_data *platform_data = inst->core->iris_platform_data;
> + u32 max_load = mbpf ? platform_data->max_core_mbpf : platform_data->max_core_mbps;
> + u32 max_session_cnt = platform_data->max_session_count;
> + u32 core0_session_cnt = 0, core1_session_cnt = 0;
> + u32 core0_load = 0, core1_load = 0;
> + bool select_core0, select_core1;
> + struct iris_inst *instance;
> + u32 load, new_load;
> +
> + inst->core_id = 0;
> +
> + list_for_each_entry(instance, &inst->core->instances, list) {
> + load = mbpf ? iris_get_mbpf(instance) : iris_get_mbps(instance);
> +
> + if (instance->core_id == IRIS_VCODEC0) {
> + core0_load += load;
> + core0_session_cnt++;
> + } else if (instance->core_id == IRIS_VCODEC1) {
> + core1_load += load;
> + core1_session_cnt++;
> + }
> + }
> +
> + new_load = mbpf ? iris_get_mbpf(inst) : iris_get_mbps(inst);
> +
> + select_core0 = core0_load + new_load <= max_load && core0_session_cnt < max_session_cnt;
> + select_core1 = core1_load + new_load <= max_load && core1_session_cnt < max_session_cnt;
> +
> + if (select_core0 && select_core1)
> + inst->core_id = (core0_load <= core1_load) ? IRIS_VCODEC0 : IRIS_VCODEC1;
> + else if (select_core0)
> + inst->core_id = IRIS_VCODEC0;
> + else if (select_core1)
> + inst->core_id = IRIS_VCODEC1;
> + else
> + return -ENOMEM;
> +
> + return 0;
> +}
[Severity: High]
Does unconditionally zeroing and reassigning core_id corrupt the session
state if called mid-session?
If parameters are dynamically updated during streaming (for example, via
iris_venc_s_parm()), iris_check_core_mbpf() and iris_check_core_mbps() are
invoked sequentially. Would the MBPS check overwrite the assignment made by
the MBPF check, ignoring whether the newly assigned core has sufficient
MBPF capacity?
Additionally, since the hardware is only notified of the core ID during
stream-on via HFI_PROP_CORE_ID, could dynamically changing inst->core_id
here leave the driver calculating power for one core while the firmware
continues executing the session on another?
> +
> +static u64 iris_vpu36_get_required_freq(struct iris_inst *inst)
> +{
> + u64 vcodec0_freq = 0, vcodec1_freq = 0;
> + struct iris_core *core = inst->core;
> + struct iris_inst *instance;
> +
> + list_for_each_entry(instance, &core->instances, list) {
> + if (!instance->max_input_data_size)
> + continue;
> +
> + if (instance->core_id == IRIS_VCODEC0)
> + vcodec0_freq += instance->power.min_freq;
> + else
> + vcodec1_freq += instance->power.min_freq;
[Severity: High]
Does this else block unintentionally include unassigned sessions?
As mentioned above, new sessions initially have an unassigned core_id (0)
when iris_scale_power() is called. Since 0 is not equal to IRIS_VCODEC0,
won't this falsely add the unassigned session's required frequency to
Core 1?
If a heavy session is misattributed to a lightly loaded Core 1 instead of
a heavily loaded Core 0, could the resulting maximum frequency be
artificially low and cause the hardware to underclock?
> + }
> +
> + return max(vcodec0_freq, vcodec1_freq);
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260715-glymur-v9-0-8cf2cbe12a07@oss.qualcomm.com?part=10
next prev parent reply other threads:[~2026-07-15 14:42 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-15 14:09 [PATCH v9 00/14] media: iris: Add support for glymur platform Vishnu Reddy
2026-07-15 14:09 ` [PATCH v9 01/14] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-07-15 14:22 ` sashiko-bot
2026-07-15 14:09 ` [PATCH v9 02/14] media: iris: Add hooks to initialize and tear down context banks Vishnu Reddy
2026-07-15 14:23 ` sashiko-bot
2026-07-15 14:09 ` [PATCH v9 03/14] media: iris: Add helper to create a context bank device Vishnu Reddy
2026-07-15 14:09 ` [PATCH v9 04/14] media: iris: Add helper to select relevant " Vishnu Reddy
2026-07-15 14:29 ` sashiko-bot
2026-07-15 14:09 ` [PATCH v9 05/14] media: iris: Skip DMA mask setting to core device when IOMMU is not mapped Vishnu Reddy
2026-07-15 14:22 ` sashiko-bot
2026-07-15 14:10 ` [PATCH v9 06/14] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-07-15 14:37 ` sashiko-bot
2026-07-15 14:10 ` [PATCH v9 07/14] media: iris: Replace enum-indexed clock and power domain tables with per-block structures Vishnu Reddy
2026-07-15 14:39 ` sashiko-bot
2026-07-15 14:10 ` [PATCH v9 08/14] media: iris: Add power sequence for glymur Vishnu Reddy
2026-07-15 14:36 ` sashiko-bot
2026-07-15 14:10 ` [PATCH v9 09/14] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook Vishnu Reddy
2026-07-15 14:10 ` [PATCH v9 10/14] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-07-15 14:42 ` sashiko-bot [this message]
2026-07-15 14:10 ` [PATCH v9 11/14] media: iris: Add hooks for pixel and non-pixel context banks Vishnu Reddy
2026-07-15 14:52 ` sashiko-bot
2026-07-15 15:27 ` Bryan O'Donoghue
2026-07-15 14:10 ` [PATCH v9 12/14] media: iris: Add platform data for glymur Vishnu Reddy
2026-07-15 14:10 ` [PATCH v9 13/14] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
2026-07-15 15:18 ` sashiko-bot
2026-07-15 14:10 ` [PATCH v9 14/14] arm64: dts: qcom: glymur-crd: Enable iris video codec node Vishnu Reddy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260715144207.C76D11F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=busanna.reddy@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.