All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Nas Chung" <nas.chung@chipsnmedia.com>
Cc: conor+dt@kernel.org, media-ci@linuxtv.org, robh@kernel.org,
	devicetree@vger.kernel.org
Subject: Re: [PATCH v7 7/9] media: chips-media: wave6: Add Wave6 thermal cooling device
Date: Fri, 04 Sep 2026 07:00:11 +0000	[thread overview]
Message-ID: <20260904070011.E61AF1F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <e3cb770b50ce5932f0ec0ed25419cd8271a04780.1788496816.git.nas.chung@chipsnmedia.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Medium] Initial thermal state commands from the framework are silently discarded during registration due to a premature check on `thermal->cooling`.
- [Medium] The cooling device acts as a silent placebo if PM domain performance states are unsupported.
- [Medium] The driver incorrectly uses `dev_pm_genpd_set_performance_state()` with a raw frequency in kHz, violating the OPP/genpd abstraction and risking hardware malfunction on platforms with abstract performance levels.
- [Low] Defensive out-of-bounds check returns success (0) instead of an error, masking invalid requests and caching wrong states.
--

commit 99914a36008f0afa814ae979e8bbaf4616a8b747
Author: Nas Chung <nas.chung@chipsnmedia.com>

media: chips-media: wave6: Add Wave6 thermal cooling device

Add a thermal cooling device for the Wave6 VPU.
The device operates within the Linux thermal framework,
adjusting the VPU performance state based on thermal conditions.

> diff --git a/drivers/media/platform/chips-media/wave6/wave6-vpu-thermal.c b/drivers/media/platform/chips-media/wave6/wave6-vpu-thermal.c
> new file mode 100644
> index 0000000000000..1e67943b213bd
> --- /dev/null
> +++ b/drivers/media/platform/chips-media/wave6/wave6-vpu-thermal.c
> @@ -0,0 +1,143 @@

[ ... ]

> +static int wave6_vpu_thermal_cooling_update(struct vpu_thermal_cooling *thermal,
> +					    int state)
> +{
> +	unsigned long new_clock_rate;
> +	int ret;
> +
> +	if (state > thermal->thermal_max || !thermal->cooling)
> +		return 0;

[Severity: Low]
Does returning 0 for an invalid state request (state > thermal->thermal_max)
mask the error from the thermal core? It seems this would incorrectly allow
the caller wave6_vpu_cooling_set_cur_state() to cache this invalid state in
thermal->thermal_event.

[Severity: Medium]
Will the !thermal->cooling check incorrectly trigger during the initial
synchronous state assignment?

When devm_thermal_of_child_cooling_device_register() is called in
wave6_vpu_cooling_init(), it synchronously calls
wave6_cooling_ops.set_cur_state(). The registration function has not yet
returned to assign the pointer to thermal->cooling, so this check evaluates
to true. This would silently discard the initial cooling state set by the
thermal governor.

> +
> +	new_clock_rate = DIV_ROUND_UP(thermal->freq_table[state], HZ_PER_KHZ);
> +	dev_dbg(thermal->dev, "receive cooling state: %d, new clock rate %ld\n",
> +		state, new_clock_rate);
> +
> +	ret = dev_pm_genpd_set_performance_state(thermal->dev, new_clock_rate);

[Severity: Medium]
Is it correct to use dev_pm_genpd_set_performance_state() with a raw
frequency in kHz?

The dev_pm_genpd_set_performance_state() function expects a performance
state index (OPP level). Calculating
DIV_ROUND_UP(thermal->freq_table[state], HZ_PER_KHZ) instead of retrieving
the actual OPP level via dev_pm_opp_get_level() could violate the OPP/genpd
abstraction. On platforms where the performance domain uses abstract levels,
dividing the frequency by 1000 could result in an invalid or zero performance
state, breaking the cooling mitigation.

> +	if (ret && !((ret == -ENODEV) || (ret == -EOPNOTSUPP))) {

[Severity: Medium]
Does ignoring -ENODEV and -EOPNOTSUPP errors create a situation where the
cooling device acts as a silent placebo?

If the platform is missing genpd performance state support for the VPU,
these errors are caught and 0 (success) is returned. The thermal governor
will believe the device was throttled and will keep trying, but temperatures
will not drop since the device is not actually being cooled.

> +		dev_err(thermal->dev, "failed to set perf to %lu, ret = %d\n",
> +			new_clock_rate, ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +}

[ ... ]

> +int wave6_vpu_cooling_init(struct device *dev, struct vpu_thermal_cooling *thermal)
> +{

[ ... ]

> +	thermal->thermal_event = 0;
> +	thermal->cooling = devm_thermal_of_child_cooling_device_register(dev,
> +									 dev->of_node,
> +									 dev_name(thermal->dev),
> +									 thermal,
> +									 &wave6_cooling_ops);

[Severity: Medium]
As noted above in wave6_vpu_thermal_cooling_update(), since this is where
registration happens, thermal->cooling is only assigned after the framework
might have already attempted to set an initial cooling state. This causes
that initial command to be silently discarded.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1788496816.git.nas.chung@chipsnmedia.com?part=7

  reply	other threads:[~2026-09-04  7:00 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-04  6:46 [PATCH v7 0/9] Add support for Wave6 video codec driver Nas Chung
2026-09-04  6:46 ` [PATCH v7 1/9] media: v4l2-common: Fix P010 format info Nas Chung
2026-09-04  6:46 ` [PATCH v7 2/9] dt-bindings: media: nxp: Add Wave6 video codec device Nas Chung
2026-09-08  9:50   ` Krzysztof Kozlowski
2026-09-09 16:33   ` Frank Li
2026-09-04  6:46 ` [PATCH v7 3/9] media: chips-media: wave6: Add Wave6 VPU interface Nas Chung
2026-09-04  7:04   ` sashiko-bot
2026-09-09 16:39     ` Frank Li
2026-09-09 23:53       ` Nas Chung
2026-09-09 19:49   ` Frank Li
2026-09-10  8:14     ` Nas Chung
2026-09-10 19:50   ` Frank Li
2026-09-04  6:46 ` [PATCH v7 4/9] media: chips-media: wave6: Add v4l2 m2m driver support Nas Chung
2026-09-04  7:21   ` sashiko-bot
2026-09-10 20:37   ` Frank Li
2026-09-11  7:12     ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 5/9] media: chips-media: wave6: Add Wave6 core driver Nas Chung
2026-09-04  7:03   ` sashiko-bot
2026-09-10 20:48   ` Frank Li
2026-09-11  8:35     ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 6/9] media: chips-media: wave6: Improve debugging capabilities Nas Chung
2026-09-04  7:02   ` sashiko-bot
2026-09-09 20:40   ` Frank Li
2026-09-10  4:38     ` Nas Chung
2026-09-10 16:16       ` Frank Li
2026-09-11  3:53         ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 7/9] media: chips-media: wave6: Add Wave6 thermal cooling device Nas Chung
2026-09-04  7:00   ` sashiko-bot [this message]
2026-09-04  6:46 ` [PATCH v7 8/9] media: chips-media: wave6: Add Wave6 control driver Nas Chung
2026-09-04  7:05   ` sashiko-bot
2026-09-10 21:04   ` Frank Li
2026-09-11  7:07     ` Nas Chung
2026-09-04  6:46 ` [PATCH v7 9/9] arm64: dts: freescale: imx95: Add video codec node Nas Chung
2026-09-10 20:00 ` [PATCH v7 0/9] Add support for Wave6 video codec driver Frank Li
2026-09-11  6:58   ` Nas Chung

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=20260904070011.E61AF1F00A3E@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.org \
    --cc=nas.chung@chipsnmedia.com \
    --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.