Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp6002888pxb; Mon, 14 Feb 2022 12:53:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwrl4aL4A494JLi4ZzmwsSaR7vEkypC+LL8uwEKPdR5172lrFD7sNwwVB76JjPXlvjiQFpZ X-Received: by 2002:a17:902:7146:: with SMTP id u6mr632271plm.47.1644871993097; Mon, 14 Feb 2022 12:53:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644871993; cv=none; d=google.com; s=arc-20160816; b=xQ2F/171D8ZyyNwpiUb4iRDv5aqTGsXex9c0313LJptIkJ3rkEGepnI8z43mOuA8CW gUxnuf3L98FrWAkd4ebHRrT4HuzE4YOnorOnam5cIZdr0k7HTKLLD2AqkDlZhYvsBzVz hnwyiI7IZ778Y1qo5tylV24tXKDMQhPL1VbZfNnTAha0SolhRZR5+i/+F6/s/kk1gMNb hbG/YXSoMHpFGR3I5A/4/jhDqyyq0Dk3n4OPySGa4Zjc8fMrNhAzwWjZ8u1a5PKMeVGz 5yiwHnaIfhaZJZZ2L/evhxMj0r8r8usilBU0hl4yhQhIayD5q51n7yquz507sEVZ8MB8 Qmvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=p6dBLyiIN+bJfT9WZbI3qVNozU+HYflQ3RQysbeMrEY=; b=w4z1WBoprQLBLpFOLvqQvG5Bs6+GmGJXMduE5aN8NkX6noLdnpyWEAutv4x3Holtns VMQUrnSdZFUeFE+OUCk7t/WkAI3PFi4U2mOVJk7qdd0bkMFG3mNXiKouBoZk8dZqpWiJ /Ah0oCEKNvH5Yf0YnVQEAXasFGo9LQ9a8ImW9f23aA0EnVb3v2wNPzlc/Z/CY/4mK8O8 faYwevnIKIBSoikc+1rhdYJgjreUZGc2pyAZEGcS9lCjK6utJTiZkEqxwCe0nFn8+A71 0Z5SfgTxOYQpVbNLkwJBlLSx2cRmBti6/ZkqfiVHjc95o8p51VO75w4eBTNggPzxiVBY 23iA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Vd/a8uDB"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n68si27158224pfd.135.2022.02.14.12.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 12:53:13 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Vd/a8uDB"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 02CE710661B; Mon, 14 Feb 2022 12:17:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245001AbiBNJpZ (ORCPT + 99 others); Mon, 14 Feb 2022 04:45:25 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243229AbiBNJnp (ORCPT ); Mon, 14 Feb 2022 04:43:45 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E696CA54; Mon, 14 Feb 2022 01:38:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D0638B80DA9; Mon, 14 Feb 2022 09:38:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7872C340F0; Mon, 14 Feb 2022 09:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644831479; bh=OS55XowkhI3CqDz/e8i9pKkA6nzSUACJ0ExuNWM5heM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vd/a8uDBUOu/ARi8ptN1GAr0CfCtcUWD733umecV0RQTSekdlayfnQwa0CCLkttoV bnz7Ozou9+23REwjDzHIFB29Bxc7PrmetYrusPFfRQ8KBYv14HLRK4oakgr8y34M0I Hqb3U7DW+Te8ApA7vijzgm/s/LADO9bAOU3kGolg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Armin Wolf , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Guenter Roeck Subject: [PATCH 5.4 68/71] hwmon: (dell-smm) Speed up setting of fan speed Date: Mon, 14 Feb 2022 10:26:36 +0100 Message-Id: <20220214092454.325425404@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220214092452.020713240@linuxfoundation.org> References: <20220214092452.020713240@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Armin Wolf commit c0d79987a0d82671bff374c07f2201f9bdf4aaa2 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: Armin Wolf Reviewed-by: Pali Rohár Link: https://lore.kernel.org/r/20211021190531.17379-6-W_Armin@gmx.de Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/dell-smm-hwmon.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -301,7 +301,7 @@ static int i8k_get_fan_nominal_speed(int } /* - * 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) { @@ -313,7 +313,7 @@ static int i8k_set_fan(int fan, int spee speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : speed); regs.ebx = (fan & 0xff) | (speed << 8); - return i8k_smm(®s) ? : i8k_get_fan_status(fan); + return i8k_smm(®s); } static int i8k_get_temp_type(int sensor) @@ -427,7 +427,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; @@ -488,7 +488,11 @@ i8k_ioctl_unlocked(struct file *fp, unsi 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: