Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp25797rdh; Wed, 22 Nov 2023 16:49:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8VSNwWhHqCoFhx4p5Uf9zsB0D0G/Xsj588p0iRGZ2yXBOvT6SNUjws0eqJRShGxb99um9 X-Received: by 2002:a05:6808:110:b0:3b6:b073:20d7 with SMTP id b16-20020a056808011000b003b6b07320d7mr4193860oie.17.1700700576317; Wed, 22 Nov 2023 16:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700576; cv=none; d=google.com; s=arc-20160816; b=qmIEmGoTdEw9tI55NIYQiiTGVKQQcFngLmZ0Hy3zW9WBUq3UfeZD2zKM2mMn0rHpyL 2URB+GXusx+BEDpvQZT9k5Ql278U+mk+ctICOsCAybqRPYCXJP8+X5DEgBPNkf1vSUKO qM3SNKf41uY6oegSYOteCrcHKu2RjrxVpo4roO4MhJ0dPPJVnsU2Ck6Y3t560Gsn7v/Y wyTIrMkRBAtlF4ONVSvcyMxmsqCPk0GBc6ZdMO/9nqr2s4SXlk3SBp+fMKiKI3I+mnC4 NAa53TtjLNH1ASKYDjIRzelHDVVMHX0N3UcSSSj3WnXmoSVFRw+jEAzTViGq/HSJZ38R jngw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gkwepnos2efa5UuDgqgf/2gY08Z1AaSDPSIHSIX6g08=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=pp1YWhWML5a0HPMYYHgzmKV+Yy6PC9CBRNx3aXMMtqsmvNUKzgLsmlLn8689lVHCu6 6X8yhTeeFsKZXUhIP2PMOyF/SyZoHpbCYc3brSnX9gbrFBEgiFFnBbboKi7YckZd52ON tfD7nPamb6zdNcqo4GnDywjqf7HJUSLa8pp97RsGT6M6xzzjd7/mNchkze4p3AXxfLy5 I7zic/BsKBn+O1u4iaMw6/lHNTrpGhA94E/FtmvhlsILJK4p2u3eR6K/dEwCqExbeCng 4sdOuiheIBJ7B8E8VcsfenXyPS9DaYYT8NMcciBVUbRBD4/ChN4Xk8q2Dhgeovv0eJ65 kXLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BTUdNJ0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id 33-20020a630a21000000b005bf77518dc6si219366pgk.286.2023.11.22.16.49.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:49:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BTUdNJ0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B0319829BC66; Wed, 22 Nov 2023 16:49:25 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232615AbjKWAtT (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjKWAtJ (ORCPT ); Wed, 22 Nov 2023 19:49:09 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2841B6; Wed, 22 Nov 2023 16:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700521; x=1701305321; i=w_armin@gmx.de; bh=V0YTO8SuhbXFllpMUpGLmImayJAGwiYZye/V9QjFzzU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=BTUdNJ0libzzPYhGTGfyiPHCmP13YSDytd77NrQDdazgGSvV8dum3u9GHlCAxEAi AwWKCSQjiwlMEGDSTnq/9ABTstng3jePMAxIC+owDRkON4C5vhEa7qbAsVGzqiiuw j2caZDqKu7+pZumE2d9HhscMryujg7GZscxOv950U3pn3U62DCT17XbFYQWmkJgmz NPPD/bpxtUCkqJL5flv94aiBtuB64G4GCCeKqZV/508Ff3LYYj2oGl71sOZ9/D88I pqZyPkRgM6NMVifMu/ZzIcL5q4tIptQicmhAFq/nsVUbFHtfVFR/G3U9fSYk7pM0M p+4qhji6nwODZwLtxg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M26rD-1r43161wPR-002YQT; Thu, 23 Nov 2023 01:48:41 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/9] hwmon: (dell-smm) Move whitelist handling to module init Date: Thu, 23 Nov 2023 01:48:14 +0100 Message-Id: <20231123004820.50635-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:sLZEVJEQ6YFGZknxrKfmcCR3R5oC/Vc18dLepzqElrW6tyI+9ns 6CoEKi1sItTiElnJddM9X3sZod+NwulAcAI2pMGcDeU/dnN17T2DSPjWB2Kl7xLr5Uxlx5f 7mFv72IPYkWe3LjaK35hwwmDzkWN8KBplTZLC9leOc+APSr4MacrF4meHrSYJc5DdjJx8B+ 8lE5EV7d37BoYkWA6YuoQ== UI-OutboundReport: notjunk:1;M01:P0:aD226kWhsiE=;dizW7S46DR9LjAKbC0E6GAHaNw0 IdZ2Rf0Qw6fn0LZL7kTyBz6FttjBc1Vb+4S8s8m2ZFc2vlABF76Zqb9a9SglVKFbaD6tP5F1U cjf4LDzq0pWeMMLHfFgaHNy8RNYMUqVO9t/woI0EUCH88LiqTsA3UZWbsyEgbP6mR9bYIZY2l VU1QqnHpLgmhNYnfp+hy6YdZx1cnGclCP3cJgz97rUXsKLogsHAJx3qZkvoMaRMXw98f8gpA7 hp5IPP2/YKPjRRL0OJp7QyZUr/KYJgjeXZd9GH3U+NqXEA5hlhwsvme/YNoWZhTgDCSBNXEFm EUpQxoYTxvipypauKG5ikHU16FqXbSHSiJwe3w6mXA8Vhtf8u8yt1+3SCE8ZyDnQGU52SMQ2G 9Ib/G3ha9U+tXao4aGUjijiFgD83lGCaA5X8rS0MsbmzEAKW+n2h+okIYary50kg4oVBfvUCj 1lPRCUSUUhWoxdwJgjQrvHfSrwFyYwWwvcFbPhkF/7UvEbfcIh1XkPF9YG89rmW4Xo1dUCtBo DY4WoAHNj2HySv8WeoTfj0t0fRy6nb9OXQNw51bEehjGbXkuuImHmpP1CME5ldkSL2y/kU+5j a7fI+NEgHSgEdtKYXkSLzMn5R2rnoFgGxIibpVqP7I+FNdJl5+/y4wYy3paRTH9sWpeaVEdF1 wx/UZszwWMzJGMncr7IcxnW5Y7y8Ma2yNnmy5pbupUPuAjmO6ffg97f1zh0yvghQu+49KafQy qAVlJhP/0HP5s7Kq61shy+BSp6+aWI+QANPK1jG2jqnycnIXjB3LhYVmaZt97/RUWP7KwsO2w 8XuUDYp+DVUWhjrTZFxVh+8ZYp2B79Tt6f6emCuEH/BOr4zHMwh/kg75y54/uvhnhpC9F+EeW gtQ4rGhqJP32o5UT+XCy7mxv2nIclO1sMTtiCtJj2xc5E/OoPSr1RvDUFzsjE6/9aclA7myQ5 Lb+2YRRXUSXX4BmIUwHJ2uWwaEw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:25 -0800 (PST) Future SMM calling backends will not be able to probe during module init, meaning the DMI tables used for whitelisting features would have to drop their __initconst attribute. Prevent this by moving the whitelist handling to module init. Tested-by: Reviewed-by: Hans de Goede Signed-off-by: Armin Wolf =2D-- drivers/hwmon/dell-smm-hwmon.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon= .c index 87d668799c9f..1cbdfd77773e 100644 =2D-- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -90,8 +90,6 @@ struct dell_smm_data { uint i8k_fan_mult; uint i8k_pwm_mult; uint i8k_fan_max; - unsigned int manual_fan; - unsigned int auto_fan; int temp_type[DELL_SMM_NO_TEMP]; bool fan[DELL_SMM_NO_FANS]; int fan_type[DELL_SMM_NO_FANS]; @@ -138,6 +136,8 @@ MODULE_PARM_DESC(fan_max, "Maximum configurable fan sp= eed (default: autodetect)" static bool disallow_fan_type_call, disallow_fan_support; +static unsigned int manual_fan, auto_fan; + static const char * const temp_labels[] =3D { "CPU", "GPU", @@ -329,7 +329,7 @@ static int i8k_enable_fan_auto_mode(const struct dell_= smm_data *data, bool enabl if (disallow_fan_support) return -EINVAL; - regs.eax =3D enable ? data->auto_fan : data->manual_fan; + regs.eax =3D enable ? auto_fan : manual_fan; return dell_smm_call(data->ops, ®s); } @@ -741,7 +741,7 @@ static umode_t dell_smm_is_visible(const void *drvdata= , enum hwmon_sensor_types break; case hwmon_pwm_enable: - if (data->auto_fan) + if (auto_fan) /* * There is no command for retrieve the current status * from BIOS, and userspace/firmware itself can change @@ -1370,7 +1370,7 @@ static const struct dmi_system_id i8k_whitelist_fan_= control[] __initconst =3D { static int __init dell_smm_probe(struct platform_device *pdev) { struct dell_smm_data *data; - const struct dmi_system_id *id, *fan_control; + const struct dmi_system_id *id; int ret; data =3D devm_kzalloc(&pdev->dev, sizeof(struct dell_smm_data), GFP_KERN= EL); @@ -1406,15 +1406,6 @@ static int __init dell_smm_probe(struct platform_de= vice *pdev) data->i8k_fan_max =3D fan_max ? : I8K_FAN_HIGH; 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_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"); - } - ret =3D dell_smm_init_hwmon(&pdev->dev); if (ret) return ret; @@ -1437,6 +1428,9 @@ static struct platform_device *dell_smm_device; */ static void __init dell_smm_init_dmi(void) { + struct i8k_fan_control_data *control; + const struct dmi_system_id *id; + if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { if (!force) { pr_notice("Disabling fan support due to BIOS bugs\n"); @@ -1454,6 +1448,15 @@ static void __init dell_smm_init_dmi(void) pr_warn("Enabling fan type call despite BIOS bugs\n"); } } + + id =3D dmi_first_match(i8k_whitelist_fan_control); + if (id && id->driver_data) { + control =3D id->driver_data; + manual_fan =3D control->manual_fan; + auto_fan =3D control->auto_fan; + + pr_info("Enabling support for setting automatic/manual fan control\n"); + } } static int __init i8k_init(void) =2D- 2.39.2