Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp584766pxb; Tue, 15 Feb 2022 22:55:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxGdMu+Ov4Y2y0hJm+4r/0Y1FQwRpJzzD7QBnEZ2+e6tOEGsNL8w+QHKCQKDVxqUFAS8Y1B X-Received: by 2002:a63:6c3:0:b0:347:6699:4983 with SMTP id 186-20020a6306c3000000b0034766994983mr1145886pgg.416.1644994526416; Tue, 15 Feb 2022 22:55:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644994526; cv=none; d=google.com; s=arc-20160816; b=aBgDYsud5Rpz5s1C8jOsRQ8zqoSnDEAaQ95a/p0y8i8MNMetSruFxabrJFEtodvVVa gq8Vkh7dn3vPZLYOZGWxKv8faWNHR0le17+ol+cwihXyvNta/EfPdgObvJlD7LuXrB1J 1Ef//56/N3wTbbEKPhX5jEhJQtmjitEczIXsd+M7v0NzTJtUW2cC2ZZ1zKpWTN5B9ZeZ FITq6FEisVx7jUwTOyNsft4Z9ljVVNaF01PQs84FDFq3MicNnd5J0WZLLP44+BA6qYZm G8wUDfqUI8d/2heUXdYXyeIK/2StI2w2Jjmp5Uv2GyHZZY9Re4aHn95Myqx1s8ILtxid lcsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=xLTLc3eRUzZNYM90w/0tyYsa1RV8sdCsgmnldCk/iNo=; b=Fuz7erf77aF7oF2l/6ocN2oMu08zMNWhjxEn5+LmVMLIg4Efr5BqiM2N9ygM5SgwPL X1Z5nkNc+fGY5bpyXaNYc/YIY+wZf+QePwwDAL2XiA38oNX9XpxIytAcowlRRDBS7cy5 dsQDbi3FjkeN0T0zsJJjaiRqNtTcYYo4096EAO/ekwINMXbKZEwXcZsV6W2naVJG9Ynk hIGrRULJdJv19WFcDH86p9aNeaR28wedkLHUWyYIfweO5I8G7b6JrWRponsTWnG/yTe8 gVh6OkL3ME9pW+/NKiR4RtV1J66KjnC6bil12ey55Urc8Fy3imwbUPoqmIpP2rS5LiiT 830A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=OWKRGKqW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q17si15637360pln.295.2022.02.15.22.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 22:55:26 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=OWKRGKqW; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C29E217F134; Tue, 15 Feb 2022 22:37:49 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243845AbiBOTqF (ORCPT + 99 others); Tue, 15 Feb 2022 14:46:05 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243856AbiBOTqE (ORCPT ); Tue, 15 Feb 2022 14:46:04 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93FFD46676; Tue, 15 Feb 2022 11:45:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1644954335; bh=t7E1wBwBZ1L0pSaVu8ORZHH6TzOpG2QxjJQD1qRfkjs=; h=X-UI-Sender-Class:Subject:To:Cc:References:From:Date:In-Reply-To; b=OWKRGKqWpH3T9Qh7ApvbdjoprRAvqdaX7lNb6d9gUYOA+4LwExR/eEr+6+cKB7Ryl xlJZApM/KDFmH+V9k2kLhQEWyTwhQoLyuwbi/wTrvFJmfeWm8B1/t9aRuqCMWyyfwI quFalf0+DT18sGEFS8Rd7XE6mEpe7dRxlxiuThLc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [141.30.226.129] ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MtfNl-1o8bBJ38aF-00v4j9; Tue, 15 Feb 2022 20:45:34 +0100 Subject: Re: [PATCH 1/7] hwmon: (dell-smm) Allow for specifying fan control method as module parameter To: =?UTF-8?Q?Pali_Roh=c3=a1r?= Cc: jdelvare@suse.com, linux@roeck-us.net, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220215191113.16640-1-W_Armin@gmx.de> <20220215191113.16640-2-W_Armin@gmx.de> <20220215191941.azk5gpcn42ahcnna@pali> From: Armin Wolf Message-ID: <8309c55b-110c-5123-f7bc-8a82bdbf5086@gmx.de> Date: Tue, 15 Feb 2022 20:45:33 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20220215191941.azk5gpcn42ahcnna@pali> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-Language: en-US X-Provags-ID: V03:K1:Zob9yYEJWaX3OKgk8E5VO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dPIb95KH2oGC/2iY5GWqIHI0w4s1iglyuY4VkpgO2YYGcgIYdFcVa3KUQlJ Fo44+2yVijx9yJ2w29n2gz5qGpiQwjurB9gv+QfaEU2FOxW+c98DFif1rMNVtP1y38UtJPFyK o9N7YukykQ864reuKUgkqZcUqR718wykayXTCCh4zpDeaar2LEAUNr14QaZ9lfrfs09Dhn/EE wsTBm+I+tbu7m7fDjHgx0VlfginTyEPxNWo6lI6SA56nCC3Q2fULXZS9++1pR1nYbbvdcF24g otU3hFMJOizG58= X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 15.02.22 um 20:19 schrieb Pali Roh=C3=A1r: > On Tuesday 15 February 2022 20:11:07 Armin Wolf wrote: >> Right now, the only way to test if setting manual/auto fan control work= s >> is to edit and recompile the module, which may be too cumbersome for >> the average user. > There is also another way suitable for testing purposes which do not > requires any kernel patch. Call iopl(3) syscall which changes I/O > privilege level to 3 and which allows to poke I/O registers. > This is not possible under kernel lockdown/Secure Boot. >> Allow for specifying the desired fan mode control method when loading >> the module, but taint the kernel if so since there is the possibility >> for strange side effects on non-whitelisted models. >> Also update docs and kernel-parameters.txt accordingly. >> >> Tested on a Dell Inspiron 3505. >> >> Signed-off-by: Armin Wolf >> --- >> .../admin-guide/kernel-parameters.txt | 3 +++ >> Documentation/hwmon/dell-smm-hwmon.rst | 21 ++++++++++------ >> drivers/hwmon/dell-smm-hwmon.c | 25 +++++++++++++-----= - >> 3 files changed, 35 insertions(+), 14 deletions(-) >> >> diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Document= ation/admin-guide/kernel-parameters.txt >> index d68053db21cc..4f1b6c2b7ed1 100644 >> --- a/Documentation/admin-guide/kernel-parameters.txt >> +++ b/Documentation/admin-guide/kernel-parameters.txt >> @@ -968,6 +968,9 @@ >> dell_smm_hwmon.fan_max=3D >> [HW] Maximum configurable fan speed. >> >> + dell_smm_hwmon.fan_mode_method=3D >> + [HW] Method to use for changing fan mode. >> + >> dfltcc=3D [HW,S390] >> Format: { on | off | def_only | inf_only | always } >> on: s390 zlib hardware support for compression on >> diff --git a/Documentation/hwmon/dell-smm-hwmon.rst b/Documentation/hwm= on/dell-smm-hwmon.rst >> index beec88491171..564d99cda869 100644 >> --- a/Documentation/hwmon/dell-smm-hwmon.rst >> +++ b/Documentation/hwmon/dell-smm-hwmon.rst >> @@ -67,13 +67,16 @@ for your hardware. It is possible that codes that w= ork for other >> laptops actually work for yours as well, or that you have to discover >> new codes. >> >> -Check the list ``i8k_whitelist_fan_control`` in file >> -``drivers/hwmon/dell-smm-hwmon.c`` in the kernel tree: as a first >> -attempt you can try to add your machine and use an already-known code >> -pair. If, after recompiling the kernel, you see that ``pwm1_enable`` >> -is present and works (i.e., you can manually control the fan speed), >> -then please submit your finding as a kernel patch, so that other users >> -can benefit from it. Please see >> +As a first step, you can load the module with the module parameter >> +``fan_mode_method`` set to 1 to test if your hardware works with >> +an already know method for disabling automatic BIOS fan control. >> +If ``pwm1_enable`` is now present and works (i.e., you can >> +manually control the fan speed), then please submit your finding >> +as a kernel patch, so that other users can benefit from it. >> +Just add your model to the list ``i8k_whitelist_fan_control`` in >> +file ``drivers/hwmon/dell-smm-hwmon.c`` in the kernel tree and use >> +the already known code pair. >> +Please read >> :ref:`Documentation/process/submitting-patches.rst ` >> for information on submitting patches. >> >> @@ -120,6 +123,10 @@ Module parameters >> Maximum configurable fan speed. (default: >> autodetect) >> >> +* fan_mode_method:uint >> + Method to use for changing fan mode (default: >> + from whitelist) >> + >> Legacy ``/proc`` interface >> -------------------------- >> >> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hw= mon.c >> index 9949eeb79378..1c4cc516c8b2 100644 >> --- a/drivers/hwmon/dell-smm-hwmon.c >> +++ b/drivers/hwmon/dell-smm-hwmon.c >> @@ -111,6 +111,10 @@ static uint fan_max; >> module_param(fan_max, uint, 0); >> MODULE_PARM_DESC(fan_max, "Maximum configurable fan speed (default: a= utodetect)"); >> >> +static uint fan_mode_method; >> +module_param_unsafe(fan_mode_method, uint, 0); >> +MODULE_PARM_DESC(fan_mode_method, "Method to use for changing fan mode= (default: from whitelist)"); > No, please really do not introduce another kernel parameter for this > driver. There are already many and we do not need to extend this list. > >> + >> struct smm_regs { >> unsigned int eax; >> unsigned int ebx; >> @@ -677,7 +681,7 @@ static umode_t dell_smm_is_visible(const void *drvd= ata, enum hwmon_sensor_types >> >> break; >> case hwmon_pwm_enable: >> - if (data->auto_fan) >> + if (data->auto_fan && data->manual_fan) >> /* >> * There is no command for retrieve the current status >> * from BIOS, and userspace/firmware itself can change >> @@ -1282,14 +1286,21 @@ static int __init dell_smm_probe(struct platfor= m_device *pdev) >> data->i8k_fan_max =3D fan_max ? : I8K_FAN_HIGH; /* Must not be 0 */ >> data->i8k_pwm_mult =3D DIV_ROUND_UP(255, data->i8k_fan_max); >> >> - fan_control =3D dmi_first_match(i8k_whitelist_fan_control); >> - if (fan_control && fan_control->driver_data) { >> - const struct i8k_fan_control_data *control =3D fan_control->driver_d= ata; >> + /* value specified via module param overrides whitelist */ >> + if (fan_mode_method > 0 && fan_mode_method <=3D ARRAY_SIZE(i8k_fan_co= ntrol_data)) { >> + data->manual_fan =3D i8k_fan_control_data[fan_mode_method - 1].manua= l_fan; >> + data->auto_fan =3D i8k_fan_control_data[fan_mode_method - 1].auto_fa= n; >> + } else { >> + fan_control =3D dmi_first_match(i8k_whitelist_fan_control); >> + if (fan_control && fan_control->driver_data) { >> + const struct i8k_fan_control_data *control =3D fan_control->driver_= data; >> >> - data->manual_fan =3D control->manual_fan; >> - data->auto_fan =3D control->auto_fan; >> - dev_info(&pdev->dev, "enabling support for setting automatic/manual = fan control\n"); >> + data->manual_fan =3D control->manual_fan; >> + data->auto_fan =3D control->auto_fan; >> + } >> } >> + if (data->manual_fan && data->auto_fan) >> + dev_info(&pdev->dev, "enabling support for setting automatic/manual = fan control\n"); >> >> if (!fan_mult) { >> /* >> -- >> 2.30.2 >>