All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32
@ 2022-08-28  7:46 Luke D. Jones
  2022-08-29 13:35 ` Guenter Roeck
  2022-09-01 15:34 ` Hans de Goede
  0 siblings, 2 replies; 4+ messages in thread
From: Luke D. Jones @ 2022-08-28  7:46 UTC (permalink / raw)
  To: hdegoede
  Cc: linux-kernel, linux-hwmon, platform-driver-x86, markgross, Luke D. Jones

Fix for TUF laptops returning with an -ENOSPC on calling
asus_wmi_evaluate_method_buf() when fetching default curves. The TUF method
requires at least 32 bytes space.

This also moves and changes the pr_debug() in fan_curve_check_present() to
pr_warn() in fan_curve_get_factory_default() so that there is at least some
indication in logs of why it fails.

Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
 drivers/platform/x86/asus-wmi.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 3d9fd58573f9..11203213e00d 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -108,7 +108,7 @@ module_param(fnlock_default, bool, 0444);
 #define WMI_EVENT_MASK			0xFFFF
 
 #define FAN_CURVE_POINTS		8
-#define FAN_CURVE_BUF_LEN		(FAN_CURVE_POINTS * 2)
+#define FAN_CURVE_BUF_LEN		32
 #define FAN_CURVE_DEV_CPU		0x00
 #define FAN_CURVE_DEV_GPU		0x01
 /* Mask to determine if setting temperature or percentage */
@@ -2383,8 +2383,10 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
 	curves = &asus->custom_fan_curves[fan_idx];
 	err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
 					   FAN_CURVE_BUF_LEN);
-	if (err)
+	if (err) {
+		pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
 		return err;
+	}
 
 	fan_curve_copy_from_buf(curves, buf);
 	curves->device_id = fan_dev;
@@ -2402,9 +2404,6 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
 
 	err = fan_curve_get_factory_default(asus, fan_dev);
 	if (err) {
-		pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
-			 fan_dev, err);
-		/* Don't cause probe to fail on devices without fan-curves */
 		return 0;
 	}
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32
  2022-08-28  7:46 [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32 Luke D. Jones
@ 2022-08-29 13:35 ` Guenter Roeck
  2022-09-01 14:58   ` Hans de Goede
  2022-09-01 15:34 ` Hans de Goede
  1 sibling, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2022-08-29 13:35 UTC (permalink / raw)
  To: Luke D. Jones
  Cc: hdegoede, linux-kernel, linux-hwmon, platform-driver-x86, markgross

On Sun, Aug 28, 2022 at 07:46:38PM +1200, Luke D. Jones wrote:
> Fix for TUF laptops returning with an -ENOSPC on calling
> asus_wmi_evaluate_method_buf() when fetching default curves. The TUF method
> requires at least 32 bytes space.
> 
> This also moves and changes the pr_debug() in fan_curve_check_present() to
> pr_warn() in fan_curve_get_factory_default() so that there is at least some
> indication in logs of why it fails.
> 
> Signed-off-by: Luke D. Jones <luke@ljones.dev>
> ---
>  drivers/platform/x86/asus-wmi.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 3d9fd58573f9..11203213e00d 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -108,7 +108,7 @@ module_param(fnlock_default, bool, 0444);
>  #define WMI_EVENT_MASK			0xFFFF
>  
>  #define FAN_CURVE_POINTS		8
> -#define FAN_CURVE_BUF_LEN		(FAN_CURVE_POINTS * 2)
> +#define FAN_CURVE_BUF_LEN		32
>  #define FAN_CURVE_DEV_CPU		0x00
>  #define FAN_CURVE_DEV_GPU		0x01
>  /* Mask to determine if setting temperature or percentage */
> @@ -2383,8 +2383,10 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
>  	curves = &asus->custom_fan_curves[fan_idx];
>  	err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
>  					   FAN_CURVE_BUF_LEN);
> -	if (err)
> +	if (err) {
> +		pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
>  		return err;
> +	}
>  
>  	fan_curve_copy_from_buf(curves, buf);
>  	curves->device_id = fan_dev;
> @@ -2402,9 +2404,6 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
>  
>  	err = fan_curve_get_factory_default(asus, fan_dev);
>  	if (err) {
> -		pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
> -			 fan_dev, err);
> -		/* Don't cause probe to fail on devices without fan-curves */

The pr_warn() should be here. If you want to have a message from the call
in fan_curve_enable_store(), add dev_err() there.

Guenter

>  		return 0;
>  	}
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32
  2022-08-29 13:35 ` Guenter Roeck
@ 2022-09-01 14:58   ` Hans de Goede
  0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-09-01 14:58 UTC (permalink / raw)
  To: Guenter Roeck, Luke D. Jones
  Cc: linux-kernel, linux-hwmon, platform-driver-x86, markgross

Hi All,

On 8/29/22 15:35, Guenter Roeck wrote:
> On Sun, Aug 28, 2022 at 07:46:38PM +1200, Luke D. Jones wrote:
>> Fix for TUF laptops returning with an -ENOSPC on calling
>> asus_wmi_evaluate_method_buf() when fetching default curves. The TUF method
>> requires at least 32 bytes space.
>>
>> This also moves and changes the pr_debug() in fan_curve_check_present() to
>> pr_warn() in fan_curve_get_factory_default() so that there is at least some
>> indication in logs of why it fails.
>>
>> Signed-off-by: Luke D. Jones <luke@ljones.dev>
>> ---
>>  drivers/platform/x86/asus-wmi.c | 9 ++++-----
>>  1 file changed, 4 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
>> index 3d9fd58573f9..11203213e00d 100644
>> --- a/drivers/platform/x86/asus-wmi.c
>> +++ b/drivers/platform/x86/asus-wmi.c
>> @@ -108,7 +108,7 @@ module_param(fnlock_default, bool, 0444);
>>  #define WMI_EVENT_MASK			0xFFFF
>>  
>>  #define FAN_CURVE_POINTS		8
>> -#define FAN_CURVE_BUF_LEN		(FAN_CURVE_POINTS * 2)
>> +#define FAN_CURVE_BUF_LEN		32
>>  #define FAN_CURVE_DEV_CPU		0x00
>>  #define FAN_CURVE_DEV_GPU		0x01
>>  /* Mask to determine if setting temperature or percentage */
>> @@ -2383,8 +2383,10 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
>>  	curves = &asus->custom_fan_curves[fan_idx];
>>  	err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
>>  					   FAN_CURVE_BUF_LEN);
>> -	if (err)
>> +	if (err) {
>> +		pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
>>  		return err;
>> +	}
>>  
>>  	fan_curve_copy_from_buf(curves, buf);
>>  	curves->device_id = fan_dev;
>> @@ -2402,9 +2404,6 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
>>  
>>  	err = fan_curve_get_factory_default(asus, fan_dev);
>>  	if (err) {
>> -		pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
>> -			 fan_dev, err);
>> -		/* Don't cause probe to fail on devices without fan-curves */
> 
> The pr_warn() should be here. If you want to have a message from the call
> in fan_curve_enable_store(), add dev_err() there.

Guenter I can understand where you are coming from with the warn vs err
thing but IMHO that is a minor concern and I'm actually a fan of pushing
error logging closer to the first failing call so that we only have
one place to log the error instead of having to log it separately in
all the callers.

So I'm going to take this patch as is.

Regards,

Hans


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32
  2022-08-28  7:46 [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32 Luke D. Jones
  2022-08-29 13:35 ` Guenter Roeck
@ 2022-09-01 15:34 ` Hans de Goede
  1 sibling, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2022-09-01 15:34 UTC (permalink / raw)
  To: Luke D. Jones; +Cc: linux-kernel, linux-hwmon, platform-driver-x86, markgross

Hi,

On 8/28/22 09:46, Luke D. Jones wrote:
> Fix for TUF laptops returning with an -ENOSPC on calling
> asus_wmi_evaluate_method_buf() when fetching default curves. The TUF method
> requires at least 32 bytes space.
> 
> This also moves and changes the pr_debug() in fan_curve_check_present() to
> pr_warn() in fan_curve_get_factory_default() so that there is at least some
> indication in logs of why it fails.
> 
> Signed-off-by: Luke D. Jones <luke@ljones.dev>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans


> ---
>  drivers/platform/x86/asus-wmi.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 3d9fd58573f9..11203213e00d 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -108,7 +108,7 @@ module_param(fnlock_default, bool, 0444);
>  #define WMI_EVENT_MASK			0xFFFF
>  
>  #define FAN_CURVE_POINTS		8
> -#define FAN_CURVE_BUF_LEN		(FAN_CURVE_POINTS * 2)
> +#define FAN_CURVE_BUF_LEN		32
>  #define FAN_CURVE_DEV_CPU		0x00
>  #define FAN_CURVE_DEV_GPU		0x01
>  /* Mask to determine if setting temperature or percentage */
> @@ -2383,8 +2383,10 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
>  	curves = &asus->custom_fan_curves[fan_idx];
>  	err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
>  					   FAN_CURVE_BUF_LEN);
> -	if (err)
> +	if (err) {
> +		pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
>  		return err;
> +	}
>  
>  	fan_curve_copy_from_buf(curves, buf);
>  	curves->device_id = fan_dev;
> @@ -2402,9 +2404,6 @@ static int fan_curve_check_present(struct asus_wmi *asus, bool *available,
>  
>  	err = fan_curve_get_factory_default(asus, fan_dev);
>  	if (err) {
> -		pr_debug("fan_curve_get_factory_default(0x%08x) failed: %d\n",
> -			 fan_dev, err);
> -		/* Don't cause probe to fail on devices without fan-curves */
>  		return 0;
>  	}
>  


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-01 15:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-28  7:46 [PATCH] asus-wmi: Increase FAN_CURVE_BUF_LEN to 32 Luke D. Jones
2022-08-29 13:35 ` Guenter Roeck
2022-09-01 14:58   ` Hans de Goede
2022-09-01 15:34 ` Hans de Goede

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.