提交 d2757331 编写于 作者: A Armin Wolf 提交者: Zheng Zengkai

hwmon: (dell-smm) Speed up setting of fan speed

stable inclusion
from stable-v5.10.101
commit ad53060bdfc34bb2fcc5bfff8a6f56bd425b964a
bugzilla: https://gitee.com/openeuler/kernel/issues/I5669Z

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=ad53060bdfc34bb2fcc5bfff8a6f56bd425b964a

--------------------------------

commit c0d79987 upstream.

When setting the fan speed, i8k_set_fan() calls i8k_get_fan_status(),
causing an unnecessary SMM call since from the two users of this
function, only i8k_ioctl_unlocked() needs to know the new fan status
while dell_smm_write() ignores the new fan status.
Since SMM calls can be very slow while also making error reporting
difficult for dell_smm_write(), remove the function call from
i8k_set_fan() and call it separately in i8k_ioctl_unlocked().

Tested on a Dell Inspiron 3505.
Signed-off-by: NArmin Wolf <W_Armin@gmx.de>
Reviewed-by: NPali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-6-W_Armin@gmx.deSigned-off-by: NGuenter Roeck <linux@roeck-us.net>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYu Liao <liaoyu15@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 38d0a4d1
......@@ -317,7 +317,7 @@ static int i8k_enable_fan_auto_mode(bool enable)
}
/*
* Set the fan speed (off, low, high). Returns the new fan status.
* Set the fan speed (off, low, high, ...).
*/
static int i8k_set_fan(int fan, int speed)
{
......@@ -329,7 +329,7 @@ static int i8k_set_fan(int fan, int speed)
speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : speed);
regs.ebx = (fan & 0xff) | (speed << 8);
return i8k_smm(&regs) ? : i8k_get_fan_status(fan);
return i8k_smm(&regs);
}
static int i8k_get_temp_type(int sensor)
......@@ -443,7 +443,7 @@ static int
i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
{
int val = 0;
int speed;
int speed, err;
unsigned char buff[16];
int __user *argp = (int __user *)arg;
......@@ -504,7 +504,11 @@ i8k_ioctl_unlocked(struct file *fp, unsigned int cmd, unsigned long arg)
if (copy_from_user(&speed, argp + 1, sizeof(int)))
return -EFAULT;
val = i8k_set_fan(val, speed);
err = i8k_set_fan(val, speed);
if (err < 0)
return err;
val = i8k_get_fan_status(val);
break;
default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册