Re: [PATCH v3] thermal: core: Call monitor_thermal_zone() if zone temperature is invalid

From: Rafael J. Wysocki
Date: Tue Jul 16 2024 - 07:21:52 EST


On Tue, Jul 16, 2024 at 12:55 PM Stefan Lippers-Hollmann <s.l-h@xxxxxx> wrote:
>
> Hi
>
> On 2024-07-16, Rafael J. Wysocki wrote:
> > On Tue, Jul 16, 2024 at 1:48 AM Stefan Lippers-Hollmann <s.l-h@xxxxxx> wrote:
> > > On 2024-07-15, Rafael J. Wysocki wrote:
> > > > On Mon, Jul 15, 2024 at 2:54 PM Stefan Lippers-Hollmann <s.l-h@xxxxxx> wrote:
> > > > > On 2024-07-15, Rafael J. Wysocki wrote:
> > > > > > On Mon, Jul 15, 2024 at 11:09 AM Daniel Lezcano
> > > > > > <daniel.lezcano@xxxxxxxxxx> wrote:
> > > > > > > On 15/07/2024 06:45, Eric Biggers wrote:
> > > > > > > > On Thu, Jul 04, 2024 at 01:46:26PM +0200, Rafael J. Wysocki wrote:
> > > > > > > >> From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> > > [...]
> > > > > Silencing the warnings is already a big improvement - and that patch
> > > > > works to this extent for me with an ax200, thanks.
> > > >
> > > > So attached is a patch that should avoid enabling the thermal zone
> > > > when it is not ready for use in the first place, so it should address
> > > > both the message and the useless polling.
> > > >
> > > > I would appreciate giving it a go (please note that it hasn't received
> > > > much testing so far, though).
> > >
> > > Sadly this patch doesn't seem to help:
> >
> > This is likely because it is missing checks for firmware image type.
> > I've added them to the attached new version. Please try it.
> >
> > I've also added two pr_info() messages to get a better idea of what's
> > going on, so please grep dmesg for "Thermal zone not ready" and
> > "Enabling thermal zone".
>
> This is the output with the patch applied:

Thanks for testing!

> $ dmesg | grep -i -e iwlwifi -e thermal
> [ 0.081026] CPU0: Thermal monitoring enabled (TM1)
> [ 0.113898] thermal_sys: Registered thermal governor 'fair_share'
> [ 0.113900] thermal_sys: Registered thermal governor 'bang_bang'
> [ 0.113901] thermal_sys: Registered thermal governor 'step_wise'
> [ 0.113902] thermal_sys: Registered thermal governor 'user_space'
> [ 0.113903] thermal_sys: Registered thermal governor 'power_allocator'
> [ 3.917770] iwlwifi 0000:04:00.0: enabling device (0140 -> 0142)
> [ 3.926543] iwlwifi 0000:04:00.0: Detected crf-id 0x3617, cnv-id 0x100530 wfpm id 0x80000000
> [ 3.926551] iwlwifi 0000:04:00.0: PCI dev 2723/0084, rev=0x340, rfid=0x10a100
> [ 3.936737] iwlwifi 0000:04:00.0: TLV_FW_FSEQ_VERSION: FSEQ Version: 89.3.35.37
> [ 4.021494] iwlwifi 0000:04:00.0: loaded firmware version 77.a20fb07d.0 cc-a0-77.ucode op_mode iwlmvm
> [ 4.347478] iwlwifi 0000:04:00.0: Detected Intel(R) Wi-Fi 6 AX200 160MHz, REV=0x340
> [ 4.347616] iwl_mvm_thermal_zone_register: Thermal zone not ready

So this means that iwl_mvm_thermal_zone_register() sees that the
thermal zone is not ready and returns without enabling it. So far so
good.

> [ 4.478749] iwlwifi 0000:04:00.0: Detected RF HR B3, rfid=0x10a100
> [ 4.478777] thermal thermal_zone2: Enabling thermal zone

This means that iwl_mvm_load_ucode_wait_alive() has called
iwl_mvm_thermal_tzone_enable() for thermal_zone2 after checking that
the firmware image type is IWL_UCODE_REGULAR and after setting
IWL_MVM_STATUS_FIRMWARE_RUNNING is mvm->status.

> [ 4.543601] iwlwifi 0000:04:00.0: base HW address: 94:e6:f7:XX:XX:XX
> [ 4.559564] thermal thermal_zone2: failed to read out thermal zone (-61)

And interestingly enough, iwl_mvm_tzone_get_temp() sees that
IWL_MVM_STATUS_FIRMWARE_RUNNING is not set in mvm->status or the
firmware image type is not IWL_UCODE_REGULAR. I'm guessing the
former.

> [ 4.602339] iwlwifi 0000:04:00.0 wlp4s0: renamed from wlan0
> [ 4.810373] thermal thermal_zone2: failed to read out thermal zone (-61)
> [ 5.066381] thermal thermal_zone2: failed to read out thermal zone (-61)
> [ 5.322385] thermal thermal_zone2: failed to read out thermal zone (-61)
> [ 5.579377] thermal thermal_zone2: failed to read out thermal zone (-61)
> [ 5.834375] thermal thermal_zone2: failed to read out thermal zone (-61)
> [ 6.091372] thermal thermal_zone2: failed to read out thermal zone (-61)
> [ 6.346400] thermal thermal_zone2: failed to read out thermal zone (-61)
> [...]

Since there is only one place where IWL_MVM_STATUS_FIRMWARE_RUNNING is
set and that is in iwl_mvm_load_ucode_wait_alive(), I think that it is
cleared somewhere after iwl_mvm_load_ucode_wait_alive() has completed
and before iwl_mvm_tzone_get_temp() runs.