From patchwork Thu Aug 22 17:38:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 822376 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E818D1CF29F; Thu, 22 Aug 2024 17:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348342; cv=none; b=J+DOVXD2Q5buPIvhqJgrd3X334GesLI5OenfTAqs+MrJii4ew4DJBVBulwVUDHeugyOArsKQWGyXTjH75DRHHi3NpcBfawmPD7bPaToXqeoGzDnDeAnYK8FE5SjCrt1cr6IrKWkY3kZulwZ3ge6u1ujf/odU85ioWyBkBGDCtF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348342; c=relaxed/simple; bh=BbYO8qSnw2y/jBOvKNubFq7zoOkUJfc3ZcDANXSuRTU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jM9wICN2/UUyunj1wFz9+rMNBNBluiCAMmLEt8HaMz/Wg4VqXVydqTp/GHrpQiAgrsZscdI241HD+FPNhDNDAyGhfUiSpMFXLEyDJq3VinJIoG1W/fXYrO0rCHepjn4Afj/+sYCw1eL3Mbfp3VDwpS+4OWMyMHmFnp2RjPb0cwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=P2TzdK5h; arc=none smtp.client-ip=212.227.15.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="P2TzdK5h" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724348321; x=1724953121; i=w_armin@gmx.de; bh=kR7/6t3ny+HiH2HuN3BHgXTTTLW/wXcXOTfLz658PAE=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=P2TzdK5h5o7GPaX64So63DspSNYD6s8LGmtpT1HSNHsN6BUeFRzeiZtIysA7JClE KKORJTODev0kX5uIl8BT9hMnlxSg2t3KV2SiPm7OCOF9JK+rKJdbfBxuLBYxV0cdn K348rKW4ynb0GEcNed9O7N2aHC9lYNr0OeaDLN/Z+4v+RX0IfjZpcEBaEqwO1grHY s7/zuViRLUnPg1e7OHgIjervcrLB1SdVP+9/rY0T15+fT9NEOsG3ghQFlw5o//mcH F9ZRIvU/co1g8t20fdLIsaaxKhX8QNkHRgT2zuruaExoyQqn9Y+E+tOhQjmwqGEwk xbMeCOTB1oKMz4oqYg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWRRZ-1se37S2eex-00RPrh; Thu, 22 Aug 2024 19:38:41 +0200 From: Armin Wolf To: james@equiv.tech, jlee@suse.com, corentin.chary@gmail.com, luke@ljones.dev, matan@svgalib.org, coproscefalo@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, rafael@kernel.org, lenb@kernel.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] platform/x86: wmi: Pass event data directly to legacy notify handlers Date: Thu, 22 Aug 2024 19:38:06 +0200 Message-Id: <20240822173810.11090-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822173810.11090-1-W_Armin@gmx.de> References: <20240822173810.11090-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:lX7/mYJwmEl9dVzp8qxpourSGK2xDBCjx49zuandty1zvX7vaI4 LHbmCh0YMA/Vj2ciEV8qimzRMTclam5X2z1zi9qvkR3Pp+ClfJr/rEdfKJpGGMeufv4opu0 JkBTzMjraixG311InFqe1hchSuyJFy4SGz/aVpekQ3tG/80OM0EN/Ejt7F9e63Zv3meRLtq 4hF+DAzR63+lrfleC36HQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:XrY7WgEjQbw=;IhMr11kHb4V1WfqLlw2PJST7Qi1 jsZ5j7rnVwMj9b9s7rZop2oPIL4Yx/9WbhYljOwQtM6sUjOsOCdavnfqTBR//qLUVXAcDhq8n GM/snexcVWi4t3gOfqZ7h3ZuAAMmIoGP0bzcjX1BCpt9s1FAP2PvZrWnrfxCY/XbXiYST2HVf lZTgZkYkpQtjIlETFG5tB6xW4//+9rVahZQVRmHx460Q8bIXfOrQ4NycRIVffsheleKNBZql4 WiITke10MChDrlb0Rr5yV+GyGlEFMZqFEEom9x/QE1JGPfsEjvjhNAm5Ixsg5fJAUUOC9ao4/ VYXvWJeRddw7rHJdBd6z33OZ2LjjDxiJQnIJIAP1Y24YYCnpzVYvVPmM50Nd3uYVcxB67zd5c xdE7HxdftdOYJDRN5PjGd+XdlL75tbLZ0gkoWJLx4T5ZPK4Cqb/Si70KkKV5B8ZWuYS8fO/lo 0guoDXpM00bE7nEc9RGIvgZFM3zz8OlYnV7zTs6KrY7aIQWYOJpWYifZPr0zaJDB+xeNhPwBh nfuYBKk7pRpiNwCxaM7KzKedqdkGEfsLhMnugBcN+XRRO5UD2/7eXYCrWVRro8sH3AWJqKc5f 9WIqc8cG87xz0/efE3lJ1wMeNu0IXGP/sVKBiOAcBi2rbbIDRzcHFuxvRwuOaDpi2c97I4Hmh e4JfWIQ8PP6sIj9kHO/ERudljYoZZxMDGfc6hmR11rH/657ifjbQiMdteymeYbTxzEyuJJKe7 MTOkhaAsVtzxCfJOt4+67zgGPuo4Tx8dv5hqC80uzBmg0+17I4uB5m2UfLdlsIJn/AOp9nnqy I2nGjxxbIM711ua15elxPT7BuieZuOT24bfzQAy9GYWFg= The current legacy WMI handlers are susceptible to picking up wrong WMI event data on systems where different WMI devices share some notification IDs. Prevent this by letting the WMI driver core taking care of retrieving the event data. This also simplifies the legacy WMI handlers and their implementation inside the WMI driver core. Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/hwmon/hp-wmi-sensors.c | 17 ++-------- drivers/platform/x86/acer-wmi.c | 16 +-------- drivers/platform/x86/asus-wmi.c | 19 ++--------- drivers/platform/x86/dell/dell-wmi-aio.c | 13 +------ drivers/platform/x86/hp/hp-wmi.c | 16 +-------- drivers/platform/x86/huawei-wmi.c | 14 +------- drivers/platform/x86/lg-laptop.c | 13 +------ drivers/platform/x86/msi-wmi.c | 20 ++--------- drivers/platform/x86/toshiba-wmi.c | 15 +-------- drivers/platform/x86/wmi.c | 43 ++++++++++-------------- include/linux/acpi.h | 2 +- 11 files changed, 34 insertions(+), 154 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index b5325d0e72b9..6892518d537c 100644 --- a/drivers/hwmon/hp-wmi-sensors.c +++ b/drivers/hwmon/hp-wmi-sensors.c @@ -1597,15 +1597,13 @@ static void hp_wmi_devm_notify_remove(void *ignored) } /* hp_wmi_notify - WMI event notification handler */ -static void hp_wmi_notify(u32 value, void *context) +static void hp_wmi_notify(union acpi_object *wobj, void *context) { struct hp_wmi_info *temp_info[HP_WMI_MAX_INSTANCES] = {}; - struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; struct hp_wmi_sensors *state = context; struct device *dev = &state->wdev->dev; struct hp_wmi_event event = {}; struct hp_wmi_info *fan_info; - union acpi_object *wobj; acpi_status err; int event_type; u8 count; @@ -1632,16 +1630,10 @@ static void hp_wmi_notify(u32 value, void *context) mutex_lock(&state->lock); - err = wmi_get_event_data(value, &out); - if (ACPI_FAILURE(err)) - goto out_unlock; - - wobj = out.pointer; - err = populate_event_from_wobj(dev, &event, wobj); if (err) { dev_warn(dev, "Bad event data (ACPI type %d)\n", wobj->type); - goto out_free_wobj; + goto out_free; } event_type = classify_event(event.name, event.category); @@ -1666,13 +1658,10 @@ static void hp_wmi_notify(u32 value, void *context) break; } -out_free_wobj: - kfree(wobj); - +out_free: devm_kfree(dev, event.name); devm_kfree(dev, event.description); -out_unlock: mutex_unlock(&state->lock); } diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c index 349169d050c5..7169b84ccdb6 100644 --- a/drivers/platform/x86/acer-wmi.c +++ b/drivers/platform/x86/acer-wmi.c @@ -2223,39 +2223,25 @@ static void acer_rfkill_exit(void) } } -static void acer_wmi_notify(u32 value, void *context) +static void acer_wmi_notify(union acpi_object *obj, void *context) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; struct event_return_value return_value; - acpi_status status; u16 device_state; const struct key_entry *key; u32 scancode; - status = wmi_get_event_data(value, &response); - if (status != AE_OK) { - pr_warn("bad event status 0x%x\n", status); - return; - } - - obj = (union acpi_object *)response.pointer; - if (!obj) return; if (obj->type != ACPI_TYPE_BUFFER) { pr_warn("Unknown response received %d\n", obj->type); - kfree(obj); return; } if (obj->buffer.length != 8) { pr_warn("Unknown buffer length %d\n", obj->buffer.length); - kfree(obj); return; } return_value = *((struct event_return_value *)obj->buffer.pointer); - kfree(obj); switch (return_value.function) { case WMID_HOTKEY_EVENT: diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 9c6b3937ac71..1eb6b39df604 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -4187,28 +4187,15 @@ static void asus_wmi_fnlock_update(struct asus_wmi *asus) /* WMI events *****************************************************************/ -static int asus_wmi_get_event_code(u32 value) +static int asus_wmi_get_event_code(union acpi_object *obj) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; - acpi_status status; int code; - status = wmi_get_event_data(value, &response); - if (ACPI_FAILURE(status)) { - pr_warn("Failed to get WMI notify code: %s\n", - acpi_format_exception(status)); - return -EIO; - } - - obj = (union acpi_object *)response.pointer; - if (obj && obj->type == ACPI_TYPE_INTEGER) code = (int)(obj->integer.value & WMI_EVENT_MASK); else code = -EIO; - kfree(obj); return code; } @@ -4274,10 +4261,10 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) pr_info("Unknown key code 0x%x\n", code); } -static void asus_wmi_notify(u32 value, void *context) +static void asus_wmi_notify(union acpi_object *obj, void *context) { struct asus_wmi *asus = context; - int code = asus_wmi_get_event_code(value); + int code = asus_wmi_get_event_code(obj); if (code < 0) { pr_warn("Failed to get notify code: %d\n", code); diff --git a/drivers/platform/x86/dell/dell-wmi-aio.c b/drivers/platform/x86/dell/dell-wmi-aio.c index c7b7f1e403fb..54096495719b 100644 --- a/drivers/platform/x86/dell/dell-wmi-aio.c +++ b/drivers/platform/x86/dell/dell-wmi-aio.c @@ -70,20 +70,10 @@ static bool dell_wmi_aio_event_check(u8 *buffer, int length) return false; } -static void dell_wmi_aio_notify(u32 value, void *context) +static void dell_wmi_aio_notify(union acpi_object *obj, void *context) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; struct dell_wmi_event *event; - acpi_status status; - status = wmi_get_event_data(value, &response); - if (status != AE_OK) { - pr_info("bad event status 0x%x\n", status); - return; - } - - obj = (union acpi_object *)response.pointer; if (obj) { unsigned int scancode = 0; @@ -114,7 +104,6 @@ static void dell_wmi_aio_notify(u32 value, void *context) break; } } - kfree(obj); } static int __init dell_wmi_aio_input_setup(void) diff --git a/drivers/platform/x86/hp/hp-wmi.c b/drivers/platform/x86/hp/hp-wmi.c index 876e0a97cee1..8c05e0dd2a21 100644 --- a/drivers/platform/x86/hp/hp-wmi.c +++ b/drivers/platform/x86/hp/hp-wmi.c @@ -834,28 +834,16 @@ static struct attribute *hp_wmi_attrs[] = { }; ATTRIBUTE_GROUPS(hp_wmi); -static void hp_wmi_notify(u32 value, void *context) +static void hp_wmi_notify(union acpi_object *obj, void *context) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; u32 event_id, event_data; - union acpi_object *obj; - acpi_status status; u32 *location; int key_code; - status = wmi_get_event_data(value, &response); - if (status != AE_OK) { - pr_info("bad event status 0x%x\n", status); - return; - } - - obj = (union acpi_object *)response.pointer; - if (!obj) return; if (obj->type != ACPI_TYPE_BUFFER) { pr_info("Unknown response received %d\n", obj->type); - kfree(obj); return; } @@ -872,10 +860,8 @@ static void hp_wmi_notify(u32 value, void *context) event_data = *(location + 2); } else { pr_info("Unknown buffer length %d\n", obj->buffer.length); - kfree(obj); return; } - kfree(obj); switch (event_id) { case HPWMI_DOCK_EVENT: diff --git a/drivers/platform/x86/huawei-wmi.c b/drivers/platform/x86/huawei-wmi.c index 09d476dd832e..d81fd5df4a00 100644 --- a/drivers/platform/x86/huawei-wmi.c +++ b/drivers/platform/x86/huawei-wmi.c @@ -734,26 +734,14 @@ static void huawei_wmi_process_key(struct input_dev *idev, int code) sparse_keymap_report_entry(idev, key, 1, true); } -static void huawei_wmi_input_notify(u32 value, void *context) +static void huawei_wmi_input_notify(union acpi_object *obj, void *context) { struct input_dev *idev = (struct input_dev *)context; - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; - acpi_status status; - status = wmi_get_event_data(value, &response); - if (ACPI_FAILURE(status)) { - dev_err(&idev->dev, "Unable to get event data\n"); - return; - } - - obj = (union acpi_object *)response.pointer; if (obj && obj->type == ACPI_TYPE_INTEGER) huawei_wmi_process_key(idev, obj->integer.value); else dev_err(&idev->dev, "Bad response type\n"); - - kfree(response.pointer); } static int huawei_wmi_input_setup(struct device *dev, const char *guid) diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c index 9c7857842caf..4d57cf803473 100644 --- a/drivers/platform/x86/lg-laptop.c +++ b/drivers/platform/x86/lg-laptop.c @@ -182,21 +182,11 @@ static union acpi_object *lg_wmbb(struct device *dev, u32 method_id, u32 arg1, u return (union acpi_object *)buffer.pointer; } -static void wmi_notify(u32 value, void *context) +static void wmi_notify(union acpi_object *obj, void *context) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; - acpi_status status; long data = (long)context; pr_debug("event guid %li\n", data); - status = wmi_get_event_data(value, &response); - if (ACPI_FAILURE(status)) { - pr_err("Bad event status 0x%x\n", status); - return; - } - - obj = (union acpi_object *)response.pointer; if (!obj) return; @@ -218,7 +208,6 @@ static void wmi_notify(u32 value, void *context) pr_debug("Type: %i Eventcode: 0x%llx\n", obj->type, obj->integer.value); - kfree(response.pointer); } static void wmi_input_setup(void) diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c index fd318cdfe313..4a7ac85c4db4 100644 --- a/drivers/platform/x86/msi-wmi.c +++ b/drivers/platform/x86/msi-wmi.c @@ -170,20 +170,9 @@ static const struct backlight_ops msi_backlight_ops = { .update_status = bl_set_status, }; -static void msi_wmi_notify(u32 value, void *context) +static void msi_wmi_notify(union acpi_object *obj, void *context) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; struct key_entry *key; - union acpi_object *obj; - acpi_status status; - - status = wmi_get_event_data(value, &response); - if (status != AE_OK) { - pr_info("bad event status 0x%x\n", status); - return; - } - - obj = (union acpi_object *)response.pointer; if (obj && obj->type == ACPI_TYPE_INTEGER) { int eventcode = obj->integer.value; @@ -192,7 +181,7 @@ static void msi_wmi_notify(u32 value, void *context) eventcode); if (!key) { pr_info("Unknown key pressed - %x\n", eventcode); - goto msi_wmi_notify_exit; + return; } if (event_wmi->quirk_last_pressed) { @@ -204,7 +193,7 @@ static void msi_wmi_notify(u32 value, void *context) pr_debug("Suppressed key event 0x%X - " "Last press was %lld us ago\n", key->code, ktime_to_us(diff)); - goto msi_wmi_notify_exit; + return; } last_pressed = cur; } @@ -221,9 +210,6 @@ static void msi_wmi_notify(u32 value, void *context) } } else pr_info("Unknown event received\n"); - -msi_wmi_notify_exit: - kfree(response.pointer); } static int __init msi_wmi_backlight_setup(void) diff --git a/drivers/platform/x86/toshiba-wmi.c b/drivers/platform/x86/toshiba-wmi.c index 77c35529ab6f..12c46455e8dc 100644 --- a/drivers/platform/x86/toshiba-wmi.c +++ b/drivers/platform/x86/toshiba-wmi.c @@ -32,26 +32,13 @@ static const struct key_entry toshiba_wmi_keymap[] __initconst = { { KE_END, 0 } }; -static void toshiba_wmi_notify(u32 value, void *context) +static void toshiba_wmi_notify(union acpi_object *obj, void *context) { - struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *obj; - acpi_status status; - - status = wmi_get_event_data(value, &response); - if (ACPI_FAILURE(status)) { - pr_err("Bad event status 0x%x\n", status); - return; - } - - obj = (union acpi_object *)response.pointer; if (!obj) return; /* TODO: Add proper checks once we have data */ pr_debug("Unknown event received, obj type %x\n", obj->type); - - kfree(response.pointer); } static const struct dmi_system_id toshiba_wmi_dmi_table[] __initconst = { diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 1d0b2d6040d1..6ab181dd94ab 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1227,40 +1227,33 @@ static int wmi_notify_device(struct device *dev, void *data) if (!(wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *event)) return 0; + /* The ACPI WMI specification says that _WED should be + * evaluated every time an notification is received, even + * if no consumers are present. + * + * Some firmware implementations actually depend on this + * by using a queue for events which will fill up if the + * WMI driver core stops evaluating _WED due to missing + * WMI event consumers. + */ + ret = wmi_get_notify_data(wblock, &obj); + if (ret < 0) + return -EIO; + down_read(&wblock->notify_lock); /* The WMI driver notify handler conflicts with the legacy WMI handler. * Because of this the WMI driver notify handler takes precedence. */ if (wblock->dev.dev.driver && wblock->driver_ready) { - ret = wmi_get_notify_data(wblock, &obj); - if (ret >= 0) { - wmi_notify_driver(wblock, obj); - kfree(obj); - } + wmi_notify_driver(wblock, obj); } else { - if (wblock->handler) { - wblock->handler(*event, wblock->handler_data); - } else { - /* The ACPI WMI specification says that _WED should be - * evaluated every time an notification is received, even - * if no consumers are present. - * - * Some firmware implementations actually depend on this - * by using a queue for events which will fill up if the - * WMI driver core stops evaluating _WED due to missing - * WMI event consumers. - * - * Because of this we need this seemingly useless call to - * wmi_get_notify_data() which in turn evaluates _WED. - */ - ret = wmi_get_notify_data(wblock, &obj); - if (ret >= 0) - kfree(obj); - } - + if (wblock->handler) + wblock->handler(obj, wblock->handler_data); } up_read(&wblock->notify_lock); + kfree(obj); + acpi_bus_generate_netlink_event("wmi", acpi_dev_name(wblock->acpi_device), *event, 0); return -EBUSY; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 0687a442fec7..eed105b1fbfb 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -386,7 +386,7 @@ extern bool acpi_is_pnp_device(struct acpi_device *); #if defined(CONFIG_ACPI_WMI) || defined(CONFIG_ACPI_WMI_MODULE) -typedef void (*wmi_notify_handler) (u32 value, void *context); +typedef void (*wmi_notify_handler) (union acpi_object *data, void *context); int wmi_instance_count(const char *guid); From patchwork Thu Aug 22 17:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 821364 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 175831CF291; Thu, 22 Aug 2024 17:38:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348341; cv=none; b=fQkDm7Li1p2bMBfXwiI8ni6eRpNQsUv+ak34N1gBS2PxdledfeJ7NOaauEQp2DfoaopBYXJxpkro6Ky5q/0ysbMsExWP2Qz5u8ty+8goJcFJtxa2zqc9aAlCu/i3AtLAe3C52ocn0BKu4KZNBplPDE2/vrpdXlxwCxQUAd0CvJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348341; c=relaxed/simple; bh=0mBU2SlCG+z/j3wvMKKRfaR/g6z4m2pjVgYWvs16XQw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c4J5ms0b5T92K5e3aqS3QnpJLPniON3BwxEDq4o/7a3Y5S5iJinjcIDDJ59zwqvFtNV8e6syWJ+ro3YhjVoZOpAi7GyJXSMrGQvLVQYtCGoEOBtQdPfYjpLRydxAuOLPfx7lVGjbickXG3VKpKKooxzomIta7EmruADnPX3Ac1s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=RizIsVRn; arc=none smtp.client-ip=212.227.17.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="RizIsVRn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724348323; x=1724953123; i=w_armin@gmx.de; bh=p+rLNIe3IFZaI1uPLVO7BH8uG2A2z2pX0gRWi9vzxtI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=RizIsVRnqSGOP4CrUAabyQPm/orUbdR10+RbdRf4QgaP84hXqiqR1x6F5K48pxnw 6eg9v4RGsPOK2BC0PaBej0il4pjuNDojwaZ+D222VdHZj/Ge0PRMTCN50jOTXhuVa x0AeS5Qe+GUqMIbrngHiKr8hh09D0zyaRKec7kCyw9SVUOUPZxXjEgzUUErnrgHDc lvfgHDyrE1P7582E03rgVisXqOh5E6m7UnwC0+EVDyIweMfrSTzTRHSE7ivWqhZ5E 7lzXPQX6ozoVaAP6FOO45v9L3HXlv4A6tVQL05D3AbFe9DQg4ED0dUDk1bi2rPWwf eGOmukUbHZ5wsNcZTA== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MFsYx-1suc281Oj1-00FKjd; Thu, 22 Aug 2024 19:38:43 +0200 From: Armin Wolf To: james@equiv.tech, jlee@suse.com, corentin.chary@gmail.com, luke@ljones.dev, matan@svgalib.org, coproscefalo@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, rafael@kernel.org, lenb@kernel.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] hwmon: (hp-wmi-sensors) Check if WMI event data exists Date: Thu, 22 Aug 2024 19:38:07 +0200 Message-Id: <20240822173810.11090-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822173810.11090-1-W_Armin@gmx.de> References: <20240822173810.11090-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:nWWC9iET8W1EJA8cU22SEbP5jfzKDDVIdMDAd5lSRWfBkA/qQ3O odDk6FfvB3pU24zvLpEcO7V8Y2UQs48vTf0HhjlNgFCEOuU7IXWE2kS9D3Lptxg6F7a7NpK zn8ImxdlHc46NX2xtyQfCj4YX3K+w81/2T/VtiyL036+Q4muU3k6wKbFUdd78CCGIx4rpE5 Nz4LqfS4gcn5e0mkKIz8g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:uqwifykSEpk=;Fhe+LbB+XJYhYBfzcaNqYoW4hN6 wdXJWiDteVUmNPx9anmg9JSOJZDo5DRS79vooiK6xX9ddY80Mt235OfK8jefRDdpxaNiuqwj7 sDRMxAMVfjqyV1CJr47H3t/c63BKtMCX6pEvj2ZKNA7gvmzGjmQ3ULpZVqOToaEuWIozNBFto mU5JeCVy3UhupnQIy6TDvR/IBli/EWadInbzhQ/a27KLxpCLNvT2ImP68LvATYZGI+9TDqjFX ez1o4XuQKeOMHh/I9yo6Pp6gJ7V+aXgRqhV5QU3srW2x/InJZ/1LCCYr2f0CUXHtxOb+cm4Av jicf6ApLad7W0Tysax1Vr9XOGUWVkjxlAso973RbrhxlhacBLBHWeIYNru9Kb1nBxAhIbqwBR Ps5tSJtLLCbMtViG0yd4ba9Ou3a6J/Qlm9s0ajqvzKRhHXlJWHH+TnfcSsY7XCZ0xaW/PuXAq qJh+A1lanW7iUC8+lvvjDD9Ohum1AusW5tPUf+taRRzDl1khTS4VIC2H0Rm4ef8pAV962IPRo 7hSutwsJxH6LBeM0AkE3aib2x50SWPrMLCQnxvaAG7YPTGsfj2CytgYckF5gwRdgoRY//rhs5 aALQGUyNw68tKgh4Fa/kp4QMGYmERAwiWgLZL75gPXVHyke7uxDZN6Q2SPggPPbrlcadUR6ch VBENRXLVzLDt1bSlBLIWIhq98ZuClhtODcp3TS68kFsWigkbg2z/moXY06J5Bff+jIcGnysN2 Y3jB7qilJaUi23T2B9o50OY1oDuruEfAPM2Z7ytsY0xowiPTxI89CYkdZBNnctPF+xID1IfoH gi7SJe5vs8pVIudtwevvaJ0A== The BIOS can choose to return no event data in response to a WMI event, so the ACPI object passed to the WMI notify handler can be NULL. Check for such a situation and ignore the event in such a case. Signed-off-by: Armin Wolf Reviewed-by: James Seo Acked-by: Guenter Roeck --- drivers/hwmon/hp-wmi-sensors.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.39.2 diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index 6892518d537c..d6bdad26feb1 100644 --- a/drivers/hwmon/hp-wmi-sensors.c +++ b/drivers/hwmon/hp-wmi-sensors.c @@ -1628,6 +1628,9 @@ static void hp_wmi_notify(union acpi_object *wobj, void *context) * HPBIOS_BIOSEvent instance. */ + if (!wobj) + return; + mutex_lock(&state->lock); err = populate_event_from_wobj(dev, &event, wobj); From patchwork Thu Aug 22 17:38:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 821363 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD16D1CF2AF; Thu, 22 Aug 2024 17:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348343; cv=none; b=GvqxCm7QPsDxFEyGiKC26gQWUy+jL+GmtvRTS6HGmAoZjQViWaOlrHkFBTG8cuiLWRLWagdGhkdQYxNnnStMcE5IF8RmVhG1u4nOS3GGHq16A/XxaUIIkneGyy5XEJRswzdu6yNhVCOHmewzNxA+rieo+0NWwEziU1sInQIxghM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348343; c=relaxed/simple; bh=xk7GAhpuKOrsY1jPLtSS2k+JNdNZXKMod9/aywnPR6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ffl6TOaJYWlFJ3JJrWYxRul+Q8ARJf9Hkyr1BkhFMkFQYH5H5OQfXSR+rl+G65zT1SRnNObwxlDob8DalD9XxI1ld4wSu1jZo+BUIFF9sk4I/90DweS3MMLlq9LRv9PFOlX6ERrNv3GeeOSNZbfhyG+AiOwekwtKVtcAWO93CEo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=PzvImjcC; arc=none smtp.client-ip=212.227.17.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="PzvImjcC" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724348325; x=1724953125; i=w_armin@gmx.de; bh=OlDvB9yyiEHlxAZCtd5jRTJU/gPtXJkmhmn+Zzh0VPU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=PzvImjcCNrM7gIkWOYpZGEadEey72tdQJX3vy9XGxQ2Q027oV7US9sp0RH80G1WO LiTT2vUhlnVkKyreWTfjfVrCZHDwD+IomQcAHGLFgUUgSJcnBwg06vD50fJ12CozK i1iQ/77rkTqcVUWOBvQ4blhzBcEpNC/yPFIksQ7aEQAimPyHLu15Mp7eWE1TuvX3G ftI4/h3eheoa5ztSNzLBBHH4yubDQjG8fHBjg3lL2S1TPlmKlbeNd7EYnSkhhE640 9JcDxK05535aI043uhiDbvzmSDUf+csVIjUqRe4SnxlxV9P6NREwbwizb1nlPsL/b TxNg2KJe7/KDyfTvrw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MO9z7-1sVpvQ2pyL-00InBv; Thu, 22 Aug 2024 19:38:45 +0200 From: Armin Wolf To: james@equiv.tech, jlee@suse.com, corentin.chary@gmail.com, luke@ljones.dev, matan@svgalib.org, coproscefalo@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, rafael@kernel.org, lenb@kernel.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/5] platform/x86: wmi: Remove wmi_get_event_data() Date: Thu, 22 Aug 2024 19:38:08 +0200 Message-Id: <20240822173810.11090-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822173810.11090-1-W_Armin@gmx.de> References: <20240822173810.11090-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:421ERWJKEQNrzoMK8H/fYXmW85Vs/C2H4ED8ImoitO6N77yX2qt Ha2JtDVDPcjbiBF23n+AkbfS0B+U6F/mmtdykED6t8Jieak3/Fmjd1A3SlaI2WCnNK2MALG OEyCj5wamaaT29kDRANKj1Em5zmGzJalYJay3pMlAv/fkGNOaKCtvwm0EEIv4YbnWRuBRzd SiKyOkcgQ/YXCT37e+IxA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:hzxiQ+4jD8w=;aeYxhFJzEd0UM7e/j7F3ITa94BB giz2i67us2Y7cc0RC8wYcRT/vGKhogY+50+UDXop5JwDlwQ6J9o0BFQHQDD+bzW+JBVYC3j81 2RaYggY0S4qrlgN6ueDB0Q0b34sI/EUoYuU37ZiiLqj/UeGn5+DuQNsCYMm845O73yHflzksK PZSe3jYXPcAfJSIhnM/TYlsu5ffXt/MHPDjiV7kU1iaTl0IlPVnI3FaDD9dcZ7f78LPemXI8t VZHkswy0+myEqe+vptT0exM/OXyc2eBOYDDuMxSTmZSkGHzQYz3CiasKfHwqonMympSeRRTL4 CRJy2Sfr8kUy4DZwpdX81PFEd8TrNpRmkypJd5G97sG2WTkDhmJMLuGE/ew3Wl/60xpM8nP26 XffpsgcfKXnU2Gxvs9JgyE5ZcPNpXIglEiY39dOkxw9kOF0WR/3Gv4wMYRcqvp6FjEM/HHYr+ ciXJZd/GzBoIHcs5y8m12KjKDH7HiD3nAcp8Awv54nYUyFmjBOwO/4X6S5uj533ulcU7eHj5o GvudNBF7H12FyJ4nO2WpW8TH2C9zE+qk1HjIdmPzM0vlk1I+/G49aLXbnjRiGJllRT0qHsLE7 o/hAlE2dKyhDrvuBmWk5Ei1O5PE+vvbx2ZHnl8kCZbxjpAyd/bFtgo95QfEQaVJtVeFvCdsto OGuJD/iKj5UoPxqTwHZYiyh4r8RUo93mcXQP0N9wC5BDTpSHGF+tP+T64SJdtf9kf97zw5mFi OvNZcYHVisfG+IcvXroezWIR6fSwWBB2Z6IYYGyf2Dzyv/j3wYZZNma/aaW/OF1azKx5K2rH6 qB67TpbV1x/feiWdMjxh1DBw== Since the WMI driver core now takes care of retrieving the WMI event data even for legacy WMI notify handlers, this function is no longer used. Remove it to prevent WMI drivers from messing up the ACPI firmware on some machines. Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/wmi.c | 57 -------------------------------------- include/linux/acpi.h | 1 - 2 files changed, 58 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 6ab181dd94ab..c7f0754f74b4 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -199,23 +199,6 @@ static int wmidev_match_guid(struct device *dev, const void *data) return 0; } -static int wmidev_match_notify_id(struct device *dev, const void *data) -{ - struct wmi_block *wblock = dev_to_wblock(dev); - const u32 *notify_id = data; - - /* Legacy GUID-based functions are restricted to only see - * a single WMI device for each GUID. - */ - if (test_bit(WMI_GUID_DUPLICATED, &wblock->flags)) - return 0; - - if (wblock->gblock.flags & ACPI_WMI_EVENT && wblock->gblock.notify_id == *notify_id) - return 1; - - return 0; -} - static const struct bus_type wmi_bus_type; static struct wmi_device *wmi_find_device_by_guid(const char *guid_string) @@ -235,17 +218,6 @@ static struct wmi_device *wmi_find_device_by_guid(const char *guid_string) return dev_to_wdev(dev); } -static struct wmi_device *wmi_find_event_by_notify_id(const u32 notify_id) -{ - struct device *dev; - - dev = bus_find_device(&wmi_bus_type, NULL, ¬ify_id, wmidev_match_notify_id); - if (!dev) - return ERR_PTR(-ENODEV); - - return to_wmi_device(dev); -} - static void wmi_device_put(struct wmi_device *wdev) { put_device(&wdev->dev); @@ -649,35 +621,6 @@ acpi_status wmi_remove_notify_handler(const char *guid) } EXPORT_SYMBOL_GPL(wmi_remove_notify_handler); -/** - * wmi_get_event_data - Get WMI data associated with an event (deprecated) - * - * @event: Event to find - * @out: Buffer to hold event data - * - * Get extra data associated with an WMI event, the caller needs to free @out. - * - * Return: acpi_status signaling success or error. - */ -acpi_status wmi_get_event_data(u32 event, struct acpi_buffer *out) -{ - struct wmi_block *wblock; - struct wmi_device *wdev; - acpi_status status; - - wdev = wmi_find_event_by_notify_id(event); - if (IS_ERR(wdev)) - return AE_NOT_FOUND; - - wblock = container_of(wdev, struct wmi_block, dev); - status = get_event_data(wblock, out); - - wmi_device_put(wdev); - - return status; -} -EXPORT_SYMBOL_GPL(wmi_get_event_data); - /** * 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 eed105b1fbfb..3cbe4b57bc73 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -401,7 +401,6 @@ 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(u32 event, struct acpi_buffer *out); extern bool wmi_has_guid(const char *guid); extern char *wmi_get_acpi_device_uid(const char *guid); From patchwork Thu Aug 22 17:38:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 822375 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D53FA1CEACC; Thu, 22 Aug 2024 17:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.17.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348344; cv=none; b=n42zbRcYR89Zhp4YxFcGkczYQ0bzeFPuT5KulqXSIE6ZSbPLoiboiHddEb7ZduOPSGSZGRnqGODqmOM24X9rt3hSNHIO9fXDnhxXQhM4CTa4aDYM+qBpLpUQbGE2YCL3O+OC6OJXnnmVgGCrS32tSFC3MCru2r7KfL6VC8WgtiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348344; c=relaxed/simple; bh=Zx6VLkyJnlwRkWyPWUrI7rYgqbSUFqf6kLgkivSXUIE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TpiUfZtQH+eQ7OIQVgwUPeOPcoXL53+mcXKMlWSreSXxQp2//wr6Rl4EIG5FgU/v2w63oxBMRY7IpbEP9822DyffO3E+kpTeqxJGcQgy2dQZmGjznW3JtvamA5/fG50FcoTJJ0rDzgRlqcHzBLHj92+1NG/7tVxBkEwrDlcfnLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=NW9uBl4+; arc=none smtp.client-ip=212.227.17.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="NW9uBl4+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724348327; x=1724953127; i=w_armin@gmx.de; bh=yp72eb20PMYV+rHiupjM7lbpqXmjLCrxRfHSyP3Ato0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=NW9uBl4+GGIEcSCOpMUCJdaT9TxEMNggIYav0wLsUCUykRhMqa//OAEBKriyD7sa 3BexpMkJHIHeoSjYN7pNUPtIvr4P7nhcQqBNoipkPWoB4ppF8JiCyB2qU1wHJwFYk vw9VG1PpPRwwnuox2+RfxcHG6H40p6639vnAiUQ0M7jUpY3+LyPKl/jiENgIXRd/6 3zGNa+ojNwP4zUHvdRRknwUO8xnmeCvrERJJDeVy5bN5nQEf/kRoFX3SjsyKdRzZw CQxPMWPWroQCkW1pfn1jSudKRTGXaXCQQwkxhnT7TXmy+S8VNrBaLa0vLwtjKyPac I9w0xN/FUSnb65Ce+Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mqb1c-1sLH9D11yi-00lleD; Thu, 22 Aug 2024 19:38:47 +0200 From: Armin Wolf To: james@equiv.tech, jlee@suse.com, corentin.chary@gmail.com, luke@ljones.dev, matan@svgalib.org, coproscefalo@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, rafael@kernel.org, lenb@kernel.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/5] platform/x86: wmi: Merge get_event_data() with wmi_get_notify_data() Date: Thu, 22 Aug 2024 19:38:09 +0200 Message-Id: <20240822173810.11090-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822173810.11090-1-W_Armin@gmx.de> References: <20240822173810.11090-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:gsHzByznMkS8JUj2/L9W5/v1Nu6RgXOa/xvoH5wfjlGxNITsASe aSLkjCBUyK4nqVO5kNNknHFX0WL6gO6Fgs89Am+aWexYe/gfAMfoVAsUyid8WocL+JdL6KC KucdwbnTwMeMHmMc+gi1hnKml3VtnQ4o9NXj/beuJwUvRvayd88nuPr52eHeVJk/Nwxm9dP JF3p0QdTNcWfxOF4u+yXw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:q6Jiengjsp4=;FFrXC6z7twiLHOmpBxoVGb6UHyd syNhVdYuOzGtLfgbTv2WRXkFy441+SAs/iJOKZYMgXJIpxYzqKcER/X/p8CR3s/XmMRQrEeIw R145mAmrLYFfwNNh0Qcy5ptqxcsT0Ccz13kjfFu8rCByUSMucCI/wE3zOukoXOfmU0jbku5KD xRVXbwMohUbaqo4QizK3hpACTxhef0sI0W5gSIuojRVdAktIEFqRy1+SIVa0yHlyxdmGQ/N/U 7h9z0ZhcPUdlwpjo4nXA2gzYxcxGfTUkLsK0j89AosLQsRLIdxKDJMugeJ4Arb0F8g5Uuz+8h Y7tAkAXUO4Esl7CFJ8t09rnbkR62jDRrPkyIuE36u29ew0mTfSbybp8UP6tPIyLjRD+Um9sxN 70/sSM1lYizaskLLyIl8/40/bmD76ppoo+DiErHOBeN8DVOc3zVaRHLz7TnszHXjz7ekUA3wy jDMSF5PPSJpQP5gezL+zCSjzWUhe9kKln0E3TUHed9EZWLHOq2J2rhRwo3Nx1PLNzolEbdvy4 ds7RglC7+pPhI6ePiyWffOYyO0UdODjG/Gp34DlB2dDhImDqN/6iXMKuV8z96LzKQELzp5vJx 1/HEFgdbOXVe+Qr29mfky0Gf651h/u4qM7Nb9y2VMGShgltd9T9oOhTtMXYmQRv4+n9KSta1w lMATK5KxSg3VVmEoRNMeJg7GWjQVw27/bfiiIlHx12C64CRgWhPZyLtQKANF9gTe60QTYIwcu ETBt8SebLx3Ix8ObzuJXm3LwdyOQ/KIOg6GUaUQ7A5MBTWCgUNNeQ6cbgfPjx0CV60uVukKG7 IfEib6m+5VoYZ5QlBrqcQW4hjwZs6rUX2GFuBV9WuqmSw= Since get_event_data() is only called by wmi_get_notify_data(), it makes sense to merge both functions. Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/platform/x86/wmi.c | 43 +++++++++++++++----------------------- 1 file changed, 17 insertions(+), 26 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index c7f0754f74b4..6b27833ba5d9 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -166,22 +166,6 @@ static inline acpi_object_type get_param_acpi_type(const struct wmi_block *wbloc return ACPI_TYPE_BUFFER; } -static acpi_status get_event_data(const struct wmi_block *wblock, struct acpi_buffer *out) -{ - union acpi_object param = { - .integer = { - .type = ACPI_TYPE_INTEGER, - .value = wblock->gblock.notify_id, - } - }; - struct acpi_object_list input = { - .count = 1, - .pointer = ¶m, - }; - - return acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, out); -} - static int wmidev_match_guid(struct device *dev, const void *data) { struct wmi_block *wblock = dev_to_wblock(dev); @@ -1129,14 +1113,19 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) static int wmi_get_notify_data(struct wmi_block *wblock, union acpi_object **obj) { struct acpi_buffer data = { ACPI_ALLOCATE_BUFFER, NULL }; + union acpi_object param = { + .integer = { + .type = ACPI_TYPE_INTEGER, + .value = wblock->gblock.notify_id, + } + }; + struct acpi_object_list input = { + .count = 1, + .pointer = ¶m, + }; acpi_status status; - if (test_bit(WMI_NO_EVENT_DATA, &wblock->flags)) { - *obj = NULL; - return 0; - } - - status = get_event_data(wblock, &data); + status = acpi_evaluate_object(wblock->acpi_device->handle, "_WED", &input, &data); if (ACPI_FAILURE(status)) { dev_warn(&wblock->dev.dev, "Failed to get event data\n"); return -EIO; @@ -1163,7 +1152,7 @@ static void wmi_notify_driver(struct wmi_block *wblock, union acpi_object *obj) static int wmi_notify_device(struct device *dev, void *data) { struct wmi_block *wblock = dev_to_wblock(dev); - union acpi_object *obj; + union acpi_object *obj = NULL; u32 *event = data; int ret; @@ -1179,9 +1168,11 @@ static int wmi_notify_device(struct device *dev, void *data) * WMI driver core stops evaluating _WED due to missing * WMI event consumers. */ - ret = wmi_get_notify_data(wblock, &obj); - if (ret < 0) - return -EIO; + if (!test_bit(WMI_NO_EVENT_DATA, &wblock->flags)) { + ret = wmi_get_notify_data(wblock, &obj); + if (ret < 0) + return -EIO; + } down_read(&wblock->notify_lock); /* The WMI driver notify handler conflicts with the legacy WMI handler. From patchwork Thu Aug 22 17:38:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 821362 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DC4E61CFEC1; Thu, 22 Aug 2024 17:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=212.227.15.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348345; cv=none; b=bAuWSk625thx3vSwpgi53Ov3cmjKbm0CwJJhB3cRkLy01BjAR3u+7/zMgiiUl4oSCd5LU++tnnQs8YNDTaMo+BBAZc7oaGiLfBwJ1Mom50/KFi1WTZacANnmDfb4//mj3Pfo/nORqA883aHEdnWfVzgjMtf03GqJgGQFmJ/WWrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724348345; c=relaxed/simple; bh=aLRBxg9o/yW/gnTo+4DGF+WN5uvzAM4YVy9Ll5L3diY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DBDFmUGLpP6/8sZYJYMbzj+4ULycYHJKkSD61gUZ2I096Z8a9lvXGexQP53qtLpJEhadv7FZ/UFnUXnCGYl/wQlkswEPF8tdd/3+Mr8pxUZYI0N/7YkVZ4W5pMlWREkG4BWaTjp7wb2KbONklqH0xyIRoK05/bFTTSfuTjpj/P4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de; spf=pass smtp.mailfrom=gmx.de; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b=Jgq3bykE; arc=none smtp.client-ip=212.227.15.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmx.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmx.de header.i=w_armin@gmx.de header.b="Jgq3bykE" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1724348328; x=1724953128; i=w_armin@gmx.de; bh=HZH34bEBWlECtrEyEvw7QJJLZAR8h5MgcQYgkL9ydUw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=Jgq3bykERWn1YjJPUDHi1Lsd/baR4sidlKyMJ/bCNjxH82FX4HJFyODeKzIROFV0 b4MTj/wcCtgYjqOmLRCrF0LgJwgQ/qIOayUH0DaFXxe4n0X3CyNrWruBJflbiLI9w wiBLuVtNWyDsjL1FJUbA2yE0gRR4jd0I+fMn3PU+8obGmlx4mqw1whSHO/FYtDoEK umNvgRm2CgihhDzie0wSRam32jFRzBpPzj3Nynt/A526AAIh5gRHT7g3guSlNVz0J SVdr87iebBaEHnffMTXiHwRdbgXg0PwIAqAxYRjLk/vNGo9DnPFy5VrOqjkFFE1X8 e2iJgWHTlcAfMCmF2Q== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MbirE-1s8gEQ2KHm-00cP0F; Thu, 22 Aug 2024 19:38:48 +0200 From: Armin Wolf To: james@equiv.tech, jlee@suse.com, corentin.chary@gmail.com, luke@ljones.dev, matan@svgalib.org, coproscefalo@gmail.com Cc: hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com, rafael@kernel.org, lenb@kernel.org, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] platform/x86: wmi: Call both legacy and WMI driver notify handlers Date: Thu, 22 Aug 2024 19:38:10 +0200 Message-Id: <20240822173810.11090-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240822173810.11090-1-W_Armin@gmx.de> References: <20240822173810.11090-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:UDipBvfTGNVeeZOaR1S4jNMHIrRiufY8GfCw0i127xvQJ0w3fMD ZGXZCDkqLGcFzdEsSFacxryvgnqzLgvgFdiouWsa9KRgk8jaZ6XPtxMO53rZo+3tysKzdiE Kr8lZmMiNR5KnNactGWgNZvBRiaQoW4UFksUi3aXaEi06LgdAndRqDolTOdfTU0oenw2P8U Eh16ZMFoQejWq8aoXyXqA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:b4JDTVPIRoE=;2eionCkk0qauEx+jTUfW5w2gyht UIUXJq7eSuONwX+oMvDRxKVEBMGQZ0Lt+11RjYFj39lXgU9rVFWzNIE6rFi/noiVdCQbFOsEx Q484DWC9TMlDGE1gh6EKzYuaoxy3eS0SJ45G28gEbuumGCL2gci9XhUQZwOAoQUBq5PvTEMkE 7niFw48CFV4Mns9IzyGOl9jQu/DBblRk2OjBfoXiG4MGJJ9QYueDHZ/HpjtOpUR3Rnkj9je23 6875vUcZbHIOZ/x05NR3D4cgYAZ8A4Ow/QQSg4CnT1TVPwZ414Jjqk+E/oLLJayom22VGOr0u vvXEnqvoxfhj4uZQWREqQYSjMzMtP1bjbMq+GXoPH3TNQx8x8US+zwbvzuTmSBAOUMJpAUNjL 63/jL8Joc6HVhi6E9So2Fx3YswRRoyvRjpPSAQsipLJxjlSI0F2Tuw4xbQNc5oUHZmGhjoUB/ L3XreYGKleYbNdoudvTtYDAfTazCnH5sTGaSOISaRZdu78gbc/Ero0P9yVD3dqeZ3aIGHlakM TRT9od1xdfNIHPpCIHhqF3o1goohMayS9IZgH5BSrKWEISh7sNtCCinZDohJy6eIYrqAUReSj qvky1aul2s14MZXwp44WNWOlv5YWSEQeM1TjQfiQdEjJrieLohdGNok8cnXccVFp2IUUVYN5U 7KHsVGRnCbpfJvvWPlP+xLDgjVTZ/Efd5Jv25gsZhOM24cSxQ22S8TUm01OcRozCu80Q0fOcp IZ6PeC8/8ogxP5RUenyf2YfP/pAH2KTzIN2ViIjQ7T0jqPkndUQ9xWw/KnknOF4Oa610es2kW Rt9yd5DBiHjGK+mdFfoRuxvQ== Since the legacy WMI notify handlers are now using the WMI event data provided by the WMI driver core, they can coexist with modern WMI driver notify handlers. Remove the precedence of WMI driver notify handlers and call both when receiving an event. Signed-off-by: Armin Wolf --- drivers/platform/x86/wmi.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) -- 2.39.2 diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index 6b27833ba5d9..3cbe180c3fc0 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -1175,15 +1175,13 @@ static int wmi_notify_device(struct device *dev, void *data) } down_read(&wblock->notify_lock); - /* The WMI driver notify handler conflicts with the legacy WMI handler. - * Because of this the WMI driver notify handler takes precedence. - */ - if (wblock->dev.dev.driver && wblock->driver_ready) { + + if (wblock->dev.dev.driver && wblock->driver_ready) wmi_notify_driver(wblock, obj); - } else { - if (wblock->handler) - wblock->handler(obj, wblock->handler_data); - } + + if (wblock->handler) + wblock->handler(obj, wblock->handler_data); + up_read(&wblock->notify_lock); kfree(obj);