Skip to contentSkip to conversation

platform/x86: asus-wmi: don't fail if platform_profile already registered

PATCH In review Luke D. Jones 3 participants 5 messages Sep 10, 2024 – Sep 17, 2024

Subsystems (2)
lore
Share & tools
lore

Luke D. Jones

author maintainer
#0 lore raw

PATCH 1/1 platform/x86: asus-wmi: don't fail if platform_profile already registered

On some newer laptops ASUS laptops SPS support is advertised but not actually used, causing the AMD driver to register as a platform_profile handler.

If this happens then the asus_wmi driver would error with -EEXIST when trying to register its own handler leaving the user with a possibly unusable system. This is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.

We can safely continue loading the driver instead of bombing out.

---
 drivers/platform/x86/asus-wmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +7 -2
index fbb3345cc65a..d53c4aff519f 100644
@@ -3876,8 +3876,13 @@ static int platform_profile_setup(struct asus_wmi *asus)
 		asus->platform_profile_handler.choices);
 
 	err = platform_profile_register(&asus->platform_profile_handler);
-	if (err)
+	if (err == -EEXIST) {
+		pr_warn("%s, a platform_profile handler is already registered\n", __func__);
+		return 0;
+	} else if (err) {
+		pr_err("%s, failed at platform_profile_register: %d\n", __func__, err);
 		return err;
+	}
 
 	asus->platform_profile_support = true;
 	return 0;
@@ -4752,7 +4757,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 		goto fail_fan_boost_mode;
 
 	err = platform_profile_setup(asus);
-	if (err)
+	if (err && err != -EEXIST)
 		goto fail_platform_profile_setup;
 
 	err = asus_wmi_sysfs_init(asus->platform_device);
Signature · 1 line
2.46.0
maintainer
#1 lore raw
Quoted 22 lines · Luke D. Jones

On some newer laptops ASUS laptops SPS support is advertised but not actually used, causing the AMD driver to register as a platform_profile handler.

If this happens then the asus_wmi driver would error with -EEXIST when trying to register its own handler leaving the user with a possibly unusable system. This is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.

We can safely continue loading the driver instead of bombing out.

---
 drivers/platform/x86/asus-wmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +0 -0
index fbb3345cc65a..d53c4aff519f 100644

drivers/platform/x86/asus-wmi.c static int platform_profile_setup(struct asus_wmi *asus) · line 3883

Quoted 9 lines
drivers/platform/x86/asus-wmi.c +5 -1
@@ -3876,8 +3876,13 @@ static int platform_profile_setup(struct asus_wmi *asus)
 		asus->platform_profile_handler.choices);
 
 	err = platform_profile_register(&asus->platform_profile_handler);
-	if (err)
+	if (err == -EEXIST) {
+		pr_warn("%s, a platform_profile handler is already registered\n", __func__);
+		return 0;
+	} else if (err) {
+		pr_err("%s, failed at platform_profile_register: %d\n", __func__, err);

Don't print __func__ in user visible warn/error/info messages but use plain English please.

drivers/platform/x86/asus-wmi.c static int asus_wmi_add(struct platform_device *pdev) · line 4760

Quoted 11 lines
drivers/platform/x86/asus-wmi.c +2 -1
 		return err;
+	}
 
 	asus->platform_profile_support = true;
 	return 0;
@@ -4752,7 +4757,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 		goto fail_fan_boost_mode;
 
 	err = platform_profile_setup(asus);
-	if (err)
+	if (err && err != -EEXIST)

Hi Luke,

Hans had a comment about this line against the previous version.

Also, this patch has entirely lost the version information. It's v3 now I think.

Signature · 1 line
 i.
author maintainer
#2 lore raw
Quoted 26 lines · Ilpo Järvinen
Quoted 24 lines · Luke D. Jones

On some newer laptops ASUS laptops SPS support is advertised but not actually used, causing the AMD driver to register as a platform_profile handler.

If this happens then the asus_wmi driver would error with -EEXIST when trying to register its own handler leaving the user with a possibly unusable system. This is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.

We can safely continue loading the driver instead of bombing out.

---
 drivers/platform/x86/asus-wmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +0 -0
index fbb3345cc65a..d53c4aff519f 100644
@@ -3876,8 +3876,13 @@ static int platform_profile_setup(struct asus_wmi *asus)
 asus->platform_profile_handler.choices);
 
Quoted 10 lines

drivers/platform/x86/asus-wmi.c static int platform_profile_setup(struct asus_wmi *asus) · line 3883

Quoted 7 lines
drivers/platform/x86/asus-wmi.c +5 -1
 err = platform_profile_register(&asus->platform_profile_handler);
- if (err)
+ if (err == -EEXIST) {
+ pr_warn("%s, a platform_profile handler is already registered\n", __func__);
+ return 0;
+ } else if (err) {
+ pr_err("%s, failed at platform_profile_register: %d\n", __func__, err);

Don't print __func__ in user visible warn/error/info messages but use plain English please.

Ack. I've done this a few times now. Sorry I missed this one.

Quoted 15 lines

drivers/platform/x86/asus-wmi.c static int asus_wmi_add(struct platform_device *pdev) · line 4760

Quoted 12 lines
drivers/platform/x86/asus-wmi.c +2 -1
 return err;
+ }
 
 asus->platform_profile_support = true;
 return 0;
@@ -4752,7 +4757,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 goto fail_fan_boost_mode;
 
 err = platform_profile_setup(asus);
- if (err)
+ if (err && err != -EEXIST)

Hi Luke,

Quoted 4 lines

Hans had a comment about this line against the previous version.

Also, this patch has entirely lost the version information. It's v3 now I think.

Uh.... sorry, I seem to have lost it in the depths of my inbox even with filters and searching. I'll look it up on lore and ensure everything is correct next go round.

Cheers,
Luke.

#3 lore raw
In reply to Luke D. Jones

Hi,

Quoted 10 lines · Luke D. Jones

On some newer laptops ASUS laptops SPS support is advertised but not actually used, causing the AMD driver to register as a platform_profile handler.

If this happens then the asus_wmi driver would error with -EEXIST when trying to register its own handler leaving the user with a possibly unusable system. This is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.

Quoted 3 lines

We can safely continue loading the driver instead of bombing out.

Thank you for your patch. I've applied this now, dropping the second unnecessary chunk manually so there is no need to send out a new version.

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

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

Quoted 32 lines
---
 drivers/platform/x86/asus-wmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +7 -2
index fbb3345cc65a..d53c4aff519f 100644
@@ -3876,8 +3876,13 @@ static int platform_profile_setup(struct asus_wmi *asus)
 		asus->platform_profile_handler.choices);
 
 	err = platform_profile_register(&asus->platform_profile_handler);
-	if (err)
+	if (err == -EEXIST) {
+		pr_warn("%s, a platform_profile handler is already registered\n", __func__);
+		return 0;
+	} else if (err) {
+		pr_err("%s, failed at platform_profile_register: %d\n", __func__, err);
 		return err;
+	}
 
 	asus->platform_profile_support = true;
 	return 0;
@@ -4752,7 +4757,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 		goto fail_fan_boost_mode;
 
 	err = platform_profile_setup(asus);
-	if (err)
+	if (err && err != -EEXIST)
 		goto fail_platform_profile_setup;
 
 	err = asus_wmi_sysfs_init(asus->platform_device);
author maintainer
#4 lore raw
Quoted 24 lines · Hans de Goede

Hi,

Quoted 10 lines · Luke D. Jones

On some newer laptops ASUS laptops SPS support is advertised but not actually used, causing the AMD driver to register as a platform_profile handler.

If this happens then the asus_wmi driver would error with -EEXIST when trying to register its own handler leaving the user with a possibly unusable system. This is especially true for laptops with an MCU that emit a stream of HID packets, some of which can be misinterpreted as shutdown signals.

Quoted 3 lines

We can safely continue loading the driver instead of bombing out.

Thank you for your patch. I've applied this now, dropping the second unnecessary chunk manually so there is no need to send out a new version.

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

Quoted 8 lines

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

Okay Thanks Hans,

Quoted 37 lines
Quoted 35 lines


---
 drivers/platform/x86/asus-wmi.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/platform/x86/asus-wmi.c +7 -2
index fbb3345cc65a..d53c4aff519f 100644
@@ -3876,8 +3876,13 @@ static int platform_profile_setup(struct asus_wmi *asus)
 asus->platform_profile_handler.choices);
 
 err = platform_profile_register(&asus->platform_profile_handler);
- if (err)
+ if (err == -EEXIST) {
+ pr_warn("%s, a platform_profile handler is already registered\n", __func__);
+ return 0;
+ } else if (err) {
+ pr_err("%s, failed at platform_profile_register: %d\n", __func__, err);
 return err;
+ }
 
 asus->platform_profile_support = true;
 return 0;
@@ -4752,7 +4757,7 @@ static int asus_wmi_add(struct platform_device *pdev)
 goto fail_fan_boost_mode;
 
 err = platform_profile_setup(asus);
- if (err)
+ if (err && err != -EEXIST)
 goto fail_platform_profile_setup;
 
 err = asus_wmi_sysfs_init(asus->platform_device);