* [PATCH 0/2] platform/x86: asus-wmi: extra debugging and a fix
@ 2024-07-13 7:59 Luke D. Jones
2024-07-13 7:59 ` [PATCH 1/2] platform/x86: asus-wmi: add debug print in more key places Luke D. Jones
2024-07-13 7:59 ` [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered Luke D. Jones
0 siblings, 2 replies; 5+ messages in thread
From: Luke D. Jones @ 2024-07-13 7:59 UTC (permalink / raw)
To: platform-driver-x86
Cc: corentin.chary, hdegoede, ilpo.jarvinen, linux-kernel,
Luke D. Jones
These are two patches, one of which is a fix to prevent certain situations
from arising.
The patch to add extra debug prints has come in extremely useful to find
causes of issues for users such as when a WMI method is returning a valid
value but which must be masked.
Luke D. Jones (2):
platform/x86: asus-wmi: add debug print in more key places
platform/x86: asus-wmi: don't fail if platform_profile already
registered
drivers/platform/x86/asus-wmi.c | 67 +++++++++++++++++++++++++++------
1 file changed, 55 insertions(+), 12 deletions(-)
--
2.45.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] platform/x86: asus-wmi: add debug print in more key places
2024-07-13 7:59 [PATCH 0/2] platform/x86: asus-wmi: extra debugging and a fix Luke D. Jones
@ 2024-07-13 7:59 ` Luke D. Jones
2024-07-13 7:59 ` [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered Luke D. Jones
1 sibling, 0 replies; 5+ messages in thread
From: Luke D. Jones @ 2024-07-13 7:59 UTC (permalink / raw)
To: platform-driver-x86
Cc: corentin.chary, hdegoede, ilpo.jarvinen, linux-kernel,
Luke D. Jones
Add more verbose debug print in the WMI method calls. This helps a lot
with debugging various issues working with regular users as the WMI
methods can be traced now.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/platform/x86/asus-wmi.c | 58 +++++++++++++++++++++++++++------
1 file changed, 48 insertions(+), 10 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 799d928c7d3d..4c129881ce28 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -334,20 +334,29 @@ static int asus_wmi_evaluate_method3(u32 method_id,
status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id,
&input, &output);
- if (ACPI_FAILURE(status))
+ pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x\n",
+ __func__, method_id, arg0, arg1, arg2);
+ if (ACPI_FAILURE(status)) {
+ pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n",
+ __func__, method_id, arg0, -EIO);
return -EIO;
+ }
obj = (union acpi_object *)output.pointer;
if (obj && obj->type == ACPI_TYPE_INTEGER)
tmp = (u32) obj->integer.value;
+ pr_debug("Result: 0x%08x\n", tmp);
if (retval)
*retval = tmp;
kfree(obj);
- if (tmp == ASUS_WMI_UNSUPPORTED_METHOD)
+ if (tmp == ASUS_WMI_UNSUPPORTED_METHOD) {
+ pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n",
+ __func__, method_id, arg0, -ENODEV);
return -ENODEV;
+ }
return 0;
}
@@ -377,20 +386,29 @@ static int asus_wmi_evaluate_method5(u32 method_id,
status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id,
&input, &output);
- if (ACPI_FAILURE(status))
+ pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
+ __func__, method_id, arg0, arg1, arg2, arg3, arg4);
+ if (ACPI_FAILURE(status)) {
+ pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n",
+ __func__, method_id, arg0, -EIO);
return -EIO;
+ }
obj = (union acpi_object *)output.pointer;
if (obj && obj->type == ACPI_TYPE_INTEGER)
tmp = (u32) obj->integer.value;
+ pr_debug("Result: %x\n", tmp);
if (retval)
*retval = tmp;
kfree(obj);
- if (tmp == ASUS_WMI_UNSUPPORTED_METHOD)
+ if (tmp == ASUS_WMI_UNSUPPORTED_METHOD) {
+ pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n",
+ __func__, method_id, arg0, -ENODEV);
return -ENODEV;
+ }
return 0;
}
@@ -416,8 +434,13 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,
status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID, 0, method_id,
&input, &output);
- if (ACPI_FAILURE(status))
+ pr_debug("%s called (0x%08x) with args: 0x%08x, 0x%08x\n",
+ __func__, method_id, arg0, arg1);
+ if (ACPI_FAILURE(status)) {
+ pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n",
+ __func__, method_id, arg0, -EIO);
return -EIO;
+ }
obj = (union acpi_object *)output.pointer;
@@ -453,8 +476,11 @@ static int asus_wmi_evaluate_method_buf(u32 method_id,
kfree(obj);
- if (err)
+ if (err) {
+ pr_debug("%s, (0x%08x), arg 0x%08x failed: %d\n",
+ __func__, method_id, arg0, err);
return err;
+ }
return 0;
}
@@ -542,6 +568,7 @@ static bool asus_wmi_dev_is_present(struct asus_wmi *asus, u32 dev_id)
{
u32 retval;
int status = asus_wmi_get_devstate(asus, dev_id, &retval);
+ pr_debug("%s called (0x%08x), retval: 0x%08x\n", __func__, dev_id, retval);
return status == 0 && (retval & ASUS_WMI_DSTS_PRESENCE_BIT);
}
@@ -3559,18 +3586,27 @@ static int asus_wmi_custom_fan_curve_init(struct asus_wmi *asus)
err = fan_curve_check_present(asus, &asus->cpu_fan_curve_available,
ASUS_WMI_DEVID_CPU_FAN_CURVE);
- if (err)
+ if (err) {
+ pr_err("%s, checked 0x%08x, failed: %d\n",
+ __func__, ASUS_WMI_DEVID_CPU_FAN_CURVE, err);
return err;
+ }
err = fan_curve_check_present(asus, &asus->gpu_fan_curve_available,
ASUS_WMI_DEVID_GPU_FAN_CURVE);
- if (err)
+ if (err) {
+ pr_err("%s, checked 0x%08x, failed: %d\n",
+ __func__, ASUS_WMI_DEVID_GPU_FAN_CURVE, err);
return err;
+ }
err = fan_curve_check_present(asus, &asus->mid_fan_curve_available,
ASUS_WMI_DEVID_MID_FAN_CURVE);
- if (err)
+ if (err) {
+ pr_err("%s, checked 0x%08x, failed: %d\n",
+ __func__, ASUS_WMI_DEVID_MID_FAN_CURVE, err);
return err;
+ }
if (!asus->cpu_fan_curve_available
&& !asus->gpu_fan_curve_available
@@ -4398,8 +4434,10 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
else if (attr == &dev_attr_available_mini_led_mode.attr)
ok = asus->mini_led_dev_id != 0;
- if (devid != -1)
+ if (devid != -1) {
ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0);
+ pr_debug("%s called 0x%08x, ok: %x\n", __func__, devid, ok);
+ }
return ok ? attr->mode : 0;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered
2024-07-13 7:59 [PATCH 0/2] platform/x86: asus-wmi: extra debugging and a fix Luke D. Jones
2024-07-13 7:59 ` [PATCH 1/2] platform/x86: asus-wmi: add debug print in more key places Luke D. Jones
@ 2024-07-13 7:59 ` Luke D. Jones
2024-07-29 15:45 ` Ilpo Järvinen
1 sibling, 1 reply; 5+ messages in thread
From: Luke D. Jones @ 2024-07-13 7:59 UTC (permalink / raw)
To: platform-driver-x86
Cc: corentin.chary, hdegoede, ilpo.jarvinen, linux-kernel,
Luke D. Jones
On some newer laptops it appears that an AMD driver can register 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.
Signed-off-by: Luke D. Jones <luke@ljones.dev>
---
drivers/platform/x86/asus-wmi.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 4c129881ce28..7d87ff68f418 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3836,8 +3836,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;
@@ -4713,7 +4718,7 @@ static int asus_wmi_add(struct platform_device *pdev)
throttle_thermal_policy_set_default(asus);
err = platform_profile_setup(asus);
- if (err)
+ if (err && err != -EEXIST)
goto fail_platform_profile_setup;
err = asus_wmi_sysfs_init(asus->platform_device);
--
2.45.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered
2024-07-13 7:59 ` [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered Luke D. Jones
@ 2024-07-29 15:45 ` Ilpo Järvinen
2024-08-05 23:55 ` Luke Jones
0 siblings, 1 reply; 5+ messages in thread
From: Ilpo Järvinen @ 2024-07-29 15:45 UTC (permalink / raw)
To: Luke D. Jones; +Cc: platform-driver-x86, corentin.chary, Hans de Goede, LKML
On Sat, 13 Jul 2024, Luke D. Jones wrote:
> On some newer laptops it appears that an AMD driver can register 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.
>
> Signed-off-by: Luke D. Jones <luke@ljones.dev>
> ---
> drivers/platform/x86/asus-wmi.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index 4c129881ce28..7d87ff68f418 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -3836,8 +3836,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);
Please don't print __func__ to user in warnings or errors, and try to
write in English what is the reason (instead of resorting to use function
names).
--
i.
> return err;
> + }
>
> asus->platform_profile_support = true;
> return 0;
> @@ -4713,7 +4718,7 @@ static int asus_wmi_add(struct platform_device *pdev)
> throttle_thermal_policy_set_default(asus);
>
> err = platform_profile_setup(asus);
> - if (err)
> + if (err && err != -EEXIST)
> goto fail_platform_profile_setup;
>
> err = asus_wmi_sysfs_init(asus->platform_device);
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered
2024-07-29 15:45 ` Ilpo Järvinen
@ 2024-08-05 23:55 ` Luke Jones
0 siblings, 0 replies; 5+ messages in thread
From: Luke Jones @ 2024-08-05 23:55 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: platform-driver-x86, corentin.chary, Hans de Goede, LKML
On Tue, 30 Jul 2024, at 3:45 AM, Ilpo Järvinen wrote:
> On Sat, 13 Jul 2024, Luke D. Jones wrote:
>
> > On some newer laptops it appears that an AMD driver can register 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.
> >
> > Signed-off-by: Luke D. Jones <luke@ljones.dev>
> > ---
> > drivers/platform/x86/asus-wmi.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> > index 4c129881ce28..7d87ff68f418 100644
> > --- a/drivers/platform/x86/asus-wmi.c
> > +++ b/drivers/platform/x86/asus-wmi.c
> > @@ -3836,8 +3836,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);
>
> Please don't print __func__ to user in warnings or errors, and try to
> write in English what is the reason (instead of resorting to use function
> names).
Sorry, I do know this. The patch must have been submitted after your advice on it last time. Not sure.
In either case v2 incoming. I'll skip cover letter due to the tiny size.
> > return err;
> > + }
> >
> > asus->platform_profile_support = true;
> > return 0;
> > @@ -4713,7 +4718,7 @@ static int asus_wmi_add(struct platform_device *pdev)
> > throttle_thermal_policy_set_default(asus);
> >
> > err = platform_profile_setup(asus);
> > - if (err)
> > + if (err && err != -EEXIST)
> > goto fail_platform_profile_setup;
> >
> > err = asus_wmi_sysfs_init(asus->platform_device);
> >
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-05 23:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-13 7:59 [PATCH 0/2] platform/x86: asus-wmi: extra debugging and a fix Luke D. Jones
2024-07-13 7:59 ` [PATCH 1/2] platform/x86: asus-wmi: add debug print in more key places Luke D. Jones
2024-07-13 7:59 ` [PATCH 2/2] platform/x86: asus-wmi: don't fail if platform_profile already registered Luke D. Jones
2024-07-29 15:45 ` Ilpo Järvinen
2024-08-05 23:55 ` Luke Jones
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.