All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs
@ 2019-11-04 18:11 Leonid Maksymchuk
  2019-11-04 18:26 ` [RFC PATCH 1/3] platform/x86: asus_wmi: Fix return value of fan_boost_mode_store Leonid Maksymchuk
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Leonid Maksymchuk @ 2019-11-04 18:11 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, acpi4asus-user, chiu, yurii.pavlovskyi,
	kristian, andy, dvhart, corentin.chary

Hi,

this patch series adds support of ASUS TUF laptops on Ryzen CPUs to existing
asus_wmi platform driver and also fixes minor bug.

(Resend with proper patch indentation)

Leonid Maksimchuk (3):
   asus_wmi: Fix return value of fan_boost_mode_store
   asus_wmi: Add support for fan boost mode on FX505DY/FX705DY
   asus_wmi: Set default fan boost mode to normal

  drivers/platform/x86/asus-wmi.c            | 57 ++++++++++++++++++++++--------
  include/linux/platform_data/x86/asus-wmi.h |  1 +
  2 files changed, 43 insertions(+), 15 deletions(-)

-- 
1.8.3.1


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

* [RFC PATCH 1/3] platform/x86: asus_wmi: Fix return value of fan_boost_mode_store
  2019-11-04 18:11 [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs Leonid Maksymchuk
@ 2019-11-04 18:26 ` Leonid Maksymchuk
  2019-11-04 18:28 ` [RFC PATCH 2/3] platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY Leonid Maksymchuk
  2019-11-04 18:29 ` [RFC PATCH 3/3] platform/x86: asus_wmi: Set default fan boost mode to normal Leonid Maksymchuk
  2 siblings, 0 replies; 6+ messages in thread
From: Leonid Maksymchuk @ 2019-11-04 18:26 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, acpi4asus-user, chiu, yurii.pavlovskyi,
	kristian, andy, dvhart, corentin.chary

Function fan_boost_mode_store should return number of bytes written
but instead it returns return value of kstrtou8 which is 0 if
conversion is succefull. This leads to infinite loop after any
write to it's SysFS entry.

Fixes: b096f626a682 ("platform/x86: asus-wmi: Switch fan boost mode")
Signed-off-by: Leonid Maksymchuk <leonmaxx@gmail.com>
---
  drivers/platform/x86/asus-wmi.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 821b08e..723aa4d 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1718,7 +1718,7 @@ static ssize_t fan_boost_mode_store(struct device *dev,
  	asus->fan_boost_mode = new_mode;
  	fan_boost_mode_write(asus);
  
-	return result;
+	return count;
  }
  
  // Fan boost mode: 0 - normal, 1 - overboost, 2 - silent
-- 
1.8.3.1


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

* [RFC PATCH 2/3] platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY
  2019-11-04 18:11 [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs Leonid Maksymchuk
  2019-11-04 18:26 ` [RFC PATCH 1/3] platform/x86: asus_wmi: Fix return value of fan_boost_mode_store Leonid Maksymchuk
@ 2019-11-04 18:28 ` Leonid Maksymchuk
  2019-11-04 18:29 ` [RFC PATCH 3/3] platform/x86: asus_wmi: Set default fan boost mode to normal Leonid Maksymchuk
  2 siblings, 0 replies; 6+ messages in thread
From: Leonid Maksymchuk @ 2019-11-04 18:28 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, acpi4asus-user, chiu, yurii.pavlovskyi,
	kristian, andy, dvhart, corentin.chary

On ASUS FX505DY/FX705DY laptops fan boost mode is same as in other
TUF laptop models but have different ACPI device ID and different key
code.

Signed-off-by: Leonid Maksymchuk <leonmaxx@gmail.com>
---
  drivers/platform/x86/asus-wmi.c            | 42 ++++++++++++++++++++----------
  include/linux/platform_data/x86/asus-wmi.h |  1 +
  2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 723aa4d..f4e5840 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -61,6 +61,7 @@
  #define NOTIFY_KBD_BRTDWN		0xc5
  #define NOTIFY_KBD_BRTTOGGLE		0xc7
  #define NOTIFY_KBD_FBM			0x99
+#define NOTIFY_KBD_FBM_2		0xae
  
  #define ASUS_WMI_FNLOCK_BIOS_DISABLED	BIT(0)
  
@@ -194,7 +195,7 @@ struct asus_wmi {
  	int fan_pwm_mode;
  	int agfn_pwm;
  
-	bool fan_boost_mode_available;
+	int fan_boost_mode_available;
  	u8 fan_boost_mode_mask;
  	u8 fan_boost_mode;
  
@@ -1616,24 +1617,33 @@ static int fan_boost_mode_check_present(struct asus_wmi *asus)
  	u32 result;
  	int err;
  
-	asus->fan_boost_mode_available = false;
+	asus->fan_boost_mode_available = 0;
  
  	err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE,
  				    &result);
-	if (err) {
-		if (err == -ENODEV)
-			return 0;
-		else
-			return err;
+
+	if (err == 0 &&
+			(result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
+			(result & ASUS_FAN_BOOST_MODES_MASK)) {
+		asus->fan_boost_mode_available = 1;
+		asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
+		return 0;
  	}
  
-	if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
+	err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE_2,
+				    &result);
+
+	if (err == 0 &&
+			(result & ASUS_WMI_DSTS_PRESENCE_BIT) &&
  			(result & ASUS_FAN_BOOST_MODES_MASK)) {
-		asus->fan_boost_mode_available = true;
+		asus->fan_boost_mode_available = 2;
  		asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK;
  	}
  
-	return 0;
+	if (err == -ENODEV)
+		return 0;
+
+	return err;
  }
  
  static int fan_boost_mode_write(struct asus_wmi *asus)
@@ -1641,12 +1651,15 @@ static int fan_boost_mode_write(struct asus_wmi *asus)
  	int err;
  	u8 value;
  	u32 retval;
+	u32 dev_id = asus->fan_boost_mode_available == 1 ?
+			ASUS_WMI_DEVID_FAN_BOOST_MODE :
+			ASUS_WMI_DEVID_FAN_BOOST_MODE_2;
  
  	value = asus->fan_boost_mode;
  
  	pr_info("Set fan boost mode: %u\n", value);
-	err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_BOOST_MODE, value,
-				    &retval);
+	err = asus_wmi_set_devstate(dev_id, value, &retval);
+
  	if (err) {
  		pr_warn("Failed to set fan boost mode: %d\n", err);
  		return err;
@@ -2000,7 +2013,8 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus)
  		return;
  	}
  
-	if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) {
+	if (asus->fan_boost_mode_available &&
+			(code == NOTIFY_KBD_FBM || code == NOTIFY_KBD_FBM_2) {
  		fan_boost_mode_switch_next(asus);
  		return;
  	}
@@ -2177,7 +2191,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
  	else if (attr == &dev_attr_als_enable.attr)
  		devid = ASUS_WMI_DEVID_ALS_ENABLE;
  	else if (attr == &dev_attr_fan_boost_mode.attr)
-		ok = asus->fan_boost_mode_available;
+		ok = asus->fan_boost_mode_available != 0;
  
  	if (devid != -1)
  		ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h
index 60249e2..714782b 100644
--- a/include/linux/platform_data/x86/asus-wmi.h
+++ b/include/linux/platform_data/x86/asus-wmi.h
@@ -58,6 +58,7 @@
  #define ASUS_WMI_DEVID_LIGHT_SENSOR	0x00050022 /* ?? */
  #define ASUS_WMI_DEVID_LIGHTBAR		0x00050025
  #define ASUS_WMI_DEVID_FAN_BOOST_MODE	0x00110018
+#define ASUS_WMI_DEVID_FAN_BOOST_MODE_2	0x00120075
  
  /* Misc */
  #define ASUS_WMI_DEVID_CAMERA		0x00060013
-- 
1.8.3.1


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

* [RFC PATCH 3/3] platform/x86: asus_wmi: Set default fan boost mode to normal
  2019-11-04 18:11 [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs Leonid Maksymchuk
  2019-11-04 18:26 ` [RFC PATCH 1/3] platform/x86: asus_wmi: Fix return value of fan_boost_mode_store Leonid Maksymchuk
  2019-11-04 18:28 ` [RFC PATCH 2/3] platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY Leonid Maksymchuk
@ 2019-11-04 18:29 ` Leonid Maksymchuk
  2 siblings, 0 replies; 6+ messages in thread
From: Leonid Maksymchuk @ 2019-11-04 18:29 UTC (permalink / raw)
  To: linux-kernel
  Cc: platform-driver-x86, acpi4asus-user, chiu, yurii.pavlovskyi,
	kristian, andy, dvhart, corentin.chary

Set default fan boost mode to normal for multiple reasons:

1) existing code assumes that laptop started in normal mode and that is
    not always correct.
2) FX705DY/FX505DY starts in silent mode and under heavy CPU load it
    overheats and drops CPU frequency to 399MHz [1]. Setting fan mode to
    normal avoids overheating.

[1] Link: https://bugzilla.kernel.org/show_bug.cgi?id=203733

Signed-off-by: Leonid Maksymchuk <leonmaxx@gmail.com>
---
  drivers/platform/x86/asus-wmi.c | 13 +++++++++++++
  1 file changed, 13 insertions(+)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index f4e5840..70c5fbb 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1674,6 +1674,18 @@ static int fan_boost_mode_write(struct asus_wmi *asus)
  	return 0;
  }
  
+static int fan_boost_mode_set_default(struct asus_wmi *asus)
+{
+	int result = 0;
+
+	if (asus->fan_boost_mode_available) {
+		asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL;
+		result = fan_boost_mode_write(asus);
+	}
+
+	return result;
+}
+
  static int fan_boost_mode_switch_next(struct asus_wmi *asus)
  {
  	u8 mask = asus->fan_boost_mode_mask;
@@ -2450,6 +2462,7 @@ static int asus_wmi_add(struct platform_device *pdev)
  	err = fan_boost_mode_check_present(asus);
  	if (err)
  		goto fail_fan_boost_mode;
+	fan_boost_mode_set_default(asus);
  
  	err = asus_wmi_sysfs_init(asus->platform_device);
  	if (err)
-- 
1.8.3.1


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

* Re: [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs
  2019-11-04 10:52 [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs Leon Maxx
@ 2019-11-04 14:33 ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2019-11-04 14:33 UTC (permalink / raw)
  To: Leon Maxx
  Cc: Linux Kernel Mailing List, Platform Driver, acpi4asus-user,
	Andy Shevchenko, Darren Hart, Corentin Chary, Daniel Drake,
	Yurii Pavlovskyi

On Mon, Nov 4, 2019 at 12:53 PM Leon Maxx <leonmaxx@gmail.com> wrote:
>
> Hi,
>
> this patch series adds support of ASUS TUF laptops on Ryzen CPUs to existing
> asus_wmi platform driver and also fixes minor bug.
>

All three patches are broken. Please, fix your MTA / MUA (for the
latter one it's highly recommended to use git-send-email).
You may test patches by sending to another address you have in some
extarnal domain.

> Leonid Maksimchuk (3):
>   platform/x86: asus_wmi: Fix return value of fan_boost_mode_store
>   platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY
>   platform/x86: asus_wmi: Set default fan boost mode to normal
>
>  drivers/platform/x86/asus-wmi.c            | 57 +++++++++++++++++++++--------
>  include/linux/platform_data/x86/asus-wmi.h |  1 +
>  2 files changed, 43 insertions(+), 15 deletions(-)



-- 
With Best Regards,
Andy Shevchenko

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

* [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs
@ 2019-11-04 10:52 Leon Maxx
  2019-11-04 14:33 ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Leon Maxx @ 2019-11-04 10:52 UTC (permalink / raw)
  To: linux-kernel, platform-driver-x86, acpi4asus-user, andy, dvhart,
	corentin.chary, drake, yurii.pavlovskyi

Hi,

this patch series adds support of ASUS TUF laptops on Ryzen CPUs to existing
asus_wmi platform driver and also fixes minor bug.

Leonid Maksimchuk (3):
  platform/x86: asus_wmi: Fix return value of fan_boost_mode_store
  platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY
  platform/x86: asus_wmi: Set default fan boost mode to normal

 drivers/platform/x86/asus-wmi.c            | 57 +++++++++++++++++++++--------
 include/linux/platform_data/x86/asus-wmi.h |  1 +
 2 files changed, 43 insertions(+), 15 deletions(-)

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

end of thread, other threads:[~2019-11-04 18:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-04 18:11 [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs Leonid Maksymchuk
2019-11-04 18:26 ` [RFC PATCH 1/3] platform/x86: asus_wmi: Fix return value of fan_boost_mode_store Leonid Maksymchuk
2019-11-04 18:28 ` [RFC PATCH 2/3] platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY Leonid Maksymchuk
2019-11-04 18:29 ` [RFC PATCH 3/3] platform/x86: asus_wmi: Set default fan boost mode to normal Leonid Maksymchuk
  -- strict thread matches above, loose matches on Subject: below --
2019-11-04 10:52 [RFC PATCH 0/3] asus_wmi: Support of ASUS TUF laptops on Ryzen CPUs Leon Maxx
2019-11-04 14:33 ` Andy Shevchenko

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.