From patchwork Fri Jun 17 22:54:46 2016 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: 9185117 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 6E590608A6 for ; Fri, 17 Jun 2016 22:56:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A15F27EED for ; Fri, 17 Jun 2016 22:56:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48FD5282EE; Fri, 17 Jun 2016 22:56:34 +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=unavailable 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 C758927EED for ; Fri, 17 Jun 2016 22:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754949AbcFQWzb (ORCPT ); Fri, 17 Jun 2016 18:55:31 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:34977 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753509AbcFQWz0 (ORCPT ); Fri, 17 Jun 2016 18:55:26 -0400 Received: by mail-wm0-f66.google.com with SMTP id k184so1034501wme.2; Fri, 17 Jun 2016 15:55:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uNgwevTu78JHvnPWB42nmv8STdQDwJN3DNDZH1UqXdQ=; b=Vzs10PwV8GodsMnMa8wxT1j4tfV1qPi1NJXlmJH8+3Bvjqjf13a1JxNq8iHcqCvAUg +nzjIqnqympRNIG7AUkhmL8XM7LDEhoAWl8Zo3vbKwhEwGii/KTKND1rS8/kIQCeTgtu dzFuKAnkDe1YSxcNy/iOqrRMUDReJEOwlUeNb4n4jFqQRmKY9bcWjubrOAxpE2tY0vhO hpKncWlwwyf1XHHdTM35QOj88nrF2ZGp/wpAqNGRl7lEnrzvszpFqIuGz0cWJsqcGmut WX5N0Dcxi4eUu0OW2S0KDDsSRofHHy1UfsZs50esrJ+iImaaphJ7anpbfQkInzxgCGpS evZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uNgwevTu78JHvnPWB42nmv8STdQDwJN3DNDZH1UqXdQ=; b=eDvQnm4/sfxOZJ7Pu9VZpvOTMMVJvjn7HGyaQ9pFeeN5XqyG7WgS/Q3y3toGgED0lb Sil52hAckTSxMsn/Ye6f1jie+BKhWa5DKIXItYjEZtFC3l5t7iGrZvRPBZy41hwDHIjw L96ownLtXkdhQGMzXaQANS/VKRrWtesS7AanhjhnpZJwunD4q65odHYe/2t0FOcjd0z1 Qz+4leZhllJbiijghrxfFHp0D9CdJO5NByJbkn+v+oSqlgGa8g2+zAsuTL2b2uCaJnWA Tw3yeDDVAjWXTSpmnSjC9mSNR6pbPSRFMCb3SQLAHfV/tnW+olVhk3fOGcFEFhD3v9MD JqRw== X-Gm-Message-State: ALyK8tL/xC+DrCQHMHt61vCi/mlAVbGnzRaItgJbsEqT5VhKfM9iXSnlIidbpPOKZ5bZLA== X-Received: by 10.28.26.4 with SMTP id a4mr620262wma.92.1466204125218; Fri, 17 Jun 2016 15:55:25 -0700 (PDT) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id d137sm806128wmd.12.2016.06.17.15.55.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jun 2016 15:55:24 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jean Delvare , Guenter Roeck , Jan C Peters , Thorsten Leemhuis , =?UTF-8?q?David=20Santamar=C3=ADa=20Rogado?= , Peter Saunderson , Tolga Cakir , "Austin S. Hemmelgarn" , Mario_Limonciello@dell.com, Gabriele Mazzotta , =?UTF-8?q?Micha=C5=82=20K=C4=99pie=C5=84?= , Dakota Whipple , Leon Yu Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH 3/6] hwmon: (dell-smm) Disallow fan_type() calls on broken machines Date: Sat, 18 Jun 2016 00:54:46 +0200 Message-Id: <1466204089-17030-4-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1466204089-17030-1-git-send-email-pali.rohar@gmail.com> References: <1466204089-17030-1-git-send-email-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 Some Dell machines have especially broken SMM or BIOS which cause that once fan_type() is called then CPU fan speed going randomly up and down. And for fixing this behaviour reboot is required. So this patch creates fan_type blacklist of affected Dell machines and disallow fan_type() call on them to prevent that erratic behaviour. Old blacklist which disabled loading driver on some machines added in commits a4b45b25f18d ("hwmon: (dell-smm) Blacklist Dell Studio XPS 8100") and 6220f4ebd7b4 ("hwmon: (dell-smm) Blacklist Dell Studio XPS 8000") were moved to FAN_TYPE blacklist. Reported-by: Jan C Peters Signed-off-by: Pali Rohár Link: https://bugzilla.kernel.org/show_bug.cgi?id=100121 Cc: stable@vger.kernel.org # v4.0+, will need backport --- drivers/hwmon/dell-smm-hwmon.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index c8bd3fdd..4bbc587 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -73,6 +73,7 @@ static u32 i8k_hwmon_flags; 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; #define I8K_HWMON_HAVE_TEMP1 (1 << 0) #define I8K_HWMON_HAVE_TEMP2 (1 << 1) @@ -241,6 +242,9 @@ static int i8k_get_fan_type(int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; + if (disallow_fan_type_call) + return -EINVAL; + regs.ebx = fan & 0xff; return i8k_smm(®s) ? : regs.eax & 0xff; } @@ -726,6 +730,9 @@ static struct attribute *i8k_attrs[] = { static umode_t i8k_is_visible(struct kobject *kobj, struct attribute *attr, int index) { + if (disallow_fan_type_call && + (index == 9 || index == 12)) + return 0; if (index >= 0 && index <= 1 && !(i8k_hwmon_flags & I8K_HWMON_HAVE_TEMP1)) return 0; @@ -937,12 +944,14 @@ static struct dmi_system_id i8k_dmi_table[] __initdata = { MODULE_DEVICE_TABLE(dmi, i8k_dmi_table); -static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { +/* + * On some machines once I8K_SMM_GET_FAN_TYPE is issued then CPU fan speed + * randomly going up and down due to bug in Dell SMM or BIOS. Here is blacklist + * of affected Dell machines for which we disallow I8K_SMM_GET_FAN_TYPE call. + * See bug: https://bugzilla.kernel.org/show_bug.cgi?id=100121 + */ +static struct dmi_system_id i8k_blacklist_fan_type_dmi_table[] __initdata = { { - /* - * CPU fan speed going up and down on Dell Studio XPS 8000 - * for unknown reasons. - */ .ident = "Dell Studio XPS 8000", .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), @@ -950,16 +959,19 @@ static struct dmi_system_id i8k_blacklist_dmi_table[] __initdata = { }, }, { - /* - * CPU fan speed going up and down on Dell Studio XPS 8100 - * for unknown reasons. - */ .ident = "Dell Studio XPS 8100", .matches = { DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Studio XPS 8100"), }, }, + { + .ident = "Dell Inspiron 580", + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "Inspiron 580 "), + }, + }, { } }; @@ -974,8 +986,7 @@ static int __init i8k_probe(void) /* * Get DMI information */ - if (!dmi_check_system(i8k_dmi_table) || - dmi_check_system(i8k_blacklist_dmi_table)) { + if (!dmi_check_system(i8k_dmi_table)) { if (!ignore_dmi && !force) return -ENODEV; @@ -986,6 +997,9 @@ static int __init i8k_probe(void) i8k_get_dmi_data(DMI_BIOS_VERSION)); } + if (dmi_check_system(i8k_blacklist_fan_type_dmi_table)) + disallow_fan_type_call = true; + strlcpy(bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), sizeof(bios_version)); strlcpy(bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL),