From patchwork Sun Sep 1 03:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13786227 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 5C5581859; Sun, 1 Sep 2024 03:11:50 +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=1725160313; cv=none; b=S6gDIKSNjcSCMOnnFSjebc7N9gNwOeb4ul62a7+M/vQVx8PwIYQx91HXZvv8OVKCS17n3iqHFBOLPp4jVatavj1ctqiAzqB53kV+cB41YkHGhy7ODudn60MsldUS+LUcRBbH6zei03cTT466xN8xzrUIu/XtoicpigK/UkIN0Os= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725160313; c=relaxed/simple; bh=LaWnLcIk1vTrMitnfrliOw3wapLo5uNal6+HwDyS28Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JAnd4ZvZhwqzHpoL73cdYd9U6BxoIoV3CMa/F9aLeZ43h+JwkbCaDvSC2vPdNeAdoZ/6kZFddszJ2jlCbQwJR7W/qBWEeFpsRtRe4DgGYtlhm/EufQJn91XaxOXB8jjZf549kZLwU1PrgNAF/nziD9tI0gd04Gp28D/pbLyTjNs= 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=N/N4Mevv; 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="N/N4Mevv" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1725160278; x=1725765078; i=w_armin@gmx.de; bh=HaMEaXJFD8xYVLL10ruRknx3YqoN4wteHeuS95v5VCM=; 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=N/N4MevvYeQPfj8J9/BonHdUEFh0caKwztdWVPZAKu5CT+m1fs2em81S8tRm8zQH YOxb1er1yfXsY8NL7KGidN3TMlYBpBl+IkOE7RTfWFV/n1IWTeJ32/eEh2rplhfc+ +WcngBHaiwIYfQS1/IwQfJFppo34sgkpckQmNSaZyJJDjzaX6/NLcP8RQwhy0648b RuRsHKG0jkxOt+GGugK8OnJc8z+zbi3NRU3TPxKNi9epK6vY2clHeH56KM4cswKdB b0XiCCEKBdN9fL1CVYJrWQqxHLTdD159IGke6wtJYKBZXQyyKLzf2SW+w1i0vpwLk B+PSbf3+I8AQ/dOMBQ== 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 1MzyuS-1rpjDE2pny-00vRz1; Sun, 01 Sep 2024 05:11:18 +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, linux@roeck-us.net, jdelvare@suse.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 v2 1/5] hwmon: (hp-wmi-sensors) Check if WMI event data exists Date: Sun, 1 Sep 2024 05:10:51 +0200 Message-Id: <20240901031055.3030-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240901031055.3030-1-W_Armin@gmx.de> References: <20240901031055.3030-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:AFzmpbJ2ccVyaKPAj1+Xleq+wmdPWlx81//HtZhXUAN/lTl5LtL XWQ1jZp9xo3PqYiMveuojcf7bZOcjN3jbWFaTpEkfP8SmrXxBB5B0dDapA7Hq6LBGSRXPtX k6PdcZ1Y7hQ4jVmb6PQFNGqfiQC3X6tPWGHE2/hrtfeg/6ODd0Z3vA1OqVuYwC4PJOzeCGM q6ueVqQhHF+JUsfMKkMuQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:Uf6QCbIxWIo=;Pde6K+/Tt38u/em6ZDLfM9jfDnw KUGouCupjstAiQxUTnDO7k/K5DzOjYokltgEQtD4I40bJh7oSMWkR4f3AALjWo4FrAtzzwr7E bEJP+qCq9kf4k2wKaiXoZJHUZx6qS60YYWV85LBLHusK3CNV5EAde2O+WOWLJQ2NHxwmmNI5l HGJ8QNuj03xO6bgE1idc3M+gv/sSPvrrsuBhL/S0SfKyfL6FAEB3zi8VDMlegorzkNovXz7tz BQKcDERZrfXypKcoe3VFvq6jXzyBzffFHfr4xAxXuDRVC4iWvOYa8UUDaV+qv/4CT1EBK5skr vhxxg4aw2vjLAEkxMmVovS2LknTx/0dpZC9sVMUcMDD2sU0yeGEBx/nV0vqbm+vS/8IFdbXND fF7iRjJs1YiBfQWwFdGkSPpsb7Qwuyl9jtNPF3dNWN1tFuq8i1yYefY3rcRo7pVI1YZonQC3u QTEbYbh9R5dPUYx9KayUXQLY4c1quR88RkcvYHvH8c+WaUorv+fqAyZlAr/Q81RxCjM3AI00V wM5a9p2lpuKjZqj4ZP/PluQCkEqguwmpM6HU7UatYozp+iDjpzrd3YIKQKOt5baQqqPExyk9n yjDHgPWXUSv8f9362rFPR7SlkXwLgHE0B+XuGFjZJyOEZURJnp0Fvps1BUHxxWCyPPviusBwj st6/1YabnYzpgPxnxrF+uyJlns93PAlDRJ6UvM1rHxiL0um90mUhThj/YLwdgUlmEkGAJKKJ0 /OaxLOtqKH0FpNWuGHBhUuLt8rrbml2FwhsHoIk9BUYuEssNFuUsBSNvMH35FCknbXy9yB92s 2ieZfTPzRQLgDQwdVyBAEabQ== 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. Fixes: 23902f98f8d4 ("hwmon: add HP WMI Sensors driver") Signed-off-by: Armin Wolf Reviewed-by: Ilpo Järvinen --- drivers/hwmon/hp-wmi-sensors.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.39.2 diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index b5325d0e72b9..dfa1d6926dea 100644 --- a/drivers/hwmon/hp-wmi-sensors.c +++ b/drivers/hwmon/hp-wmi-sensors.c @@ -1637,6 +1637,8 @@ static void hp_wmi_notify(u32 value, void *context) goto out_unlock; wobj = out.pointer; + if (!wobj) + goto out_unlock; err = populate_event_from_wobj(dev, &event, wobj); if (err) { From patchwork Sun Sep 1 03:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13786228 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 4DC312BD05; Sun, 1 Sep 2024 03:11:51 +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=1725160314; cv=none; b=CJ6fZY3A3s5Dj8ij+u6+MvgjSuMd1xuanKwNg2onCWDxYkZnF2bfpGIVy8s4SthpYmeqcaGOdj0e0cGJlzsN5V2nLpTGceR8ARMmZvjN7qfZVYxGmU88mT2jVBQHukhOCD9hhuUT6KBsS+gaZ3NexFuOf+xFIc3e6ajAM+LkyrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725160314; c=relaxed/simple; bh=rv9OBi71fbe/a7CPMJebya9FJGV4VBsECfVRwAuuxh4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=QfXjPA7/tXSKfHB2luiXY1b1T62JvEfmXmT2Jm8HMzgSRr/C7DQ7SS2DantpI34e6CSTScNDaQsURs/2wNrVxMlefrIXUNTGIYItV3uUGb/kar62B4cQkqP3Jf7GgE/iVJeXTavhT+1QF4SFAZu8rIKCGI2d563+n9n4+dEgrzw= 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=lejYik+A; 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="lejYik+A" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1725160280; x=1725765080; i=w_armin@gmx.de; bh=fZnSJulc4dtFhoUS7lxxs7JDhRJ31cX6J//rA3Enl/U=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=lejYik+AgeK+kgtco06N4Mcckye53c3oeqeY1v+Xzt+wN+S+02iovzbUY3WjKnlG hpzYZaLTw8+18owjUM7hbHNtr/KoByLj/EogoCJh4dr7ZzNoJPhF5JjvWRtVG3Cay GSy0SjJawXu7md0vCMDJDjaS2S25m8QxIsyvmfl0N9AIEl4NsJ6ahJKRnLTUi4VPc 2m194K3mYqDqpOWPUc76XFGhNENq3cV3eOrNA/T/i5tMiy3LlQ9/ulOoVe5sFxVMS PapoaefD42bx7eF0Zi7Zr5zRfTbU0dT9ld7Rz5drQQjnBukIFsjO9HalJ/AKbw5W7 /K9+7k6ODv17K7ukgQ== 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 1MIdiZ-1spqCD1BXJ-00E2Vu; Sun, 01 Sep 2024 05:11:20 +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, linux@roeck-us.net, jdelvare@suse.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 v2 2/5] platform/x86: wmi: Pass event data directly to legacy notify handlers Date: Sun, 1 Sep 2024 05:10:52 +0200 Message-Id: <20240901031055.3030-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240901031055.3030-1-W_Armin@gmx.de> References: <20240901031055.3030-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:gwEXzSHF8k3I9oI9LgInWMWthgZ8VvIoF+VpgBxno+d48uo8SRW 3YnbUuJ87ceJYMV7IlJ7e+bp2ZC0n1N9FegUd1pyJhlnjC4aliVGvQP7kC9+KFnjJE+M0iY 1stPsGV66D0dnyoD1ymQ2J+oaE++gclJBlwrTeUbhaBkNyKOfNsmHcX2WdmILzmDJbZgAHZ 4AQkizRoQGdAHdMqPC1Qw== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:PhfRo9c8K6Y=;z0xzp5bNCdyrhLSUYmoUr09Vv9p O5xfcFuVTT+5KHgBx6JKRrmIeuckAB7OtsRx7gUxyRpKsZGPGr0dEJWfA2t1y+ca2MAUoyki1 ntUkWyp4brNBEDYeKjnBxYEoYkunk11AejqLuXNepYPtseJDdR5hI17h3NgpmgUD9gxMnUMXb elOsyKh/2jGrvHIwsr03umHz0RXAYzBT/LUzSqn+JOKRpxPfXxpiC4ApsFQH4nJO5No+hRPsT DrQ6LbqDgwhqgOO588yXjI9TYp2wS4KRw1SAsP0Z5OBRyMLyE+0sitfD6ELKKpqRmWAirjhuG 8aqs2kGB601LNKh3e5zCqZftaKI9ElBUXX9z8DmP3p58SjpqtPgNpfCRhTSl6aPJgI16RgL9z TPVS00jchI+gqP4R8zzX6tFUhb09VHhrELtij9fAvBnQkA9ueY7qFZlbFL9pFTAvAb3RMym1u ZgFA8tPtOgTsI/pcZmBc2SDXto0d1UL7xSKYN8LIy9XkHvtLpRlqJm0KEZBebYLdoXIEjnbok PwY/flLdYFY7uI4TzCROgVlj7wcPGmNjvV1SY9ekQPnmeFgDQPp03sd0fMTNAwHG+9nOl3YWT NLbTj8/ZlZfGesE1NwIe/+5zAs5NjQa1auaQ96OK6RHcxMVF6z3JYSV6Uwd5W7v0zMI3jMaZM WRNiRBE691JY97LNt6g9ZbuJvymJZ0tsh5pg1KTRhBhRq4g23nJ2IQ3GGoVFug5Inl7yA2+h6 Q23vXzYczo/o2p61Nym9cLniqrnwIkDHfBxoafv+61s7wEQq5lePHi+J8xOHEnTdVmjmuCOj9 1uI2ye4ZtuWSW2oOHL8VQR8A== 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. Reviewed-by: Ilpo Järvinen Reviewed-by: Hans de Goede Signed-off-by: Armin Wolf --- drivers/hwmon/hp-wmi-sensors.c | 22 ++++-------- 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, 37 insertions(+), 156 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/hp-wmi-sensors.c b/drivers/hwmon/hp-wmi-sensors.c index dfa1d6926dea..d6bdad26feb1 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; @@ -1630,20 +1628,15 @@ static void hp_wmi_notify(u32 value, void *context) * HPBIOS_BIOSEvent instance. */ - mutex_lock(&state->lock); - - err = wmi_get_event_data(value, &out); - if (ACPI_FAILURE(err)) - goto out_unlock; - - wobj = out.pointer; if (!wobj) - goto out_unlock; + return; + + mutex_lock(&state->lock); 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); @@ -1668,13 +1661,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 55d31d4fefd6..4b57102c7f62 100644 --- a/drivers/platform/x86/lg-laptop.c +++ b/drivers/platform/x86/lg-laptop.c @@ -205,21 +205,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; @@ -241,7 +231,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 Sun Sep 1 03:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13786229 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 656102E651; Sun, 1 Sep 2024 03:11:52 +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=1725160315; cv=none; b=qub65kFPmu6s5okEeSmLj1GqsWqQWkuBWSReAoSOhfbsvW1WprZvge3pOk1kovBM3DOVCrgIWOneUCo71nFyc3X+XLAsU5PbkXLTrct95y77HwTnk1/EVQEGad/7hRz4Z2/7juwhLfuJw5i0wbn4f/8GKIcr8zr+WO8WYi+GAtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725160315; c=relaxed/simple; bh=s4TW1WtAdPg+owGssuVS48Y+lQP34Pd+ooOIJCkz478=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=pDAiAZhU8KgGzqGtIU6eFR6krXXeJR/0dpHPr3jwRtSLY0QHRSgOgqgS+cqgSLOaSDgY4+OFejHbSf3zpTT3K9bMD6K433nSCYP+9A4Rc9wA3JbkHBBxYy29SwBTEsV+OFWE8n9ZLazfkwt2QaE29TtB5782RJkDJFmbZEDJ/ec= 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=uQgqLYgr; 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="uQgqLYgr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1725160283; x=1725765083; i=w_armin@gmx.de; bh=hg6S4gplBMMEaLxRK4ARyTK8NSLWEHkbdxC8ofXgSL4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=uQgqLYgrYAfVLfnmB3oikKJLWtDSuv0LAvij2R2DUoYC9vzR5OAgtJJDKPR152xn 7la8ea8+9B6xlIX1qAlunLwhMrFivh3sTTlX+/Plc8XyVa0AmWzpunfaauRPTidBq jq/HgpXbRgBo8vWGPpqKQfzQNiv9vHu5ty/cDk98RixkXj4lCsPCU+52ywl6xZMEw PYE+ACgZuyQQBja/PIUCdZohmrU1nFIHVFdKp577tB5dnjRdmFiNbB603jXJ3CZwf /xUg0CKPevpVkVqgnzw5R6R+BD7jea6MVNvTunvtfpxUjP5PAca/rI8jKRe/yfy7p N8zPVuQYG6I7B9N5/w== 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 1MhU5R-1s612u0rJb-00cIHE; Sun, 01 Sep 2024 05:11:23 +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, linux@roeck-us.net, jdelvare@suse.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 v2 3/5] platform/x86: wmi: Remove wmi_get_event_data() Date: Sun, 1 Sep 2024 05:10:53 +0200 Message-Id: <20240901031055.3030-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240901031055.3030-1-W_Armin@gmx.de> References: <20240901031055.3030-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:UlBrZM6/pwbag7fZm4yy57Y1UPyF+5BH1FMiWU8TLKyAePsF5oA PEwXEkolr20/jEJI/FL0Go0PoTPXbKTEG2m1Nbr5s1po3cJ1ImAHOyhPcAmmMKYUS4d7b8x uB2M/AnBrrt87NPhaYwyvXzXzb4eKTximvDyGF34d37MxViHpZ8PrxPaCTla86apiDlH5w2 FCxw8WUBPrRKzmtK/h2dQ== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:KrPx1r+J56U=;SbcQqkaFSnmx8NkFzWjTvo3l5Jq QE3b/dtDPXKyQKDjTzDgMvu/qqMVQVlMFZmxqFzqX6EbXNOm094Eu7fKtQNHpRAyysQrarQm9 w8v3gomzYRpV4w3rLcojgmQk3F+G6xP8h0J8R1VX4QwmP4fL34AGA7Z/3IA5KiiC5pgjjzVWR 9zZ2ttsaOM/yaxq8/0r2MCOykI8i4nvCuTIqAAvQJU2PUekXrx7j/E+190RgiCZYIsWYwf6dx sa72dEtbC61jsGLRr/bzEKfZmTQTju4AJ4t7daKQKjE7IiBNC8VaYMjwS9YQEeW7hxy7BhuOT bN7IsbpeI93ak0JLZqM8HgKlV3vxn4rHzf2Af0PsMfmxjTrJmV2FSd6P69GEygwjkXAyq7Ble pp2bBeoMHD+B9UMBJyDaDcGqOCtvgsxatXnPrygSVWubkcYJwzLPjx5/lC7ZDJ82BAuSiwPoo nBuVdFlBjepopQaieiy7AEzvcHRygLfZ/jNsjgVCRdJZoMddFBne8Q4Wzeeo4f5KL+Uxp1jCk ClW9eGN6On9x0TuVt9l1yU6JxnKK4dpimL+yxXxq2jwoI5ThnumLc/sg+rM4xJi1qlvfka477 70k9uKJNsaX+X9lv6Khsfl4R5R2uHRKwugOTal8jPs5acYOTFrruAU0ISsBGxGUNBFd7lbRc2 FtZYYmcDWOwY/fcT1OAjgIXA46gHoyDt/hXdIbh8gx/51mje7S/PW9o0UrQzc7+O1h760XNB9 VqVNOwqB/4EqdWXCx4zXBAxQaO+npS9waUy2S/1XKq3RrslGPSl5I5NrTBZPJ33M2/69WpYLW zltYtKF7IsgXuwtITwTcOj1w== 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. Reviewed-by: Ilpo Järvinen Reviewed-by: Hans de Goede Signed-off-by: Armin Wolf --- 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 Sun Sep 1 03:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13786230 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 E3A91381BE; Sun, 1 Sep 2024 03:11:53 +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=1725160316; cv=none; b=KJzLdm/ZFmv9bXbuQDHJASGBt/G1SyeLgeo+F3OsQLDBx9pfYzMqFQDboKxNX0WfDPceM+J4USIDQ4Vglemvd1qynYSz9Rr+i61nmweMUqAcUrn3MAHE87Id6lXj1LRc2wjx5ocfPJm5vTIA+bSnamC8qlWtBFtLZI/8z6RoPqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725160316; c=relaxed/simple; bh=al9iIx7sg7Fe/w5XRrgpXWBu78w/jKFbm1wkMOmqMJg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=BGN0tL/lJBwBemlgDYLhJv/0oQLHwe2aJi5pcfLbH0/D5kPsIr4oVsgCzY0Hw6sZ3cQVtu4XzlW1FtHSEpMK0m8kUI0GIHTEcXqhDBu45eVu4LYDs5Av0tD6wcpd6830TlUqHWrrQXg69YHKpX+no6fjcs1YZMIuKQqEVBbHfEM= 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=XugCvM2b; 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="XugCvM2b" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1725160285; x=1725765085; i=w_armin@gmx.de; bh=KaCyQtW/XfmUGIxt14OAfBRRg6d1YDSK1q5z/XEQjLI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:Message-Id:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding:cc: content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=XugCvM2bvCSBCmiSgNa3Db1aLLHzC27wVjTcpminv+nKo0jVa9Jmn1/eq7qGQ33W lbhWkj6cAhkqBsXC4MzLrEWrk7vZDfdNmImExmakq3jE0izcBrsvbHrWKk0Q5TiYa KuASyYqmzMCCC4NFYcZp1t5BIGa+JVfz5RylWn1EAIiPaF8J1hvfJrjViQAfwlsVg lE1HmYh2ZDCoohH63UmVj0Iy3yTFLY+nbiSD4oYVxm4RgdU8ee3KGVtPbiMheEQBS Z42I0HoB/lYEjJxN95j/Zrr70oaXAAFMPH/L4jvYbWXdx4uJAG9J4IdreTQxNQiRm AQ/OYkvwYVviicYAag== 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 1M2wKq-1sntJY49bI-004gnz; Sun, 01 Sep 2024 05:11:25 +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, linux@roeck-us.net, jdelvare@suse.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 v2 4/5] platform/x86: wmi: Merge get_event_data() with wmi_get_notify_data() Date: Sun, 1 Sep 2024 05:10:54 +0200 Message-Id: <20240901031055.3030-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240901031055.3030-1-W_Armin@gmx.de> References: <20240901031055.3030-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:sKr4i9MYti8tEQ113XL0z8KTHo/eDpcJW0zPngsUwmilquKVhgw /kGz5h1lXYdxAsC3M09U1GtQvJY+ic6/UGPYt3Iqb04jk58YXW2a4BHQghKLjOmbD2SOsPd EzdE6TXk2bslQQSS1V5Cevq7hEXH4xz+ZWaxSsdeflSXwnWQrgNQhMfMrQ+5PMlJ+thvt4H 1rst4Q1Uo3Q1Pqo+OSSIA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:0Rgf4R2Yuz8=;IhwF/acb0aAhdGakE8sbh1BKMlS IzxTGtBWlLdAsgn7FXEHEGcFV5EP6U6RZMlVnO1LVTHscctLv34YcYIRoO4opzvJpV3xEjmFm pJWoSMWfYQB5UHCHoa3itC246/+TVhSyP3YPddZJehiP6LL8YpQnmZD4JZkmvJYvjiqAgPo4w 7/i1vQFRR2QwCJS+gciWPC9/Fgoys7Ylp98RncJOymHkIy7sBcKCOAoJ4WmOjn+ToWYJg1j8A rlrVmLAQG/BT8KZ5j91/K989GG+S0V5xtNzLyaYgj41cYpVlIAe7jWX5ic5aKr4DlbPMMvJBH HFJaOhkux2d5P1wlp/eSnvkr4QGuTgpJCp+HGrsCnJIiYgzoZ6WTXjZvguY7Tii6IGDwsKzRB Xl8I8rMaSBz2JfC9KT30nw14iTUCEo9WFnIe3ddIanagJpbxLs+2TIfs2cmNFszfZFhp8yyQB mY0KAuqEVUUirdFNXsgUR7tAN6q1Tb2MoM3ujOc6nzXHRZMkKllYpMeTce/QBI/Rv3esX6/4d q6IaDM70n6qqJkKOKvvuUSQyw9ArlRAa86JQYMieuXRNb+P9iF3AZJBV5Ok4xfMM8PfIC9295 vGxex3R8uct+4etTeTFHvT2RI19z0VoUfNcfGsYqy8xGSbLLsvKgGVSUE3uXJHBt83YFbASp1 7esBrZuPd7FmaBaRsBtnRKie4JXeQgmG722vyjp444T0PpY6fTNhs8rWsIai5kouUQEz/ehKs OCgoAgDH7p3463mY4OCGVvofCaXBVEY3wm3yq4NTHFOgaAN06jQcLWSza9V4gmxFXdj8Ni9Ew 8WBZdUEY9EsOGXjoxvlxTp8g== Since get_event_data() is only called by wmi_get_notify_data(), it makes sense to merge both functions. Reviewed-by: Ilpo Järvinen Reviewed-by: Hans de Goede Signed-off-by: Armin Wolf --- 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 Sun Sep 1 03:10:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13786231 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 89E1161FCF; Sun, 1 Sep 2024 03:11: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=1725160320; cv=none; b=GR+ZQzjEyLAEbNnhK2Igukj9kcs4g6R5tS4FQMHDFoG9gwYljoQSnMDgdmeI0G72EYMEJ+cdNiuRYjX8WYA0fXGD2+xCbOu038VduIygMWPlr0AFwjiQ4Ypzrn7Iu95T3t+bQgVdMtC70NdkjEDYwqh12dVxsdpaEq8RlWY1G+w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725160320; c=relaxed/simple; bh=N1SRxLIMiaHEWQcXmpZUWs7IxLXL+xAMhqICn9t2VOY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cNdpI51LJDxNaBW860K4vm7javYWumxQjgGVtmfMKZM9MqTvLiE88T7x4G0QttIw53mROzpxMkIIcvv4h9DYwKxrD9pRYhlIgf2ycMpJ6XjKhA4pvVMRfEhR+PRglYlHYMJHwABJZAA4cq0ZThwevUmtmKIZha0P2TqTanpYHB0= 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=Mjl0aqus; 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="Mjl0aqus" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1725160287; x=1725765087; i=w_armin@gmx.de; bh=Fh+NRxC7VdSPBTxoHvz8oXusb/Km1qqXvRO90lsQ+bY=; 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=Mjl0aqusaFE6B4ajtDRJ+J/vCGAfF8aze8sRMLciQXVuC3JWTl49F0iplfmn0iSS e7pHxH9t8vXhIyy6xCTKAWUH4dIPfyk6nUKWUg53laJZ5VZtJBh7XAT3mVv03P9jt 7ETxFKPp0vFJNBkLkrKIs32xOY48oV+D2mBvYFEaPgCXRS9JLTb/kj/MFu/I5mvvo rfArt5G/DAsL/WY5zm/IZ3fVRyuBXUschMR8u7TguqLn2lUrCykK+84bNSZPAbrS6 I1Xzx/1BarrwaaNgrQ4LAj36YnDGgm+JuIvbxCG+C7PUmpCG9fUumF0lRBqLHT+K/ cVKhoVKrx9t/H1dZdw== 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 1N4z6q-1s3X0E3jgS-013fiD; Sun, 01 Sep 2024 05:11:26 +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, linux@roeck-us.net, jdelvare@suse.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 v2 5/5] platform/x86: wmi: Call both legacy and WMI driver notify handlers Date: Sun, 1 Sep 2024 05:10:55 +0200 Message-Id: <20240901031055.3030-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240901031055.3030-1-W_Armin@gmx.de> References: <20240901031055.3030-1-W_Armin@gmx.de> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Provags-ID: V03:K1:Q8iapphxleB0wEpmapMSDOSsrBZf3Tuc6vg2za1AvOK0/PAerH7 gETG8EHGDBFVe/mSiSAGpjOwiDkzQFeVx5HY6x+mpOB2e5oFGXfxPDo5ixAoLqWEXnfOBp5 syANV0+Okd5jIcGZp7QCTPV4N7xOXoWdfMTuWR4N+obWm/gcjdNCOfe1j1q0QiTB62YWnt1 RpysFHd2cp8njXU0KZS9w== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:5GzjSi1jG/E=;a7fjHAiFAoEAM5Mt1Ki5bigJWza sM5wGwL2rEazra1oD7bSgzHUtDm/obKvcbmzP16SLCn75yRjco1/Rf0khfF4gwYhqdcz4izQP ILp+Q7AZCShuqPWgbtZi8JI3TPCR2PZBxxwMBLZkr7smpE4+wUUsYy8XU5bL3lWP71QhxYjvU 2OWkuRe+y+vl8TgB99yeQ+OMmp5o0gEAsIxPy76HNgyfzKV+WB5+a0V2QB2WuYPiiutbq/W5m CWKo4zANdzVBOmS1zT7mdRMC0fFWieJaWrXtxnfGx+Zg2YAnM46GLb5GuHDTsCyp1A2iJfPz8 lbxNP32n9xkqPIxLM31nNW3h37Kl0CizDNps6ZqPTzrJDc95tYwvBCdUcas0yP3Ujnq5o08Be YlW+kTIftN+jymw2AnexkBi5FtV5qsygk05iQ29EqskZRhMbNZNCRWYhxLHNWCXvAw5UfwXqf 3c0qWaGEpVG23gliF0juu7cfmLt0xRGiEy9d0p8tt/r8hXa2tYRfzML/Ms2BPV41187zr/Lfu IyCOzvUemqUiuYhBTGpPrAm+wSJgB8vm6tGWsvR/H177QMSdvtpXKRJF1CCJCoqqFyDs37QPT FND8veLznMXscD4TILdlMEj874l4i6vsHh63xOOhMlPu1op7Tg4ArWrrTUvsnvFwdEV0uJP1D QQkT9Ffyd45q3nj1z4pSAJcWcuLEeEiPM4mwD27562AHBClhpC1/RFzw0PrajziVxKlEAk8P7 QsWbNwZesJBId45TKStbyjsygklsF37v92FwIE5EefpxPTBacEflL/MzZn5PvENeve0US2gRN nABUesSbSXm4TV5SI01mf1eA== 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. Reviewed-by: Hans de Goede 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);