From: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com>
To: Ronald Claveau <linux-kernel-dev@aliel.fr>
Cc: linux-pm@vger.kernel.org, linux-amlogic@lists.infradead.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
Guillaume La Roque <glaroque@baylibre.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@kernel.org>,
Zhang Rui <rui.zhang@intel.com>,
Lukasz Luba <lukasz.luba@arm.com>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Neil Armstrong <neil.armstrong@linaro.org>,
Kevin Hilman <khilman@baylibre.com>,
Jerome Brunet <jbrunet@baylibre.com>,
Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Subject: Re: [PATCH v3 4/8] thermal: amlogic: Add support for secure monitor calibration readout
Date: Thu, 23 Apr 2026 17:17:13 +0200 [thread overview]
Message-ID: <8a4dcb94-ab88-4559-9027-49308ad02b73@oss.qualcomm.com> (raw)
In-Reply-To: <19d70883-21db-4963-841d-7c00505e0d9e@aliel.fr>
On 4/23/26 17:09, Ronald Claveau wrote:
> Hi Daniel,
>
> Thanks for your feedback.
>
> On 4/23/26 12:25 PM, Daniel Lezcano wrote:
>>
>> Hi Ronald,
>>
function1() {
>>> + if (pdata->data->use_sm) {
>>> + struct device_node *sm_np;
>>> + struct of_phandle_args ph_args;
>>> +
>>> + ret = of_parse_phandle_with_fixed_args(pdev->dev.of_node,
>>> + "amlogic,secure-monitor",
>>> + 1, 0, &ph_args);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + sm_np = ph_args.np;
>>> + if (!sm_np) {
>>> + dev_err(dev,
>>> + "Failed to parse secure monitor phandle\n");
>>> + return -ENODEV;
>>> + }
>>> +
>>> + pdata->sm_fw = meson_sm_get(sm_np);
>>> + of_node_put(sm_np);
>>> + if (!pdata->sm_fw) {
>>> + dev_err(dev, "Failed to get secure monitor firmware\n");
>>> + return -EPROBE_DEFER;
>>> + }
>>> +
>>> + pdata->tsensor_id = ph_args.args[0];
>>> + }
}
function2() {
else {
>>> + pdata->sec_ao_map = syscon_regmap_lookup_by_phandle
>>> + (pdev->dev.of_node, "amlogic,ao-secure");
>>> + if (IS_ERR(pdata->sec_ao_map)) {
>>> + dev_err(dev, "syscon regmap lookup failed.\n");
>>> + return PTR_ERR(pdata->sec_ao_map);
>>> + }
>>> }
}
> Sure, I will do that.
>
>>> pdata->tzd = devm_thermal_of_zone_register(&pdev->dev
>>
>> The thermal zone is registered before calling
>> amlogic_thermal_initialize(), thus pdata->trim_info is not initialized.
>> When a thermal zone is registered the thermal framework reads the
>> temperature, so it reads an invalid value because:
>>
>> devm_thermal_of_zone_register()
>> -> thermal_of_zone_register()
>> -> thermal_zone_device_register_with_trips()
>> -> thermal_zone_device_enable()
>> -> __thermal_zone_device_update()
>> -> __thermal_zone_get_temp()
>> -> amlogic_thermal_get_temp()
>> -> amlogic_thermal_code_to_millicelsius()
>> [ Use of uninitialized pdata->trim_info ]
>>
>> Right ?
>>
>
> Yes, I will move the initialize before the register.
>
>> IIUC, amlogic_thermal_initialize() can be also split and moved the
>> corresponding blocks to the functions to be created in the comment above.
>>
>
> The SM and syscon setup will be extracted into two functions.
> amlogic_thermal_initialize() itself is kept as-is but moved before
> devm_thermal_of_zone_register().
> Let me know if you'd prefer a different approach.
In the initialize function the following chunk is added:
+ if (pdata->data->use_sm) {
+ return meson_sm_get_thermal_calib(pdata->sm_fw,
+ &pdata->trim_info,
+ pdata->tsensor_id);
+ }
I was suggesting to move it to function1() and the rest of code from
initialize in function2()
That results in amlogic_thermal_initialize() to be dissolved in
function1() and function2()
next prev parent reply other threads:[~2026-04-23 15:17 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-21 7:19 [PATCH v3 0/8] arm64: amlogic: T7 thermal support Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 1/8] dt-bindings: thermal: amlogic: Add support for T7 Ronald Claveau
2026-04-21 17:05 ` Conor Dooley
2026-04-21 7:19 ` [PATCH v3 2/8] firmware: meson: sm: Thermal calibration read via secure monitor Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 3/8] firmware: meson: sm: Add thermal calibration SMC call Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 4/8] thermal: amlogic: Add support for secure monitor calibration readout Ronald Claveau
2026-04-23 10:25 ` Daniel Lezcano
2026-04-23 15:09 ` Ronald Claveau
2026-04-23 15:17 ` Daniel Lezcano [this message]
2026-04-23 15:29 ` Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 5/8] arm64: dts: amlogic: t7: Add cooling cells to all CPUs Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 6/8] arm64: dts: amlogic: t7: Add thermal sensor nodes Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 7/8] arm64: dts: amlogic: t7: Add thermal zones Ronald Claveau
2026-04-21 7:19 ` [PATCH v3 8/8] arm64: dts: amlogic: t7: khadas-vim4: Add fan cooling to " Ronald Claveau
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=8a4dcb94-ab88-4559-9027-49308ad02b73@oss.qualcomm.com \
--to=daniel.lezcano@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=daniel.lezcano@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=glaroque@baylibre.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=krzk+dt@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel-dev@aliel.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=martin.blumenstingl@googlemail.com \
--cc=neil.armstrong@linaro.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=rui.zhang@intel.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