The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Armin Wolf <W_Armin@gmx.de>
Cc: Dell.Client.Kernel@dell.com, pali@kernel.org,
	mjg59@srcf.ucam.org,  soyer@irl.hu,
	Hans de Goede <hansg@kernel.org>,
	 platform-driver-x86@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>,
	 linux@roeck-us.net, linux-hwmon@vger.kernel.org,
	mario.limonciello@amd.com
Subject: Re: [PATCH v5 6/9] hwmon: (dell-smm) Use new buffer-based WMI API
Date: Tue, 9 Jun 2026 14:32:40 +0300 (EEST)	[thread overview]
Message-ID: <668d1484-e516-ce17-b4cb-dc69aa5372d3@linux.intel.com> (raw)
In-Reply-To: <20260605205937.530897-7-W_Armin@gmx.de>

On Fri, 5 Jun 2026, Armin Wolf wrote:

> Use the new buffer-based WMI API to also support ACPI firmware
> implementations that do not use ACPI buffers for returning the
> results of a SMM call.
> 
> Acked-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>
> ---
>  drivers/hwmon/dell-smm-hwmon.c | 47 ++++++++++++----------------------
>  1 file changed, 16 insertions(+), 31 deletions(-)
> 
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 038edffc1ac7..0dbee562220b 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -12,8 +12,9 @@
>  
>  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
>  
> -#include <linux/acpi.h>
> +#include <linux/align.h>
>  #include <linux/capability.h>
> +#include <linux/compiler_attributes.h>
>  #include <linux/cpu.h>
>  #include <linux/ctype.h>
>  #include <linux/delay.h>
> @@ -36,10 +37,10 @@
>  #include <linux/thermal.h>
>  #include <linux/types.h>
>  #include <linux/uaccess.h>
> +#include <linux/unaligned.h>
>  #include <linux/wmi.h>
>  
>  #include <linux/i8k.h>
> -#include <linux/unaligned.h>
>  
>  #define I8K_SMM_FN_STATUS	0x0025
>  #define I8K_SMM_POWER_STATUS	0x0069
> @@ -232,7 +233,7 @@ static const struct dell_smm_ops i8k_smm_ops = {
>  /*
>   * Call the System Management Mode BIOS over WMI.
>   */
> -static ssize_t wmi_parse_register(u8 *buffer, u32 length, unsigned int *reg)
> +static ssize_t wmi_parse_register(u8 *buffer, size_t length, unsigned int *reg)
>  {
>  	__le32 value;
>  	u32 reg_size;
> @@ -253,7 +254,7 @@ static ssize_t wmi_parse_register(u8 *buffer, u32 length, unsigned int *reg)
>  	return reg_size + sizeof(reg_size);
>  }
>  
> -static int wmi_parse_response(u8 *buffer, u32 length, struct smm_regs *regs)
> +static int wmi_parse_response(u8 *buffer, size_t length, struct smm_regs *regs)
>  {
>  	unsigned int *registers[] = {
>  		&regs->eax,
> @@ -261,7 +262,7 @@ static int wmi_parse_response(u8 *buffer, u32 length, struct smm_regs *regs)
>  		&regs->ecx,
>  		&regs->edx
>  	};
> -	u32 offset = 0;
> +	size_t offset = 0;
>  	ssize_t ret;
>  	int i;
>  
> @@ -273,19 +274,16 @@ static int wmi_parse_response(u8 *buffer, u32 length, struct smm_regs *regs)
>  		if (ret < 0)
>  			return ret;
>  
> -		offset += ret;
> +		/* WMI aligns u32 integers on a 4 byte boundary */
> +		offset = ALIGN(offset + ret, 4);
>  	}
>  
> -	if (offset != length)
> -		return -ENOMSG;
> -
>  	return 0;
>  }
>  
>  static int wmi_smm_call(struct device *dev, struct smm_regs *regs)
>  {
>  	struct wmi_device *wdev = container_of(dev, struct wmi_device, dev);
> -	struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL };
>  	u32 wmi_payload[] = {
>  		sizeof(regs->eax),
>  		regs->eax,
> @@ -296,32 +294,19 @@ static int wmi_smm_call(struct device *dev, struct smm_regs *regs)
>  		sizeof(regs->edx),
>  		regs->edx
>  	};
> -	const struct acpi_buffer in = {
> +	const struct wmi_buffer in = {
>  		.length = sizeof(wmi_payload),
> -		.pointer = &wmi_payload,
> +		.data = &wmi_payload,
>  	};
> -	union acpi_object *obj;
> -	acpi_status status;
> +	struct wmi_buffer out;
>  	int ret;
>  
> -	status = wmidev_evaluate_method(wdev, 0x0, DELL_SMM_LEGACY_EXECUTE, &in, &out);
> -	if (ACPI_FAILURE(status))
> -		return -EIO;
> -
> -	obj = out.pointer;
> -	if (!obj)
> -		return -ENODATA;
> -
> -	if (obj->type != ACPI_TYPE_BUFFER) {
> -		ret = -ENOMSG;
> -
> -		goto err_free;
> -	}
> -
> -	ret = wmi_parse_response(obj->buffer.pointer, obj->buffer.length, regs);
> +	ret = wmidev_invoke_method(wdev, 0x0, DELL_SMM_LEGACY_EXECUTE, &in, &out, sizeof(__le32));
> +	if (ret < 0)
> +		return ret;
>  
> -err_free:
> -	kfree(obj);
> +	ret = wmi_parse_response(out.data, out.length, regs);
> +	kfree(out.data);
>  
>  	return ret;

If you used __free() here, you could do just:

	return wmi_parse_response(out.data, out.length, regs);

>  }
> 

-- 
 i.


  reply	other threads:[~2026-06-09 11:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-05 20:59 [PATCH v5 0/9] Convert most Dell WMI drivers to use the new buffer-based API Armin Wolf
2026-06-05 20:59 ` [PATCH v5 1/9] platform/x86: dell-descriptor: Use new buffer-based WMI API Armin Wolf
2026-06-09 10:58   ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 2/9] platform/x86: dell-privacy: " Armin Wolf
2026-06-05 20:59 ` [PATCH v5 3/9] platform/x86: dell-smbios-wmi: " Armin Wolf
2026-06-05 20:59 ` [PATCH v5 4/9] platform/x86: dell-wmi-base: " Armin Wolf
2026-06-09 11:16   ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 5/9] platform/x86: dell-ddv: " Armin Wolf
2026-06-05 20:59 ` [PATCH v5 6/9] hwmon: (dell-smm) " Armin Wolf
2026-06-09 11:32   ` Ilpo Järvinen [this message]
2026-06-05 20:59 ` [PATCH v5 7/9] platform/wmi: Make wmi_bus_class const Armin Wolf
2026-06-09 11:33   ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 8/9] platform/wmi: Make sysfs attributes const Armin Wolf
2026-06-09 11:34   ` Ilpo Järvinen
2026-06-05 20:59 ` [PATCH v5 9/9] modpost: Handle malformed WMI GUID strings Armin Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=668d1484-e516-ce17-b4cb-dc69aa5372d3@linux.intel.com \
    --to=ilpo.jarvinen@linux.intel.com \
    --cc=Dell.Client.Kernel@dell.com \
    --cc=W_Armin@gmx.de \
    --cc=hansg@kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mario.limonciello@amd.com \
    --cc=mjg59@srcf.ucam.org \
    --cc=pali@kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=soyer@irl.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox