From patchwork Sat Jan 27 16:28:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 10187575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8369A601D5 for ; Sat, 27 Jan 2018 16:29:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F9CE28A1B for ; Sat, 27 Jan 2018 16:29:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6326328B11; Sat, 27 Jan 2018 16:29:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF0F28A1B for ; Sat, 27 Jan 2018 16:29:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753140AbeA0Q3a (ORCPT ); Sat, 27 Jan 2018 11:29:30 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32791 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753138AbeA0Q33 (ORCPT ); Sat, 27 Jan 2018 11:29:29 -0500 Received: by mail-wm0-f65.google.com with SMTP id x4so38922182wmc.0; Sat, 27 Jan 2018 08:29:28 -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=IyAcllhRkAvIY0cX4EpEsmRvUBU0xCkmZC6Mw++7Fns=; b=Cfm8AQgP23xtvVKWtmnaoyF5UCd3kF/tJdychMhDO/lMS9KEY3bspdfsM2HQPoK1F5 dMb21tGTNBFPa7QkBJw19y8zlsBHyxqWMlYhd2Vse3t/YTgGatB9nfYJFhkTB90bjv67 dN23vDHuqZzzuq3EKGOLSRcHE2OW22o++0wztTbWPT37hlWTrttfu5iUJXz3nS0+wrNE emOij85dsDofFVMVr8wG7dd+QGqL2BCONrpcuSimt2QK2GkQPz8g/UneDiKcpCZlKisY q+cG4SYk78SFJa6KtENpomI2YiaLCY45U3QXq5Cja/GZ3rOw8jTnZYitMrblIvb1Fk72 oAaw== 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=IyAcllhRkAvIY0cX4EpEsmRvUBU0xCkmZC6Mw++7Fns=; b=c+o/FcVZTYpmfi9pUDK6ONvCPllM4XR0qHdJI0pRjjj6IxaSuYGXFlqxuBKcxPwVJj efMi1cqbU90HpHi33xuTotphJnzwOymEiEz+wRtTcPILdtH4amYyweCdqYmURmWpH8cn e483FnLH4jGRxWqhFaegraW87l3C/UE2JicsDTtohADDmN1odnp4WbrTq25eZy1m1Zay iqW/QKBySJ5hyjRSHJABlogBLutvBetCRu/CJuZEBBgCWVprEq2hZOwIxcd0hwZd+/Y6 O1Vl8i9J42SQakBCHl9/4sEfaSQi57b4De6MRV/QwioT09swHvhMJ+7/v7GNYXN8/SrM M4Fw== X-Gm-Message-State: AKwxytdL4QzwPK+eYHtle43g/Md3lBJDRSVDu6pp+sFRnUA330rHOoZw 4BPI+JeEb7JAGpGYB8L6ISs= X-Google-Smtp-Source: AH8x226bCYKamCw73kN9eaA7d3fzCg9hbgIGTWh0EiNKcF0MN91u0dC8QKLhH9lYoM9iWl2MjB+avw== X-Received: by 10.28.149.17 with SMTP id x17mr13632959wmd.19.1517070567588; Sat, 27 Jan 2018 08:29:27 -0800 (PST) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id m6sm5310216wmb.6.2018.01.27.08.29.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 27 Jan 2018 08:29:26 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Guenter Roeck , Oleksandr Natalenko , Jonathan Buzzard , Mario Limonciello Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] hwmon: (dell-smm) Disable fan support for Dell Inspiron 7720 Date: Sat, 27 Jan 2018 17:28:34 +0100 Message-Id: <20180127162834.14675-1-pali.rohar@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180127162204.13752-1-pali.rohar@gmail.com> References: <20180127162204.13752-1-pali.rohar@gmail.com> MIME-Version: 1.0 Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Calling fan related SMM functions implemented by Dell BIOS firmware on Dell Inspiron 7720 freeze kernel for about 500ms. Until Dell fixes it we need to disable fan support for Dell Inspiron 7720 as it makes system unusable. Via "force" module param fan support can be enabled. Reported-by: vova7890@mail.ru Signed-off-by: Pali Rohár Link: https://bugzilla.kernel.org/show_bug.cgi?id=195751 Cc: stable@vger.kernel.org # v4.0+, will need backport --- drivers/hwmon/dell-smm-hwmon.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index aef4f8317ae2..3f8b4e482b64 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -76,6 +76,7 @@ static uint i8k_fan_mult = I8K_FAN_MULT; static uint i8k_pwm_mult; static uint i8k_fan_max = I8K_FAN_HIGH; static bool disallow_fan_type_call; +static bool disallow_fan_support; #define I8K_HWMON_HAVE_TEMP1 (1 << 0) #define I8K_HWMON_HAVE_TEMP2 (1 << 1) @@ -242,6 +243,9 @@ static int i8k_get_fan_status(int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN, }; + if (disallow_fan_support) + return -EINVAL; + regs.ebx = fan & 0xff; return i8k_smm(®s) ? : regs.eax & 0xff; } @@ -253,6 +257,9 @@ static int i8k_get_fan_speed(int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_SPEED, }; + if (disallow_fan_support) + return -EINVAL; + regs.ebx = fan & 0xff; return i8k_smm(®s) ? : (regs.eax & 0xffff) * i8k_fan_mult; } @@ -264,7 +271,7 @@ static int _i8k_get_fan_type(int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; - if (disallow_fan_type_call) + if (disallow_fan_support || disallow_fan_type_call) return -EINVAL; regs.ebx = fan & 0xff; @@ -289,6 +296,9 @@ static int i8k_get_fan_nominal_speed(int fan, int speed) { struct smm_regs regs = { .eax = I8K_SMM_GET_NOM_SPEED, }; + if (disallow_fan_support) + return -EINVAL; + regs.ebx = (fan & 0xff) | (speed << 8); return i8k_smm(®s) ? : (regs.eax & 0xffff) * i8k_fan_mult; } @@ -300,6 +310,9 @@ static int i8k_set_fan(int fan, int speed) { struct smm_regs regs = { .eax = I8K_SMM_SET_FAN, }; + if (disallow_fan_support) + return -EINVAL; + speed = (speed < 0) ? 0 : ((speed > i8k_fan_max) ? i8k_fan_max : speed); regs.ebx = (fan & 0xff) | (speed << 8); @@ -772,6 +785,8 @@ static struct attribute *i8k_attrs[] = { static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, int index) { + if (disallow_fan_support && index >= 8) + return 0; if (disallow_fan_type_call && (index == 9 || index == 12 || index == 15)) return 0; @@ -1039,6 +1054,23 @@ static const struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initconst }; /* + * On some machines all fan related SMM functions implemented by Dell BIOS + * firmware freeze kernel for about 500ms. Until Dell fixes these problems fan + * support for affected blacklisted Dell machines stay disabled. + * See bug: https://bugzilla.kernel.org/show_bug.cgi?id=195751 + */ +static struct dmi_system_id i8k_blacklist_fan_support_dmi_table[] __initdata = { + { + .ident = "Dell Inspiron 7720", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Inspiron 7720"), + }, + }, + { } +}; + +/* * Probe for the presence of a supported laptop. */ static int __init i8k_probe(void) @@ -1060,6 +1092,12 @@ static int __init i8k_probe(void) i8k_get_dmi_data(DMI_BIOS_VERSION)); } + if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { + pr_warn("broken Dell BIOS detected, disallow fan support\n"); + if (!force) + disallow_fan_support = true; + } + if (dmi_check_system(i8k_blacklist_fan_type_dmi_table)) { pr_warn("broken Dell BIOS detected, disallow fan type call\n"); if (!force)