From patchwork Sat May 21 14:46:41 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: 9130581 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 E0F7960762 for ; Sat, 21 May 2016 14:47:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9E2027D00 for ; Sat, 21 May 2016 14:47:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE6A428135; Sat, 21 May 2016 14:47:39 +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 4B4AD27D00 for ; Sat, 21 May 2016 14:47:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751261AbcEUOri (ORCPT ); Sat, 21 May 2016 10:47:38 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:34887 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751209AbcEUOrh (ORCPT ); Sat, 21 May 2016 10:47:37 -0400 Received: by mail-wm0-f68.google.com with SMTP id s63so3874553wme.2; Sat, 21 May 2016 07:47:36 -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:mime-version :content-transfer-encoding; bh=GpDuTgR6Y3cEDpRDnBTgpp0kZpGJ9lQjlofd0uKK4+E=; b=GyFnUkg2hzAukw6haPopAUw2dOB+Ch2q70oSZQKVLe8yTaB38t84ZfLKTXulAPgwHR nLoh+5AhzzzJYSOXD3eWWIQHFyPED6YzEulsIfYDAgZS7CDPTycY10+5PJK/Zy58zWu0 CG3Vebhbv54n+U3NH2nAykyXzCs8nnxXZqi7n5lLEWvSAENicLcZReRJDKI7XRHEhEtJ Z2gMaQS7tWQqmVcQuHVyJh7u+D0HX9w1qNFvH3kX4oLArOLjccxdbgoQdq4OIYn+6j0t dKHjB0XZCecOU1il4w/zQMtQowz/6WZYDW+LvWtzvyLuiEdtCkPwF1buY0DBySY6/10m w6BA== 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:mime-version :content-transfer-encoding; bh=GpDuTgR6Y3cEDpRDnBTgpp0kZpGJ9lQjlofd0uKK4+E=; b=Ta8mWyQeo1gQhrKDPl+u4RMGQnRkkw+M7baxa1X4m4U0VkVynk76Q8/mAe3bfTZwQ/ dAR4XTTpnoXaA7OXU4bJPJWS/Xb2XZ4cARTwceqGNDg+71MLyyIvJQzDDoa9Fk+Bs9qL Kwx+Qxp2XZ5jBHKu4hjxBETf++JnkxPNqUBagdiDdtOinh65BcfPEAigVHzSHQRykMMR +PCaiUwzNwAWFx+544znI6+IoqvWs1mStdxQcSB48vrHKJpiZbNZIMCCr0R85btAwXQd 0Ftaw6zAdRcv6UIBEQ8ujPzbZ4Vu6m+X11gp5Be6nQhH3KLEcZ0QoHXZyf42JwM00MFc tWAg== X-Gm-Message-State: AOPr4FX2GCsermk4nDYvMI0uoym2W9RK8NomcJ5MBUBioD8zHFcBm0HDSpeLYx7aYotHWw== X-Received: by 10.28.136.84 with SMTP id k81mr9205430wmd.27.1463842055625; Sat, 21 May 2016 07:47:35 -0700 (PDT) Received: from Pali-Latitude.lan (pali.kolej.mff.cuni.cz. [78.128.193.202]) by smtp.gmail.com with ESMTPSA id y1sm25280997wjy.36.2016.05.21.07.47.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 21 May 2016 07:47:34 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Jan C Peters , Thorsten Leemhuis , =?UTF-8?q?David=20Santamar=C3=ADa=20Rogado?= , Peter Saunderson , Jean Delvare , Guenter Roeck , Tolga Cakir Cc: linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH] dell-smm-hwmon: Cache fan_type() calls and use fan_status() for fan detection Date: Sat, 21 May 2016 16:46:41 +0200 Message-Id: <1463842001-17785-1-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 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 On more Dell machines (e.g. Dell Precision M3800) I8K_SMM_GET_FAN_TYPE call is too expensive (CPU is too long in SMM mode) and cause kernel to hang. This patch cache type for each fan (as it should not change) and change the way how fan presense is detected. It revert and use function fan_status() as was before commit f989e55452c7 ("i8k: Add support for fan labels"). Moreover, kernel hangs for 2 - 3 seconds only sometimes and only on some Dell machines. When kernel hangs fan speed is at max. So it was hard to debug and bisect where is root of this problem. It looks like this is bug in Dell BIOS which implement fan type SMM code... and there is no way how to fix it in kernel. Signed-off-by: Pali Rohár Reviewed-by: Jean Delvare Reported-and-tested-by: Tolga Cakir Fixes: f989e55452c7 ("i8k: Add support for fan labels") Link: https://bugzilla.kernel.org/show_bug.cgi?id=112021 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 | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) --- Hi! Jan C Peters, Thorsten Leemhuis, David Santamaría Rogado, Peter Saunderson and others, can you test this patch if it fixes your freeze problem at boottime and when using "sensors" program? I need to know if this patch fixes problem on Dell Studio XPS 8000 and Dell Studio XPS 8100 machines, so we can revert git commits: 6220f4ebd7b4 ("hwmon: (dell-smm) Blacklist Dell Studio XPS 8000") a4b45b25f18d ("hwmon: (dell-smm) Blacklist Dell Studio XPS 8100") diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index c43318d..577445f 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -235,7 +235,7 @@ static int i8k_get_fan_speed(int fan) /* * Read the fan type. */ -static int i8k_get_fan_type(int fan) +static int _i8k_get_fan_type(int fan) { struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; @@ -243,6 +243,17 @@ static int i8k_get_fan_type(int fan) return i8k_smm(®s) ? : regs.eax & 0xff; } +static int i8k_get_fan_type(int fan) +{ + /* I8K_SMM_GET_FAN_TYPE SMM call is expensive, so cache values */ + static int types[2] = { INT_MIN, INT_MIN }; + + if (types[fan] == INT_MIN) + types[fan] = _i8k_get_fan_type(fan); + + return types[fan]; +} + /* * Read the fan nominal rpm for specific fan speed. */ @@ -767,13 +778,13 @@ static int __init i8k_init_hwmon(void) if (err >= 0) i8k_hwmon_flags |= I8K_HWMON_HAVE_TEMP4; - /* First fan attributes, if fan type is OK */ - err = i8k_get_fan_type(0); + /* First fan attributes, if fan status is OK */ + err = i8k_get_fan_status(0); if (err >= 0) i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN1; - /* Second fan attributes, if fan type is OK */ - err = i8k_get_fan_type(1); + /* Second fan attributes, if fan status is OK */ + err = i8k_get_fan_status(1); if (err >= 0) i8k_hwmon_flags |= I8K_HWMON_HAVE_FAN2;