From patchwork Fri Nov 8 16:44:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Maksymchuk X-Patchwork-Id: 11235263 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 94A8B1599 for ; Fri, 8 Nov 2019 16:44:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73DF9206A3 for ; Fri, 8 Nov 2019 16:44:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="com7jnRF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727612AbfKHQog (ORCPT ); Fri, 8 Nov 2019 11:44:36 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:46571 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727149AbfKHQof (ORCPT ); Fri, 8 Nov 2019 11:44:35 -0500 Received: by mail-lj1-f193.google.com with SMTP id e9so6865315ljp.13; Fri, 08 Nov 2019 08:44:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cK+IGE/NngSL6LBLRuXqj1unYMeLxTCgHc31IK6M3A8=; b=com7jnRF5SZ9/ccNJQmHeb811+9z4q6zQpNqargqN4kMxwN+PtSkDWcgGhb66Uhr7s pCcM4eXTHQren2dDDoxjDXnlFGcfagRddvzKf3yB/A3Lmezgp4N2RYrfEFH8TpgXHc73 +Is0fXX2zvLQAKUuT6+VLdGgh7rhB2ennX5FHcI6XPFIJVQYXX6jehAZjwB0itJuy4jU baXmWFAt85GVpj+/wuOplH8pIYVd7Tsf4olpr4ABfPrOKd6CpHkJLzDRYi7awb/7oxcd cW3fwLLHXvhekF7F5RGUUsT2cd9PtOR1Yued636PH6yHmffOwZMNhyCa2qALr999aqV+ Amng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cK+IGE/NngSL6LBLRuXqj1unYMeLxTCgHc31IK6M3A8=; b=ocJquGb7sQhav0TouIOmaCZJ7yhmoIKHhgqbWLP9mIyn4OE0RT7O68m34dE+S+/lHU grI304MFh+2FDkfuQqqQIPqi/ZkQ+3Br7vCNIvbEINO4sYbV2QvYStFzT2kvRlRMmOzq S1ofUDjHKwgdsFjO3RZxaVnW/1fyA6hgpsJC1PEkdyrdl5kCMEks5FwJiiNTunUTLHZT 4/e2WLTWyur7miER/GnfqvfjLuFxcV/AK7fen07K5ZaeHbqAn2NT9v92GLIbQEAtnCe+ eRjd9lZGwtmPjdmO81b5Yaj6sKKBVeZGSUzeUyNyTqijqYRbj4kJgG6kTy6lsWhMyaxX qGMQ== X-Gm-Message-State: APjAAAU5jZ9NaVyn3AbtE9tigc7PoAMLwPYAEY8FR5fx7ytVxahsolIO YLjiLze2jYw0+TiJPcpw449XbayjJio= X-Google-Smtp-Source: APXvYqwnqP1/jFgP5c/CIcNf5IFpRJbWD/bxegdrv46BVSwI40CW/JtrxhItMkGjkKVpEuZwWMQAmg== X-Received: by 2002:a2e:9112:: with SMTP id m18mr7712122ljg.75.1573231472347; Fri, 08 Nov 2019 08:44:32 -0800 (PST) Received: from localhost.localdomain ([91.237.107.85]) by smtp.googlemail.com with ESMTPSA id z19sm2696415ljk.66.2019.11.08.08.44.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 08:44:31 -0800 (PST) From: Leonid Maksymchuk To: linux-kernel@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, chiu@endlessm.com, yurii.pavlovskyi@gmail.com, kristian@klausen.dk, andy@infradead.org, dvhart@infradead.org, corentin.chary@gmail.com, Leonid Maksymchuk Subject: [PATCH v4 1/3] asus_wmi: Fix return value of fan_boost_mode_store Date: Fri, 8 Nov 2019 18:44:16 +0200 Message-Id: <20191108164416.2969-1-leonmaxx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108164317.2874-1-leonmaxx@gmail.com> References: <20191108164317.2874-1-leonmaxx@gmail.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Function fan_boost_mode_store should return number of bytes written but instead it returns return value of kstrtou8 which is 0 if conversion is succefull. This leads to infinite loop after any write to it's SysFS entry. Fixes: b096f626a682 ("platform/x86: asus-wmi: Switch fan boost mode") Signed-off-by: Leonid Maksymchuk --- drivers/platform/x86/asus-wmi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 821b08e01635..723aa4d969dc 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1718,7 +1718,7 @@ static ssize_t fan_boost_mode_store(struct device *dev, asus->fan_boost_mode = new_mode; fan_boost_mode_write(asus); - return result; + return count; } // Fan boost mode: 0 - normal, 1 - overboost, 2 - silent From patchwork Fri Nov 8 16:45:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Maksymchuk X-Patchwork-Id: 11235265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0BC951599 for ; Fri, 8 Nov 2019 16:45:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D3E8320865 for ; Fri, 8 Nov 2019 16:45:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RyHZ5XeS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727963AbfKHQpy (ORCPT ); Fri, 8 Nov 2019 11:45:54 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:39020 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbfKHQpy (ORCPT ); Fri, 8 Nov 2019 11:45:54 -0500 Received: by mail-lj1-f195.google.com with SMTP id p18so6914376ljc.6; Fri, 08 Nov 2019 08:45:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gCwDRHsjMshwUjrnqGW1EzKHumkWqiiCQKHVnFSnF9E=; b=RyHZ5XeSBZdOFsYP3XbnSFbcW5JAvJ/lbSGnoyyZ78hyCwaQ2x+kSZ1DTXU6wg3ilt RZEsOTsq7qqpn+fTm6ATTEJ0x0Y7Fx82cBjpl39ESZlVYf2xLYTTMst7w9wnhuMfS8je Nya4qVRhOJxtgYH8OLEG5jJ4+7irdC2X8rJumxzR7qMDHHL3hi3GRIZLH9wtJRDhYb4l F66cP6zPTPXFUc7nD05c4JjXENsNCf+s4m6UZCMuU5MUAO1IrA02LFpOctaiJBIHcAf+ e2meX7kS5gGLV+eyO6q+BerCnKrQNv45tfFD6dSsnrz2q+OVJuYhk5n5l8N69Xrl6TCg Y1xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gCwDRHsjMshwUjrnqGW1EzKHumkWqiiCQKHVnFSnF9E=; b=tyT3HlhV/ppP7I73epp07k/BZQhWWyLvE52RPepYUilMDUI4XPrr5Unu22LMJCp+/q ksD/MKCK8mi85LrqURaXE9O90kl8UyLv6I0TIvcQ5R7RYmsHA/GLy0JUiwwMlVrrv7xR zsOp/ZVVGVmRig7D7jYuBWA4CTuFeiV4fOGWZ9EfYk8wvAUJbhkhtrnwTsWkQCif5LIQ zS9+O6TyLo/W1SI8JA/Bg3lWZCltXtciDP3mHunFlDNo19NAQhWA5uhwyV76oJ7JuEYE BveieJHEJeG1spztN/wB06uJC/aCSPlfpReOPOKqYEpcLbP/bWYhDzwxkSGwR5kpXrSU 7Leg== X-Gm-Message-State: APjAAAV2fcT27H3oKx/tAKKhUgX1nWpgwNEQxfKDLKMPQuQM8tSe4jN8 avuPVn87EB/kaqXqiYOrZYCx9dETKzg= X-Google-Smtp-Source: APXvYqxNeXNznXar9K/SaRmW1l/terky20bwTvI63gvGUqLPzCfSMQrwm9riTTcHnNu4NbIhrxwf8w== X-Received: by 2002:a2e:4703:: with SMTP id u3mr424645lja.126.1573231551883; Fri, 08 Nov 2019 08:45:51 -0800 (PST) Received: from localhost.localdomain ([91.237.107.85]) by smtp.googlemail.com with ESMTPSA id d4sm2727416lfi.32.2019.11.08.08.45.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 08:45:51 -0800 (PST) From: Leonid Maksymchuk To: linux-kernel@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, chiu@endlessm.com, yurii.pavlovskyi@gmail.com, kristian@klausen.dk, andy@infradead.org, dvhart@infradead.org, corentin.chary@gmail.com, Leonid Maksymchuk Subject: [PATCH v4 2/3] asus_wmi: Support fan boost mode on FX505DY/FX705DY Date: Fri, 8 Nov 2019 18:45:37 +0200 Message-Id: <20191108164537.3123-1-leonmaxx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108164317.2874-1-leonmaxx@gmail.com> References: <20191108164317.2874-1-leonmaxx@gmail.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org On ASUS FX505DY/FX705DY laptops fan boost mode is same as in other TUF laptop models but have different ACPI device ID and different hotkey code. Signed-off-by: Leonid Maksymchuk --- drivers/platform/x86/asus-wmi.c | 29 ++++++++++++++++------ include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 723aa4d969dc..4f9c0b99f352 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -61,6 +61,7 @@ MODULE_LICENSE("GPL"); #define NOTIFY_KBD_BRTDWN 0xc5 #define NOTIFY_KBD_BRTTOGGLE 0xc7 #define NOTIFY_KBD_FBM 0x99 +#define NOTIFY_KBD_FBM_2 0xae #define ASUS_WMI_FNLOCK_BIOS_DISABLED BIT(0) @@ -195,6 +196,7 @@ struct asus_wmi { int agfn_pwm; bool fan_boost_mode_available; + u32 fan_boost_mode_dev_id; u8 fan_boost_mode_mask; u8 fan_boost_mode; @@ -1611,15 +1613,12 @@ static int asus_wmi_fan_init(struct asus_wmi *asus) /* Fan mode *******************************************************************/ -static int fan_boost_mode_check_present(struct asus_wmi *asus) +static int fan_boost_mode_check_device(struct asus_wmi *asus, u32 dev_id) { u32 result; int err; - asus->fan_boost_mode_available = false; - - err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE, - &result); + err = asus_wmi_get_devstate(asus, dev_id, &result); if (err) { if (err == -ENODEV) return 0; @@ -1630,12 +1629,27 @@ static int fan_boost_mode_check_present(struct asus_wmi *asus) if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) && (result & ASUS_FAN_BOOST_MODES_MASK)) { asus->fan_boost_mode_available = true; + asus->fan_boost_mode_dev_id = dev_id; asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK; } return 0; } +static int fan_boost_mode_check_present(struct asus_wmi *asus) +{ + int err; + + asus->fan_boost_mode_available = false; + err = fan_boost_mode_check_device(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE); + + if (err || asus->fan_boost_mode_available) + return err; + + return fan_boost_mode_check_device(asus, + ASUS_WMI_DEVID_FAN_BOOST_MODE_2); +} + static int fan_boost_mode_write(struct asus_wmi *asus) { int err; @@ -1645,7 +1659,7 @@ static int fan_boost_mode_write(struct asus_wmi *asus) value = asus->fan_boost_mode; pr_info("Set fan boost mode: %u\n", value); - err = asus_wmi_set_devstate(ASUS_WMI_DEVID_FAN_BOOST_MODE, value, + err = asus_wmi_set_devstate(asus->fan_boost_mode_dev_id, value, &retval); if (err) { pr_warn("Failed to set fan boost mode: %d\n", err); @@ -2000,7 +2014,8 @@ static void asus_wmi_handle_event_code(int code, struct asus_wmi *asus) return; } - if (asus->fan_boost_mode_available && code == NOTIFY_KBD_FBM) { + if (asus->fan_boost_mode_available && + (code == NOTIFY_KBD_FBM || code == NOTIFY_KBD_FBM_2)) { fan_boost_mode_switch_next(asus); return; } diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h index 60249e22e844..714782b193b3 100644 --- a/include/linux/platform_data/x86/asus-wmi.h +++ b/include/linux/platform_data/x86/asus-wmi.h @@ -58,6 +58,7 @@ #define ASUS_WMI_DEVID_LIGHT_SENSOR 0x00050022 /* ?? */ #define ASUS_WMI_DEVID_LIGHTBAR 0x00050025 #define ASUS_WMI_DEVID_FAN_BOOST_MODE 0x00110018 +#define ASUS_WMI_DEVID_FAN_BOOST_MODE_2 0x00120075 /* Misc */ #define ASUS_WMI_DEVID_CAMERA 0x00060013 From patchwork Fri Nov 8 16:46:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Maksymchuk X-Patchwork-Id: 11235269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 00A041575 for ; Fri, 8 Nov 2019 16:47:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D01AB2178F for ; Fri, 8 Nov 2019 16:47:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="A2fNiNh6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726129AbfKHQr0 (ORCPT ); Fri, 8 Nov 2019 11:47:26 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34384 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbfKHQr0 (ORCPT ); Fri, 8 Nov 2019 11:47:26 -0500 Received: by mail-lj1-f196.google.com with SMTP id 139so6925876ljf.1; Fri, 08 Nov 2019 08:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ruDzCFGTnibQWfw6eGTcqpKQB6fF0oRUt7fDkDjSl4k=; b=A2fNiNh6wFIBLG0Gy4E9lTn2QQkhbfkInruQoJ19Tn4MVDI7qdmLPX2BHfNHkheAR2 SazZrHu9lZFI3abwISz3kGuvCbCvM9GZ3BuV7lZOktkDoUjHU2H2FLlX40POzn+RXsW0 u37WEN9wQ4y4MtjvDA/kGOUiYWs1kvw5JFmuX4T6JPPs3NbObv7sVI3v9+Yh7qupLzxi pC/a3RWnKTp3+0ZQ/vIK7E1EnM3iB0gZzb0OWPgyIkTSPW9odEHd8ZZUikZHFvwGDm06 i2eEJsDxFmrkaQfQVnptmXX0AGIS17PeCI4AasSwEykk7bXRkCK/SwEzBRrbG9q/OBYk HAvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ruDzCFGTnibQWfw6eGTcqpKQB6fF0oRUt7fDkDjSl4k=; b=tmyE09vvo2RcZxphil8V1fcBMeWF6WDL6QyKMejuGTaHSEZgBuSYxYa6anglt5L3Oj W7xaP+A2MJwGV1kZXeR9jy3iTjcoq/InPiMssinSRoiu6Q/VfZkct5Sa08BpQelzucgi fdipiptptpzAmhpffOrpoQiCPWMFxkD6Ern6gsFZiAKnzBn+xtWwHmHNl1HlVlFT2cUG FDcWF6g4FIxMl9T5sWfx6fZLSL4vFsLtwkZkerLp6ACniOblSo3jbvtcYGhTWoh7APxc B4dE4oRM4cCIwYPVVlzLpw2crLmVY32q7n3fe5KzNUUQ89QnG+OaR4Scz0YqMxMmvY7v 72fA== X-Gm-Message-State: APjAAAWBDIWOBbQLP2l7+Wn3g3gvQQy0Jmlby1nkwv1WZVKo/D2fHso8 f+SIlxaUpxlY2ncw03fGFj2mlNT+9hM= X-Google-Smtp-Source: APXvYqx/g1MVap0Pkj3DOsKO7eHBIvo4hWDmGcLEXx335XgFY9+ODFw4MbZgkqh7sXcGBGUXU2VSXQ== X-Received: by 2002:a2e:9d8d:: with SMTP id c13mr1219810ljj.71.1573231643626; Fri, 08 Nov 2019 08:47:23 -0800 (PST) Received: from localhost.localdomain ([91.237.107.85]) by smtp.googlemail.com with ESMTPSA id i30sm3162236lfp.39.2019.11.08.08.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 08:47:23 -0800 (PST) From: Leonid Maksymchuk To: linux-kernel@vger.kernel.org Cc: platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, chiu@endlessm.com, yurii.pavlovskyi@gmail.com, kristian@klausen.dk, andy@infradead.org, dvhart@infradead.org, corentin.chary@gmail.com, Leonid Maksymchuk Subject: [PATCH v4 3/3] asus_wmi: Set default fan boost mode to normal Date: Fri, 8 Nov 2019 18:46:52 +0200 Message-Id: <20191108164652.3223-1-leonmaxx@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191108164317.2874-1-leonmaxx@gmail.com> References: <20191108164317.2874-1-leonmaxx@gmail.com> MIME-Version: 1.0 Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Set default fan boost mode to normal for multiple reasons: 1) existing code assumes that laptop started in normal mode and that is not always correct. 2) FX705DY/FX505DY starts in silent mode and under heavy CPU load it overheats and drops CPU frequency to 399MHz [1]. Setting fan mode to normal avoids overheating. [1] Link: https://bugzilla.kernel.org/show_bug.cgi?id=203733 Signed-off-by: Leonid Maksymchuk --- drivers/platform/x86/asus-wmi.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 4f9c0b99f352..e6565b4e7ed7 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1675,6 +1675,15 @@ static int fan_boost_mode_write(struct asus_wmi *asus) return 0; } +static int fan_boost_mode_set_default(struct asus_wmi *asus) +{ + if (!asus->fan_boost_mode_available) + return 0; + + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; + return fan_boost_mode_write(asus); +} + static int fan_boost_mode_switch_next(struct asus_wmi *asus) { u8 mask = asus->fan_boost_mode_mask; @@ -2451,6 +2460,7 @@ static int asus_wmi_add(struct platform_device *pdev) err = fan_boost_mode_check_present(asus); if (err) goto fail_fan_boost_mode; + fan_boost_mode_set_default(asus); err = asus_wmi_sysfs_init(asus->platform_device); if (err)