From: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
To: Philipp Zabel <p.zabel@pengutronix.de>, rafael@kernel.org
Cc: daniel.lezcano@kernel.org, rui.zhang@intel.com,
lukasz.luba@arm.com, matthias.bgg@gmail.com,
laura.nao@collabora.com, fshao@chromium.org, wenst@chromium.org,
jiapeng.chong@linux.alibaba.com, frank-w@public-files.de,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, kernel@collabora.com
Subject: Re: [PATCH] thermal/drivers/mediatek/lvts_thermal: Make reset optional for MT8196
Date: Tue, 21 Jul 2026 12:43:10 +0200 [thread overview]
Message-ID: <8a9aed82-5f0c-4ad8-91c5-1e1ac169781d@collabora.com> (raw)
In-Reply-To: <16651472d6a782bdef63e1c9742444de08c59f1e.camel@pengutronix.de>
On 7/21/26 09:53, Philipp Zabel wrote:
> On Mo, 2026-07-20 at 16:42 +0200, AngeloGioacchino Del Regno wrote:
>> Depending on the SoC+Firmware combination, the LVTS hardware may be
>> may be actively used by one or even multiple concurrent MCUs!
>> In this case, resetting it may produce either a severe slowdown of
>> the entire system, or even a thermal protection AP reset, as some
>> MCU(s) may be reading a very high or very low temperature while the
>> LVTS is being reset.
>>
>> On those, don't fail if no reset is found as that may be omitted on
>> purpose, but still check if there's one, because some board(s) may
>> be running on a different bootchain with reduced firmwares or using
>> firmwares with reduced functionality.
>>
>> Add a new "optional_reset" member to lvts_data and use it to check
>> whether the resets should be mandatory or not.
>>
>> Also, while at it, since devm_reset_control_get_by_index() is now
>> deprecated, change the probe function to instead call function
>> devm_reset_control_get_exclusive_by_index(), which does the same.
>
> Why is this using _by_index() at all? mediatek,lvts-thermal.yaml
> specifies a single reset, so the driver should just
> devm_reset_control_get_exclusive(dev, NULL).
>
>>
>> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>> ---
>> drivers/thermal/mediatek/lvts_thermal.c | 29 ++++++++++++++++++++++---
>> 1 file changed, 26 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/thermal/mediatek/lvts_thermal.c b/drivers/thermal/mediatek/lvts_thermal.c
>> index 92711896ce24..6670b5458f2c 100644
>> --- a/drivers/thermal/mediatek/lvts_thermal.c
>> +++ b/drivers/thermal/mediatek/lvts_thermal.c
>> @@ -160,6 +160,7 @@ struct lvts_data {
>> int gt_calib_bit_offset;
>> unsigned int def_calibration;
>> u16 msr_offset;
>> + bool optional_reset;
>
> No need to complicate things. It's not the driver's business to check
> device tree correctness. Just make the reset optional, as the commit
> message says.
>
>> };
>>
>> struct lvts_sensor {
>> @@ -1473,9 +1474,29 @@ static int lvts_probe(struct platform_device *pdev)
>> if (IS_ERR(lvts_td->base))
>> return dev_err_probe(dev, PTR_ERR(lvts_td->base), "Failed to map io resource\n");
>>
>> - lvts_td->reset = devm_reset_control_get_by_index(dev, 0);
>> - if (IS_ERR(lvts_td->reset))
>> - return dev_err_probe(dev, PTR_ERR(lvts_td->reset), "Failed to get reset control\n");
>> + /*
>> + * Depending on the SoC+Firmware combination, the LVTS hardware may be
>> + * may be actively used by one or even multiple concurrent MCUs!
>> + * In this case, resetting it may produce either a severe slowdown of
>> + * the entire system, or even a thermal protection AP reset, as some
>> + * MCU(s) may be reading a very high or very low temperature while the
>> + * LVTS is being reset.
>> + *
>> + * On those, don't fail if no reset is found as that may be omitted on
>> + * purpose, but still check if there's one, because some board(s) may
>> + * be running on a different bootchain with reduced firmwares or using
>> + * firmwares with reduced functionality.
>> + */
>> + lvts_td->reset = devm_reset_control_get_exclusive_by_index(dev, 0);
>
> So this should be:
>
> lvts_td->reset = devm_reset_control_get_optional_exclusive(dev, NULL);
>
>> + if (IS_ERR(lvts_td->reset)) {
>> + if (lvts_data->optional_reset) {
>> + dev_dbg(dev, "No reset found. LVTS may be used by firmware.\n");
>> + lvts_td->reset = NULL;
>
> This is not necessary then.
>
>> + } else {
>> + return dev_err_probe(dev, PTR_ERR(lvts_td->reset),
>> + "Failed to get reset control\n");
>> + }
>
> And this part could be kept as before.
>
>> + }
>>
>> irq = platform_get_irq(pdev, 0);
>> if (irq < 0)
>> @@ -2163,6 +2184,7 @@ static const struct lvts_data mt8196_lvts_mcu_data = {
>> .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT8196,
>> .msr_offset = LVTS_MSR_OFFSET_MT8196,
>> .ops = &lvts_platform_ops_mt8196,
>> + .optional_reset = true,
>
> But mediatek,lvts-thermal.yaml still specifies the reset as required
> for mediatek,mt8196-lvts-ap. That should be changed instead.
>
>> };
>>
>> static const struct lvts_data mt8196_lvts_ap_data = {
>> @@ -2175,6 +2197,7 @@ static const struct lvts_data mt8196_lvts_ap_data = {
>> .num_cal_offsets = LVTS_NUM_CAL_OFFSETS_MT8196,
>> .msr_offset = LVTS_MSR_OFFSET_MT8196,
>> .ops = &lvts_platform_ops_mt8196,
>> + .optional_reset = true,
>
> Same as above, but for mediatek,mt8196-lvts-mcu.
>
Ack. Will send a v2 shortly.
Thanks,
Angelo
prev parent reply other threads:[~2026-07-21 10:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 14:42 AngeloGioacchino Del Regno
2026-07-21 7:53 ` Philipp Zabel
2026-07-21 10:43 ` AngeloGioacchino Del Regno [this message]
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=8a9aed82-5f0c-4ad8-91c5-1e1ac169781d@collabora.com \
--to=angelogioacchino.delregno@collabora.com \
--cc=daniel.lezcano@kernel.org \
--cc=frank-w@public-files.de \
--cc=fshao@chromium.org \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=kernel@collabora.com \
--cc=laura.nao@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=lukasz.luba@arm.com \
--cc=matthias.bgg@gmail.com \
--cc=p.zabel@pengutronix.de \
--cc=rafael@kernel.org \
--cc=rui.zhang@intel.com \
--cc=wenst@chromium.org \
/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
all inboxes | Powered by JetHome®