From patchwork Sat Nov 4 15:55:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445555 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 F2F58C4332F for ; Sat, 4 Nov 2023 15:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbjKDP4i (ORCPT ); Sat, 4 Nov 2023 11:56:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjKDP4h (ORCPT ); Sat, 4 Nov 2023 11:56:37 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CAD8AD45; Sat, 4 Nov 2023 08:56:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113365; x=1699718165; i=w_armin@gmx.de; bh=Bj1Fql5njftd7cc6/C+EO3KOgcnvPmCItfr4JnJy2ys=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=QgQEdUBB6TrQUC7L31TQSFs1woitioLTA1RLKJwrur2tHd/5n1eZaveAUAljxfFz pkjGnzxT8ze1/x0dPWk4bRmWiaDRFxbPeDS9bnKQbZ9+1pJ1gHlZyBQs4r0goZzb3 LW90XtRDCgOlz9sq8NvlMut1JP9ipFsVpQK/EH258ivYoM62halxziuSXeJRDp4Xr S+0TUG7jqRX72hhxzGhWh8bxg+X8VCeQS1BA4l3ch8Zts6dGEBp/nrKR0ubxBVTRD LZ5DZnUEMeL/b8AzKIwCCzA7QFMLo5cYBUuMxes7MKA28nZ+mMvaew0d9m40PY3aH A20OtuXHkdSs+Mmz6g== 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 (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MrQIv-1rkS821rnD-00oWqr; Sat, 04 Nov 2023 16:56:05 +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 1/9] hwmon: (dell-smm) Prepare for multiple SMM calling backends Date: Sat, 4 Nov 2023 16:55:51 +0100 Message-Id: <20231104155559.11842-2-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:sQvsfdTTJsnPhwsYLfPZrEFYHwG6BOwzUbXyTVCfBO15E39WLe0 RU6EaT+OYMFGmXNtgP/HfIrGDmQE0q7bvm2fbeGWU3GGTA8JYrOJcYQ9IkXkCdhTESuIkaJ zAlhAfc+4FKTHrmP/SDC2anXeuW3X47q+iTX5JJ/UWfVyFVbBsIBEtxQkLKyZXw978eOwyQ ldey+h6zAILnQZZXyHH7g== UI-OutboundReport: notjunk:1;M01:P0:FrzbgbHcff0=;ptbLG4kz/KGcJ97nIjsdPp0BDlx Qau8QSkwqiH4u5wkqsx9srybPyUW8Hp9aMYpKQKJZiueZmGTHz37PCCnRCBwBUtr36LYcM/Lm J38Z2ARZrcA+9A3zzbaFcC6FzcjuqJEz+WEt24yRDYNyRZLSY8jbdSSN5Nm3nXfHGztEJqJw7 xcJrA8/qUr7BeIeypEXTbHhi2fPoPdphiZ9/yX1AlRg8TbhotsWLNNvmjKROkCyeQtPc6O62T Ip5Q9PYh1yetZr3eSlN4ja5hB6sNt5deyLU4BLORQhfAXH375pc/97AO96WEMit/NBf6nB3yT QX19jGdtvEgBX3PV+QrU/FDHRl3Vc0Dvx4QlMBnQJKCblC7WCHI8DPqrlS0fwHcIiFQMbUjA5 li0GJzTaE/+pAbSH31j7owh0EMOJioEV5rzT3Zolh7o6TW1OjFMX7iK97Ezu4tAD1zdFCfCmf AOMnWUMZDvihzoRIqAXROHmfpcsJYjtGvnd+Ds5S/afNC40vMr1XXm54cwQjpIyXff/UDXRvt G0lNX8++Of40fr5f1NLYG9K3t38Qow8n8UkFcCbwimTGLXHJg6iS2H0O7g6mlHzUwCNfdLqy5 EK5Ads41arX3D2YqxHB7pZjez2lpTAKSGva9FvJrZPDEJ+oAKHiuP7n6eVTwURmuVCtCuenlH uyDYcPNjFZ22ADm4HKQEt5wcD26xmipZJmbafIlxr8oR5r+LRt/G3qxuXVMvUTYqNLA7lgKBw CeEv+2HvYRPX1W5sIQ7NnVqKFCWwggSSAuch3oJV5EjDCMlG/e5VKyfgstRIsmnUvQvSCr4/C qyOcwc9D9si0xjxFUxScKBA3q4GknkWJwIjS1Wujm2UQfwZ3FB5vXwmoCDUVmX6+5YyVmucDS qZPa2fvSQmMVsbXLwOzZSBEmd5kz7TFWf/3oCWKg73oSTXoMpy3XjhFpac3qDS7lX/UypgRD9 OZimaMi/OS4alyzFBqoVjvLAA84= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Modern Dell machines support multiple ways to issue an SMM call. Prepare support for those by introducing dell_smm_ops, which is used by dell_smm_call() to perform a SMM call. Each SMM backend needs to provide a dell_smm_ops structure. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 131 ++++++++++++++++++++------------- 1 file changed, 79 insertions(+), 52 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 44aaf9b9191d..a3273780f7c3 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -69,6 +69,20 @@ #define DELL_SMM_NO_TEMP 10 #define DELL_SMM_NO_FANS 3 +struct smm_regs { + int eax; + int ebx; + int ecx; + int edx; + int esi; + int edi; +}; + +struct dell_smm_ops { + struct device *smm_dev; + int (*smm_call)(struct device *smm_dev, struct smm_regs *regs); +}; + struct dell_smm_data { struct mutex i8k_mutex; /* lock for sensors writes */ char bios_version[4]; @@ -84,6 +98,7 @@ struct dell_smm_data { bool fan[DELL_SMM_NO_FANS]; int fan_type[DELL_SMM_NO_FANS]; int *fan_nominal_speed[DELL_SMM_NO_FANS]; + const struct dell_smm_ops *ops; }; struct dell_smm_cooling_data { @@ -123,15 +138,6 @@ static uint fan_max; module_param(fan_max, uint, 0); MODULE_PARM_DESC(fan_max, "Maximum configurable fan speed (default: autodetect)"); -struct smm_regs { - unsigned int eax; - unsigned int ebx; - unsigned int ecx; - unsigned int edx; - unsigned int esi; - unsigned int edi; -}; - static const char * const temp_labels[] = { "CPU", "GPU", @@ -171,12 +177,8 @@ static inline const char __init *i8k_get_dmi_data(int field) */ static int i8k_smm_func(void *par) { - ktime_t calltime = ktime_get(); struct smm_regs *regs = par; - int eax = regs->eax; - int ebx = regs->ebx; unsigned char carry; - long long duration; /* SMM requires CPU 0 */ if (smp_processor_id() != 0) @@ -193,14 +195,7 @@ static int i8k_smm_func(void *par) "+S" (regs->esi), "+D" (regs->edi)); - duration = ktime_us_delta(ktime_get(), calltime); - pr_debug("smm(0x%.4x 0x%.4x) = 0x%.4x carry: %d (took %7lld usecs)\n", - eax, ebx, regs->eax & 0xffff, carry, duration); - - if (duration > DELL_SMM_MAX_DURATION) - pr_warn_once("SMM call took %lld usecs!\n", duration); - - if (carry || (regs->eax & 0xffff) == 0xffff || regs->eax == eax) + if (carry) return -EINVAL; return 0; @@ -209,7 +204,7 @@ static int i8k_smm_func(void *par) /* * Call the System Management Mode BIOS. */ -static int i8k_smm(struct smm_regs *regs) +static int i8k_smm_call(struct device *dummy, struct smm_regs *regs) { int ret; @@ -220,6 +215,37 @@ static int i8k_smm(struct smm_regs *regs) return ret; } +static const struct dell_smm_ops i8k_smm_ops = { + .smm_call = i8k_smm_call, +}; + +static int dell_smm_call(const struct dell_smm_ops *ops, struct smm_regs *regs) +{ + int eax = regs->eax; + int ebx = regs->ebx; + long long duration; + ktime_t calltime; + int ret; + + calltime = ktime_get(); + ret = ops->smm_call(ops->smm_dev, regs); + duration = ktime_us_delta(ktime_get(), calltime); + + pr_debug("SMM(0x%.4x 0x%.4x) = 0x%.4x status: %d (took %7lld usecs)\n", + eax, ebx, regs->eax & 0xffff, ret, duration); + + if (duration > DELL_SMM_MAX_DURATION) + pr_warn_once("SMM call took %lld usecs!\n", duration); + + if (ret < 0) + return ret; + + if ((regs->eax & 0xffff) == 0xffff || regs->eax == eax) + return -EINVAL; + + return 0; +} + /* * Read the fan status. */ @@ -233,7 +259,7 @@ static int i8k_get_fan_status(const struct dell_smm_data *data, u8 fan) if (data->disallow_fan_support) return -EINVAL; - return i8k_smm(®s) ? : regs.eax & 0xff; + return dell_smm_call(data->ops, ®s) ? : regs.eax & 0xff; } /* @@ -249,7 +275,7 @@ static int i8k_get_fan_speed(const struct dell_smm_data *data, u8 fan) if (data->disallow_fan_support) return -EINVAL; - return i8k_smm(®s) ? : (regs.eax & 0xffff) * data->i8k_fan_mult; + return dell_smm_call(data->ops, ®s) ? : (regs.eax & 0xffff) * data->i8k_fan_mult; } /* @@ -265,7 +291,7 @@ static int _i8k_get_fan_type(const struct dell_smm_data *data, u8 fan) if (data->disallow_fan_support || data->disallow_fan_type_call) return -EINVAL; - return i8k_smm(®s) ? : regs.eax & 0xff; + return dell_smm_call(data->ops, ®s) ? : regs.eax & 0xff; } static int i8k_get_fan_type(struct dell_smm_data *data, u8 fan) @@ -290,7 +316,7 @@ static int __init i8k_get_fan_nominal_speed(const struct dell_smm_data *data, u8 if (data->disallow_fan_support) return -EINVAL; - return i8k_smm(®s) ? : (regs.eax & 0xffff); + return dell_smm_call(data->ops, ®s) ? : (regs.eax & 0xffff); } /* @@ -304,7 +330,7 @@ static int i8k_enable_fan_auto_mode(const struct dell_smm_data *data, bool enabl return -EINVAL; regs.eax = enable ? data->auto_fan : data->manual_fan; - return i8k_smm(®s); + return dell_smm_call(data->ops, ®s); } /* @@ -320,35 +346,35 @@ static int i8k_set_fan(const struct dell_smm_data *data, u8 fan, int speed) speed = (speed < 0) ? 0 : ((speed > data->i8k_fan_max) ? data->i8k_fan_max : speed); regs.ebx = fan | (speed << 8); - return i8k_smm(®s); + return dell_smm_call(data->ops, ®s); } -static int __init i8k_get_temp_type(u8 sensor) +static int __init i8k_get_temp_type(const struct dell_smm_data *data, u8 sensor) { struct smm_regs regs = { .eax = I8K_SMM_GET_TEMP_TYPE, .ebx = sensor, }; - return i8k_smm(®s) ? : regs.eax & 0xff; + return dell_smm_call(data->ops, ®s) ? : regs.eax & 0xff; } /* * Read the cpu temperature. */ -static int _i8k_get_temp(u8 sensor) +static int _i8k_get_temp(const struct dell_smm_data *data, u8 sensor) { struct smm_regs regs = { .eax = I8K_SMM_GET_TEMP, .ebx = sensor, }; - return i8k_smm(®s) ? : regs.eax & 0xff; + return dell_smm_call(data->ops, ®s) ? : regs.eax & 0xff; } -static int i8k_get_temp(u8 sensor) +static int i8k_get_temp(const struct dell_smm_data *data, u8 sensor) { - int temp = _i8k_get_temp(sensor); + int temp = _i8k_get_temp(data, sensor); /* * Sometimes the temperature sensor returns 0x99, which is out of range. @@ -359,7 +385,7 @@ static int i8k_get_temp(u8 sensor) */ if (temp == 0x99) { msleep(100); - temp = _i8k_get_temp(sensor); + temp = _i8k_get_temp(data, sensor); } /* * Return -ENODATA for all invalid temperatures. @@ -375,12 +401,12 @@ static int i8k_get_temp(u8 sensor) return temp; } -static int __init i8k_get_dell_signature(int req_fn) +static int __init dell_smm_get_signature(const struct dell_smm_ops *ops, int req_fn) { struct smm_regs regs = { .eax = req_fn, }; int rc; - rc = i8k_smm(®s); + rc = dell_smm_call(ops, ®s); if (rc < 0) return rc; @@ -392,12 +418,12 @@ static int __init i8k_get_dell_signature(int req_fn) /* * Read the Fn key status. */ -static int i8k_get_fn_status(void) +static int i8k_get_fn_status(const struct dell_smm_data *data) { struct smm_regs regs = { .eax = I8K_SMM_FN_STATUS, }; int rc; - rc = i8k_smm(®s); + rc = dell_smm_call(data->ops, ®s); if (rc < 0) return rc; @@ -416,12 +442,12 @@ static int i8k_get_fn_status(void) /* * Read the power status. */ -static int i8k_get_power_status(void) +static int i8k_get_power_status(const struct dell_smm_data *data) { struct smm_regs regs = { .eax = I8K_SMM_POWER_STATUS, }; int rc; - rc = i8k_smm(®s); + rc = dell_smm_call(data->ops, ®s); if (rc < 0) return rc; @@ -464,15 +490,15 @@ static long i8k_ioctl(struct file *fp, unsigned int cmd, unsigned long arg) return 0; case I8K_FN_STATUS: - val = i8k_get_fn_status(); + val = i8k_get_fn_status(data); break; case I8K_POWER_STATUS: - val = i8k_get_power_status(); + val = i8k_get_power_status(data); break; case I8K_GET_TEMP: - val = i8k_get_temp(0); + val = i8k_get_temp(data, 0); break; case I8K_GET_SPEED: @@ -539,14 +565,14 @@ static int i8k_proc_show(struct seq_file *seq, void *offset) int fn_key, cpu_temp, ac_power; int left_fan, right_fan, left_speed, right_speed; - cpu_temp = i8k_get_temp(0); /* 11100 µs */ + cpu_temp = i8k_get_temp(data, 0); /* 11100 µs */ left_fan = i8k_get_fan_status(data, I8K_FAN_LEFT); /* 580 µs */ right_fan = i8k_get_fan_status(data, I8K_FAN_RIGHT); /* 580 µs */ left_speed = i8k_get_fan_speed(data, I8K_FAN_LEFT); /* 580 µs */ right_speed = i8k_get_fan_speed(data, I8K_FAN_RIGHT); /* 580 µs */ - fn_key = i8k_get_fn_status(); /* 750 µs */ + fn_key = i8k_get_fn_status(data); /* 750 µs */ if (power_status) - ac_power = i8k_get_power_status(); /* 14700 µs */ + ac_power = i8k_get_power_status(data); /* 14700 µs */ else ac_power = -1; @@ -665,7 +691,7 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types switch (attr) { case hwmon_temp_input: /* _i8k_get_temp() is fine since we do not care about the actual value */ - if (data->temp_type[channel] >= 0 || _i8k_get_temp(channel) >= 0) + if (data->temp_type[channel] >= 0 || _i8k_get_temp(data, channel) >= 0) return 0444; break; @@ -747,7 +773,7 @@ static int dell_smm_read(struct device *dev, enum hwmon_sensor_types type, u32 a case hwmon_temp: switch (attr) { case hwmon_temp_input: - ret = i8k_get_temp(channel); + ret = i8k_get_temp(data, channel); if (ret < 0) return ret; @@ -994,7 +1020,7 @@ static int __init dell_smm_init_hwmon(struct device *dev) u8 i; for (i = 0; i < DELL_SMM_NO_TEMP; i++) { - data->temp_type[i] = i8k_get_temp_type(i); + data->temp_type[i] = i8k_get_temp_type(data, i); if (data->temp_type[i] < 0) continue; @@ -1353,6 +1379,7 @@ static int __init dell_smm_probe(struct platform_device *pdev) mutex_init(&data->i8k_mutex); platform_set_drvdata(pdev, data); + data->ops = &i8k_smm_ops; if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { if (!force) { @@ -1445,8 +1472,8 @@ static int __init i8k_init(void) /* * Get SMM Dell signature */ - if (i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG1) && - i8k_get_dell_signature(I8K_SMM_GET_DELL_SIG2)) { + if (dell_smm_get_signature(&i8k_smm_ops, I8K_SMM_GET_DELL_SIG1) && + dell_smm_get_signature(&i8k_smm_ops, I8K_SMM_GET_DELL_SIG2)) { if (!force) return -ENODEV; From patchwork Sat Nov 4 15:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445557 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 DC71AC4332F for ; Sat, 4 Nov 2023 15:56:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232279AbjKDP4o (ORCPT ); Sat, 4 Nov 2023 11:56:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232069AbjKDP4l (ORCPT ); Sat, 4 Nov 2023 11:56:41 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EDBDD48; 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=1699113368; x=1699718168; i=w_armin@gmx.de; bh=wR4353YnrKhD4Of+t0tLDfA0Ba3QrBQXXpZeY1nQ7TI=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Xt9qGUNKYxtQruWat4nuciRCpXb9Y+RH+ogtAxaThSybCFxONRz8HgG5wUakpWgy QsNND2N+CM8VSBFFs8BYeGcrHUodyL9ij84zV3P2bUUHeKzNZK/9/Jvr7gGUCBtW7 7fRo7o5QNZ0pJkfdRmWBo9/FrZxHrT8O30n10qFSmmt37IdKuxyhTIjWs1Bp+Obwq 73BPuStEhFy44/jL566pw32zgCxrvFATMR0DG+pVNxR3NhYQ8eBjvy1QXy/vM2ePx P3pCuKSnX/fmTpBpM00mEIWTOZ9cqBCNQwnYC3DnC8hs3uhWwfbphVlu4MjpzfcjH YJ+hLCkRDjKXVYWDdA== 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 (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M2wGs-1r0Ovz3QiK-003QMM; Sat, 04 Nov 2023 16:56:07 +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 2/9] hwmon: (dell-smm) Move blacklist handling to module init Date: Sat, 4 Nov 2023 16:55:52 +0100 Message-Id: <20231104155559.11842-3-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:hupyRLrGZtrbi4TPfjd+dtUKNv2xlwdnm7ix9rCqT0nN13OM5Im BtxhDipc/93Ly0KSZbeNZNRLzOERtzgeLBoCNc17rFKZog2hHQ9rTQ6zcNWxIOR316+9Syo EX3Fs1MnJ0FfBZTgcTgMFBFvExIRg12NnBxL7mGaag8+skj+TTBp7W04gA0yAHkjGXMUOQ0 jex66Kr7Fvmpo0BF17VWA== UI-OutboundReport: notjunk:1;M01:P0:LjtWrzpUyhg=;rlwpm0mFvdUe5sZ/W++GaUodZ2B RDmwMuyn9iMIIcQ2Fe+RrhAAFeHeTtVU5gHpEeYMqx98mdlwtF16tP+r99B2lhr0+rzatDPdO yDO1eAl296BEpzBPWkRvxxfBBViUbFJAEXIETzLexs3bCJ4TmYhEmdXI+AmaQWQZk77pIwR83 YDkRoT7GGpP+SHxRwqMovEN1uy5GkNNtMjwLBJyBqDzHhapXoYctW3TmVojLq7SQm+yJUBYBw P5NOn2R9KYLIEa9Y3TxhF7HLXPZ5NRQj2H/blVDo44x9h8+KJvyQxKpQT3nQ11tenPj8y6QXH rVORM6/fRpP3CtPtE6Cv3EOf6BWZemlzdcdIIajOgHLziLkaMovf8qS7jRyi5roBXae8QyRuH cJIGOSWGm+HTGjLrL1LYX8IWr5qnH6paUuMFmv4FTO6Tlh6vEal1N40OSE5vuSklVtAyMj+DL SjL5NkVeMimJ93rELhkjsg3IY4EdMPLo2JXZnMGGEOlY4fCJMkM6KUahVnEjtXGfZhubZYNBS ELndHRoUNcag2/6eomraNbAozcF4EzxCQhM1n/dDRUx3BfV2krbgi33+aNQaphazXmRpegwV6 8XomA/sYQzEeDLyBSoSr7OnBzFLlN63b/dbLS5pE8xgebqIWfWm8n8XG0DEcfJuu2VOW5nMQo gi+AR8ry7Lt2uTtzGSaXGzLXA1B3WIJVV1jBrRm8PFyAvLPzaeV9W6NX7nkcNv9cIL5OL9ZdA D1VeWP7E/6/E+RdZ6hoK30keROFAaejXf31v56d3yqTxf+MPx0HAPwXKvzB+6tpCMCmHQM3rb ezYS8EwJORwz/L/skL/xkwicHh4qF2A7FNaxpvItcWIUMQFWTHWJFoxmYRjXpVD+2OSVsfcfv BRrCjTqJeqOWj761G6qIEld8EY2hLxyhjkm384Y0d2IKFQVpeDW0ZOldBAIqrGyPQ0rnuijkt 6XlR3pCdnTH+WTSu1fI5ovwK0Sw= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Future SMM calling backends will not be able to probe during module init, meaning the DMI tables used for backlisting broken features would have to drop their __initconst attribute. Prevent this by moving the blacklist handling to module init. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 63 ++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 29 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index a3273780f7c3..ccb3fcff4f60 100644 --- 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; - bool disallow_fan_type_call; - bool disallow_fan_support; unsigned int manual_fan; unsigned int auto_fan; int temp_type[DELL_SMM_NO_TEMP]; @@ -138,6 +136,8 @@ static uint fan_max; module_param(fan_max, uint, 0); MODULE_PARM_DESC(fan_max, "Maximum configurable fan speed (default: autodetect)"); +static bool disallow_fan_type_call, disallow_fan_support; + static const char * const temp_labels[] = { "CPU", "GPU", @@ -256,7 +256,7 @@ static int i8k_get_fan_status(const struct dell_smm_data *data, u8 fan) .ebx = fan, }; - if (data->disallow_fan_support) + if (disallow_fan_support) return -EINVAL; return dell_smm_call(data->ops, ®s) ? : regs.eax & 0xff; @@ -272,7 +272,7 @@ static int i8k_get_fan_speed(const struct dell_smm_data *data, u8 fan) .ebx = fan, }; - if (data->disallow_fan_support) + if (disallow_fan_support) return -EINVAL; return dell_smm_call(data->ops, ®s) ? : (regs.eax & 0xffff) * data->i8k_fan_mult; @@ -288,7 +288,7 @@ static int _i8k_get_fan_type(const struct dell_smm_data *data, u8 fan) .ebx = fan, }; - if (data->disallow_fan_support || data->disallow_fan_type_call) + if (disallow_fan_support || disallow_fan_type_call) return -EINVAL; return dell_smm_call(data->ops, ®s) ? : regs.eax & 0xff; @@ -313,7 +313,7 @@ static int __init i8k_get_fan_nominal_speed(const struct dell_smm_data *data, u8 .ebx = fan | (speed << 8), }; - if (data->disallow_fan_support) + if (disallow_fan_support) return -EINVAL; return dell_smm_call(data->ops, ®s) ? : (regs.eax & 0xffff); @@ -326,7 +326,7 @@ static int i8k_enable_fan_auto_mode(const struct dell_smm_data *data, bool enabl { struct smm_regs regs = { }; - if (data->disallow_fan_support) + if (disallow_fan_support) return -EINVAL; regs.eax = enable ? data->auto_fan : data->manual_fan; @@ -340,7 +340,7 @@ static int i8k_set_fan(const struct dell_smm_data *data, u8 fan, int speed) { struct smm_regs regs = { .eax = I8K_SMM_SET_FAN, }; - if (data->disallow_fan_support) + if (disallow_fan_support) return -EINVAL; speed = (speed < 0) ? 0 : ((speed > data->i8k_fan_max) ? data->i8k_fan_max : speed); @@ -705,7 +705,7 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types } break; case hwmon_fan: - if (data->disallow_fan_support) + if (disallow_fan_support) break; switch (attr) { @@ -715,7 +715,7 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types break; case hwmon_fan_label: - if (data->fan[channel] && !data->disallow_fan_type_call) + if (data->fan[channel] && !disallow_fan_type_call) return 0444; break; @@ -731,7 +731,7 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types } break; case hwmon_pwm: - if (data->disallow_fan_support) + if (disallow_fan_support) break; switch (attr) { @@ -1381,24 +1381,6 @@ static int __init dell_smm_probe(struct platform_device *pdev) platform_set_drvdata(pdev, data); data->ops = &i8k_smm_ops; - if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { - if (!force) { - dev_notice(&pdev->dev, "Disabling fan support due to BIOS bugs\n"); - data->disallow_fan_support = true; - } else { - dev_warn(&pdev->dev, "Enabling fan support despite BIOS bugs\n"); - } - } - - if (dmi_check_system(i8k_blacklist_fan_type_dmi_table)) { - if (!force) { - dev_notice(&pdev->dev, "Disabling fan type call due to BIOS bugs\n"); - data->disallow_fan_type_call = true; - } else { - dev_warn(&pdev->dev, "Enabling fan type call despite BIOS bugs\n"); - } - } - strscpy(data->bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), sizeof(data->bios_version)); strscpy(data->bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), @@ -1453,6 +1435,27 @@ static struct platform_device *dell_smm_device; /* * Probe for the presence of a supported laptop. */ +static void __init dell_smm_init_dmi(void) +{ + if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { + if (!force) { + pr_notice("Disabling fan support due to BIOS bugs\n"); + disallow_fan_support = true; + } else { + pr_warn("Enabling fan support despite BIOS bugs\n"); + } + } + + if (dmi_check_system(i8k_blacklist_fan_type_dmi_table)) { + if (!force) { + pr_notice("Disabling fan type call due to BIOS bugs\n"); + disallow_fan_type_call = true; + } else { + pr_warn("Enabling fan type call despite BIOS bugs\n"); + } + } +} + static int __init i8k_init(void) { /* @@ -1469,6 +1472,8 @@ static int __init i8k_init(void) i8k_get_dmi_data(DMI_BIOS_VERSION)); } + dell_smm_init_dmi(); + /* * Get SMM Dell signature */ From patchwork Sat Nov 4 15:55:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445556 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 386ABC4332F for ; Sat, 4 Nov 2023 15:56:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232024AbjKDP4l (ORCPT ); Sat, 4 Nov 2023 11:56:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229491AbjKDP4k (ORCPT ); Sat, 4 Nov 2023 11:56:40 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B4419D; Sat, 4 Nov 2023 08:56:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113371; x=1699718171; i=w_armin@gmx.de; bh=ifOYwAxjzP5mj81yd22nPAM7GrmUV1QGSVAX6g3Ytlk=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=aeNpnhMe7UEn0GC5HmgFu0ZvtJC9ulUuql3yJUbh5sMwt1nB8xDJbt8Dgzpjo2XS F9yv4I3+ao486wgJbhXzfDQlUyeBe9ZEFWjgB7caQX9dFrQ9NNEc7xZTClPgUvvy9 9DusNKxgw7xihZhcP2VkkWyA5lPMbZFy9F/RBitOhUXvPU+GdmGyFsBxAa5m0YOw2 dTBokE/vV8FXxVzATESGNsQw96hYP6oKGnF4627IGIF94afHdezC+A0/cLYejO1ev 0hTZhyuuVJTp2Zg5oyzv/EgYj7LC1OIYWqMEcQ3Fd8AtQflZkGRdGy+b+3+ITtYxL RcsMw/DeFTyllM6dsw== 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 (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N7QxB-1rVWZr3clR-017mVX; Sat, 04 Nov 2023 16:56:10 +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 3/9] hwmon: (dell-smm) Move whitelist handling to module init Date: Sat, 4 Nov 2023 16:55:53 +0100 Message-Id: <20231104155559.11842-4-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:fhnBU4BVWsJWvd3qaltsAgfCTlgrwgdwK7Yf2Rw17jIEaLL7td5 OSTF97H6a1ahaJjm18ySO8fVix7nGOS2l1Wft3E0nuzjZP3DholsFNnwfHwN8rgFBO0yrJc LDBhyHY+dC3nID0wZB3TIHl0+Gvac7UDAYxUWy9Yb1n2AhSvOn3Lo9zd9+dQ4NCgOgnaUq6 QLBya7NdlB7J+yIquDb4g== UI-OutboundReport: notjunk:1;M01:P0:+GB79O5BKMA=;eht47skEnIL3mo9I9LYAA0vmFtU 4MqDLnLLRPsu4ogYQUR4zTagHWlnwmUTRscC8HoFLXOMP4WITHZEmVR6YuzKOndVFB6vD/Scv HZqhIyVXU8f6zQ/uAVc5LwsNqm8iR/yJqq7URzmSg4wPTYDEGgMP4zvHpv1v3vcHZD4hhpnQW y3iIb1jH+IZYHlC19QYGajvO5TFdluEFQKFRQaX8n9uehw7aPuw7YXH5HtvQg4vtq6oZi2/tl IYHLmyIe1RdK97uc5OmlD4uJoCOWJ1JBWKxSRjSqObZwYHUUz047hOqFotEK8sV+vcKz4d+VA m6XKfQU/sWfJj1xqnIy+OfJ21Q9EanDaKSkViVclmHLllrmP7yRDCOwIpUouG7aqkbwJqvZKs bf17x9E8ZlhjIbjV5a+LdekVw7uJOUZzuEUeCfJHOCSp1j6DyVTwtnCl0AX23qW/Lya58yOwi 4ApeuV+rVBk47ZjzyOJEnKwKFeCeT63x3PdiDp4BP+VV05Agf2cAmpsv5KLgxAkY9419sVHSz 9BjUq1g9DqL8EGaKAWgIz72l/tsAWkJIAARDCLJC5O+jZIQ8AyX6DmZF6H3YWVH+Zsqlpz5RH HgKupE+2CmZ30o4uFeQ0OhAv/aknjzhpXMi7sZhcDPU0R3hzrv95WUTAHMWVrUVOHAaUC/a9p McjNC0fy4Jf6TcsWKPSfUoN7Bq6hfNdpDwE59icfdoSxyq6jUJmltvJK6uy9aSVKloCGDKOvC l1DFgul4pLgUFvVKRyIEe54DD8AU43z8IeQtNvsKoKk7CboOxosLjy987UIh6KszAGKTjxsVJ 2n/JRpnkkXgHKkkrpeusXmM/Zau6DGFWsf+anULWklmfyTcJ6cvz/eDVsJ96vs17WoFNLmLhs p10TTEyMYO9EYafllwQwFCFtcLvh1hvUD7jk/rLSJnN3DWUr5RgiX09nn/7nvRjpzyLtmYKIc VTOB/IpVh2FclSx+Nq0yKOkcvnU= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org 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. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index ccb3fcff4f60..3a792faf2369 100644 --- 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 speed (default: autodetect)" static bool disallow_fan_type_call, disallow_fan_support; +static unsigned int manual_fan, auto_fan; + static const char * const temp_labels[] = { "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 = enable ? data->auto_fan : data->manual_fan; + regs.eax = 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 = { 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 = devm_kzalloc(&pdev->dev, sizeof(struct dell_smm_data), GFP_KERNEL); @@ -1406,15 +1406,6 @@ static int __init dell_smm_probe(struct platform_device *pdev) data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH; data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max); - fan_control = dmi_first_match(i8k_whitelist_fan_control); - if (fan_control && fan_control->driver_data) { - const struct i8k_fan_control_data *control = fan_control->driver_data; - - data->manual_fan = control->manual_fan; - data->auto_fan = control->auto_fan; - dev_info(&pdev->dev, "enabling support for setting automatic/manual fan control\n"); - } - ret = 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 = dmi_first_match(i8k_whitelist_fan_control); + if (id && id->driver_data) { + control = id->driver_data; + manual_fan = control->manual_fan; + auto_fan = control->auto_fan; + + pr_info("Enabling support for setting automatic/manual fan control\n"); + } } static int __init i8k_init(void) From patchwork Sat Nov 4 15:55:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445559 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 0AC67C0018A for ; Sat, 4 Nov 2023 15:56:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232335AbjKDP4q (ORCPT ); Sat, 4 Nov 2023 11:56:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232265AbjKDP4n (ORCPT ); Sat, 4 Nov 2023 11:56:43 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4E63CD4C; Sat, 4 Nov 2023 08:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113372; x=1699718172; i=w_armin@gmx.de; bh=h1b+qI1DwuXjAP0XrrB6EkWVEvalXVcaQqX1+xZYP50=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=BdEh+QAhm9CJdLAgX0bNBL1TtKOEOSX7X/KLaNARfjvj6/JQmr2Q2xkP39BN9upX so4xBhrjLzyIY3c2fy9VB8uq0+MhetdDIzubo7TDzzLXdHeMpgwgWLu5LjOv3Yo0Q trhNqV3vLQha7LTmoQhooCv2eiFb08jyYKFxOIH9pQvyOmQd1+8XtSdMXCh8aHsZP inmCXOTx5+gG1QagIRH/Eubap0zNdHiHen4vH1MG4s31siOfMvmHUaXxf0PVWdQ8k A38iqD2JrTVjZcm5+XYEXcrPvMzkygD+G5ZS+SFAfSvW1FjVQb+hjbNc/9pSuOaFb cHzpws0OcCIewf9mCg== 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 1MHGCo-1rCUI80wDY-00DIsy; Sat, 04 Nov 2023 16:56:12 +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 4/9] hwmon: (dell-smm) Move DMI config handling to module init Date: Sat, 4 Nov 2023 16:55:54 +0100 Message-Id: <20231104155559.11842-5-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:bz7/ryikIYg2AiEcGrXV/jQkDU/cC7KLoivKsCXJ6hqnvRV/2w3 0NR3L3BklSJPu/8JVZOshTQqGd+Vza/kzYEfOnkajc9g075SEuI9tE42sEss61cQcHOKHlK cFZ7n4onJYnLiK7alWzeTqd819sTqMsH1u8WxYKnzYDfSSfgthx1tyIEkO9EUNrcdo/bVHJ /JF14U1UjwyVkl7FrZf3Q== UI-OutboundReport: notjunk:1;M01:P0:EsyBWgDtB+c=;RxGT5+Hul98rdC8JxPhAeSvizIJ vznHvf3ZUWj3lDgqOMEyqjCL7Ez1WIKOX+yJdFFdG7GGhEmV+np2WvYrpdtHDHphz1tTLqoyM CbS2pwQld2sC7yUd2hCRFXVH6j68dCLLMpV1rxEmtZ2U0d8y9Nw7ayU4hxNcWaxJgLTNzdOgD U3OHRpAaUGITjZ4iLJEu3NFWVezXqM9oR8khrYOaeTIuN1P8v8/tTzWWyjLB7oZx8pam+5+QZ Ncx6LsPkHAIcSp3DS0Swu6MAvuJs8Eh/Wybs8ShCPGhrZu1VxdNmFUoxWAqxE5DfMIABHPmFc dpQTncbWTwab7NnPTPmZKWR04Nr+eyncEUyUaTh1wKWo5LM8/cUFFBW0WzHm0QuwRxy2xsnYu mFM8WI1klfVNhNCTn9DI/+SR4/4B0FnvW+57ftYByD79Sgh8KJ/5QDYZILwTsiN2yGJEaxse1 Sw2jgtc9sJ/8VKfiwnc3+69Lful/n+6e4cLrt9+Jh4ZXz0e6YEqAT417O3fkJHJDgQ3GiyENV +Jl2rDETIFJVYj+qxSxUFW90q93AzTGTfJ/GQecX1s7ksglHfcxx3oQro9DtLXNjqhMx18xi9 UOt9WYkDfP1WFIyjoS0Kg23bG9xwtU0V7FcPkGBfc3prsDB0SD2YQ0ckUWtA9D35M84mwNtee FqogdWFxPXhkvYJYXFIc/Jjp39wYEQ5jOUFmuz6nOSEFb1/wBLM421nGsc7PbPbEFIX/1CPoc gtGmpEOhpFNyofDkd8gMz+gZjqRKRN3MnAvjTruG6p1bEqR2Tum6aXSl4rDVgZmY9PCh0/LhP fjtqFiRuPNjZI/hr58YMxj+F1wm6niKRJAY9uDZMJCnZpj/pKWtTwMqZ/AToJ5y7LLlo+SGQX 19FHNWNYa8VU8RhXanSuj+3f6D0oUQI5k1HSTHVESHbpmFxZXBSzP9ZHQTTefOZf0qAJ1MUm7 2/mdU6/Q/icqKwaC9yeAwqtI4/4= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Future SMM calling backends will not be able to probe during module init, meaning the DMI tables holding config data would have to drop their __initconst attribute. Prevent this by moving the config handling to module init. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 3a792faf2369..3d14a3baf8e4 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -1370,7 +1370,6 @@ static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = { static int __init dell_smm_probe(struct platform_device *pdev) { struct dell_smm_data *data; - const struct dmi_system_id *id; int ret; data = devm_kzalloc(&pdev->dev, sizeof(struct dell_smm_data), GFP_KERNEL); @@ -1386,21 +1385,6 @@ static int __init dell_smm_probe(struct platform_device *pdev) strscpy(data->bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), sizeof(data->bios_machineid)); - /* - * 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); - if (id && id->driver_data) { - const struct i8k_config_data *conf = id->driver_data; - - if (!fan_mult && conf->fan_mult) - fan_mult = conf->fan_mult; - - if (!fan_max && conf->fan_max) - fan_max = conf->fan_max; - } - /* All options must not be 0 */ data->i8k_fan_mult = fan_mult ? : I8K_FAN_MULT; data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH; @@ -1429,6 +1413,7 @@ static struct platform_device *dell_smm_device; static void __init dell_smm_init_dmi(void) { struct i8k_fan_control_data *control; + struct i8k_config_data *config; const struct dmi_system_id *id; if (dmi_check_system(i8k_blacklist_fan_support_dmi_table)) { @@ -1449,6 +1434,20 @@ 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); + if (id && id->driver_data) { + config = id->driver_data; + if (!fan_mult && config->fan_mult) + fan_mult = config->fan_mult; + + if (!fan_max && config->fan_max) + fan_max = config->fan_max; + } + id = dmi_first_match(i8k_whitelist_fan_control); if (id && id->driver_data) { control = id->driver_data; 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) From patchwork Sat Nov 4 15:55:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445561 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 1D537C4708E for ; Sat, 4 Nov 2023 15:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232439AbjKDP4y (ORCPT ); Sat, 4 Nov 2023 11:56:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232354AbjKDP4s (ORCPT ); Sat, 4 Nov 2023 11:56:48 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF5CDD48; Sat, 4 Nov 2023 08:56:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113375; x=1699718175; i=w_armin@gmx.de; bh=KzTtitQlUrweVrr5QpGq17vU3ttU7nbis5K8mH0T98M=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=DWotbEIAxLNdMlJsOFjKM/gyPKqaV+bpABpQs9MqIqx+RgFwTp8cnXb4ekgDNRYX 0q9BlPKuPtV9TvDSW2UK60vgPCpsgI4j/CN/4vTPvh3XPiw+hYEyeoWLswYHAfALy bd7XFRYuvw3DRHBsA8PfXulETKC8oFrS9Bzy/ScfJCnvYvXGz7IW+A0VGpkjG2Bn2 XKAhHyAkN1Woi8SsP5XunFyZLGO+8PRyBElGuCGH81Gt1NZUmQi8twk48ur2lejZo RHyQeP6xeqgm1S/A3F3tatMWE65MkQ85Ci0nNdJECSViIv3XWGcI103NzGv833Zl7 MnBJKM0yfU536gvtUQ== 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 (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MmlT2-1rflIv0gb8-00jsdk; Sat, 04 Nov 2023 16:56:15 +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 6/9] hwmon: (dell-smm) Introduce helper function for data init Date: Sat, 4 Nov 2023 16:55:56 +0100 Message-Id: <20231104155559.11842-7-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:IGW+Zf7o8zLl/z8q4IGAVyRHvZ1Z1fKCMJH5xOqbSSmfb9oW7NW L5OVq5DeDyGHd+x4D4rTuSEoDJsK3yWm8PrlQyCRJv9xhoSik7G7RwQYlBC1NRSRfX6la9k 0DLtad1u53AziYHj8otKxNOMU8ndVfFGrpCge+y/NOOBuSGTh5nqVMq2fyW1xz8V9ehdB3Y xeg9p/68QWdHV7Nmlzidg== UI-OutboundReport: notjunk:1;M01:P0:fj4C8uLnVVk=;/EXtlkVw7waSM5BAb9t17HcGE+M ZIeUI5tczW8f5bertWsuS24awCEksfY05TSn4iY8yVXwX1z1KDuAMGEE1INAwQDiCXiXu8fpU cJ7qQ1zBn571GElX0Go923ecfE4CGYTlU0A8QQ54gGkB+4uk9PIx8YNJuKJFkhz8kNALZjvDs Ibgez7FY8b9P9nY3bN+jfGIHErnTI5a6kt9jQkrFwu6yleCiFdZdlTfe3rwaLPSPnfd0AfVTH 6VJu0VjzJlWm7LFg2Mx3ZUQVpY9H/evNc1LFVYmLc1ElNNv9UsvHvyJ/RC+kHoYyB+D01BzB3 zxY7nUHkFWCCaoOo8EU+mpzgOTabn0H9R4gBDbudcPU6v4lvQgKL6XvU6QcYaX7kGmqGCDnXf hlLNSx27zxdVuhhHQ2eWCUAzwe/GdNra2PNMjwKcxiWJh2i8aV5i94yety+QyZHZVoYaBZ3zF lcxWEyBeEZhqonJfyuGFnKYmDBREj89HA+wAydpLOLsYUWKm55hDRbSbL+MNEqIXi8/QeaUxz ppqMwbuxCl5Jnap9V96zo6+LvOJS7LrkXBDAH+bDYvNU0wUEg5/Dvxy7x2p/qDH7KwbqXcnrh OQS4HuJVeDVwtbRj1DE6TpsqsWV/hmaUby/m9FzinuMkt2UHWuX0EskVZExqK8yFKIzaniEJh iQ2F72wYGndZ6EbQrKTXhjesLYRDQt1it7sXvBv/HrIo7VPjC7DvVbBsg4nuZBk/IvR+F2I5y 6eh7ZFnnv/00OX//EA8Yshg22NBYNzUldilcmTn87AQe9DWqQQMIqIfviuy6z4g8SL3VMzZcx 7vo907DSwcdPNV7f7h2yKyxqDta9lkO5F6/ng1pIfkdw6LSvqVDqNgUJDntn2H+7g1Iwf8Oyp RWRObeVY8cA0Ah3a0U2g37MSWszjjBulumtXBS4jteDJzRWS7oY1AO/SFlV7/lcv30cM65/ED 2H0OXkGo1kcdgR7Qg4GK0BzG+eY= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org In the future, multiple SMM calling backends will exist, with each backend being required to initialize its data. Introduce a helper function for this so the code necessary to initialize dell_smm_data is not duplicated between different backends. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 46 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 4a2c0d1ffa5b..2547b09929e6 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -623,6 +623,11 @@ static void __init i8k_init_procfs(struct device *dev) { struct dell_smm_data *data = dev_get_drvdata(dev); + strscpy(data->bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), + sizeof(data->bios_version)); + strscpy(data->bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), + sizeof(data->bios_machineid)); + /* Only register exit function if creation was successful */ if (proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data)) devm_add_action_or_reset(dev, i8k_exit_procfs, NULL); @@ -1078,6 +1083,26 @@ static int __init dell_smm_init_hwmon(struct device *dev) return PTR_ERR_OR_ZERO(dell_smm_hwmon_dev); } +static int __init dell_smm_init_data(struct device *dev, const struct dell_smm_ops *ops) +{ + struct dell_smm_data *data; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + mutex_init(&data->i8k_mutex); + dev_set_drvdata(dev, data); + + data->ops = ops; + /* All options must not be 0 */ + data->i8k_fan_mult = fan_mult ? : I8K_FAN_MULT; + data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH; + data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max); + + return 0; +} + static const struct dmi_system_id i8k_dmi_table[] __initconst = { { .ident = "Dell G5 5590", @@ -1386,26 +1411,11 @@ static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = { static int __init dell_smm_probe(struct platform_device *pdev) { - struct dell_smm_data *data; int ret; - data = devm_kzalloc(&pdev->dev, sizeof(struct dell_smm_data), GFP_KERNEL); - if (!data) - return -ENOMEM; - - mutex_init(&data->i8k_mutex); - platform_set_drvdata(pdev, data); - data->ops = &i8k_smm_ops; - - strscpy(data->bios_version, i8k_get_dmi_data(DMI_BIOS_VERSION), - sizeof(data->bios_version)); - strscpy(data->bios_machineid, i8k_get_dmi_data(DMI_PRODUCT_SERIAL), - sizeof(data->bios_machineid)); - - /* All options must not be 0 */ - data->i8k_fan_mult = fan_mult ? : I8K_FAN_MULT; - data->i8k_fan_max = fan_max ? : I8K_FAN_HIGH; - data->i8k_pwm_mult = DIV_ROUND_UP(255, data->i8k_fan_max); + ret = dell_smm_init_data(&pdev->dev, &i8k_smm_ops); + if (ret < 0) + return ret; ret = dell_smm_init_hwmon(&pdev->dev); if (ret) From patchwork Sat Nov 4 15:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445560 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 56CD3C4332F for ; Sat, 4 Nov 2023 15:56:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232401AbjKDP4w (ORCPT ); Sat, 4 Nov 2023 11:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232310AbjKDP4p (ORCPT ); Sat, 4 Nov 2023 11:56:45 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAAF0D51; Sat, 4 Nov 2023 08:56:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113378; x=1699718178; i=w_armin@gmx.de; bh=E0zIFDIJGnBlG8u/9g+iTGRmgZ57wIRy0eOPDX28wDc=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=HxSpKYYzEdbLw8ExApSJAtY3fQS+6n58kAp11C4CSY18QYpIIX3zqgrNOw2qOfSL c9Omv07qJVAcmUpr+uWWW1LRt3cHmlXba37VBOJOXMLAXW+MIaNHqATBbFbG4e+yI g9BKn/Z3MVvw8tgKTagY/QXabxOt+QiGUQgphYQgAlkHnad8HC4djmm9BJ7HJpNZd lsCrDi5SUzS6o1YXF8u9SwC/k1xbHPNMPrpSySiHOqjv4a4uu0xvhLcSY3zgnNJpR JD7E7z94O3TuCMnRu4JuXhx309sKUAwr9nWu8E1vv37iMVSBjmQY2rTvrBaUWS42Q JOw7vQITuLAiDHwiMg== 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 (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MNsw4-1qoFLO0huS-00OH4Z; Sat, 04 Nov 2023 16:56:18 +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 7/9] hwmon: (dell-smm) Add support for WMI SMM interface Date: Sat, 4 Nov 2023 16:55:57 +0100 Message-Id: <20231104155559.11842-8-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:jzjesbErgQnhElmaxvyrwzxWR8GZuHa+dwzmJf76bQhSTAoN6O1 NyHEr58FkL+t5P5syOw7DQ8m/wnLnUrArDZ89EjL0Vbhe42tSCS56wjdGTSequBrI5cn4X6 x63v+Q9s/auVdf2YWRTyev0u1irL9H2hyUO2cl3p6CoueI0Xw742SCdmXMp6J5mbFEnqc+0 8UmwHVPIfpmuSIQVapaWg== UI-OutboundReport: notjunk:1;M01:P0:WA2aNQ9YhQs=;JqDnJim8pX+j875VtuGeeMrzw+a 0+ab1qXdHs91gr7N3MydwkSZk5no3OT1cz8Ht3io1JX2/4IODmqu2EBnh4xpouAMjH5VqyZfE EZvCBw+qNdory0J9vKryZmXijBoWrizlHK6u8iTinPfkyR372V7g4Z9HKClyBQWd43h+EjTN6 03WVaH5l37wp7Pts3gtBJO4jNSkrXU6uTFWly7VJgNRrOIdMFM5iAu6iUMJ2wareYG7SpBEVF 694Al5kmy0bZF9oryIHfh5PDeZCRgoW9lpt5PGJEcCYqVq1b3DL2oW8iL9MonBir62Q1pJFAv ptsrBpdslr+QKD7+z3nHICrABbJWpJKwJi2C+x3vcLsNi9y2fqlzMRybNVHKvhHMm5Ga9pgbH 3FlKQFk12nU/kASXj/uIqnHt/Kd3G/K00K0xV27ok5yDmsgtxtHBonzSR9Xnxt6b1uT1igqDx 8mwlLQBenT6OgMjSYLjn93U2amju+W1Zk/J+fLw5V2lFUHCKH+wQRDQ7BQT31SMJYnpIkLJTH gVTVwgFS51OyHsTp3TCZRrhXEGx5GIC6e/iNcHQG8TEt6wPpUBwXs+zBfVEOJdGhZXqJ7hTU+ OZY4lvY4wls6DFpaDn25LOC/YPmRcjHvM8+jCOdTJIqosME37uYU4E2MNPNo4BrJZgWymO6Ci kLAj+yusHb2zeUjzI6QyaWA4GDWM2wyneCUHDUyHzElkh4SEXLgx8ByTozFJQPunI4vL6lsNg A0pRaxgbtMw/gjGm90dmhKcjkOkif76wExxz7gXHwJOhnCbwCxYYmwVBUtDh2+5vmV7AF4VGU 8BfOjBdBbqBJz17z+7cpNcOM3X423dmkqNVA1VQ2Xi/SUJrJQyo9JuwkjbKOhB3hn5F3u2CSl Jj3U1dIyyLz+qxQXjhlx6LFc6VXw2YsflRUVJMglQXEB5VmIxGbybr5f9ErioGGiZ2xWbNpZ2 1OgdNKhC56ocsR7j+9OVt9MF3fg= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Some Dell machines like the Dell Optiplex 7000 do not support the legacy SMM interface, but instead expect all SMM calls to be issued over a special WMI interface. Add support for this interface so users can control the fans on those machines. Signed-off-by: Armin Wolf --- drivers/hwmon/Kconfig | 1 + drivers/hwmon/dell-smm-hwmon.c | 164 +++++++++++++++++++++++++++++---- drivers/platform/x86/wmi.c | 1 + 3 files changed, 147 insertions(+), 19 deletions(-) -- 2.39.2 diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index cf27523eed5a..76cb05db1dcf 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -512,6 +512,7 @@ config SENSORS_DS1621 config SENSORS_DELL_SMM tristate "Dell laptop SMM BIOS hwmon driver" + depends on ACPI_WMI depends on X86 imply THERMAL help diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 2547b09929e6..36d41262d579 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -12,6 +12,7 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -34,8 +35,10 @@ #include #include #include +#include #include +#include #define I8K_SMM_FN_STATUS 0x0025 #define I8K_SMM_POWER_STATUS 0x0069 @@ -66,6 +69,8 @@ #define I8K_POWER_AC 0x05 #define I8K_POWER_BATTERY 0x01 +#define DELL_SMM_WMI_GUID "F1DDEE52-063C-4784-A11E-8A06684B9B01" + #define DELL_SMM_NO_TEMP 10 #define DELL_SMM_NO_FANS 3 @@ -219,6 +224,69 @@ static const struct dell_smm_ops i8k_smm_ops = { .smm_call = i8k_smm_call, }; +/* + * Call the System Management Mode BIOS over WMI. + */ +static int wmi_smm_call(struct device *dev, struct smm_regs *regs) +{ + struct wmi_device *wdev = container_of(dev, struct wmi_device, dev); + struct acpi_buffer out = { ACPI_ALLOCATE_BUFFER, NULL }; + u32 wmi_payload[] = { + sizeof(regs->eax), + regs->eax, + sizeof(regs->ebx), + regs->ebx, + sizeof(regs->ecx), + regs->ecx, + sizeof(regs->edx), + regs->edx + }; + const struct acpi_buffer in = { + .length = sizeof(wmi_payload), + .pointer = &wmi_payload, + }; + union acpi_object *obj; + acpi_status status; + u32 *wmi_response; + int ret = 0; + int i; + + status = wmidev_evaluate_method(wdev, 0x0, 0x1, &in, &out); + if (ACPI_FAILURE(status)) + return -EIO; + + obj = out.pointer; + if (!obj) + return -ENODATA; + + if (obj->type != ACPI_TYPE_BUFFER && obj->buffer.length != sizeof(wmi_payload)) { + ret = -ENOMSG; + + goto err_free; + } + + wmi_response = (u32 *)obj->buffer.pointer; + + /* Check if register size is correct */ + for (i = 0; i < ARRAY_SIZE(wmi_payload); i += 2) { + if (get_unaligned_le32(&wmi_response[i]) != sizeof(wmi_response[i + 1])) { + ret = -ENOMSG; + + goto err_free; + } + } + + regs->eax = get_unaligned_le32(&wmi_response[1]); + regs->ebx = get_unaligned_le32(&wmi_response[3]); + regs->ecx = get_unaligned_le32(&wmi_response[5]); + regs->edx = get_unaligned_le32(&wmi_response[7]); + +err_free: + kfree(obj); + + return ret; +} + static int dell_smm_call(const struct dell_smm_ops *ops, struct smm_regs *regs) { int eax = regs->eax; @@ -306,7 +374,7 @@ static int i8k_get_fan_type(struct dell_smm_data *data, u8 fan) /* * Read the fan nominal rpm for specific fan speed. */ -static int __init i8k_get_fan_nominal_speed(const struct dell_smm_data *data, u8 fan, int speed) +static int i8k_get_fan_nominal_speed(const struct dell_smm_data *data, u8 fan, int speed) { struct smm_regs regs = { .eax = I8K_SMM_GET_NOM_SPEED, @@ -349,7 +417,7 @@ static int i8k_set_fan(const struct dell_smm_data *data, u8 fan, int speed) return dell_smm_call(data->ops, ®s); } -static int __init i8k_get_temp_type(const struct dell_smm_data *data, u8 sensor) +static int i8k_get_temp_type(const struct dell_smm_data *data, u8 sensor) { struct smm_regs regs = { .eax = I8K_SMM_GET_TEMP_TYPE, @@ -401,7 +469,7 @@ static int i8k_get_temp(const struct dell_smm_data *data, u8 sensor) return temp; } -static int __init dell_smm_get_signature(const struct dell_smm_ops *ops, int req_fn) +static int dell_smm_get_signature(const struct dell_smm_ops *ops, int req_fn) { struct smm_regs regs = { .eax = req_fn, }; int rc; @@ -986,7 +1054,7 @@ static const struct hwmon_chip_info dell_smm_chip_info = { .info = dell_smm_info, }; -static int __init dell_smm_init_cdev(struct device *dev, u8 fan_num) +static int dell_smm_init_cdev(struct device *dev, u8 fan_num) { struct dell_smm_data *data = dev_get_drvdata(dev); struct thermal_cooling_device *cdev; @@ -1017,7 +1085,7 @@ static int __init dell_smm_init_cdev(struct device *dev, u8 fan_num) return ret; } -static int __init dell_smm_init_hwmon(struct device *dev) +static int dell_smm_init_hwmon(struct device *dev) { struct dell_smm_data *data = dev_get_drvdata(dev); struct device *dell_smm_hwmon_dev; @@ -1083,7 +1151,7 @@ static int __init dell_smm_init_hwmon(struct device *dev) return PTR_ERR_OR_ZERO(dell_smm_hwmon_dev); } -static int __init dell_smm_init_data(struct device *dev, const struct dell_smm_ops *ops) +static int dell_smm_init_data(struct device *dev, const struct dell_smm_ops *ops) { struct dell_smm_data *data; @@ -1409,6 +1477,9 @@ static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = { { } }; +/* + * Legacy SMM backend driver. + */ static int __init dell_smm_probe(struct platform_device *pdev) { int ret; @@ -1434,6 +1505,47 @@ static struct platform_driver dell_smm_driver = { static struct platform_device *dell_smm_device; +/* + * WMI SMM backend driver. + */ +static int dell_smm_wmi_probe(struct wmi_device *wdev, const void *context) +{ + struct dell_smm_ops *ops; + int ret; + + ops = devm_kzalloc(&wdev->dev, sizeof(*ops), GFP_KERNEL); + if (!ops) + return -ENOMEM; + + ops->smm_call = wmi_smm_call; + ops->smm_dev = &wdev->dev; + + if (dell_smm_get_signature(ops, I8K_SMM_GET_DELL_SIG1) && + dell_smm_get_signature(ops, I8K_SMM_GET_DELL_SIG2)) + return -ENODEV; + + ret = dell_smm_init_data(&wdev->dev, ops); + if (ret < 0) + return ret; + + return dell_smm_init_hwmon(&wdev->dev); +} + +static const struct wmi_device_id dell_smm_wmi_id_table[] = { + { DELL_SMM_WMI_GUID, NULL }, + { } +}; +MODULE_DEVICE_TABLE(wmi, dell_smm_wmi_id_table); + +static struct wmi_driver dell_smm_wmi_driver = { + .driver = { + .name = KBUILD_MODNAME, + .probe_type = PROBE_PREFER_ASYNCHRONOUS, + }, + .id_table = dell_smm_wmi_id_table, + .probe = dell_smm_wmi_probe, +}; + /* * Probe for the presence of a supported laptop. */ @@ -1485,33 +1597,43 @@ static void __init dell_smm_init_dmi(void) } } -static int __init i8k_init(void) +static int __init dell_smm_legacy_check(void) { - /* - * Get DMI information - */ if (!dmi_check_system(i8k_dmi_table)) { if (!ignore_dmi && !force) return -ENODEV; - pr_info("not running on a supported Dell system.\n"); + pr_info("Probing for legacy SMM handler on unsupported machine\n"); pr_info("vendor=%s, model=%s, version=%s\n", i8k_get_dmi_data(DMI_SYS_VENDOR), i8k_get_dmi_data(DMI_PRODUCT_NAME), i8k_get_dmi_data(DMI_BIOS_VERSION)); } - dell_smm_init_dmi(); - - /* - * Get SMM Dell signature - */ if (dell_smm_get_signature(&i8k_smm_ops, I8K_SMM_GET_DELL_SIG1) && dell_smm_get_signature(&i8k_smm_ops, I8K_SMM_GET_DELL_SIG2)) { if (!force) return -ENODEV; - pr_err("Unable to get Dell SMM signature\n"); + pr_warn("Forcing legacy SMM calls on a possibly incompatible machine\n"); + } + + return 0; +} + +static int __init i8k_init(void) +{ + int ret; + + dell_smm_init_dmi(); + + ret = dell_smm_legacy_check(); + if (ret < 0) { + /* + * On modern machines, SMM communication happens over WMI, meaning + * the SMM handler might not react to legacy SMM calls. + */ + return wmi_driver_register(&dell_smm_wmi_driver); } dell_smm_device = platform_create_bundle(&dell_smm_driver, dell_smm_probe, NULL, 0, NULL, @@ -1522,8 +1644,12 @@ static int __init i8k_init(void) static void __exit i8k_exit(void) { - platform_device_unregister(dell_smm_device); - platform_driver_unregister(&dell_smm_driver); + if (dell_smm_device) { + platform_device_unregister(dell_smm_device); + platform_driver_unregister(&dell_smm_driver); + } else { + wmi_driver_unregister(&dell_smm_wmi_driver); + } } module_init(i8k_init); diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c index a78ddd83cda0..0b3e63c21d26 100644 --- a/drivers/platform/x86/wmi.c +++ b/drivers/platform/x86/wmi.c @@ -106,6 +106,7 @@ MODULE_DEVICE_TABLE(acpi, wmi_device_ids); static const char * const allow_duplicates[] = { "05901221-D566-11D1-B2F0-00A0C9062910", /* wmi-bmof */ "8A42EA14-4F2A-FD45-6422-0087F7A7E608", /* dell-wmi-ddv */ + "F1DDEE52-063C-4784-A11E-8A06684B9B01", /* dell-smm-hwmon */ NULL }; From patchwork Sat Nov 4 15:55:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445562 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 03EAAC4167B for ; Sat, 4 Nov 2023 15:56:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232406AbjKDP4x (ORCPT ); Sat, 4 Nov 2023 11:56:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjKDP4q (ORCPT ); Sat, 4 Nov 2023 11:56:46 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D98A5D45; Sat, 4 Nov 2023 08:56:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113380; x=1699718180; i=w_armin@gmx.de; bh=q6cARFSLIG3o2btPPaMZi74WireLHu6yHBRBI8lSF8g=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=T4AMUjbpECECbLgusPKR+/3VijUyy/WvxJaLNjQgipPH2+8zj4BRMia1FBb4dLAA XizBqVaOZpMr2eM+X/IxdETJAFHX52jKY/klMT7dH7aE/vlxBWKYUglUPU//o27b4 9ONXITnL68B5te146m+UbSxHHZkwLJpDeu5AgASU7gE1EXRDZgJkItGtwL7P7Dx+p FuKffuwaNXHpG8rS+MOOsE0dbeafoG8mrLdFOT40vw7liUwysjeOt2CJcYcQ8vTPc 5CgPWm26fN62b2K86t7gDekl8NCU1ujyGk2m4JC5BebT+LcuFhaQkZVJTp4x/sphO fJLkjBV1hXZdX2PPJg== 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 1N3bSj-1rPSpL0mbj-010cIP; Sat, 04 Nov 2023 16:56:20 +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 8/9] hwmon: (dell-smm) Document the WMI SMM interface Date: Sat, 4 Nov 2023 16:55:58 +0100 Message-Id: <20231104155559.11842-9-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:kOBTuwVlIrQcUiY2l/atFBfUWYfK96gs1cBaS8Txv8qiXZh9Qcs vATNekt57z+yXPAp+xLIc+uJ9L5nnMstUtUycNJ3xZwHGSWImwfJ229v6yHMladI/H7U3Vi +ueHaAzA0Fcgd18WWwfsM1Gw4iDucb40fBdyLe/coiCx0aYcMC8FJFhyVDhMZf14n5j2Pxf AL0a//ViivMx/VWYADiFQ== UI-OutboundReport: notjunk:1;M01:P0:Zfn4TXe2Lkg=;EqBE00tFK915qpptKI8QT50k7WE 9oV4ViRnTUGwu+yz0gvbN6yrXvF57jFNu+ch7xq7bbCjFG6W+z+jRRjx0hg8RmbKFtBcJ0KYr w+DLwvEYq02A0YcKMNXPb1npKADXz//4xnKyErJcCkDMa+Us5NKh5SPG0KGlyQ1cdmV+JVfGl V6ubQT6/yYuAkeP6v3yBm1QxkgoLfMtbI3vqd+bZ5OZ1muwNfLXyguFnkL2Z22DpMnRpOwRqL FuZvTcPGJT0jwuHTqEbsYJJy8bG20yYBvCHmmXLpnEm3KOWKPs3gwqlBgVwoSDH4HYkTu5IMF 3v/gBQxXKeUshOvwM5EFH/SGSJZ2dDQEhUcpOaOs1ff/GqKUQDfukAO0MfhG4Ug6D9WKHiqfr Cg+xkSGrq4WLssUIw24w07VgIs9vE/Cc6ARb8bf9Kwz31m5j4ySTynCV9k0KOUsNRZgqm9RHQ tuf+yk2WmTJ/Zku/JKMdizYbrsqwln2UK/xwdv7FzmJOGRw2HjUEUthTzO6RlXoc2afOuyXHm MX9FfE7i9VzLhJ08nSY6P5MaDlSGEt4Q1gabJ0owxSJ24IJA8FbDv9rNa9xGjTf5M/AQIKemE UQUb/+f0PZTe/ktHCR1ueDnj64hIdsvd71K5vrY2V7ETUPBk3ccJC05ha7fIN/en524AapxHt Y3/krSlc9NFNvEEsXnP3ZRiWyWnCZGAqlRbZVCs2t/KC8dDO6YbVYhjErOhs2HeW7fr6xH7v3 lJwogwaByOrM50auhIeVpuP+gjkxDPIdbt8Udiij7BCVCfJHiGefKgXYgEG3/1sWvqg06IaLI yYkRc/v8SY+UWCUPgIDVpdF5+BISKAFCBOYAFt9GZhiJHxk4Yy6Td79nlJAH2bhE9JxZPHsCf W+DjUnmkvpwGD9xEB0Vv3bF8wPuEGwkQIiqetFhAfpJh9uXjWxcx0SXpDLLLZtkNOrSEXZfFU Vm7JLcaj1egCx2RYFfmXk0lnJno= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Document the WMI SMM interface so that future developers can better understand how it works. Signed-off-by: Armin Wolf --- Documentation/hwmon/dell-smm-hwmon.rst | 38 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) -- 2.39.2 diff --git a/Documentation/hwmon/dell-smm-hwmon.rst b/Documentation/hwmon/dell-smm-hwmon.rst index d8f1d6859b96..977263cb57a8 100644 --- a/Documentation/hwmon/dell-smm-hwmon.rst +++ b/Documentation/hwmon/dell-smm-hwmon.rst @@ -186,8 +186,7 @@ SMM Interface The driver uses the SMM interface to send commands to the system BIOS. This interface is normally used by Dell's 32-bit diagnostic program or on newer notebook models by the buildin BIOS diagnostics. -The SMM is triggered by writing to the special ioports ``0xb2`` and ``0x84``, -and may cause short hangs when the BIOS code is taking too long to +The SMM may cause short hangs when the BIOS code is taking too long to execute. The SMM handler inside the system BIOS looks at the contents of the @@ -210,7 +209,40 @@ The SMM handler can signal a failure by either: - setting the lower sixteen bits of ``eax`` to ``0xffff`` - not modifying ``eax`` at all -- setting the carry flag +- setting the carry flag (legacy SMM interface only) + +Legacy SMM Interface +-------------------- + +When using the legacy SMM interface, a SMM is triggered by writing the least significant byte +of the command code to the special ioports ``0xb2`` and ``0x84``. This interface is not +described inside the ACPI tables and can thus only be detected by issuing a test SMM call. + +WMI SMM Interface +----------------- + +On modern Dell machines, the SMM calls are done over ACPI WMI: + +:: + + #pragma namespace("\\\\.\\root\\dcim\\sysman\\diagnostics") + [WMI, Provider("Provider_DiagnosticsServices"), Dynamic, Locale("MS\\0x409"), + Description("RunDellDiag"), guid("{F1DDEE52-063C-4784-A11E-8A06684B9B01}")] + class LegacyDiags { + [key, read] string InstanceName; + [read] boolean Active; + + [WmiMethodId(1), Implemented, read, write, Description("Legacy Method ")] + void Execute([in, out] uint32 EaxLen, [in, out, WmiSizeIs("EaxLen") : ToInstance] uint8 EaxVal[], + [in, out] uint32 EbxLen, [in, out, WmiSizeIs("EbxLen") : ToInstance] uint8 EbxVal[], + [in, out] uint32 EcxLen, [in, out, WmiSizeIs("EcxLen") : ToInstance] uint8 EcxVal[], + [in, out] uint32 EdxLen, [in, out, WmiSizeIs("EdxLen") : ToInstance] uint8 EdxVal[]); + }; + +Some machines support only the WMI SMM interface, while some machines support both interfaces. +The driver automatically detects which interfaces are present and will use the WMI SMM interface +if the legacy SMM interface is not present. The WMI SMM interface is usually slower than the +legacy SMM interface since ACPI methods need to be called in order to trigger a SMM. SMM command codes ----------------- From patchwork Sat Nov 4 15:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 13445563 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 C82F0C001B5 for ; Sat, 4 Nov 2023 15:56:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232387AbjKDP4z (ORCPT ); Sat, 4 Nov 2023 11:56:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232382AbjKDP4v (ORCPT ); Sat, 4 Nov 2023 11:56:51 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36B44D57; Sat, 4 Nov 2023 08:56:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1699113382; x=1699718182; i=w_armin@gmx.de; bh=Yxm7YEue2Zb4IoAPxRECzCcwA6ar5goRDg9DhTxupW8=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=r+971qWyLPKVKhJuArEptnH8DQjbfthcbisqcJXaN9QCcBgxkW19ZtZ1h+xDmLm2 VGi+qXjZ6JQJheCqZ+SbDcvueVou/0ln7ZtwzlrMDzqKNyNB86Oc2xKlNBjqRF0yQ 151mM8/mcsNaYRq4B1tDU7PhT8bwbYHBY2y9bFnwML0lkPSNPRMhGczbCv0zr2lxg Vk0e6yqLk0uisjAR3XvLXgEoWaEnnG7RTvGfiZX6Yrn0AFMG6glASOkxFtMaVO16l M5eCvtE1a5Vot7DPOqbe10smrKxM0AUYnNjpD63TVNqrgfzpiHbq5qVpwSP7hJf8h AqAn74GnmgqoJcIm7A== 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 (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MnJlc-1rgJFq01q8-00jFo7; Sat, 04 Nov 2023 16:56:22 +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 9/9] hwmon: (dell-smm) Add Optiplex 7000 to fan control whitelist Date: Sat, 4 Nov 2023 16:55:59 +0100 Message-Id: <20231104155559.11842-10-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:fYoOIO40BHEsB3Rh5dXnxI0AYtMbi5P9wRy2Xwq8egeIgFB1WN6 wzidT2aPjgCL2U5XXzm5+yMQc7GaCkQ0boeHGHdPF/AiqacnSv1u+QCFswGp4AQTIl/meM5 nIO46XZwjzzOF+pIC8Sh6GpM3q0cQ0mH8yA4JZKAtqFWkx+oecHxpm7Bps8nTLYPpo7qZOi JOK2uAxvQGJ5uT1+AN5RQ== UI-OutboundReport: notjunk:1;M01:P0:TqDVS66/gCo=;Ti/02sBVT753x5goa2Cl39mNSxE rNT/sbP1IVk4ipsCJn2pvqPlLBgJQKwixtGgN+UpkBI/ySKP9yIwptwSXiC1JuV8v0l0Oh5tJ sPBNDOjjcEBvuPy+dA0FMplth/n8r0pqXVJN3WTNU4XiRtrPOYzezJL/mS7/HY19KR8yt1VGW Yb+AmhoBNGvGl+pc4HhW8me7SaM1xB3ZVd10n1xD4dg0g+ST8Yn7Xm7urppeUZu1CTRLF7+Od H0RRfLPEPu0UFrKz5Rl6dYdYVBzscwGK9kOtQQ5D2FCeFhMY6dju3FClLBh7M/mgjFXfp+/YR FE/C3wFFhmWbYdRC+mPJMljKKFrkc56zEmgK8yiSvlw73D/PDnCo6Lxhr9RJBEeyfTLvwxTEC tCVoTCzA5d7sPuAfUm8ZrakUWhEfDWSqc82P2FS08GN/xeU7mYp5ni0veHQrbqtlS45OrrWr3 na9P2r7JZt8lEGNI6wFE+cskUjW9eMJgODg1IBy4WXQKDBYSZS/N91Grbi/c4ePLP6fKOyN8I wi0k7p5L4w13e5ELEXAF9FI3wrdo+OTTaBbgHA6YnaAdFNIjZw2uZg1irboTt6f6jgm5xd+TM i+nNy+swjjx9G5VYlyS4uMISj3ic+O8LXW5HnoF7ETGLF5mUqj2u1JISxCsQunlIWGq0a8RYg ax0vU7br4K6zgNG6Frt4qL281HrBoNZPtCxITC2reeoIPVGHjoLE18+ga2fHjNHM/WLApqirq 6IzMBexwanXk1RPss10G0cBG49g8QgDMwK1i2cdOoqk1s668yku9pEA/sxIxICVR/v5awWD1z PRZl8SAs3CDn1DcRZ8jsbwh2+1NoTdhNGP62RFCV1f7WilQRA1Q26qrScZHS584cgr5lm7cIN Fr68wT6HBBAExSMTDvOnyYC60XtgrfLNcYrR1mTNFxSqipHfHUqQBpiEV/OQmfYguIdeiyk3L dWCvft3s+5Yfd99xLXoHhHnX8VI= Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org A user reported that on this machine, disabling BIOS fan control is necessary in order to change the fan speed. Signed-off-by: Armin Wolf --- drivers/hwmon/dell-smm-hwmon.c | 8 ++++++++ 1 file changed, 8 insertions(+) -- 2.39.2 diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c index 36d41262d579..6aa5a9950dfb 100644 --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -1474,6 +1474,14 @@ static const struct dmi_system_id i8k_whitelist_fan_control[] __initconst = { }, .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3], }, + { + .ident = "Dell Optiplex 7000", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), + DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "OptiPlex 7000"), + }, + .driver_data = (void *)&i8k_fan_control_data[I8K_FAN_34A3_35A3], + }, { } };