diff mbox series

thermal: adding check if the thermal firmware is running

Message ID 20240517141655.2797-1-trintaeoitogc@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series thermal: adding check if the thermal firmware is running | expand

Commit Message

Guilherme Giacomo Simoes May 17, 2024, 2:16 p.m. UTC
In the dmesg is showing the message "failed to read out thermal zone"
as if the temperature read is failed by don't find the thermal zone.

After researching and debugging, I see that this specific error is
occurrenced because the thermal try read the temperature when is started,
but the firmware is not running yet.

For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
After this change, in my computer I compile and install kernel in /boot
and in my dmesg the message "failed to read out thermal zone" is not show
any more.

I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
your suggestions in mu first patch that results in this another patch.
---
 drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Kalle Valo May 17, 2024, 2:53 p.m. UTC | #1
Guilherme Giacomo Simoes <trintaeoitogc@gmail.com> writes:

> In the dmesg is showing the message "failed to read out thermal zone"
> as if the temperature read is failed by don't find the thermal zone.
>
> After researching and debugging, I see that this specific error is
> occurrenced because the thermal try read the temperature when is started,
> but the firmware is not running yet.
>
> For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
> After this change, in my computer I compile and install kernel in /boot
> and in my dmesg the message "failed to read out thermal zone" is not show
> any more.
>
> I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
> your suggestions in mu first patch that results in this another patch.
> ---
>  drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

Please read the wiki link below how to submit wireless patches. For
example, the title is wrong and you haven't signed the patch.
Guilherme Giacomo Simoes May 17, 2024, 4:35 p.m. UTC | #2
Kalle Valo <kvalo@kernel.org> writes:
>> In the dmesg is showing the message "failed to read out thermal zone"
>> as if the temperature read is failed by don't find the thermal zone.
>>
>> After researching and debugging, I see that this specific error is
>> occurrenced because the thermal try read the temperature when is started,
>> but the firmware is not running yet.
>>
>> For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
>> After this change, in my computer I compile and install kernel in /boot
>> and in my dmesg the message "failed to read out thermal zone" is not show
>> any more.
>>
>> I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
>> your suggestions in mu first patch that results in this another patch.
>> ---
>>  drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>
>Please read the wiki link below how to submit wireless patches. For
>example, the title is wrong and you haven't signed the patch.

Okay, thank you for your explanation Mr. Valo
I will fix the patch and resend this.

Em sex., 17 de mai. de 2024 às 11:53, Kalle Valo <kvalo@kernel.org> escreveu:
>
> Guilherme Giacomo Simoes <trintaeoitogc@gmail.com> writes:
>
> > In the dmesg is showing the message "failed to read out thermal zone"
> > as if the temperature read is failed by don't find the thermal zone.
> >
> > After researching and debugging, I see that this specific error is
> > occurrenced because the thermal try read the temperature when is started,
> > but the firmware is not running yet.
> >
> > For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
> > After this change, in my computer I compile and install kernel in /boot
> > and in my dmesg the message "failed to read out thermal zone" is not show
> > any more.
> >
> > I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
> > your suggestions in mu first patch that results in this another patch.
> > ---
> >  drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
>
> Please read the wiki link below how to submit wireless patches. For
> example, the title is wrong and you haven't signed the patch.
>
> --
> https://patchwork.kernel.org/project/linux-wireless/list/
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Guilherme Giacomo Simoes May 17, 2024, 4:37 p.m. UTC | #3
Kalle Valo <kvalo@kernel.org> writes:
>
> Guilherme Giacomo Simoes <trintaeoitogc@gmail.com> writes:
>
> > In the dmesg is showing the message "failed to read out thermal zone"
> > as if the temperature read is failed by don't find the thermal zone.
> >
> > After researching and debugging, I see that this specific error is
> > occurrenced because the thermal try read the temperature when is started,
> > but the firmware is not running yet.
> >
> > For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
> > After this change, in my computer I compile and install kernel in /boot
> > and in my dmesg the message "failed to read out thermal zone" is not show
> > any more.
> >
> > I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
> > your suggestions in mu first patch that results in this another patch.
> > ---
> >  drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
>
> Please read the wiki link below how to submit wireless patches. For
> example, the title is wrong and you haven't signed the patch.
>
> --
> https://patchwork.kernel.org/project/linux-wireless/list/
>
> https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

Thank you for your explanation Mr. Valo.
I will fix the patch and resend.
Jonathan Bither May 17, 2024, 4:57 p.m. UTC | #4
On 5/17/24 10:16, Guilherme Giacomo Simoes wrote:
> In the dmesg is showing the message "failed to read out thermal zone"
> as if the temperature read is failed by don't find the thermal zone.
>
> After researching and debugging, I see that this specific error is
> occurrenced because the thermal try read the temperature when is started,
> but the firmware is not running yet.
>
> For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
> After this change, in my computer I compile and install kernel in /boot
> and in my dmesg the message "failed to read out thermal zone" is not show
> any more.
>
> I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
> your suggestions in mu first patch that results in this another patch.
> ---
>   drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
> index 8083c4b2ab6b..68ab9966330c 100644
> --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
> +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
> @@ -620,8 +620,14 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
>   
>   	mutex_lock(&mvm->mutex);
>   
> -	if (!iwl_mvm_firmware_running(mvm) ||
> -	    mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
> +	const int res = iwl_mvm_firmware_running(mvm);
> +
> +	if (!res) {
> +		ret = -EAGAIN;
> +		goto out;
> +	}
> +

You could skip using the res variable and move the mutex lock here and 
simplify the above a bit. Ex:

         int temp;

-       mutex_lock(&mvm->mutex);
+       if (!iwl_mvm_firmware_running(mvm))
+               return -EAGAIN;

-       if (!iwl_mvm_firmware_running(mvm) ||
-           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
+       mutex_lock(&mvm->mutex);
+       if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
                 ret = -ENODATA;
                 goto out;
         }

> +	if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
>   		ret = -ENODATA;
>   		goto out;
>   	}
Guilherme Giacomo Simoes May 17, 2024, 5:25 p.m. UTC | #5
Em sex., 17 de mai. de 2024 às 13:57, Jonathan Bither
<jonbither@gmail.com> escreveu:
>
>
> On 5/17/24 10:16, Guilherme Giacomo Simoes wrote:
> > In the dmesg is showing the message "failed to read out thermal zone"
> > as if the temperature read is failed by don't find the thermal zone.
> >
> > After researching and debugging, I see that this specific error is
> > occurrenced because the thermal try read the temperature when is started,
> > but the firmware is not running yet.
> >
> > For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
> > After this change, in my computer I compile and install kernel in /boot
> > and in my dmesg the message "failed to read out thermal zone" is not show
> > any more.
> >
> > I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
> > your suggestions in mu first patch that results in this another patch.
> > ---
> >   drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
> >   1 file changed, 8 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
> > index 8083c4b2ab6b..68ab9966330c 100644
> > --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
> > +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
> > @@ -620,8 +620,14 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
> >
> >       mutex_lock(&mvm->mutex);
> >
> > -     if (!iwl_mvm_firmware_running(mvm) ||
> > -         mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
> > +     const int res = iwl_mvm_firmware_running(mvm);
> > +
> > +     if (!res) {
> > +             ret = -EAGAIN;
> > +             goto out;
> > +     }
> > +
>
> You could skip using the res variable and move the mutex lock here and
> simplify the above a bit. Ex:
>
>          int temp;
>
> -       mutex_lock(&mvm->mutex);
> +       if (!iwl_mvm_firmware_running(mvm))
> +               return -EAGAIN;
>
> -       if (!iwl_mvm_firmware_running(mvm) ||
> -           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
> +       mutex_lock(&mvm->mutex);
> +       if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
>                  ret = -ENODATA;
>                  goto out;
>          }
>
> > +     if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
> >               ret = -ENODATA;
> >               goto out;
> >       }

Hey Jonathan, Thank you for your suggestion.
I sended a v2 patch of this patch
https://patchwork.kernel.org/project/linux-wireless/patch/20240517171311.3705-1-trintaeoitogc@gmail.com/

If you want, you can send this suggestion in this patch v2.

Thanks.
Jonathan Bither May 17, 2024, 5:43 p.m. UTC | #6
On 5/17/24 13:25, Guilherme Giácomo Simões wrote:
> Em sex., 17 de mai. de 2024 às 13:57, Jonathan Bither
> <jonbither@gmail.com> escreveu:
>>
>> On 5/17/24 10:16, Guilherme Giacomo Simoes wrote:
>>> In the dmesg is showing the message "failed to read out thermal zone"
>>> as if the temperature read is failed by don't find the thermal zone.
>>>
>>> After researching and debugging, I see that this specific error is
>>> occurrenced because the thermal try read the temperature when is started,
>>> but the firmware is not running yet.
>>>
>>> For more legibiliti i change the tt.c for return EAGAIN when this was occurrence.
>>> After this change, in my computer I compile and install kernel in /boot
>>> and in my dmesg the message "failed to read out thermal zone" is not show
>>> any more.
>>>
>>> I would like to thanks for Rafael Wysocki <refael.j.wysocki@intel.com> for
>>> your suggestions in mu first patch that results in this another patch.
>>> ---
>>>    drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 10 ++++++++--
>>>    1 file changed, 8 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
>>> index 8083c4b2ab6b..68ab9966330c 100644
>>> --- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
>>> +++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
>>> @@ -620,8 +620,14 @@ static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
>>>
>>>        mutex_lock(&mvm->mutex);
>>>
>>> -     if (!iwl_mvm_firmware_running(mvm) ||
>>> -         mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
>>> +     const int res = iwl_mvm_firmware_running(mvm);
>>> +
>>> +     if (!res) {
>>> +             ret = -EAGAIN;
>>> +             goto out;
>>> +     }
>>> +
>> You could skip using the res variable and move the mutex lock here and
>> simplify the above a bit. Ex:
>>
>>           int temp;
>>
>> -       mutex_lock(&mvm->mutex);
>> +       if (!iwl_mvm_firmware_running(mvm))
>> +               return -EAGAIN;
>>
>> -       if (!iwl_mvm_firmware_running(mvm) ||
>> -           mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
>> +       mutex_lock(&mvm->mutex);
>> +       if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
>>                   ret = -ENODATA;
>>                   goto out;
>>           }
>>
>>> +     if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
>>>                ret = -ENODATA;
>>>                goto out;
>>>        }
> Hey Jonathan, Thank you for your suggestion.
> I sended a v2 patch of this patch
> https://patchwork.kernel.org/project/linux-wireless/patch/20240517171311.3705-1-trintaeoitogc@gmail.com/
>
> If you want, you can send this suggestion in this patch v2.
Hey Guilherme, no worries.
>
> Thanks.
diff mbox series

Patch

diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
index 8083c4b2ab6b..68ab9966330c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/tt.c
@@ -620,8 +620,14 @@  static int iwl_mvm_tzone_get_temp(struct thermal_zone_device *device,
 
 	mutex_lock(&mvm->mutex);
 
-	if (!iwl_mvm_firmware_running(mvm) ||
-	    mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
+	const int res = iwl_mvm_firmware_running(mvm);
+
+	if (!res) {
+		ret = -EAGAIN;
+		goto out;
+	}
+
+	if (mvm->fwrt.cur_fw_img != IWL_UCODE_REGULAR) {
 		ret = -ENODATA;
 		goto out;
 	}