Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Erikas Bitovtas" <xerikasxx@gmail.com>
Cc: conor+dt@kernel.org, krzk+dt@kernel.org, robh@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v7 6/8] media: qcom: venus: add power domain enable logic for Venus cores
Date: Thu, 14 May 2026 12:56:03 +0000	[thread overview]
Message-ID: <20260514125604.30B03C2BCB3@smtp.kernel.org> (raw)
In-Reply-To: <20260514-msm8939-venus-rfc-v7-6-33c6c6fb9285@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Clock initialization is incorrectly gated by the presence of power domains, leading to unclocked hardware access.
- [Medium] Runtime PM reference leak in vcodec_domains_enable() error path.
--

commit 1bdd7b26dbc6049ee656dfce05ea05b682bb5990
Author: Erikas Bitovtas <xerikasxx@gmail.com>

media: qcom: venus: add power domain enable logic for Venus cores

Attach power domains for vdec and venc cores and power them up if a vdec
or venc session is started. Vcodev clocks are added and enabled to the
core Venus device both for vcodec0 and vcodec1.

> diff --git a/drivers/media/platform/qcom/venus/pm_helpers.c b/drivers/media/platform/qcom/venus/pm_helpers.c
> index f0269524ac70e..be705d4d64b53 100644
> --- a/drivers/media/platform/qcom/venus/pm_helpers.c
> +++ b/drivers/media/platform/qcom/venus/pm_helpers.c

[ ... ]

> @@ -309,9 +343,63 @@ static int core_get_v1(struct venus_core *core)
>  	if (ret)
>  		return ret;
>  
> +	if (!res->vcodec_pmdomains)
> +		return 0;
> +
> +	ret = vcodec_clks_get(core, dev, core->vcodec_clks,
> +			      res->vcodec_clks);
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }

Will skipping vcodec_clks_get() when power domains are not present leave
the vcodec clocks uninitialized?

If a platform defines vcodec_clks but does not require vcodec_pmdomains,
this early return skips the clock retrieval entirely.

When core_power_v1() later calls vcodec_clks_enable(), it will succeed
on the NULL pointers, but the physical hardware clocks will remain disabled.
Accessing Venus hardware registers without clocks enabled can trigger an
asynchronous external abort and a kernel panic.

> +static int vcodec_domains_enable(struct venus_core *core)
> +{
> +	const struct venus_resources *res = core->res;
> +	struct device *pd_dev;
> +	int i = 0, ret;
> +
> +	if (!res->vcodec_pmdomains)
> +		return 0;
> +
> +	for (; i < res->vcodec_pmdomains_num; i++) {
> +		pd_dev = core->pmdomains->pd_devs[i];
> +		ret = pm_runtime_resume_and_get(pd_dev);
> +		if (ret)
> +			goto err;
> +
> +		ret = dev_pm_genpd_set_hwmode(pd_dev, true);
> +		if (ret && ret != -EOPNOTSUPP)
> +			goto err;
> +	}
> +
> +	return 0;
> +err:
> +	while (i--) {
> +		pd_dev = core->pmdomains->pd_devs[i];
> +		dev_pm_genpd_set_hwmode(pd_dev, false);
> +		pm_runtime_put_sync(pd_dev);
> +	}
> +	return ret;
> +}

Does this error path leak a runtime PM reference if dev_pm_genpd_set_hwmode()
fails?

If pm_runtime_resume_and_get() succeeds but the subsequent call to
dev_pm_genpd_set_hwmode() fails, the code jumps to the err label.

Since while (i--) pre-decrements the index, it skips the current iteration
index i and rolls back from i-1 down to 0.

This misses the pm_runtime_put_sync() call for the current power domain
where dev_pm_genpd_set_hwmode() failed, leaving its reference incremented
and preventing it from ever suspending.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260514-msm8939-venus-rfc-v7-0-33c6c6fb9285@gmail.com?part=6

  reply	other threads:[~2026-05-14 12:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 21:24 [PATCH v7 0/8] media: qcom: venus: add MSM8939 support Erikas Bitovtas
2026-05-13 21:24 ` [PATCH v7 1/8] media: dt-bindings: venus: Add qcom,msm8939 schema Erikas Bitovtas
2026-05-14  6:33   ` Krzysztof Kozlowski
2026-05-13 21:24 ` [PATCH v7 2/8] arm64: dts: qcom: msm8939: Add venus node Erikas Bitovtas
2026-05-13 21:24 ` [PATCH v7 3/8] arm64: dts: qcom: msm8939-longcheer-l9100: Enable " Erikas Bitovtas
2026-05-13 21:24 ` [PATCH v7 4/8] arm64: dts: qcom: msm8939-asus-z00t: add Venus Erikas Bitovtas
2026-05-13 21:24 ` [PATCH v7 5/8] clk: qcom: gcc-msm8939: mark Venus core GDSCs as hardware controlled Erikas Bitovtas
2026-05-14 12:30   ` sashiko-bot
2026-05-13 21:24 ` [PATCH v7 6/8] media: qcom: venus: add power domain enable logic for Venus cores Erikas Bitovtas
2026-05-14 12:56   ` sashiko-bot [this message]
2026-05-13 21:24 ` [PATCH v7 7/8] media: qcom: venus: add codec blacklist mechanism Erikas Bitovtas
2026-05-13 21:24 ` [PATCH v7 8/8] media: qcom: venus: Add msm8939 resource struct Erikas Bitovtas

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=20260514125604.30B03C2BCB3@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=xerikasxx@gmail.com \
    /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