From: Armin Wolf <W_Armin@gmx.de>
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 v3 2/9] hwmon: (dell-smm) Move blacklist handling to module init
Date: Mon, 6 Nov 2023 07:43:44 +0100 [thread overview]
Message-ID: <20231106064351.42347-3-W_Armin@gmx.de> (raw)
In-Reply-To: <20231106064351.42347-1-W_Armin@gmx.de>
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.
Tested-by: <serverror@serverror.com>
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
drivers/hwmon/dell-smm-hwmon.c | 63 ++++++++++++++++++----------------
1 file changed, 34 insertions(+), 29 deletions(-)
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
*/
--
2.39.2
next prev parent reply other threads:[~2023-11-06 6:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 6:43 [PATCH v3 0/9] hwmon: (dell-smm) Add support for WMI SMM interface Armin Wolf
2023-11-06 6:43 ` [PATCH v3 1/9] hwmon: (dell-smm) Prepare for multiple SMM calling backends Armin Wolf
2023-11-06 6:43 ` Armin Wolf [this message]
2023-11-06 6:43 ` [PATCH v3 3/9] hwmon: (dell-smm) Move whitelist handling to module init Armin Wolf
2023-11-06 6:43 ` [PATCH v3 4/9] hwmon: (dell-smm) Move DMI config " Armin Wolf
2023-11-06 6:43 ` [PATCH v3 5/9] hwmon: (dell-smm) Move config entries out of i8k_dmi_table Armin Wolf
2023-11-06 6:43 ` [PATCH v3 6/9] hwmon: (dell-smm) Introduce helper function for data init Armin Wolf
2023-11-06 6:43 ` [PATCH v3 7/9] hwmon: (dell-smm) Add support for WMI SMM interface Armin Wolf
[not found] ` <20231114141259.culmdxsoa3hduudm@pali>
2023-11-17 22:31 ` Armin Wolf
2023-11-06 6:43 ` [PATCH v3 8/9] hwmon: (dell-smm) Document the " Armin Wolf
2023-11-06 6:43 ` [PATCH v3 9/9] hwmon: (dell-smm) Add Optiplex 7000 to fan control whitelist Armin Wolf
2023-11-13 19:55 ` [PATCH v3 0/9] hwmon: (dell-smm) Add support for WMI SMM interface Armin Wolf
2023-11-13 20:17 ` Hans de Goede
2023-11-14 13:57 ` Guenter Roeck
2023-11-14 14:08 ` Hans de Goede
2023-11-20 13:03 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231106064351.42347-3-W_Armin@gmx.de \
--to=w_armin@gmx.de \
--cc=hdegoede@redhat.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jdelvare@suse.com \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=markgross@kernel.org \
--cc=pali@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox