From patchwork Sat Nov 4 15:55:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35DCDC4708E for ; Sat, 4 Nov 2023 15:56:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232225AbjKDP4p (ORCPT ); Sat, 4 Nov 2023 11:56:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232101AbjKDP4l (ORCPT ); Sat, 4 Nov 2023 11:56:41 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E308D45; Sat, 4 Nov 2023 08:56:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113373; x=1699718173; i=w_armin@gmx.de; bh=IzbgwTlVYWXpH84K69U34Vi9QBqWC1rRdQikBmtjfWI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=RQCLeT0mIJj95hMKQo9y6AcYApsAwSl26bZTcAa0Kr8Wk5xBvgBg6Kjjw/c4biMm JneVC1GSTszGPSbFs8WlZuZmywNYEB9wfagCCQYmhxczseM99I19AoEssh2vFTvgA +OaLydVkbi8pglt0Wm7J8cVM0NTWjcw9Xy9JBJHwIYCbfaiPJnmfInjSncRSNLyGi 3H4J36vTPlTdFrLa4BLQZJILa+7DAjk+OLDo18jNgQPWCX5aIqCSLShve033ESU/c YlCAHR4CisxDrlbWK3WvXwRK4ye6vf9yIiTx7avHPVNBFdjbWibrd/sjzLu4a9hbS +jsCVUFd37q4OMW+3g== 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 1MFsUv-1rDJEg2Y3D-00HRbW; Sat, 04 Nov 2023 16:56:13 +0100 From: Armin Wolf To: pali@kernel.org Cc: hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, jdelvare@suse.com, linux@roeck-us.net, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 5/9] hwmon: (dell-smm) Move config entries out of i8k_dmi_table Date: Sat, 4 Nov 2023 16:55:55 +0100 Message-Id: <20231104155559.11842-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231104155559.11842-1-W_Armin@gmx.de> References: <20231104155559.11842-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:amrR2pWXKaPGJ6mi0euoHpy5+vKeGrVy9flIlAiglOq8YABd9cY LpR3PwROd4+HUF74PRponuHXouoGHHZ6rJoy7jtISRenPojwOIAj7x212VQPa1E3iyIZeDo Iy3GMSYgIRZuveduD7LV48Cfiep0VCITDY+LXsnpnRa9oX+a9U9RS2lRh2MBTMysl5Up7j2 mig9n5pBnAQxH0+/6Ng/g== UI-OutboundReport: notjunk:1;M01:P0:R7SWzam2xMA=;WdxeEWnWwTqmit3rCCelgHsDHrY ONtB9m7cjE4uzI2sdhKPqpdmcDRZZX2HJxS1kSz9JF7BkMyHyuRGCRFHZfvY40ZX/kfO+5Z/i G3NQZwN9HvlxgdG58KP0wdMQTUljjbKPCdGimX7A+QDj0ggq9lfmW2J+CJ64ON7po1QJlOJRR I9Oz3pPMQGdC23OUouxRX9NgHUCf6F+F9binAoAS1TxP9M9wgSMINuCO3DNmRunlogQuqyQWh ynWu/xmf20q0qBcgD7irhi9mnnXDTAAB0WzaAyJgwkm0JCtlzwWUI3U3lW9ZSceJWoSGg+4HY D9Q0udtnCqyMlc44GJvA55oOeURC50Mvsl7v9aOKeuoxbLEq31Py/cD4QP6rW2y7gCjk9xTj8 We4QucMrBasn+UCajnH9KKmFsH/LL/12of4EM3mjzwZhGDd6sZo84/C8Eoe3ai44aJfGQeGs2 JcLcWONKAyAS+t02EU4Y4a93wM+ZZsWXHAIOUQKlwDXTAMcxBwb361HePfeVUshOdyJw0+PAn 5CjJeGUvxmQttsBp0c3uDTsLkYRs/gELOK6gmHnZ9YFkdtkfbBNWyff5r7F6zMLdu/IpAUemR i1rRQRBtvOZdD/JvYQq+NYuoe7fVhmk2Syojl5ylypkiapggg0cndO4vGiwWHlnIdctb8Us4m 3Rm1T7lO3zv7+McJFeSTYmOJ49bw1QHkSkACTG/70gU1eeNIWTC4oWfUSIgse9sh6XxSs5swX rZvE4wA94891EnsLXUKjgxdiuvgoCzY86zHBYgjXAXrdrTEDqoeGZV5I9eI2vXL27ojOncZ6D WLbIHpfZ6ZSD1VILlH12sm883GMGgqdqQZ+PlnOztjM9gJMRGG4fnNcjm5OkbTnZYlf+eDTfr DyozPjckgqf/X52TQZ/NWhKz68tIUWwlbLyRO07WxQrRiqPgU6zoIpd/sL63tBguFpnmg3+mH YG6NDi34b1D1fRHUAnD7wGtIV1A= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Currently, i8k_dmi_table contains both entries used for DMI matching and entries used to override config options. This does not allow for differentiating between "its safe to issue raw SMM calls on this machine" and "its not safe to issue raw SMM calls on this machine, but here are some config values". Since future SMM backends will need to differentiate between those two cases, move those config entries into a separate table. i8k_dmi_table now serves as a general "its safe to issue raw SMM calls" table. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 129 +++++++++++++++++++-------------- 1 file changed, 73 insertions(+), 56 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 3d14a3baf8e4..4a2c0d1ffa5b 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -1078,42 +1078,6 @@ static int __init dell_smm_init_hwmon(struct device *dev) return PTR_ERR_OR_ZERO(dell_smm_hwmon_dev); } -struct i8k_config_data { - uint fan_mult; - uint fan_max; -}; - -enum i8k_configs { - DELL_LATITUDE_D520, - DELL_PRECISION_490, - DELL_STUDIO, - DELL_XPS, -}; - -/* - * Only use for machines which need some special configuration - * in order to work correctly (e.g. if autoconfig fails on this machines). - */ - -static const struct i8k_config_data i8k_config_data[] __initconst = { - [DELL_LATITUDE_D520] = { - .fan_mult = 1, - .fan_max = I8K_FAN_TURBO, - }, - [DELL_PRECISION_490] = { - .fan_mult = 1, - .fan_max = I8K_FAN_TURBO, - }, - [DELL_STUDIO] = { - .fan_mult = 1, - .fan_max = I8K_FAN_HIGH, - }, - [DELL_XPS] = { - .fan_mult = 1, - .fan_max = I8K_FAN_HIGH, - }, -}; - static const struct dmi_system_id i8k_dmi_table[] __initconst = { { .ident = "Dell G5 5590", @@ -1143,14 +1107,6 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron"), }, }, - { - .ident = "Dell Latitude D520", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D520"), - }, - .driver_data = (void *)&i8k_config_data[DELL_LATITUDE_D520], - }, { .ident = "Dell Latitude 2", .matches = { @@ -1172,15 +1128,6 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "MP061"), }, }, - { - .ident = "Dell Precision 490", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, - "Precision WorkStation 490"), - }, - .driver_data = (void *)&i8k_config_data[DELL_PRECISION_490], - }, { .ident = "Dell Precision", .matches = { @@ -1201,7 +1148,6 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "Studio"), }, - .driver_data = (void *)&i8k_config_data[DELL_STUDIO], }, { .ident = "Dell XPS M140", @@ -1209,7 +1155,6 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), DMI_MATCH(DMI_PRODUCT_NAME, "MXC051"), }, - .driver_data = (void *)&i8k_config_data[DELL_XPS], }, { .ident = "Dell XPS", @@ -1223,6 +1168,78 @@ static const struct dmi_system_id i8k_dmi_table[] __initconst = { MODULE_DEVICE_TABLE(dmi, i8k_dmi_table); +/* + * Only use for machines which need some special configuration + * in order to work correctly (e.g. if autoconfig fails on this machines). + */ +struct i8k_config_data { + uint fan_mult; + uint fan_max; +}; + +enum i8k_configs { + DELL_LATITUDE_D520, + DELL_PRECISION_490, + DELL_STUDIO, + DELL_XPS, +}; + +static const struct i8k_config_data i8k_config_data[] __initconst = { + [DELL_LATITUDE_D520] = { + .fan_mult = 1, + .fan_max = I8K_FAN_TURBO, + }, + [DELL_PRECISION_490] = { + .fan_mult = 1, + .fan_max = I8K_FAN_TURBO, + }, + [DELL_STUDIO] = { + .fan_mult = 1, + .fan_max = I8K_FAN_HIGH, + }, + [DELL_XPS] = { + .fan_mult = 1, + .fan_max = I8K_FAN_HIGH, + }, +}; + +static const struct dmi_system_id i8k_config_dmi_table[] __initconst = { + { + .ident = "Dell Latitude D520", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Latitude D520"), + }, + .driver_data = (void *)&i8k_config_data[DELL_LATITUDE_D520], + }, + { + .ident = "Dell Precision 490", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, + "Precision WorkStation 490"), + }, + .driver_data = (void *)&i8k_config_data[DELL_PRECISION_490], + }, + { + .ident = "Dell Studio", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "Studio"), + }, + .driver_data = (void *)&i8k_config_data[DELL_STUDIO], + }, + { + .ident = "Dell XPS M140", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_MATCH(DMI_PRODUCT_NAME, "MXC051"), + }, + .driver_data = (void *)&i8k_config_data[DELL_XPS], + }, + { } +}; + /* * 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 @@ -1438,7 +1455,7 @@ static void __init dell_smm_init_dmi(void) * Set fan multiplier and maximal fan speed from DMI config. * Values specified in module parameters override values from DMI. */ - id = dmi_first_match(i8k_dmi_table); + id = dmi_first_match(i8k_config_dmi_table); if (id && id->driver_data) { config = id->driver_data; if (!fan_mult && config->fan_mult)