From: sashiko-bot@kernel.org
To: "AngeloGioacchino Del Regno" <angelogioacchino.delregno@collabora.com>
Cc: devicetree@vger.kernel.org, conor+dt@kernel.org, robh@kernel.org
Subject: Re: [PATCH v2 4/4] pmdomain: mediatek: Add support for MT8196 HFRP DirectCTL domains
Date: Tue, 07 Jul 2026 16:20:58 +0000 [thread overview]
Message-ID: <20260707162058.C21991F00AC4@smtp.kernel.org> (raw)
In-Reply-To: <20260707155535.199383-5-angelogioacchino.delregno@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Resource leak on error cleanup due to dummy `sta_mask` in simple power sequence domains causing `scpsys_domain_is_on()` to incorrectly return false.
Pre-existing issues:
- [High] Kernel panic during probe error cleanup due to unconditional dereference of `pd->data` for `HW_VOTER` domains in `scpsys_domain_is_on()`.
--
--- Patch [4]: [PATCH v2 4/4] pmdomain: mediatek: Add support for MT8196 HFRP DirectCTL domains ---
commit 6f2aa6326ce2b3105bc55383da9b0e0d8b25e2d6
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
pmdomain: mediatek: Add support for MT8196 HFRP DirectCTL domains
Add support for the power domains provided by the HFRPSYS Power Controller of
the MT8196 SoC. Those control power to the eDP and DP Transmitter IPs.
> diff --git a/drivers/pmdomain/mediatek/mt8196-pm-domains.h b/drivers/pmdomain/mediatek/mt8196-pm-domains.h
> index 2e4b287206596..d704c9fa93374 100644
> --- a/drivers/pmdomain/mediatek/mt8196-pm-domains.h
> +++ b/drivers/pmdomain/mediatek/mt8196-pm-domains.h
> @@ -602,6 +602,27 @@ static const struct scpsys_hwv_domain_data hfrpsys_hwv_domain_data_mt8196[] = {
> },
> };
>
> +static const struct scpsys_domain_data hfrpsys_domain_data_mt8196[] = {
> + [MT8196_POWER_DOMAIN_EDPTX] = {
> + .name = "edp-tx",
> + .sta_mask = MT8196_PWR_ACK,
[Severity: Medium]
Can this lead to a resource leak during error cleanup?
The MT8196_POWER_DOMAIN_EDPTX and DPTX domains use simple power sequence,
bypassing standard PWR_ACK polling. To pass validation during initialization,
they are assigned MT8196_PWR_ACK as a sta_mask.
If this bit is a dummy and not automatically driven high by hardware for these
specific domains (since it is never polled during power_on),
scpsys_domain_is_on() will perpetually read 0 and return false.
If a failure triggers probe error cleanup, scpsys_remove_one_domain() would
skip scpsys_power_off() for these domains because it incorrectly believes they
are already off. Does this leave the domain permanently powered on in a
corrupted state and leak prepared clocks and regulators?
> + .sta2nd_mask = MT8196_PWR_ACK_2ND,
> + .ctl_offs = 0x74,
> + .pwr_sta_offs = 0x74,
> + .pwr_sta2nd_offs = 0x74,
> + .caps = MTK_SCPD_SIMPLE_PWRSEQ,
> + },
[ ... ]
> diff --git a/drivers/pmdomain/mediatek/mtk-pm-domains.c b/drivers/pmdomain/mediatek/mtk-pm-domains.c
> index feba436279c54..55e7478804236 100644
> --- a/drivers/pmdomain/mediatek/mtk-pm-domains.c
> +++ b/drivers/pmdomain/mediatek/mtk-pm-domains.c
> @@ -1258,6 +1258,10 @@ static const struct of_device_id scpsys_of_match[] = {
> .compatible = "mediatek,mt8196-power-controller",
> .data = &mt8196_scpsys_data,
> },
> + {
> + .compatible = "mediatek,mt8196-hfrp-power-controller",
> + .data = &mt8196_hfrpsys_data,
> + },
[Severity: High]
This isn't a bug introduced by this patch, but could this lead to a kernel
panic during probe error cleanup?
If a hardware voter domain is probed successfully, it is added to the probed
list. If a subsequently probed domain fails, scpsys_domain_cleanup()
initiates rollback, calling scpsys_remove_one_domain() on the hardware
voter domain.
scpsys_remove_one_domain() unconditionally calls scpsys_domain_is_on(), which
attempts to read pd->data->sta_mask:
scpsys_remove_one_domain()
scpsys_domain_is_on()
u32 mask = pd->data->sta_mask;
For hardware voter domains, pd->data is explicitly set to NULL, which appears
to result in a guaranteed NULL pointer dereference. Could this bring the
system down during boot on unsupported or failing hardware configurations?
> {
> .compatible = "mediatek,mt8196-hwv-hfrp-power-controller",
> .data = &mt8196_hfrpsys_hwv_data,
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260707155535.199383-1-angelogioacchino.delregno@collabora.com?part=4
next prev parent reply other threads:[~2026-07-07 16:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 15:55 [PATCH v2 0/4] pmdomains: Fixes and add support for HFRP Direct AngeloGioacchino Del Regno
2026-07-07 15:55 ` [PATCH v2 1/4] dt-bindings: power: mediatek: Add support for MT8196 direct HFRP AngeloGioacchino Del Regno
2026-07-08 7:04 ` Krzysztof Kozlowski
2026-07-07 15:55 ` [PATCH v2 2/4] pmdomain: mediatek: Respect PD relationships during error cleanup AngeloGioacchino Del Regno
2026-07-07 15:55 ` [PATCH v2 3/4] pmdomain: mediatek: Add support for Direct CTL simple power sequence AngeloGioacchino Del Regno
2026-07-07 16:08 ` sashiko-bot
2026-07-07 16:22 ` AngeloGioacchino Del Regno
2026-07-07 15:55 ` [PATCH v2 4/4] pmdomain: mediatek: Add support for MT8196 HFRP DirectCTL domains AngeloGioacchino Del Regno
2026-07-07 16:20 ` sashiko-bot [this message]
2026-07-07 16:29 ` AngeloGioacchino Del Regno
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=20260707162058.C21991F00AC4@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=angelogioacchino.delregno@collabora.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox