From patchwork Mon Nov 4 10:54:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Maksymchuk X-Patchwork-Id: 11225393 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 BEB1215AB for ; Mon, 4 Nov 2019 10:54:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D394217F5 for ; Mon, 4 Nov 2019 10:54:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f1AGCyL6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728624AbfKDKyj (ORCPT ); Mon, 4 Nov 2019 05:54:39 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:45945 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728559AbfKDKyj (ORCPT ); Mon, 4 Nov 2019 05:54:39 -0500 Received: by mail-qt1-f194.google.com with SMTP id x21so23164129qto.12; Mon, 04 Nov 2019 02:54:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=U3NS7MGRIDkdoS3eVjdQC4auRnoPi6aRNIBzXWaDMUE=; b=f1AGCyL66sDJi3QUXxW2C+ewwVr/gz97WvEN9hg1hZmrHWH8t0qqUB3Np2IKkNUTUo JteKf2otKbtU9ZsyQ5yao8hhuxqmMSF1MgG0BkaZrj/+NaF//oZ53XD46btksqxPXo2r 8PquRcKm7CLNb6bfl8FVAjFgAUDp1Z/rlD3jyLfNxo5BQtyoMsfsMU6iDvI8okXxS22X X2+lcgTtHvwgFCu981JF8laaHC2tUw+bpvBwS+9rHeQ7EEJnCT3/l22xwGLJnENfDL1M DMHYbLjKok3ASVFj+MjB14yWY9QJl+TyWyh4R4bIE2FFYWff3PmMaGFMcaFtU7VXUL0G mWWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=U3NS7MGRIDkdoS3eVjdQC4auRnoPi6aRNIBzXWaDMUE=; b=XEKijz7tAKJiLPaBhUfYosr5PXRDUFq7x9SyFiqGSuVaDjjweh8gHoWOcmalTd+Rgg kU7M1eOJVC+Z4+M/HLI7w8KZj5fH1etDI36hquVXqPjN+PmmCj9UY+bTpOrhcW23CWIc s81AQH6rB/+neb5Q6Qe+BZBaYaI1LsJ5uESdFvxqxQqj5t/qDd+h4uWvMpuUwgoQlmuG fDgjSVJWLhBUhLYIg6GtOfvCxhRLE1SxnTxylG+HjJ9eQts3EqyPKQwZZFqHcC0V1fwg TQRx3JcAlIXylTfDf4mANsxx9wPGTEOzxe82KeiOboO990CNam131B79tuF9faJox/o6 IfHg== X-Gm-Message-State: APjAAAVqw0yGE7aaMAsdU1BNcdrcPcW2Fp9Ylcagn3XUdAFEN0x8f+Bx yNo8l4X75Q4XKo8G3nMYfPOtB4wAxQ/Oe4S91H3CjxN+9UE= X-Google-Smtp-Source: APXvYqzpQhNSh561vwWXcRjBjo44kQZ6WKt6h68IsV5eiH59WYV6BVHCwdzzzK1+/p462ZjDI/vrSS749lYeeSC6k6o= X-Received: by 2002:a0c:c3c4:: with SMTP id p4mr22067194qvi.178.1572864877195; Mon, 04 Nov 2019 02:54:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Leon Maxx Date: Mon, 4 Nov 2019 12:54:26 +0200 Message-ID: Subject: [RFC PATCH 1/3] platform/x86: asus_wmi: Fix return value of fan_boost_mode_store To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, andy@infradead.org, dvhart@infradead.org, corentin.chary@gmail.com, Daniel Drake , yurii.pavlovskyi@gmail.com 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. 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 821b08e..723aa4d 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 Mon Nov 4 10:55:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Maksymchuk X-Patchwork-Id: 11225411 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 770B71747 for ; Mon, 4 Nov 2019 10:55:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5587C217F5 for ; Mon, 4 Nov 2019 10:55:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FKC8zBUO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728727AbfKDKzY (ORCPT ); Mon, 4 Nov 2019 05:55:24 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:41622 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbfKDKzX (ORCPT ); Mon, 4 Nov 2019 05:55:23 -0500 Received: by mail-qk1-f193.google.com with SMTP id m125so17114047qkd.8; Mon, 04 Nov 2019 02:55:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=dWbpvuVtH4nrP6Vwnvej12G7U/i+V+/HVOtM2jawYEA=; b=FKC8zBUO1EclUoK9kwX4vWKSIWcUyaOW2Fuec3dw6kl4JrS3q9G2HHulUjXyws8qd6 OljVUlW+BTI/Fw37uV5VXmfqOLxVwzkOSVN1cc4nxFyFpf9bw5ccvHLz4ZJm/DDJVisc 2LArgdiI7GwExG+Hect8zYkhFUC4dR+Kb00EQYQLMRgZNmnbtfP2/GIfGEa3Cx2x0tVf KU6o37cfz0qV5Pd8Lhujv9eRBQTl3ow93inUcMA44LHk15N3Z/LWbfZytoZBV8iBI8mT 884/E6JjvcKjOe41NOhSVncbNZT75Wud8r0algXUcnsS4ClGZrY7bW3n0I3z44a/gpbt 9tcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=dWbpvuVtH4nrP6Vwnvej12G7U/i+V+/HVOtM2jawYEA=; b=Fku85bJXDo3mzOSgnpAjLxWAV7InhXhFpBl/QPmw1Ls6/FHfiSURtZ1vouKEcI1DSi KJvPI11hlJFuxyrfAUJotY3dRtgHl3r+HU4cJN7DI0S8j0uBjDapnjbHOcab5yl0kT4b EsglfL7ZJP30oFpME5IOJCkeQpGlEsvyCsci9wuYaZHPcToBr+xtAriSftJyl99HGnmk DawMPTGCbv+82HHfDAHm/rteS7LAAAIE00YdqpBBlHwtV5onU7NBVwwf0mBpiE3KFXJQ StGwaeqEUkoaqxzDATv8Wwwl9vunJPhS7cE88HkCu5wb3fVsHnVYI+MTdaUGkx9R2Ek3 5yww== X-Gm-Message-State: APjAAAWoeEUF5xJzosvC4SUtHXJNFhL7P1pV48Cnl4ElmpB71na3evu0 wyjPmy18vfaQAMfxrsq+cn4ZDg4r1XHSsRIkGjS8FETN0pg= X-Google-Smtp-Source: APXvYqzWmk0VCT1YbqhWYcuilzxfGX+5JeiCIzuYpImMwtHLaCSUAnC0Vabqb+mCiT1W6HP083K9iThrkLVuLvub50M= X-Received: by 2002:ae9:c302:: with SMTP id n2mr464880qkg.69.1572864922536; Mon, 04 Nov 2019 02:55:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Leon Maxx Date: Mon, 4 Nov 2019 12:55:11 +0200 Message-ID: Subject: [RFC PATCH 2/3] platform/x86: asus_wmi: Support fan boost mode on FX505DY/FX705DY To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, andy@infradead.org, dvhart@infradead.org, corentin.chary@gmail.com, Daniel Drake , yurii.pavlovskyi@gmail.com 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 key code. Signed-off-by: Leonid Maksymchuk --- drivers/platform/x86/asus-wmi.c | 42 ++++++++++++++++++++---------- include/linux/platform_data/x86/asus-wmi.h | 1 + 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index 723aa4d..f4e5840 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -61,6 +61,7 @@ #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) @@ -194,7 +195,7 @@ struct asus_wmi { int fan_pwm_mode; int agfn_pwm; - bool fan_boost_mode_available; + int fan_boost_mode_available; u8 fan_boost_mode_mask; u8 fan_boost_mode; @@ -1616,24 +1617,33 @@ static int fan_boost_mode_check_present(struct asus_wmi *asus) u32 result; int err; - asus->fan_boost_mode_available = false; + asus->fan_boost_mode_available = 0; err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE, &result); - if (err) { - if (err == -ENODEV) - return 0; - else - return err; + + if (err == 0 && + (result & ASUS_WMI_DSTS_PRESENCE_BIT) && + (result & ASUS_FAN_BOOST_MODES_MASK)) { + asus->fan_boost_mode_available = 1; + asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK; + return 0; } - if ((result & ASUS_WMI_DSTS_PRESENCE_BIT) && + err = asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_FAN_BOOST_MODE_2, + &result); + + if (err == 0 && + (result & ASUS_WMI_DSTS_PRESENCE_BIT) && (result & ASUS_FAN_BOOST_MODES_MASK)) { - asus->fan_boost_mode_available = true; + asus->fan_boost_mode_available = 2; asus->fan_boost_mode_mask = result & ASUS_FAN_BOOST_MODES_MASK; } - return 0; + if (err == -ENODEV) + return 0; + + return err; } static int fan_boost_mode_write(struct asus_wmi *asus) @@ -1641,12 +1651,15 @@ static int fan_boost_mode_write(struct asus_wmi *asus) int err; u8 value; u32 retval; + u32 dev_id = asus->fan_boost_mode_available == 1 ? + ASUS_WMI_DEVID_FAN_BOOST_MODE : + ASUS_WMI_DEVID_FAN_BOOST_MODE_2; 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, - &retval); + err = asus_wmi_set_devstate(dev_id, value, &retval); + if (err) { pr_warn("Failed to set fan boost mode: %d\n", err); return err; @@ -2000,7 +2013,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; } @@ -2177,7 +2191,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj, else if (attr == &dev_attr_als_enable.attr) devid = ASUS_WMI_DEVID_ALS_ENABLE; else if (attr == &dev_attr_fan_boost_mode.attr) - ok = asus->fan_boost_mode_available; + ok = asus->fan_boost_mode_available != 0; if (devid != -1) ok = !(asus_wmi_get_devstate_simple(asus, devid) < 0); diff --git a/include/linux/platform_data/x86/asus-wmi.h b/include/linux/platform_data/x86/asus-wmi.h index 60249e2..714782b 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 Mon Nov 4 10:55:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leonid Maksymchuk X-Patchwork-Id: 11225429 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 24CFC15AB for ; Mon, 4 Nov 2019 10:55:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02EBC217F5 for ; Mon, 4 Nov 2019 10:55:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dXKI99Yz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728804AbfKDKz5 (ORCPT ); Mon, 4 Nov 2019 05:55:57 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:44784 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728663AbfKDKz5 (ORCPT ); Mon, 4 Nov 2019 05:55:57 -0500 Received: by mail-qt1-f194.google.com with SMTP id o11so18150681qtr.11; Mon, 04 Nov 2019 02:55:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=rvo1SHxB9nVYQAjRXc27dF5Hg8RmRrQzx7MdaM7VmNk=; b=dXKI99YzHJ7cWkZ1hQUuEdTfaXZk3kat6uEDvhwPD2N/VlwI2UQ3sKAOIdf9qiBcMg k9VB6gsJ6VAE3AytNwdOQsiWAMB5DdQLECd+WxBntCp+DgW/Cfe7y85m0/RG7DwYGym8 r+FSwc1ame1Yi5RWV+mHOyrv0cie3RRmdR1YEoC4qOHQSdKlIhmgpPsFg8fRpC/F40Sx 5lNnEn9I37pYzOKr+Sicerj7F2oWnK1nQLMbNNTQ7MVcz+52fb2wKt8BJ4yf7arot2GO Ptqombc87PyDNOZkDRGRXwh1w6CZb3yLl9MfK883ERE+aX6atclJVojBr6MgPEP18EY6 5yUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=rvo1SHxB9nVYQAjRXc27dF5Hg8RmRrQzx7MdaM7VmNk=; b=oZAGDphXl8JdFfy82aEODNcPbcHM5YUItowCOu40czoLPcTjWcEmkEmzXxlu0tjS6X q3UiAgGSbUC9sraFsIbTkF9ROthclxrNCsRqnfsGJQUfJ9kX1WTYFh1NLhz5xfCcc4kY Z4HGFDF/j7NahSnVPHYLwsNt5yw7mJPKtAgsw0JQBRLTY9VIrei2rbvYApDj7/jBieTi IEqdfQjGkpBr7c48fvLr0bIHHfpT8azKJzmRaaqqXuTB68RdiCNYLY62VVDjcgTbFe8I Zzlwrx9tKOJxxHHSyj41QjdENlKUn2SFSBYsi9uuNiU6aSYJFnRtaDqHja59i0cCz2S5 Nyeg== X-Gm-Message-State: APjAAAXz40v/oHFsaeBFmaoRSKBScBujw6HKkzrnbtzfR7Qb6BhT/hxb L9V7Z+pexSosnTwnPB/9cTnrRAAh0MaYKWwyN+lF9Fg885I= X-Google-Smtp-Source: APXvYqygXMl4HsPWL+b5uxs86pmRyBHmjRYiwkZDhTm8Pg+KmODCvvi3F+xSQaJ5/4Ihk1T7mz8m3DcVaUj1jA5EIX0= X-Received: by 2002:ac8:23d3:: with SMTP id r19mr12004769qtr.297.1572864955304; Mon, 04 Nov 2019 02:55:55 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Leon Maxx Date: Mon, 4 Nov 2019 12:55:44 +0200 Message-ID: Subject: [RFC PATCH 3/3] platform/x86: asus_wmi: Set default fan boost mode to normal To: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, andy@infradead.org, dvhart@infradead.org, corentin.chary@gmail.com, Daniel Drake , yurii.pavlovskyi@gmail.com 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 true. 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c index f4e5840..70c5fbb 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1674,6 +1674,18 @@ static int fan_boost_mode_write(struct asus_wmi *asus) return 0; } +static int fan_boost_mode_set_default(struct asus_wmi *asus) +{ + int result = 0; + + if (asus->fan_boost_mode_available) { + asus->fan_boost_mode = ASUS_FAN_BOOST_MODE_NORMAL; + result = fan_boost_mode_write(asus); + } + + return result; +} + static int fan_boost_mode_switch_next(struct asus_wmi *asus) { u8 mask = asus->fan_boost_mode_mask; @@ -2450,6 +2462,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)