public inbox for cip-dev@lists.cip-project.org
 help / color / mirror / Atom feed
From: Claudiu Beznea <claudiu.beznea@tuxon.dev>
To: Pavel Machek <pavel@denx.de>
Cc: nobuhiro.iwamatsu.x90@mail.toshiba, cip-dev@lists.cip-project.org
Subject: Re: [PATCH 6.12.y-cip 3/6] thermal/drivers/renesas/rzg3s: Add thermal driver for the Renesas RZ/G3S SoC
Date: Wed, 7 Jan 2026 14:21:51 +0200	[thread overview]
Message-ID: <dec35e63-55cf-46d6-a69c-894f460ea7a1@tuxon.dev> (raw)
In-Reply-To: <aVLi32qigJKR3NcP@duo.ucw.cz>

Hi, Pavel,

Sorry for the late reply, I was off for a while.

On 12/29/25 22:21, Pavel Machek wrote:
> Hi!
> 
> I have some comments below.
> 
>> index 000000000000..d184dccc882f
>> --- /dev/null
>> +++ b/drivers/thermal/renesas/rzg3s_thermal.c
>> +static int rzg3s_thermal_get_temp(struct thermal_zone_device *tz, int *temp)
>> +{
>> +	struct rzg3s_thermal_priv *priv = thermal_zone_device_priv(tz);
>> +	int ts_code_ave = 0;
>> +
>> +	if (priv->mode != THERMAL_DEVICE_ENABLED)
>> +		return -EAGAIN;
> 
> I'm pretty sure -EAGAIN is wrong error code here. -EBUSY or something?

-EAGAIN is something that the thermal core expects here in case the 
temperature reading is failing:

https://elixir.bootlin.com/linux/v6.18.3/source/drivers/thermal/thermal_core.c#L319

https://elixir.bootlin.com/linux/v6.18.3/source/drivers/thermal/thermal_sysfs.c#L46


> 
>> +	/*
>> +	 * According to the HW manual (Rev.1.10, section 40.4.4 Procedure for Measuring the
>> +	 * Temperature) the computation formula is as follows:
>> +	 *
>> +	 * Tj = (ts_code_ave - priv->calib1) * 165 / (priv->calib0 - priv->calib1) - 40
>> +	 *
>> +	 * Convert everything to milli Celsius before applying the formula to avoid
>> +	 * losing precision.
>> +	 */
>> +
>> +	*temp = div_s64((s64)(ts_code_ave - MCELSIUS(priv->calib1)) * MCELSIUS(165),
>> +			MCELSIUS(priv->calib0 - priv->calib1)) - MCELSIUS(40);
>> +
>> +	/* Report it in milli degrees Celsius and round it up to 0.5 degrees Celsius. */
>> +	*temp = roundup(*temp, 500);
> 
> If we did the computation in high precision, and interface wants
> millicelsius, is rounding good idea?

If I remember correctly, not adjusting the above code for precision lead 
to temperature variation at degree level not be detected. I chose to 
round it to 0.5 milli degrees to follow similar Renesas thermal drivers.

> 
>> +static void rzg3s_thermal_set_mode(struct rzg3s_thermal_priv *priv,
>> +				   enum thermal_device_mode mode)
>> +{
>> +	struct device *dev = priv->dev;
>> +	int ret;
>> +
>> +	ret = pm_runtime_resume_and_get(dev);
>> +	if (ret)
>> +		return;
> 
> Now caller does not know if we failed or not. Should this return errno?

Yes, this one could be improved to return the error code.

Thank you,
Claudiu


  reply	other threads:[~2026-01-07 12:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 10:32 [PATCH 6.12.y-cip 0/6] RZ/G3S: Backport TSU support Claudiu
2025-12-17 10:32 ` [PATCH 6.12.y-cip 1/6] clk: renesas: r9a08g045: Add clocks, resets and power domain support for the TSU IP Claudiu
2025-12-17 10:32 ` [PATCH 6.12.y-cip 2/6] dt-bindings: thermal: r9a08g045-tsu: Document the TSU unit Claudiu
2025-12-17 10:32 ` [PATCH 6.12.y-cip 3/6] thermal/drivers/renesas/rzg3s: Add thermal driver for the Renesas RZ/G3S SoC Claudiu
2025-12-29 20:21   ` Pavel Machek
2026-01-07 12:21     ` Claudiu Beznea [this message]
2025-12-17 10:32 ` [PATCH 6.12.y-cip 4/6] arm64: dts: renesas: r9a08g045: Add OPP table Claudiu
2025-12-17 10:32 ` [PATCH 6.12.y-cip 5/6] arm64: dts: renesas: r9a08g045: Add TSU node Claudiu
2025-12-17 10:32 ` [PATCH 6.12.y-cip 6/6] arm64: defconfig: Enable Renesas RZ/G3S thermal driver Claudiu
2025-12-25  2:13 ` [PATCH 6.12.y-cip 0/6] RZ/G3S: Backport TSU support nobuhiro.iwamatsu.x90
2025-12-29 13:20   ` [cip-dev] " Claudiu Beznea
2025-12-29 20:12     ` Pavel Machek
2025-12-29 20:26   ` Pavel Machek
2026-01-05 21:57   ` Pavel Machek

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=dec35e63-55cf-46d6-a69c-894f460ea7a1@tuxon.dev \
    --to=claudiu.beznea@tuxon.dev \
    --cc=cip-dev@lists.cip-project.org \
    --cc=nobuhiro.iwamatsu.x90@mail.toshiba \
    --cc=pavel@denx.de \
    /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