From patchwork Mon May 30 11:45:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thorsten Leemhuis X-Patchwork-Id: 9141001 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 F2D5F60759 for ; Mon, 30 May 2016 11:46:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCA8427C23 for ; Mon, 30 May 2016 11:46:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C16EF281C2; Mon, 30 May 2016 11:46:14 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI 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 6CF8F27C23 for ; Mon, 30 May 2016 11:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161401AbcE3Lp4 (ORCPT ); Mon, 30 May 2016 07:45:56 -0400 Received: from basicbox7.server-home.net ([195.137.212.29]:47426 "EHLO basicbox7.server-home.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161119AbcE3Lpz (ORCPT ); Mon, 30 May 2016 07:45:55 -0400 Received: from thl.ct.heise.de (gatekeeper.heise.de [193.99.145.162]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by basicbox7.server-home.net (Postfix) with ESMTPSA id 02DB05EE7C2; Mon, 30 May 2016 13:45:51 +0200 (CEST) Subject: Re: [PATCH] dell-smm-hwmon: Cache fan_type() calls and use fan_status() for fan detection To: =?UTF-8?Q?Pali_Roh=c3=a1r?= References: <1463842001-17785-1-git-send-email-pali.rohar@gmail.com> <201605271245.47383@pali> <01084692-618a-31db-76f8-60176d1cd2cc@leemhuis.info> <201605271521.10294@pali> Cc: Jan C Peters , =?UTF-8?Q?David_Santamar=c3=ada_Rogado?= , Peter Saunderson , Jean Delvare , Guenter Roeck , Tolga Cakir , linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org From: Thorsten Leemhuis Message-ID: Date: Mon, 30 May 2016 13:45:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0 MIME-Version: 1.0 In-Reply-To: <201605271521.10294@pali> 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 Pali Rohár wrote on 27.05.2016 15:21: > On Friday 27 May 2016 15:05:54 Thorsten Leemhuis wrote: >> Pali Rohár wrote on 27.05.2016 12:45: >> So I tried a few things >> and came to the conclusion: the problem shows up as soon as >> i8k_get_fan_type() (introduced in f989e55452) is called somewhere. > So, once kernel call i8k_get_fan_type() function, then fan speed going > up/down? Yes. > To make sure that this is root of your problem, can you take some older > kernel version (where is i8k working fine) and try to patch+call that > i8k_get_fan_type() function? To check that something else cannot > interference with it... I just tried with 3.19.8 (had to install a older distro first :-/ ), where the problem does not show up (I verified just to be sure). Then I applied below patch and voila: the fan speed starts going up/down. IOW: From what I can see that SMM call that i8k_get_fan_type() triggers the problem on my Studio 8000 CU, knurd --- To unsubscribe from this list: send the line "unsubscribe linux-hwmon" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- i8k.c-unmodified 2016-05-30 13:04:32.980825405 +0200 +++ i8k.c 2016-05-30 13:25:03.186630115 +0200 @@ -41,6 +41,7 @@ #define I8K_SMM_SET_FAN 0x01a3 #define I8K_SMM_GET_FAN 0x00a3 #define I8K_SMM_GET_SPEED 0x02a3 +#define I8K_SMM_GET_FAN_TYPE 0x03a3 #define I8K_SMM_GET_TEMP 0x10a3 #define I8K_SMM_GET_DELL_SIG1 0xfea3 #define I8K_SMM_GET_DELL_SIG2 0xffa3 @@ -275,6 +276,19 @@ return i8k_smm(®s) ? : (regs.eax & 0xffff) * i8k_fan_mult; } + +/* + * Read the fan type. + */ +static int i8k_get_fan_type(int fan) +{ + struct smm_regs regs = { .eax = I8K_SMM_GET_FAN_TYPE, }; + + regs.ebx = fan & 0xff; + return i8k_smm(®s) ? : regs.eax & 0xff; +} + + /* * Set the fan speed (off, low, high). Returns the new fan status. */ @@ -870,6 +884,9 @@ if (err) goto exit_remove_proc; + // calling i8k_get_fan_type once + printk("testing i8k_get_fan_type (%d)", i8k_get_fan_type(0)); + return 0; exit_remove_proc: