From patchwork Thu Nov 23 00:48:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168655 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1606599rwn; Wed, 22 Nov 2023 16:49:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGV5f77b2oqHlRw5Uqe21jw6Hm5BbeVmzVjpqtA7oM2XDs2O+Fqixsj5HIiBE1T5ClZ4qaj X-Received: by 2002:a05:6808:1804:b0:3ae:5bf5:4ad1 with SMTP id bh4-20020a056808180400b003ae5bf54ad1mr5357591oib.33.1700700584037; Wed, 22 Nov 2023 16:49:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700583; cv=none; d=google.com; s=arc-20160816; b=hN7wXUImHzW1oSiYxSOgrER4UUzXU1cC1tmFvzTO2h6PtbwpkgfVxrY4rD6dSQJfZ0 H8t9ALPj8PUxcvVCi3Y7dJ0tHHzjrQvGDBkLKnKfFP1RV5BRaOlYB9Ci+DEBulAa96TV BnZqWEJepJ+O6uUdIh2eWrF0LW0Uex4fA3ydsiI7ifKZxSGIa9d2b17+R4ewypbRLvqR rpRJS2rxyZcH82SEYcoIZwD8+qgZcMmip4stcpbDhGRH2Pss3k5LQKmN3dPtLCZLfkqU tXdkcqORhIAGY1vtuXLdaGPYlEBlzEvjt7X0zpweSH4RfCD5Hv1kqiI4pRzcbBELjcNP JcBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gtKg7QdqhIWm2qv2/w8uXe7ZAr93QBHKKfecJNAsRNM=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=ilHemP+JhjlUFOhRx0wsmMOBuxHcRLzGIPXaRbiGLt0X/lcAMQUGqH1uLHPu+H4frL qKol/Mhuv7IpEEYMY8UIHtbKv23u/RqIr73Nr8ZMDUEwYHlnfIpUeLgUzL6yYtYmYppz kSJhsxjNtk87eCf+rqn6bljMujAtwx+wP6c9USWYCpF2+fejjgNdvZtkCGxwWFAtyNkG RyR3zwAV/Vm89bTWqrdeoEnkEiuh37na88CZ3IYrq2q7AatjbtwYIwHzUA9uv6sgfmH2 e88Nkj6XRa4M8gowFVpQuHQaYJz+JkqjAxl/bldEh6nDB5/+AVb4+dj2mQpC+tJ+oO98 o/7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="J/7OK0V3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id h13-20020a63530d000000b005c1b2d279f3si214035pgb.342.2023.11.22.16.49.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:49:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="J/7OK0V3"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 0F171829993E; Wed, 22 Nov 2023 16:49:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231789AbjKWAtM (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjKWAtI (ORCPT ); Wed, 22 Nov 2023 19:49:08 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 198F2D43; Wed, 22 Nov 2023 16:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700518; x=1701305318; i=w_armin@gmx.de; bh=vN9/AGwAZ7hHpsYr/5uuOgGbFmCNiZkhioH9QxTq8j0=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=J/7OK0V3jb2fOh934xWWh9Ja7W2o6KgMXDZOOEgMCWD8nF2l4TI0kzWYe4R45SaN pgmpbetf1L5bR/BnE6Gq11hCzrt/BKWJFsITFRjBiDYPuIHWN/p8KG3cGPf8HiALu AnjZV3QPV+rfHdzQmFLk4BA7aCoMs/4sQnt+p9/PMjNpB9rWcvFkuMk79EIU/JR1O fBA0AxKfCj3Sh9907TAPgM02q29Sa41TM5X9AXtXdPwBSPkeRT2Mbymmn3gkl0I/1 CwGSz2wm5Y5Ds3HMjMlLlnrYwyeXEa10kR/LHqEaX2Lq59vuLwY/X1iTUmefeAnN9 /F4weA5tAa/51UGL5g== 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 1MqJqD-1rj8OT2Id9-00nR2l; Thu, 23 Nov 2023 01:48:38 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/9] hwmon: (dell-smm) Prepare for multiple SMM calling backends Date: Thu, 23 Nov 2023 01:48:12 +0100 Message-Id: <20231123004820.50635-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SSGhDbWwScPOVgMhnwx57AZjhgad7AV7sb20NS5b4FPRo4v0/iP CS9yx2xewBPE4s2/SkLSZiAXcIsrfTY30Da69nqxcNbvwLyiaGH9x/n9llxC4FeRrkQhbHr B8RjS3xux9S8lx6zpa3XyIsnOECc7CIDfeDhxmtHz3LlI0mYMFSSKtkxGQ1ImZxaxnj8Uwd gjWVODd63UGQC0iG4lpvQ== UI-OutboundReport: notjunk:1;M01:P0:cmTiCbHZ/58=;YfdcEiO/hCmQUefhgzbG8/OntPS ZjdJrLVRajGJS5dtCKE885GnisLb1goVTzHX2XJ/JX4vuM4QpgBBfaVnJB1sjKq5YzOXKdAcq ey86UKEL9A/J9YmvhH2eXYNyxVpw0mJwEOqm0UBIgEVfEfP/miMMnllvdlk604jkFLI8TMvad luYFpNoCETmjJ2EkrER7d7kNyit1XhwXoS5RQyKhbEX2UAgXaN2lkJ8Y0c6rrrtNZpfeX3h7W 90XC7d4uTM2og8h66y6iv4yXYyk9u1rgmJXDvVgGH8f8vC72gYd1Jh8r3oOzTU9JzyQryUz1s 2WYeH2XetzG4bjlaUsYcAn+nzhH8S+DHBZGPgr0Rg+jCzg9miZRNt+TLGbqq3qbsYu4WPGvqF lZ8sFx/oXCUDhdtK8Yc89cy5xn/LF664lNSdNY2iWOOYiaap50LRuE25rZ0mAQpydaK4vAr47 TVC70ugruhMDZD//Y4tFzzUF+YB9DU38DXGwSdTOSFCgPn8ef6he3eVq4Zu3PZQxhIn27tzwN Do9q4M6o+z2YsJBR+8OTUPoa7HIO1XT8LhZTw0jZT8R2Fp/FCVSn//mY0wNBNx9DwbcIxy92Y /19aFL/vZvVv04H3GpBYnXfn6M2g0HKU4nS5SKxeG1e+XFItTIn7ZlSyUXwmODg875iPFzK3Y VerJiYBT+WtxS/BELyJYVz+GlY4ETVBbiZcTgrqXSF2YBZrAupWHcaZG815uUAF90CQ0BLu+T CVsfxfZjLeHdsZDMcuuEerxhImwjsI2rBa89fR/kV5FlIUGH3d3+w4CGRPxObVxGxSly3bOtb tIYFFRhgycTslDC7OXW2R0o2jL1WhncSBVYbyZfvA1Vs2n27unSKJPOZJrVh61zk4CcDsa90S rEd37DFPvAvmqlriPz3u7TF1a+SnkZCK+2JhABL3T+KntyPYomrWchCgKo62owFOZp0jHPqlW J97qAR1ZlUkGEq6W+7jUoYR9w7E= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:16 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313815823931338 X-GMAIL-MSGID: 1783313815823931338 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. Tested-by: Reviewed-by: Hans de Goede 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..f66bcfd7c330 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 { + unsigned int eax; + unsigned int ebx; + unsigned int ecx; + unsigned int edx; + unsigned int esi; + unsigned 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) +{ + unsigned int eax = regs->eax; + unsigned 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 Thu Nov 23 00:48:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168653 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1606539rwn; Wed, 22 Nov 2023 16:49:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IFr+c33MhOM2cS85hcdqYnH7wFqM7hrj385ppEz2hIg1pV2Wa8jQ2FaIBDG9vD9YjVr9rih X-Received: by 2002:aca:1004:0:b0:3ae:12f6:ac51 with SMTP id 4-20020aca1004000000b003ae12f6ac51mr4332640oiq.41.1700700577724; Wed, 22 Nov 2023 16:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700577; cv=none; d=google.com; s=arc-20160816; b=LAmxJxKyKwYqC4AT7v4b3nW+NMMM66hR5UXFHX0anJqMJZJ+eoSUB9xyLln+PIQaZl lIHI4eBabUGrO9nMfp2TNEn4a+kjDur5lMZhJjZ7IWWuZSffRLbwFdiStma4P4jhLIBr 38e48XUCn0eVQKkAaj3fmreM3lbxzzgBNcgsh9QAkWo8PNlQBmyTgcqS7HRj++S+ix0u tm20k4rCC+kq+tHR3AIWtEjPbNtgV7CiBwpeyTxSI8mcznmeqGAcdoa1gBfVY9v/SjIu xOXW+3M6UokMzh3ae0NjLoJK5bLr4ZPBqFiQKiKY59/DXB5Sti/zWW7JUyXuekUPvT3d NMkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Xz8NihmmXCyWPDnxiHilc5d1sDDarPS1hBhtde/eSIg=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=AR+tsTJ0scV00J14DKB5BAEBtNCKQR8Dw6BfoVLK2i6BO2Vj6ndGc9hlG7NaRzGsOj A86o6jX6HMCWBFAouUEjt7cS62qAnOUi/8UcpZEdPPloJUmOW51FD7m7nk2qjORLMVMC 5LTfPTCZQlnShxitkitG3By+OPLuBY7an6NbLxTW8Ksg1dOj5aCGnqjbaqsxQ4GH3D40 c6xJnb1cbjZUy251MQUPh28WOD9FOz0CTQpvlFVGXkpMfsD7DQ0o8M9D8WThCjeHmZXz QsYcGlnDClc7yv4k6vdnbpec3m4QCoJL7GzwgKS2CNsNajTWf4O9pzw5nFn3Q+R3aMTU UDbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=RlVRdU5h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id o16-20020a656a50000000b005b98aa3f613si234024pgu.405.2023.11.22.16.49.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=RlVRdU5h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id ADE108299935; Wed, 22 Nov 2023 16:49:12 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231602AbjKWAtJ (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231656AbjKWAtI (ORCPT ); Wed, 22 Nov 2023 19:49:08 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA666D46; Wed, 22 Nov 2023 16:49:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700520; x=1701305320; i=w_armin@gmx.de; bh=0V3bzfnMuRNI/HSKvd9H3yajcogpKLc5fz8Tc5YYU+E=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=RlVRdU5hrO810MAZ5l8slJAU6xEjGmxBj81/5DEKCgNmCZW+WUSqEfJ1v7dGfSiA wlLoFsbVnXcIBqmLoLqH+AiI6390+ha7jRDKF+rz3uIwsO441F1q7WMsoOmjJQa1g fSvr05chP625v/LbfFnu+l2tq9oJlNaHGOrFvuEx1kbRZzmp0+E0aBF7MYUk7ZjWc AuP5Ux8rM/btC3b3rOE6Z0Bqg6qY4k1dkfIWIHULK1RIlvwojC93WIonoNzFq0Eoj OkRIfwCWk9Z6VZpZTqdskqWxRDmROtVKkaEiElOKOGnQ8KaaI25VU92iPkAJb2YQD 1zI/hQ8giuVdUmsDiQ== 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 1MDQiS-1rD5QP43c6-00AYWC; Thu, 23 Nov 2023 01:48:40 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/9] hwmon: (dell-smm) Move blacklist handling to module init Date: Thu, 23 Nov 2023 01:48:13 +0100 Message-Id: <20231123004820.50635-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:a/fdW2dy4yeFSAYerlCeoKCs5X20lLxsnjkJMe/xNOw3HCPoC0b XCdVWBKQNBxshBIX/abhURkl1ldltxDRzeB6YV7+y4wL/Xfljrkz/a7aXCq1dv4FUAIeatt YjDeqm8e+AD+XDAOIyZDCYI1QDxXOX/RICSzBeWaCKm0HQboZLJekwbo2sq7OEe4kpx9OE8 IcrImgBvEclY1pFxyPacA== UI-OutboundReport: notjunk:1;M01:P0:KJkxZR1bsD0=;EoBxRaRiYzt2O2djAy2Wczj9GZQ LBpLai+YmtYELmJKjvZveB/lIccuz6d4iYMiGCbpAg5Vh7UQPNt9TG1RbEJKOgCAUh5nA7HyK rcfzRTE9G0ksxJktUcGClPoPUlDXL9TNtz0Ar2AzDH51EShgVWs9dmjpGa4SqA40NlisS4CJH khNcdHBV4EqaLtjiYjgQmmqPi4dJKGbjwqMZfBpZPNKnKIjM4gzpo4oZqwbNFcTp3wViT1Tv4 7X34MHGNOkfA2SGbrZ9DXDFI7mCdb639shxgQclk6E7ujNTUXmmEhDX11UWpPcOP2K6d9adat XpYFircMd35CQO/8OtlLVioAosncJeeOI6E6SJ0pZr+eccilQ4g2ijFM2XJ6v2dwEzPalrf6H HmKAcm+2K+Chmd/D96z9dM20wfhdSaBO4d9w88M62kdQNuCk6lZp4sgPnyv2OL74gG/dzgfkl wj5+hJ1p5XTvvlRPRy+qvro5asKaFkhJQrGJaLe8f/h2WjWhJ04fptHADH8Nb+VqoLT/ijLx6 s0KTvsNy3UmcFFNALoTt5wuz4UicuXNmNmPUajQeKAeWq3rWVxgnJ8FsmOrFxkRnLcE1Cs8S+ jErCmYFqCNuZXLWR+Gz5xUKc/vYN+4fTePc3hRxgDqzhimfGLKpiGHL5qwYlPS7n6iNOt6rCX AlWR7C1QXfY7q9+PwlLzC7xGjg2pM/L1Flc/i0y9IIk0mgbNyhgLKSMI5S+WKrOFiEjAu27tK 0mXHMkhjh6wDbaXE01B4exNu4DbX9BiW6EJiOvsR6XB0a+lZBKPqMFK8xe3VhpXn0Y1E2pQGp r+29viAxMLELNPs4SU4N+2mafJ53s12xZGKHvl2/0fOJzh5/NkXhQhco0qQnLFYQWL7PiReo1 QKP5hmGvZQyF5yXK8ovHCxU23XUMhrcn07DqBfleAXVjrvqDvb2BbodzD4xeRmkot+L6pwIfS N0H3dA0w5+Emyzkw2SvNXTwodvk= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313808640043335 X-GMAIL-MSGID: 1783313808640043335 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: Reviewed-by: Hans de Goede 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 f66bcfd7c330..87d668799c9f 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 Thu Nov 23 00:48:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168652 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1606528rwn; Wed, 22 Nov 2023 16:49:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IFBveGLxcMje00AT9pjYKroioji+9zKNu4jK+Nvt3jR7KV88+T2mhtcAL/wp3tl1lb569AK X-Received: by 2002:a17:903:41c7:b0:1cf:6f1a:33b0 with SMTP id u7-20020a17090341c700b001cf6f1a33b0mr4397401ple.59.1700700575880; Wed, 22 Nov 2023 16:49:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700575; cv=none; d=google.com; s=arc-20160816; b=mQOOv4GxpXfVvDCVcf+DaKPKy3UYy2J5Emg8oZygzphfTNJJL8ne2ZmLfaQkoeYf0s crnt/Y2MDF++qKvdrqv733SAbBXNWWGT2YxzRaU99BfRM4sc4jfz35pwFhbc14etfchG wOqpiHkza88olRO0bJ8DbyRz201yw3f1fsRlT7cf1oG/9LsFb+jAu2Cmix0Bc1llPmkH WJF4bhxKV32r9U5oaa94FTXLH8pdwRbQefWN4ZAbPOkqaRdm5MwLMjiO9l9AOJmxSTha 4iowvvQ3GLIfOOc+YIW/U1xO3DJgi+u+eHSs6cZx2n7k71oqkJGXXsqu/h4A6FJEbt5Z mzLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Gkwepnos2efa5UuDgqgf/2gY08Z1AaSDPSIHSIX6g08=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=pp1YWhWML5a0HPMYYHgzmKV+Yy6PC9CBRNx3aXMMtqsmvNUKzgLsmlLn8689lVHCu6 6X8yhTeeFsKZXUhIP2PMOyF/SyZoHpbCYc3brSnX9gbrFBEgiFFnBbboKi7YckZd52ON tfD7nPamb6zdNcqo4GnDywjqf7HJUSLa8pp97RsGT6M6xzzjd7/mNchkze4p3AXxfLy5 I7zic/BsKBn+O1u4iaMw6/lHNTrpGhA94E/FtmvhlsILJK4p2u3eR6K/dEwCqExbeCng 4sdOuiheIBJ7B8E8VcsfenXyPS9DaYYT8NMcciBVUbRBD4/ChN4Xk8q2Dhgeovv0eJ65 kXLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BTUdNJ0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id d16-20020a170902ced000b001ca335f71bbsi76776plg.140.2023.11.22.16.49.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:49:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=BTUdNJ0l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 85F4B829588B; Wed, 22 Nov 2023 16:49:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232615AbjKWAtT (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231634AbjKWAtJ (ORCPT ); Wed, 22 Nov 2023 19:49:09 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC2841B6; Wed, 22 Nov 2023 16:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700521; x=1701305321; i=w_armin@gmx.de; bh=V0YTO8SuhbXFllpMUpGLmImayJAGwiYZye/V9QjFzzU=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=BTUdNJ0libzzPYhGTGfyiPHCmP13YSDytd77NrQDdazgGSvV8dum3u9GHlCAxEAi AwWKCSQjiwlMEGDSTnq/9ABTstng3jePMAxIC+owDRkON4C5vhEa7qbAsVGzqiiuw j2caZDqKu7+pZumE2d9HhscMryujg7GZscxOv950U3pn3U62DCT17XbFYQWmkJgmz NPPD/bpxtUCkqJL5flv94aiBtuB64G4GCCeKqZV/508Ff3LYYj2oGl71sOZ9/D88I pqZyPkRgM6NMVifMu/ZzIcL5q4tIptQicmhAFq/nsVUbFHtfVFR/G3U9fSYk7pM0M p+4qhji6nwODZwLtxg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from mx-amd-b650.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1M26rD-1r43161wPR-002YQT; Thu, 23 Nov 2023 01:48:41 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 3/9] hwmon: (dell-smm) Move whitelist handling to module init Date: Thu, 23 Nov 2023 01:48:14 +0100 Message-Id: <20231123004820.50635-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:sLZEVJEQ6YFGZknxrKfmcCR3R5oC/Vc18dLepzqElrW6tyI+9ns 6CoEKi1sItTiElnJddM9X3sZod+NwulAcAI2pMGcDeU/dnN17T2DSPjWB2Kl7xLr5Uxlx5f 7mFv72IPYkWe3LjaK35hwwmDzkWN8KBplTZLC9leOc+APSr4MacrF4meHrSYJc5DdjJx8B+ 8lE5EV7d37BoYkWA6YuoQ== UI-OutboundReport: notjunk:1;M01:P0:aD226kWhsiE=;dizW7S46DR9LjAKbC0E6GAHaNw0 IdZ2Rf0Qw6fn0LZL7kTyBz6FttjBc1Vb+4S8s8m2ZFc2vlABF76Zqb9a9SglVKFbaD6tP5F1U cjf4LDzq0pWeMMLHfFgaHNy8RNYMUqVO9t/woI0EUCH88LiqTsA3UZWbsyEgbP6mR9bYIZY2l VU1QqnHpLgmhNYnfp+hy6YdZx1cnGclCP3cJgz97rUXsKLogsHAJx3qZkvoMaRMXw98f8gpA7 hp5IPP2/YKPjRRL0OJp7QyZUr/KYJgjeXZd9GH3U+NqXEA5hlhwsvme/YNoWZhTgDCSBNXEFm EUpQxoYTxvipypauKG5ikHU16FqXbSHSiJwe3w6mXA8Vhtf8u8yt1+3SCE8ZyDnQGU52SMQ2G 9Ib/G3ha9U+tXao4aGUjijiFgD83lGCaA5X8rS0MsbmzEAKW+n2h+okIYary50kg4oVBfvUCj 1lPRCUSUUhWoxdwJgjQrvHfSrwFyYwWwvcFbPhkF/7UvEbfcIh1XkPF9YG89rmW4Xo1dUCtBo DY4WoAHNj2HySv8WeoTfj0t0fRy6nb9OXQNw51bEehjGbXkuuImHmpP1CME5ldkSL2y/kU+5j a7fI+NEgHSgEdtKYXkSLzMn5R2rnoFgGxIibpVqP7I+FNdJl5+/y4wYy3paRTH9sWpeaVEdF1 wx/UZszwWMzJGMncr7IcxnW5Y7y8Ma2yNnmy5pbupUPuAjmO6ffg97f1zh0yvghQu+49KafQy qAVlJhP/0HP5s7Kq61shy+BSp6+aWI+QANPK1jG2jqnycnIXjB3LhYVmaZt97/RUWP7KwsO2w 8XuUDYp+DVUWhjrTZFxVh+8ZYp2B79Tt6f6emCuEH/BOr4zHMwh/kg75y54/uvhnhpC9F+EeW gtQ4rGhqJP32o5UT+XCy7mxv2nIclO1sMTtiCtJj2xc5E/OoPSr1RvDUFzsjE6/9aclA7myQ5 Lb+2YRRXUSXX4BmIUwHJ2uWwaEw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:24 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313807393132604 X-GMAIL-MSGID: 1783313807393132604 Future SMM calling backends will not be able to probe during module init, meaning the DMI tables used for whitelisting features would have to drop their __initconst attribute. Prevent this by moving the whitelist handling to module init. Tested-by: Reviewed-by: Hans de Goede Signed-off-by: Armin Wolf --- 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 87d668799c9f..1cbdfd77773e 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 Thu Nov 23 00:48:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168657 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1607218rwn; Wed, 22 Nov 2023 16:51:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0w1I6CG4gn8SvpjjRhtTT2Bq9HbpaqwtbEwcDu5Kg9pKVt1Z9BAEMD7UwUQ+d8YCeTmKF X-Received: by 2002:a05:6870:72ce:b0:1f0:3d9c:173a with SMTP id o14-20020a05687072ce00b001f03d9c173amr4316588oak.56.1700700674714; Wed, 22 Nov 2023 16:51:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700674; cv=none; d=google.com; s=arc-20160816; b=tHBFBha8EynSOs5S/xSmmSlymG+xQD9+w/1KNNptsaKltD6h0xTorjW29kh6vGRQtu byGYSe7PaCLm+fsULQQye1asiNRoT2adjormwbdVRb1+a0nOcwKOqcON5279fPku3fG9 xPPSASqjWBrddUXZEvOowl26UpJPVfhMbNfLyN/oP6dg5vLpMc/lQnzIqTQuJ0Yg90kB JGFkGdCbzp/GJQc/4YpwBBaKEQFDhkg84xB/lvXnu7OhLF07zWjbswG1j/W2XkNdUJKR xK71DKbbGW8PSObNz5xddslbfaew8cGnY3lVqlT6Wv5oC7reFXoUCQxMrTLcztWcdLwc i0Og== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uClkZR2JRdcflwWNln/yWi9KWQJlAFZ7uSOv/SQGilU=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=HCYT9t9ApzX5OSbJzVi+NTxIvxcQa0kUU3Rz8hFOdOrplrrpW9+M5PkpPrkgbVK1DN VNyx+RDq6k3jslLtzuJsw+QQCGQx/oIaqbhabZZ7qTkKVKbQN4gWt4TR274SeTnIKUv2 2nExrHF4CH8vXMKn22Fq7BATEcSKZL7NcMYOgJUh/ncMFIfDR36s4wwgwqCVO2cJ3g2R nq9gGegHtVW48+sHu6krlAE1WsRvlyDHgRD6knPlPplsFsS0RcIvR5JBqETNZe+xbx4L iHIrlysm7potePzCyEX+Y+7huvwI8jIwNwQ1zfVpg1RCGfRr1ml3Mdjr4ZVo88Qd7wSG QK9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Mtles7Ez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id 27-20020a630d5b000000b005c21d7d1114si223698pgn.818.2023.11.22.16.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:51:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=Mtles7Ez; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 531C080847A1; Wed, 22 Nov 2023 16:49:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231430AbjKWAtQ (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbjKWAtJ (ORCPT ); Wed, 22 Nov 2023 19:49:09 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC3FD1BD; Wed, 22 Nov 2023 16:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700522; x=1701305322; i=w_armin@gmx.de; bh=t9QD/ghz7nbpurzY8iozN8tJI1kzOnEist27FbYvSvQ=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=Mtles7EzSVqQbMszQI45nuo00qd3BXj/exg9gcw0HcqM3e7qM204uNFuvhD2tDnU 8J0YEOxQyncetRcqJX1Jx//9jT778n4OVK6IZFHwWgDKJQrw9wTBR4Mmz1RGKDz7y QSDLGDB9a1x7FxX/oEZrEE2znZKSvVopVapAFCEEwkbm43aREFIo0PpVqX76hUSPw olyUCY7nBKYtL1YYrtVFNmlFCY0OteEu934JhrploaulIeDQ6KAdiq8LPBZatrc3w hvyQPHDTumtPBQko6D8U5mUGqvY8FYE3P+fykYOiBOUuqZ7Bn7DU00qcr/YLkU8Im P4bymtvi11UF2RApDQ== 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 1MI5Q5-1r8yhJ39wV-00FFXA; Thu, 23 Nov 2023 01:48:42 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/9] hwmon: (dell-smm) Move DMI config handling to module init Date: Thu, 23 Nov 2023 01:48:15 +0100 Message-Id: <20231123004820.50635-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:iGBciax+Bq0YhlreLfXl8VR+gufHlqPxt3aCT4NPCNzfLE/EnRU tJ2zYv/6Rd7+eiO94egjYakqLp6k/sbAMbZW69FcNf/qsiHYMOaeUHRi3XIvT2nKPPg7xFI mexHc2WbjW4g1/zn/bRKxI2Y37tzW5EZOmR+trqefsPjNk9i0B9jgQwh4/q3fSTKXAAbGT0 04lQrwELuUlr+CBwjNO4w== UI-OutboundReport: notjunk:1;M01:P0:LURS1TZZexg=;Xk8aLUbEZPsvU5bP3yS16K3cs0y b0jh/32jTbk512DJomOF3zTySYAqkVK3RQevOqb1gzFRecUd/NJFe0BeIPJlSGN429UvoDchx qQb/pTO0PIm+oCidY7yW+DfTQyl4R/U1MLjccfHfbnnQM8jvCiyjsWMSTzo//Lw5rZWlk6s4W J54u2BcpiwNSW22Un4Qrgy48341YqWDAc+rsiW6k2tgVsUZMa4v2nhp0syNBYukMrWZyN0k9a BgMikMYkK2pHiykJJ1PdKnn51FkyvZ84dPMJ/H9kaMjjwPxTr9Sr2UNhLRvB0Wgnpudj4geVS hGKzDe+lsVk+IwdAV6zA+ANUEyo82UOw+IbX81g7fYCCx+Jy189fiO0YhFSVeHzYYFXsqwlBS k8ntf9JZgrTe9QENHxMSY2ZoOTcHVOC1tgGN/sbHqnyZKzOXbhMOMX6ihBrMoMMycJnPEggxH jf2vYODb/pBOzQsSyRriOvClKMcWftMAAosdacjWwP2YvRU821l10NPJTnbvZfJoAyvTpBSS3 RF7Aw1oi27zv2MHWf2SqVZamPo4iTdnpnviSQN+e0Ca5GvOtkRH//RKYrBHliO0Td7VEMc4Vc +e2LxZa4oQEvL8Wun/DZyI4et8nDx4o87JCt2lykaM0rGdZwbZWNtV/Ap4DtPlxOc8S5U+3Eg UPepw9zV80ACVE/nM9DdefvDIW5H86PF3eYo9dWh26qqOZzoYkDbVug2fJri2Yqyr0tEyO/1O BLZgNLwdR/7E9p1vTDxGw9g5E/PVhQkkK6ffkCHCbY/z7tvVS9IrihDpXcFpicbFp7+clwK9c KCTAg5o7qH5IOJx/509BrVPnrRv73H6QK3lUea/PAknTWemOFE1ghnZFmO97nQvFmuOutNP22 coIYj5CwCyvojlAAQvLulj+QTytQqd6KnX4eTZAkRCcZG8Sv81MVZL4PXEQ3NevbSZRe/MXPk xmeS3Hmc6+iV13O6CjwOh9K6U5Y= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313910577909107 X-GMAIL-MSGID: 1783313910577909107 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. Tested-by: Reviewed-by: Hans de Goede 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 1cbdfd77773e..158b366b0329 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 Thu Nov 23 00:48:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168654 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1606537rwn; Wed, 22 Nov 2023 16:49:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPfAfGYTTYNFK7CMDdVUN0X39dgHZixmh6qUnFjRit8ywv/h4lVwrEqzcCkaiWKyj3fom4 X-Received: by 2002:a17:90b:3ecb:b0:27d:222c:f5eb with SMTP id rm11-20020a17090b3ecb00b0027d222cf5ebmr4605481pjb.11.1700700577525; Wed, 22 Nov 2023 16:49:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700577; cv=none; d=google.com; s=arc-20160816; b=C/YJd/SxLSX3pz3EFggQh4UY5oUfhU84LOxBBGSZwqyBcyTNALIKVo/K/eOLAM+tzp 929uH3ai3Q8CyzX4E2fodHqY7YDkcCgf82FvpjmA7BTStmpCdLzCx7F9IyTkfCdRaCI8 lgClKg4QGvQuUEU8YjyP+bPRWc4U83bN9YuspnxpL61+aPN3yT/Jlm3ViOjL8c1TMkIk fRmpOhfMrsO+nSHy82fKBgiMr7iwp85pjSlf5tj+G/j+I+JbvAKZthBhKg33M10SwLEl msPWIS9w8C4c5iD9tW84/mSxkrIkJ+iBoJX1rSFzY3uhKy8J+dwvp25Jz0jdcZXetsN1 V6WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9RbKdVAY6V5DQL0jYRx4/jBF3E8kBpWuxLj6+ybz6Yo=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=WRY+uxVkqrmkmPEFYz7Mj1OkwggUnJ/g7gbHGKGN9hHQdp5geZUNKp3YaHBMO8YhCP l9Y7l9Z4pNZlVDJOmXrgkHrEs0mcGuCcOKb9RIoLv2TnX6vBOcxlxvsPgGu90kHOASew yHCT3SnAv8ek4cs0jE8HLYvD76eNOLxhJQ7CgN5VLXmXhSUeBAjKePbm7hmKIP4H7FTu RU2EAJwxI5mtKJGshkhon7FiBcIhf4EICyBY1sUwkot051K7KiwRoKF5eqzJGRghumCo fIlv/26ZjGbGw/St6k8vY30wY567yySt7dW0VS7iek6ZVlsMPtsV2hdhgXk7R1mWxEnv 0YRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=HufgPuPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id p5-20020a17090a2d8500b002850f2ced2csi226477pjd.113.2023.11.22.16.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=HufgPuPv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id B747B829BC52; Wed, 22 Nov 2023 16:49:27 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231513AbjKWAtX (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232067AbjKWAtM (ORCPT ); Wed, 22 Nov 2023 19:49:12 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.19]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64BBAD49; Wed, 22 Nov 2023 16:49:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700524; x=1701305324; i=w_armin@gmx.de; bh=KqV/DIBXCzRSkmf9e2rBEm8mBLLViY5v9BapnVCJN2w=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=HufgPuPvQ+OH+9wKX/1SNgVsXkXWzfakRC05woxXYG85ERO1kos68e59qq9ukMK6 6uqHjAmMfqGnfFdyetXBtTjxiRvniLG9IMcaT13XutDKIcOVGOzjkYz5khilGkv7c xY+OsOAgXTbK0fhxaj4xBY3CH5bn/57osys446iAI2MYK56r6Jk+ntU916v8h0mQW +oJezp+nvfP51VWzN6YZ2Qf2Wq9sW99Gpr6xNn9beyIW4qIXTTiPJ7ekj8Nn6DksK jagSHAC8Ppm/OA7jNaGFI3Uti1JiDq6EUWByC+0uuuBk5HTsXd6VeKdEC4bLaC0Qk FST1Z/bt/eiMYXlQ8w== 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 1MHoN2-1r8hiM0cAo-00Euxp; Thu, 23 Nov 2023 01:48:44 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 5/9] hwmon: (dell-smm) Move config entries out of i8k_dmi_table Date: Thu, 23 Nov 2023 01:48:16 +0100 Message-Id: <20231123004820.50635-6-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:vaaVo1hflMoDX+hdoZg64NO9l9Ixs2VdyVbtRA4JehMwp8kbgo1 fnNzscXx26CWqDAnG8zXjXnENG20pTa+/YkrsTBhLMI3g0iZ9pDM7kArxLeiHMGoOPcg+43 EpAV739mPt2XZqWXcmA8zfnlkkQDeJkokPrrrwV9jNznStdLKxD8DvW7yNmqmHLX1mXR/1S Q1dk7u7WWjZKWLWP4PR+Q== UI-OutboundReport: notjunk:1;M01:P0:cXgHUFJvHjg=;ssyJA5TsbMaYyg5RejCI3ITcZKz Q9jWMG67xGcfirRcSo6WvCA84powdaT15cEiOeB8rGidrGhHe4xQ5wOHaF+LprdGLNh8K8Cog rtjMQ1WnFxCD46P6MzjPB1TKL7nz0JkIz4YxR+J6TX+mTKh82V1CXRQZBj9NJxUrzG9eWqEjZ dBoEl4SO2a41knTVZrTpP4UHyE5PP1ky9fTnNuPRIDB3eWXfwY8eeKfPFxHfrn4Piu1uFo50Z cxTAu0BavUhRZZh3JoXZ8+gXrNw2i/XaE5KfYWTPR29lVTmtTnbZvDE+EcBEUOmX1VS784Qg+ TTdqUiRLWJcZriQNj0cjW75RmHrpOzBhYZ0XwM6p4jZQ0GjqeGf1NCoYapC/eITQWB+8lunJI NCOAXX+gynSQrPFvXwxpc/14H0znOloSJE2/ajmjlQAHNaKqsJw4fN2Pnlh2UZdA2PF5cpl1v m4lzffugouNOr6V8MMhEh/4aE3fVX8U6rHtaIZgG+t8EOrVP3f5kMXUTQVqwD7oWLawUibvzT Qv/vKKZyP9QRieeoMUAUpyAeBnApOrkEZsF+imHRIApLAadyzeH+WYIbNx/+dao/F07SBSHsC GG+lbgrHyRF/H19I2i9d13RTHCCU0JgJKPJIBK1L/v/hCb4nGu5W/UnGk70q3iTHRt8CbuKA3 +Ev4nPz3ASEhko8V6PBIJYzT5SdooYewhy5FcPAbPF/V1cTxaQKjKLCKv5XkPA41FWjB/EgmW w806ooAydhAjlieYim2Q4Q1QiQ66CpityLi+tNMvULqYg4yEE7wTwtH/NKN9/wPgaQP8BkT8o lqyGneX5drq0RbDBxMhovy/qLkJzZlK4MCg8Rv1ldr/bTow8brXLEYNOdCRsFcZtA38IBaJ8h EeSpGtC4PjQQ3lzz1jaW1A2ahvCAzcZysHSX4FnX6tf8VZfCKRpWgaickbtrw97b4uRn1llNM iOyZgb61Vxmg00D4W6kloSffx4U= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:27 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313808587455556 X-GMAIL-MSGID: 1783313808587455556 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. Tested-by: Reviewed-by: Hans de Goede 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 158b366b0329..b60755070d86 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 Thu Nov 23 00:48:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168656 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1606707rwn; Wed, 22 Nov 2023 16:49:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IEYNxMjMagLJUiqY865kWLVwzZZfy9Ox0icOtzeM5flGOGLmAgWuWv56AM99V3D6ahNuSJ2 X-Received: by 2002:a17:90b:1d92:b0:27d:5964:4ee6 with SMTP id pf18-20020a17090b1d9200b0027d59644ee6mr4494860pjb.2.1700700596754; Wed, 22 Nov 2023 16:49:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700596; cv=none; d=google.com; s=arc-20160816; b=rKdLli7uXDArr20WAUuYQhxo7oCXhUut688hwHUFiEnumwCg0dEq7E+aE8nu1SkCWF rbPA5tyt+v8l+6CH4bRowbR+ORCD9diSWkeCkf1puxZiYiMK9mYW+2b5PFW+4ZB1Z9+c 7WPSS5Oh8Z+RgpmuGGs7QqNCNfab2b27et6ceIRoxDVvdV4xK1R+NKr9bsqI93Hm+Qyh YAfYYQPZTWh0T71RWV6xX87CIrJxjvp7VTt5HkHK3sjwVjHhK3k4sXzC9uVmml5zEFqU lSppiz0jaCkevYY0SmxPU/dQrFFG/NL5YV8Rp7DreiLGb8PR24h0w58CqFfClAghCuby uaWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QFDrrUDVWa6EgG6y99RTVMcOx+FMIfObxWok4DuPzh8=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=IJvcG4b88WFwvuvwyQqzdImxcCXosrmyQ9jnXafds5IMA0TLyzmnNTp9iI2wTMdXy8 YuvnkGVnZ3zzRebAgBwqzrlWDqnv4UUlZYUbvHv/nJJF6t8tFLuTU5jOimAarHWQEiIb pY+Ex2W5vaRRkYXWvIMlF0qol0PWVuKDQP4uPu4BBXOvxEY4kS5Ud96gPlKnzEO743b4 /VYKjDgtrGEC0LHwNItK6cEc3gtXvsyTI7adJKz5Hl9qQN46N+9BXZUzmc5hxFzuskjB 7vnfxCLG0bywgNCIgBR7Khm1wIgoEp3tlcVx85IsquQnlvOXCQxxY+nd2Uva6zKXJa6+ OAAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=b4YZg92r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id pf7-20020a17090b1d8700b002801ac582d0si227247pjb.185.2023.11.22.16.49.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:49:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=b4YZg92r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 10626829BC46; Wed, 22 Nov 2023 16:49:55 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235215AbjKWAtw (ORCPT + 99 others); Wed, 22 Nov 2023 19:49:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233574AbjKWAtg (ORCPT ); Wed, 22 Nov 2023 19:49:36 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B50CA10D4; Wed, 22 Nov 2023 16:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700528; x=1701305328; i=w_armin@gmx.de; bh=QU/fikrXASrkJJFGObsA5vw2cS6jYRUC5rQHjgXzBWY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=b4YZg92rZpXgWJwHyQaR89wsr6f1h5YT6xXq9koJ8NUf2t3+yNv2Ee4mVbtS4Boq swCa1tA7lUof4Gh+I4x0wBL4JPMGFSm91JyD56H4Kbo6VuzYLGW3m0Zy9gXA0/iwa NnQ1UVfSKP8++1mRS+oyedZw2JfgYZnSvjNCUdKtXsmU2z/QHK3r3n9YH+RsRP29Q c46zL1Z5/TXyOB7NSQhfGqRpemP56qZCguceI2pYG3R2Iv4LUOGKv5gFgyDjCdXj0 C2kdU/W/FbvDNiUmQMToL6YRwqfibHJq+yEIXOxOHkJjF3iG/ILl5sKVKYmyBGE8G Ajvq8HvG6yhX2YqGSQ== 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 1N0oBx-1rII7B24mr-00wjHn; Thu, 23 Nov 2023 01:48:48 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 7/9] hwmon: (dell-smm) Add support for WMI SMM interface Date: Thu, 23 Nov 2023 01:48:18 +0100 Message-Id: <20231123004820.50635-8-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:s1fMuo2wdlUW/5cyisDKRKTpMoW1C50KaQRYjugB04Y38gSWsU8 7P8sq9WhM2+3rsbHCb9g8lZwBM2WEI3ZRjLHrtfyWAtDU38RKqBso6u3m4kswo3f4RAODp0 TQ1hgfwwAzkvGGqJRon3F6edzvpmUQ2YAaemBcjjHlX8S8vLoBAbNSgaLXc115rcpTyhPS7 GHPsrxazmZoSjTSpLIWVg== UI-OutboundReport: notjunk:1;M01:P0:3vOS++G1dgY=;wy8NRIj7z5aVgjPDv0vEW0b2w7C PuVP5Z5KzEDM8xqt/F10e02U6GeOuPqeJycaxqr2e/V8wrsyklQgzs9boVgdRdNgEi0JawhaG jJfnZy9/b3B501rxYtyBmVNH1ljouadUK2RAJinCrJe3tWkHcin5gw1+3Ubo5adSjByO7QNEE lcktU1SNkbmIsYq6zDUhmhG5s4juRX6DptcROQMcA0IoCyuFU71kJZM1nGZf2SqWOVYqbiEmL urPLvxyUV0848KU0cxciKeIYjS1odUI3gF340MjAWIVASRkxpmyMtJbnwr9JiMDsjAqsgz8q6 s1qcaCwWP5qtVYXkEC6FiG17GqQtb3QptSV/6TSMmLipwAgh0dBePAv4dm1r5+fdBF3g6rNTK 99pKhOGb+1PlinjNmzzkIefQwuHtc5u27cVk9dDm0+nsAzSieWNiNIlnhW6JkC6Cbm8KdHTGG TM9ru/R4/DAOu4F6Alwv+868WA4EHJmoJtityBWqZ7DmehXBV05iiVkH05GtiAHDw9QE0b2M+ KuJkObNNParkwB/EdBcRw4JaGifrR5/n2gPJs31D5IPXqcoZLD1j3kuXrVS4IodxlZlaO21iY h8804gZmiOIONPg27DMZ0Jo9tsn5YIevsRzm3CTmcu1exV/Wk64EXrgK6aJpkYRCGCC8Qdrx2 fo/cH6WKruvVpNLCfNcSBCP+KRsWE7xy4VsV0Y8C4jT0EbTsxIZObrMWI1ZxxsF8eh3635jOx f4kJulMvWUg0gE3XVp3sgWY5mTXgXRvlfA+FROA1//uymtK55BC7wGpHXcudb3SE9ERxJPD/R Sv0k2Lr3bB+R5XqwCsTx3IDq8GZLCpA3klFxATjLpi5Y1FfiPbG3Nif+jX1TZo8zmQgDkeUCk QGk8jZsO1O2swo/1KsAdfqKC4bqGdChcR5quyUYQoyLJEp5plJK7VU3umIJMvncyGuVMRbe0d k13ylPMSjClPR2K2OLsoDVJmEgM= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:49:55 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313807299390310 X-GMAIL-MSGID: 1783313829224473468 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. Tested-by: Reviewed-by: Hans de Goede Signed-off-by: Armin Wolf --- drivers/hwmon/Kconfig | 1 + drivers/hwmon/dell-smm-hwmon.c | 199 +++++++++++++++++++++++++++++---- drivers/platform/x86/wmi.c | 1 + 3 files changed, 182 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 a377cd08355f..95330437c5af 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,9 @@ #define I8K_POWER_AC 0x05 #define I8K_POWER_BATTERY 0x01 +#define DELL_SMM_WMI_GUID "F1DDEE52-063C-4784-A11E-8A06684B9B01" +#define DELL_SMM_LEGACY_EXECUTE 0x1 + #define DELL_SMM_NO_TEMP 10 #define DELL_SMM_NO_FANS 3 @@ -219,6 +225,103 @@ static const struct dell_smm_ops i8k_smm_ops = { .smm_call = i8k_smm_call, }; +/* + * Call the System Management Mode BIOS over WMI. + */ +static ssize_t wmi_parse_register(u8 *buffer, u32 length, unsigned int *reg) +{ + __le32 value; + u32 reg_size; + + if (length <= sizeof(reg_size)) + return -ENODATA; + + reg_size = get_unaligned_le32(buffer); + if (!reg_size || reg_size > sizeof(value)) + return -ENOMSG; + + if (length < sizeof(reg_size) + reg_size) + return -ENODATA; + + memcpy_and_pad(&value, sizeof(value), buffer + sizeof(reg_size), reg_size, 0); + *reg = le32_to_cpu(value); + + return reg_size + sizeof(reg_size); +} + +static int wmi_parse_response(u8 *buffer, u32 length, struct smm_regs *regs) +{ + unsigned int *registers[] = { + ®s->eax, + ®s->ebx, + ®s->ecx, + ®s->edx + }; + u32 offset = 0; + ssize_t ret; + int i; + + for (i = 0; i < ARRAY_SIZE(registers); i++) { + if (offset >= length) + return -ENODATA; + + ret = wmi_parse_register(buffer + offset, length - offset, registers[i]); + if (ret < 0) + return ret; + + offset += ret; + } + + if (offset != length) + return -ENOMSG; + + return 0; +} + +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; + int ret; + + status = wmidev_evaluate_method(wdev, 0x0, DELL_SMM_LEGACY_EXECUTE, &in, &out); + if (ACPI_FAILURE(status)) + return -EIO; + + obj = out.pointer; + if (!obj) + return -ENODATA; + + if (obj->type != ACPI_TYPE_BUFFER) { + ret = -ENOMSG; + + goto err_free; + } + + ret = wmi_parse_response(obj->buffer.pointer, obj->buffer.length, regs); + +err_free: + kfree(obj); + + return ret; +} + static int dell_smm_call(const struct dell_smm_ops *ops, struct smm_regs *regs) { unsigned int eax = regs->eax; @@ -306,7 +409,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 +452,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 +504,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 +1089,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 +1120,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 +1186,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 +1512,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 +1540,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 +1632,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 +1679,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 5c27b4aa9690..d68a96a2c570 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 Thu Nov 23 00:48:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 168658 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:6f03:b0:164:83eb:24d7 with SMTP id r3csp1607648rwn; Wed, 22 Nov 2023 16:52:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFiupYAh8vDEHrQ4+RwOn4FG79warElDvqDRtiJrFnz01G2QxXTdBGDpYIRDlPK5ijHYPp5 X-Received: by 2002:a05:6870:d3c3:b0:1e9:bbfe:6457 with SMTP id l3-20020a056870d3c300b001e9bbfe6457mr5729590oag.6.1700700739220; Wed, 22 Nov 2023 16:52:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700700739; cv=none; d=google.com; s=arc-20160816; b=gUQPbIv3LjrcCrgBkatdePPLjtDRc8tkezbmP8/gZPzO8QvCwIYvJNiDna34jmt+lC H16+OqhxGTzNwQXDuLRSFqiTbuJPq8vECf8arQr7BLsZ+8dW4W0EK2qWialaTymru/Ch XjM2t8PvN+HI74Fw3Ov2/FcN6tpZioOZ5Xcv9AY7jLLwjjdHyqnqSGYRv9RsedfYz8Kd 30TT27g9OKgv+T7QV5F8emntJ8aXfWS6R/4Gt5PQVPjtHJdsEE/5c5gSqAllZ2KRM9l3 BHLg1rjfj4iBqwD9k6GYPTGrHvKPdhCk4knWrPhvDmPsTJhRS6Ml4cNHhI1gBPltbbJh xjlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YQOaD0isR9P5/SPrubRbWBRUfnphefV6kQLdftB4VHU=; fh=LbJc+26ESPHxBsYHQvEuE116sbQvfgEPUOE2p6r6f4A=; b=XaU1H18/0hqHf/v+dQV+VUMBY3HXoa7HfzLmLzGMFA+ZYK367rwYYqgl1t2owmmf9v uEe/0d10IQWIS12O4qT9zV+xE+tCAkIC7obrDm2hF9XYTwoNQ8y/hwONaG4ryfv59KrE RJxIgd5n9LBHmhSXCabaztHPG4ZLDQK0dIh7m2yKdMHBJ0zxrWqoRbicsudjbLRlGrUL MwT+ZVC8uzkJdK5BUN11Itae/QpUKYkpJG3zM8e672JU9khBgb5pmCgjpN1cs8Ux+3QN DptSUJGSdh1dQjmSO3T5AdVIeM0OvcxZbuZmrwnmewuIevgqa9qOXVG5LNx7kLxiAuUZ CNDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="NdJ4HKu/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id iz2-20020a170902ef8200b001cc16aa4981si72970plb.39.2023.11.22.16.52.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 16:52:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="NdJ4HKu/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 215A3807E41A; Wed, 22 Nov 2023 16:50:28 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234394AbjKWAuI (ORCPT + 99 others); Wed, 22 Nov 2023 19:50:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231179AbjKWAtu (ORCPT ); Wed, 22 Nov 2023 19:49:50 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F9D1171F; Wed, 22 Nov 2023 16:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1700700531; x=1701305331; i=w_armin@gmx.de; bh=IpekB6HD5lK7F+Kd+JJ/yZUrtd4vGeb83HYctPW2R2A=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To: References; b=NdJ4HKu/4pf25CY2MZm6gSq/iAN3XQT6Z8G+8KOQAdRChXMM9vMexkHsZ16giomR u9TQxLoqSYXjUKbZdM/LJUig0e34CQP6G6D9HVbHsZY7tc2fUHxqChbqCwOV6oZK/ 3CVVYsMH3beNP8RlV0CbhTRVhmjoqUysmb1W+z4jQlH+gb2avSDziI9niVPQ8vAhR C5zjkfOcCNMRnUYlUayNW3p0a68DWdeYJxIdFuMS70VgTCfwXVBWfqnVCUm6ISbIs IBV/px230m+lF/5TPTe1KCjPhb68txNd7TysHG75PJClK8zlH2vocu9IzTM+5DFui pHiVE8NgYwEBY9h/CA== 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 1MwQXN-1rMfpu0oSr-00sLCa; Thu, 23 Nov 2023 01:48:51 +0100 From: Armin Wolf To: pali@kernel.org Cc: jdelvare@suse.com, linux@roeck-us.net, hdegoede@redhat.com, markgross@kernel.org, ilpo.jarvinen@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 8/9] hwmon: (dell-smm) Document the WMI SMM interface Date: Thu, 23 Nov 2023 01:48:19 +0100 Message-Id: <20231123004820.50635-9-W_Armin@gmx.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231123004820.50635-1-W_Armin@gmx.de> References: <20231123004820.50635-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:jfeSQcpPOAV12U7567kj2GLK7TAcbn+LqR+47Zhm2vMDhL47PDT kH/3wLvLTHRuKXeW9AnRV7+T889shCc9R1mOwcP17d3PEstgxlLEtFv2A4dmAW/fTg8V48n a6laLjfk28PRBUdKv2ZmohZyVhUS0yZNTDkZScvM4XbGROwrY64KVhX7niMk2rznXyEy6Kl Iv4sFQ3caidVxOZgrE6SQ== UI-OutboundReport: notjunk:1;M01:P0:8JXhW/qO+Zs=;h+T4cUIgBQMOQdKZEU/teBj3t4n i7AQl3qZyclJo4S+GOIwYibtiZdooOORDmwWgbUXX9Mx27iuc50to6wffpCJSZviCvMjE0BPt YR4NkCbI6szgJgc5p89HcRVyM+eShAdI9J/cQcm6e8AToRkvdzxqvcJsBErpqbJfaSX8/kbGE StFPuQXDIf5yaclpnbrFGK8lNrPX6iTKgpaNRSLLJfIniI+Z/7XLT4lh6UDi7My+xSQFE2hXs T+BT4REcOn5vuyhe2tk78hEtGKIdaWsh8pjrXjFfm/dTJSz+8pEwRunbFqTllfl7t8vPXjBkc zUOFS0jM7dSVI5C/sg9+RI6udbe3vDt+kv5w6Lk1EKXybghY2TBReHqxtRhWgeVOkh8uQfeCk skigdNF26DvAHS5UDj/pxcQJmF/dRXQYeWJjtA0kCarYsmqnl2pm8gLEjjj7wrYQkU0vt0/MU nL1wkqXO72ZDtz8v9Pcdr6Su0WSDCGADOWUYULuOZFaNeCfRCiuCl1fk0RozeKCdTd0E3DTCE RdA89SnXNAVaN0PVMiXzRIXqaMZUBau/ONxEEQ3cBoHDjqQL/N0ypYcuq140DNh2EXcCvpITB kGMDOJkF6PWvE9EqyIMhXRs+DTNmMJF7IcR/a/Xp6czr0XMvpGTTKVs/aVL692C7mS0fu1TeC d57+HARJOEvXr4p7fVUtGtQIH8GoXnvHj1aLsyrtWIT82kJxqi2NvPdEuP729QRXn1g+aUxF4 m4qT8H7mPgmLYsgiwAGurL2LAD/KiUtdba1K9wHZ4p/qu33wiReUBEjz69Jsv+DhLHqEpRifu f3AohTK+0RN7lIfjIFNY6jvN8zrLc6dXDtepZqQ5Rf0/sSfiAZSOWL6KvBEW8d3TWpyrDKOJc usV0DFgtzutjNz7FZsSwqA5IgnJV+ke370JTrGls6z/UhOV4ZjOvZgsGcCmb9R6uVK1Ye9Nvo 3im6R+Q1GYDYuQC6dLw9f9jOO7U= X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 22 Nov 2023 16:50:29 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783313978395080696 X-GMAIL-MSGID: 1783313978395080696 Document the WMI SMM interface so that future developers can better understand how it works. Reviewed-by: Hans de Goede 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 -----------------