From: sashiko-bot@kernel.org
To: "Vishnu Reddy" <busanna.reddy@oss.qualcomm.com>
Cc: robh@kernel.org, conor+dt@kernel.org,
linux-media@vger.kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v7 09/12] media: iris: Add support to select core for dual core platforms
Date: Wed, 03 Jun 2026 14:44:34 +0000 [thread overview]
Message-ID: <20260603144434.928EF1F00898@smtp.kernel.org> (raw)
In-Reply-To: <20260603-glymur-v7-9-afaa55d11fe0@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Dynamic core assignment logic mutates `inst->core_id` during streaming without firmware notification and without holding `inst->lock`.
- [Medium] Initial core assignment bypasses MBPS constraints.
--
commit 2b81abf719d22ec30cd3764b2bba16be2af15168
Author: Vishnu Reddy <busanna.reddy@oss.qualcomm.com>
media: iris: Add support to select core for dual core platforms
On platforms with two video codec cores, select the hardware core for
a new session based on the current Macroblocks Per Frame (MBPF) and
Macroblocks Per Second (MBPS) load on each core. The selected core is
communicated to the firmware via the HFI_PROP_CORE_ID property at
stream-on time.
> 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: Medium]
Since this initial core assignment is driven by iris_check_session_supported()
called just before this, does that function need to check both MBPF and MBPS
limits?
Currently, iris_check_session_supported() only calls iris_check_core_mbpf() to
verify Macroblocks Per Frame limits. The complementary MBPS constraint check
via iris_check_core_mbps() appears to be entirely omitted.
Could this allow a session to be successfully assigned to a core that meets
the MBPF limit but vastly exceeds its maximum processing capability (MBPS)?
> + if (ret)
> + goto error;
> +
> if (V4L2_TYPE_IS_OUTPUT(q->type)) {
> if (inst->domain == DECODER)
> ret = iris_vdec_streamon_input(inst);
[ ... ]
> diff --git a/drivers/media/platform/qcom/iris/iris_vpu3x.c b/drivers/media/platform/qcom/iris/iris_vpu3x.c
> index 65896d0c1f16b..9f8dacfa768d8 100644
> --- a/drivers/media/platform/qcom/iris/iris_vpu3x.c
> +++ b/drivers/media/platform/qcom/iris/iris_vpu3x.c
> @@ -318,6 +318,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;
[Severity: High]
Is it safe to mutate inst->core_id here during active streaming without
holding inst->lock?
This function can be reached mid-stream if a concurrent s_parm call triggers
iris_venc_s_param() -> iris_check_core_mbpf(). Since iris_venc_s_param()
executes without holding inst->lock, a concurrent call can clear
inst->core_id to 0 right before iris_set_core_id() reads it during
iris_vb2_start_streaming().
Additionally, altering inst->core_id mid-stream without notifying the
firmware (which only receives HFI_PROP_CORE_ID at stream-on) permanently
desynchronizes the driver from the firmware.
This could cause iris_vpu36_get_required_freq() to incorrectly shift the
session's power votes to the new core while the firmware continues executing
on the old core, potentially leading to hardware underclocking and system hangs.
> +
> + list_for_each_entry(instance, &inst->core->instances, list) {
> + load = mbpf ? iris_get_mbpf(instance) : iris_get_mbps(instance);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260603-glymur-v7-0-afaa55d11fe0@oss.qualcomm.com?part=9
next prev parent reply other threads:[~2026-06-03 14:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 14:18 [PATCH v7 00/12] media: iris: Add support for glymur platform Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 01/12] media: iris: Add iris vpu bus support Vishnu Reddy
2026-06-03 14:45 ` sashiko-bot
2026-06-03 14:18 ` [PATCH v7 02/12] iommu: Add iris-vpu-bus to iommu_buses Vishnu Reddy
2026-06-03 14:34 ` sashiko-bot
2026-06-03 14:18 ` [PATCH v7 03/12] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 04/12] media: iris: Add context bank hooks for platform specific initialization Vishnu Reddy
2026-06-03 14:36 ` sashiko-bot
2026-06-03 14:18 ` [PATCH v7 05/12] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-06-03 14:39 ` sashiko-bot
2026-06-03 14:18 ` [PATCH v7 06/12] media: iris: Replace enum-indexed clock and power domain tables with per-block structures Vishnu Reddy
2026-06-03 14:37 ` sashiko-bot
2026-06-03 14:18 ` [PATCH v7 07/12] media: iris: Add power sequence for glymur Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 08/12] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 09/12] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-06-03 14:44 ` sashiko-bot [this message]
2026-06-03 14:18 ` [PATCH v7 10/12] media: iris: Add platform data for glymur Vishnu Reddy
2026-06-03 14:46 ` sashiko-bot
2026-06-03 14:18 ` [PATCH v7 11/12] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
2026-06-03 14:18 ` [PATCH v7 12/12] 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=20260603144434.928EF1F00898@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=linux-media@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox