From: Bedant Patnaik <bedant.patnaik@gmail.com>
To: Jorge Lopez <jorgealtxwork@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
Andy Shevchenko <andy@infradead.org>,
"markgross@kernel.org" <markgross@kernel.org>,
"platform-driver-x86@vger.kernel.org"
<platform-driver-x86@vger.kernel.org>
Subject: Re: [RFC] platform/x86: hp-wmi: make hp_wmi_perform_query() work with certain devices
Date: Thu, 09 Jun 2022 01:11:24 +0530 [thread overview]
Message-ID: <acafed286e86158cec3ad5f0ddf9e52b912db996.camel@gmail.com> (raw)
In-Reply-To: <41be46743d21c78741232a47bbb5f1cdbcc3d21e.camel@gmail.com>
Greetings Hans, Jorge,
I have sent the zero_if_supp() patch that can be applied over Jorge's buffer size patch in the mail that I'm replying to.
This *should* be enough as the final patch. Please let me know if anything needs to be rectified.
All your input is welcome.
Thank you.
On Thu, 2022-06-09 at 00:58 +0530, Bedant Patnaik wrote:
> From 26f84d835819fa38872c673f49f1b77774927568 Mon Sep 17 00:00:00 2001
> From: Bedant Patnaik <bedant.patnaik@gmail.com>
> Date: Thu, 9 Jun 2022 00:50:53 +0530
> Subject: [PATCH] Use zero insize parameter only when supported
>
> be9d73e64957bbd31ee9a0d11adc0f720974c558 ("platform/x86: hp-wmi: Fix 0x05 error code reported by several WMI calls")
> and 12b19f14a21a2ee6348825d95b642ef2cd16794f ("platform/x86: hp-wmi: Fix hp_wmi_read_int() reporting error (0x05)")
> cause ACPI BIOS Error (bug): Attempt to CreateField of length zero (20211217/dsopcode-133) because of the ACPI
> method HWMC, which unconditionally creates a Field of size (insize*8) bits:
> CreateField (Arg1, 0x80, (Local5 * 0x08), DAIN)
> In cases where args->insize = 0, the Field size is 0, resulting in an error.
> Fix: use zero insize only if 0x5 error code is returned
>
> Tested on Omen 15 AMD (2020) board ID: 8786.
>
> Signed-off-by: Bedant Patnaik <bedant.patnaik@gmail.com>
> ---
> drivers/platform/x86/hp-wmi.c | 23 +++++++++++++++--------
> 1 file changed, 15 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c
> index 277397de5..0e07581b8 100644
> --- a/drivers/platform/x86/hp-wmi.c
> +++ b/drivers/platform/x86/hp-wmi.c
> @@ -38,6 +38,7 @@ MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4");
> #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C"
> #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4"
> #define HP_OMEN_EC_THERMAL_PROFILE_OFFSET 0x95
> +#define zero_if_sup(tmp) (zero_insize_support?0:sizeof(tmp)) // use when zero insize is required
>
> /* DMI board names of devices that should use the omen specific path for
> * thermal profiles.
> @@ -220,6 +221,7 @@ static struct input_dev *hp_wmi_input_dev;
> static struct platform_device *hp_wmi_platform_dev;
> static struct platform_profile_handler platform_profile_handler;
> static bool platform_profile_support;
> +static bool zero_insize_support;
>
> static struct rfkill *wifi_rfkill;
> static struct rfkill *bluetooth_rfkill;
> @@ -376,7 +378,7 @@ static int hp_wmi_read_int(int query)
> int val = 0, ret;
>
> ret = hp_wmi_perform_query(query, HPWMI_READ, &val,
> - 0, sizeof(val));
> + zero_if_sup(val), sizeof(val));
>
> if (ret)
> return ret < 0 ? ret : -EINVAL;
> @@ -412,7 +414,8 @@ static int hp_wmi_get_tablet_mode(void)
> return -ENODEV;
>
> ret = hp_wmi_perform_query(HPWMI_SYSTEM_DEVICE_MODE, HPWMI_READ,
> - system_device_mode, 0, sizeof(system_device_mode));
> + system_device_mode, zero_if_sup(system_device_mode),
> + sizeof(system_device_mode));
> if (ret < 0)
> return ret;
>
> @@ -499,7 +502,7 @@ static int hp_wmi_fan_speed_max_get(void)
> int val = 0, ret;
>
> ret = hp_wmi_perform_query(HPWMI_FAN_SPEED_MAX_GET_QUERY, HPWMI_GM,
> - &val, 0, sizeof(val));
> + &val, zero_if_sup(val), sizeof(val));
>
> if (ret)
> return ret < 0 ? ret : -EINVAL;
> @@ -511,7 +514,7 @@ static int __init hp_wmi_bios_2008_later(void)
> {
> int state = 0;
> int ret = hp_wmi_perform_query(HPWMI_FEATURE_QUERY, HPWMI_READ, &state,
> - 0, sizeof(state));
> + zero_if_sup(state), sizeof(state));
> if (!ret)
> return 1;
>
> @@ -522,7 +525,7 @@ static int __init hp_wmi_bios_2009_later(void)
> {
> u8 state[128];
> int ret = hp_wmi_perform_query(HPWMI_FEATURE2_QUERY, HPWMI_READ, &state,
> - 0, sizeof(state));
> + zero_if_sup(state), sizeof(state));
> if (!ret)
> return 1;
>
> @@ -600,7 +603,7 @@ static int hp_wmi_rfkill2_refresh(void)
> int err, i;
>
> err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
> - 0, sizeof(state));
> + zero_if_sup(state), sizeof(state));
> if (err)
> return err;
>
> @@ -1009,7 +1012,7 @@ static int __init hp_wmi_rfkill2_setup(struct platform_device *device)
> int err, i;
>
> err = hp_wmi_perform_query(HPWMI_WIRELESS2_QUERY, HPWMI_READ, &state,
> - 0, sizeof(state));
> + zero_if_sup(state), sizeof(state));
> if (err)
> return err < 0 ? err : -EINVAL;
>
> @@ -1485,11 +1488,15 @@ static int __init hp_wmi_init(void)
> {
> int event_capable = wmi_has_guid(HPWMI_EVENT_GUID);
> int bios_capable = wmi_has_guid(HPWMI_BIOS_GUID);
> - int err;
> + int err, tmp = 0;
>
> if (!bios_capable && !event_capable)
> return -ENODEV;
>
> + if (hp_wmi_perform_query(HPWMI_HARDWARE_QUERY, HPWMI_READ, &tmp,
> + sizeof(tmp), sizeof(tmp)) == HPWMI_RET_INVALID_PARAMETERS)
> + zero_insize_support = true;
> +
> if (event_capable) {
> err = hp_wmi_input_setup();
> if (err)
next prev parent reply other threads:[~2022-06-08 19:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 13:24 [RFC] platform/x86: hp-wmi: make hp_wmi_perform_query() work with certain devices Bedant Patnaik
2022-06-07 13:35 ` Hans de Goede
[not found] ` <CAOOmCE8QYEwh6TrgA=_sTcm4spkuk3rjMS4g78nbBbWXWUB2aQ@mail.gmail.com>
2022-06-07 17:25 ` Hans de Goede
2022-06-07 18:11 ` Jorge Lopez
2022-06-07 18:37 ` Bedant Patnaik
2022-06-07 19:47 ` Jorge Lopez
2022-06-08 19:28 ` Bedant Patnaik
2022-06-08 19:41 ` Bedant Patnaik [this message]
2022-06-09 13:50 ` Jorge Lopez
2022-06-09 15:09 ` Andy Shevchenko
2022-06-10 20:27 ` Hans de Goede
2022-06-07 19:20 ` Hans de Goede
2022-06-07 18:52 ` Bedant Patnaik
2022-06-07 18:54 ` Bedant Patnaik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=acafed286e86158cec3ad5f0ddf9e52b912db996.camel@gmail.com \
--to=bedant.patnaik@gmail.com \
--cc=andy@infradead.org \
--cc=hdegoede@redhat.com \
--cc=jorgealtxwork@gmail.com \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox