From: Armin Wolf <W_Armin@gmx.de>
To: Philipp Jungkamp <p.jungkamp@gmx.net>,
Hans de Goede <hdegoede@redhat.com>,
Mark Gross <markgross@kernel.org>
Cc: platform-driver-x86@vger.kernel.org
Subject: Re: [PATCH v2 1/2] platform/x86: wmi: Disambiguate WMI event data on some ACPI tables
Date: Sun, 13 Nov 2022 21:30:39 +0100 [thread overview]
Message-ID: <828b7403-40a2-0da4-6bd2-b2370f05f998@gmx.de> (raw)
In-Reply-To: <20221113121259.14895-1-p.jungkamp@gmx.net>
Am 13.11.22 um 13:12 schrieb Philipp Jungkamp:
> The ACPI DSDT table includes multiple WMI blocks which emit events with
> the same notify_id. The wmi_get_event_data() function chooses the
> wmi_block with the _WED handler to call based on the notify_id. This
> function may call the wrong _WED event handler based on the order the
> WMI blocks are parsed.
>
> This introduces wmi_get_event_data_with_guid() to diambiguate the _WED
> call to get metadata for an event. The GUID here is the one of the
> containing WMI block, not the one of the WMI event itself.
Hello,
maybe it would be better to instead rewrite the driver to utilize the WMI bus infrastructure?
Because a GUID is not guaranteed to be unique inside a system, there would still be a chance
to call the wrong _WED handler.
AFAIK only utilizing the WMI bus infrastructure would fully disambiguate the WMI event data.
Armin Wolf
> Signed-off-by: Philipp Jungkamp <p.jungkamp@gmx.net>
> ---
> Was separating this change into it's own commit correct?
>
> drivers/platform/x86/wmi.c | 30 ++++++++++++++++++++++++++++++
> include/linux/acpi.h | 3 +++
> 2 files changed, 33 insertions(+)
>
> diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
> index 223550a10d4d..56b666f4b40b 100644
> --- a/drivers/platform/x86/wmi.c
> +++ b/drivers/platform/x86/wmi.c
> @@ -659,6 +659,36 @@ acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out)
> }
> EXPORT_SYMBOL_GPL(wmi_get_event_data);
>
> +/**
> + * wmi_get_event_data_with_guid - Get WMI data associated with an event by guid
> + *
> + * Consider using this instead of wmi_get_event_data() when the notify_id
> + * of the WMI event may not be unique among all WMI blocks of a device.
> + *
> + * @guid: GUID of the WMI block for this event
> + * @event: Event to find
> + * @out: Buffer to hold event data. out->pointer should be freed with kfree()
> + *
> + * Returns extra data associated with an event in WMI.
> + */
> +acpi_status wmi_get_event_data_with_guid(const char *guid, u32 event, struct acpi_buffer *out)
> +{
> + struct wmi_block *wblock = NULL;
> + struct guid_block *gblock;
> + acpi_status status;
> +
> + status = find_guid(guid, &wblock);
> + if (ACPI_FAILURE(status))
> + return AE_NOT_FOUND;
> +
> + gblock = &wblock->gblock;
> + if ((gblock->flags & ACPI_WMI_EVENT) && gblock->notify_id == event)
> + return get_event_data(wblock, out);
> +
> + return AE_NOT_FOUND;
> +}
> +EXPORT_SYMBOL_GPL(wmi_get_event_data_with_guid);
> +
> /**
> * wmi_has_guid - Check if a GUID is available
> * @guid_string: 36 char string of the form fa50ff2b-f2e8-45de-83fa-65417f2f49ba
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 3015235d65e3..51ac4d6bcae1 100644
> --- a/include/linux/acpi.h
> +++ b/include/linux/acpi.h
> @@ -423,6 +423,9 @@ extern acpi_status wmi_set_block(const char *guid, u8 instance,
> extern acpi_status wmi_install_notify_handler(const char *guid,
> wmi_notify_handler handler, void *data);
> extern acpi_status wmi_remove_notify_handler(const char *guid);
> +extern acpi_status wmi_get_event_data_with_guid(const char *guid,
> + u32 event,
> + struct acpi_buffer *out);
> extern acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out);
> extern bool wmi_has_guid(const char *guid);
> extern char *wmi_get_acpi_device_uid(const char *guid);
> --
> 2.38.1
>
next prev parent reply other threads:[~2022-11-13 20:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-11 16:04 [PATCH] Add IdeaPad WMI Fn Keys driver Philipp Jungkamp
2022-09-11 16:18 ` Hans de Goede
2022-09-19 7:54 ` Hans de Goede
2022-11-10 20:02 ` Philipp Jungkamp
2022-11-10 21:02 ` Hans de Goede
2022-11-13 12:12 ` [PATCH v2 1/2] platform/x86: wmi: Disambiguate WMI event data on some ACPI tables Philipp Jungkamp
2022-11-13 12:12 ` [PATCH v2 2/2] platform/x86: ideapad-laptop: support for more special keys in WMI Philipp Jungkamp
2022-11-13 20:30 ` Armin Wolf [this message]
2022-11-13 21:42 ` [PATCH v2 1/2] platform/x86: wmi: Disambiguate WMI event data on some ACPI tables Philipp Jungkamp
2022-11-13 23:02 ` Armin Wolf
2022-11-14 14:41 ` [PATCH v3] platform/x86: ideapad-laptop: support for more special keys in WMI Philipp Jungkamp
2022-11-14 16:15 ` Hans de Goede
2022-11-14 16:41 ` Hans de Goede
2022-11-15 0:09 ` [PATCH v4] " Philipp Jungkamp
2022-11-15 21:19 ` Hans de Goede
2022-11-16 11:06 ` [PATCH v5] " Philipp Jungkamp
2022-11-16 14:43 ` Hans de Goede
2022-11-15 2:27 ` [PATCH v3] " Armin Wolf
2022-11-15 11:19 ` Hans de Goede
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=828b7403-40a2-0da4-6bd2-b2370f05f998@gmx.de \
--to=w_armin@gmx.de \
--cc=hdegoede@redhat.com \
--cc=markgross@kernel.org \
--cc=p.jungkamp@gmx.net \
--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 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.