Commit Graph

53 Commits

Author SHA1 Message Date
Muchun Song 359745d783 proc: remove PDE_DATA() completely
Remove PDE_DATA() completely and replace it with pde_data().

[akpm@linux-foundation.org: fix naming clash in drivers/nubus/proc.c]
[akpm@linux-foundation.org: now fix it properly]

Link: https://lkml.kernel.org/r/20211124081956.87711-2-songmuchun@bytedance.com
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2022-01-22 08:33:37 +02:00
Armin Wolf 565210c781 hwmon: (dell-smm) Pack the whole smm_regs struct
When desiring the whole struct to be packed, __packed
should be applied to the whole struct, not just
every struct member except the first one.

Tested on a Dell Inspiron 3505.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20211221162805.104202-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-12-26 15:02:07 -08:00
Armin Wolf 87b93329fd hwmon: (dell-smm) Unify i8k_ioctl() and i8k_ioctl_unlocked()
The only purpose of i8k_ioctl() is to call i8k_ioctl_unlocked()
with i8k_mutex held. Judging from the hwmon code, this mutex
only needs to be held when setting the fan speed/mode, so
the operation of I8K_SET_FAN is guaranteed to be atomic.
Unify both functions and reduce the locking of i8k_mutex
to I8K_SET_FAN.

Tested on a Dell Inspiron 3505.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211211155422.16830-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-12-26 15:02:06 -08:00
Armin Wolf 0240538774 hwmon: (dell-smm) Simplify ioctl handler
The second switch-case has no real purpose:

- for I8K_BIOS_VERSION, val does not represent a return value,
  making the check for error values unnecessary.
- for I8K_MACHINE_ID, val remains zero, so the error check is
  unnecessary too.

Remove the switch-case and move the calls to copy_to_user()
into the first switch-case for I8K_BIOS_VERSION/_MACHINE_ID.
Omit buff[] since data->bios_machineid already contains the string
with the necessary zero padding through devm_kzalloc().

Tested on a Dell Inspiron 3505.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211211155422.16830-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-12-26 15:02:06 -08:00
Armin Wolf dbd3e6eaf3 hwmon: (dell-smm) Fix warning on /proc/i8k creation error
The removal function is called regardless of whether
/proc/i8k was created successfully or not, the later
causing a WARN() on module removal.
Fix that by only registering the removal function
if /proc/i8k was created successfully.

Tested on a Inspiron 3505.

Fixes: 039ae58503 ("hwmon: Allow to compile dell-smm-hwmon driver without /proc/i8k")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211112171440.59006-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-11-14 16:57:16 -08:00
Armin Wolf c0d79987a0 hwmon: (dell-smm) Speed up setting of fan speed
When setting the fan speed, i8k_set_fan() calls i8k_get_fan_status(),
causing an unnecessary SMM call since from the two users of this
function, only i8k_ioctl_unlocked() needs to know the new fan status
while dell_smm_write() ignores the new fan status.
Since SMM calls can be very slow while also making error reporting
difficult for dell_smm_write(), remove the function call from
i8k_set_fan() and call it separately in i8k_ioctl_unlocked().

Tested on a Dell Inspiron 3505.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-6-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf 927d89ee96 hwmon: (dell-smm) Add comment explaining usage of i8k_config_data[]
i8k_config_data[] should only be used for applying device specific
quirks in case autoconfig does not work properly on certain
devices.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-5-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf e64325e8c5 hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVAL
Returning -ENOIOCTLCMD gives the callers a better
hint of what went wrong and is the recommended
behavior.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-4-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf 38c5b0dd7d hwmon: (dell-smm) Use strscpy_pad()
Using strscpy_pad() allows for fewer memory accesses
since memset() will not unconditionally zero-out
the whole buffer.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf 6105870f79 hwmon: (dell-smm) Sort includes in alphabetical order
Sort includes for better overview.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20211021190531.17379-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-21 13:14:27 -07:00
Armin Wolf b1986c8e31 hwmon: (dell-smm) Add support for fanX_min, fanX_max and fanX_target
The nominal speed of each fan can be obtained with
i8k_get_fan_nominal_speed(), however the result is not available
from userspace.
Change that by adding fanX_min, fanX_max and fanX_target attributes.
All are RO since fan control happens over pwm.

Tested on a Dell Inspiron 3505 and a Dell Latitude C600.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210926221044.14327-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-16 14:58:42 -07:00
Armin Wolf 8a0c75a1c3 hwmon: (dell-smm) Remove unnecessary includes
sched.h and io.h are not used anywhere in dell-smm-hwmon.c.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210926221044.14327-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-10-12 07:22:42 -07:00
Armin Wolf 8713b4a49c hwmon: (dell-smm) Rework SMM function debugging
Drop #ifdef DEBUG and use ktime_us_delta()
for improved precision.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814190516.26718-1-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Armin Wolf 782a99c146 hwmon: (dell-smm) Mark i8k_get_fan_nominal_speed as __init
Mark function i8k_get_fan_nominal_speed() as __init since
it is only used in code also marked as __init.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814143637.11922-5-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Armin Wolf c510f6accb hwmon: (dell-smm) Mark tables as __initconst
Both the config and the DMI tables never change and
are only used during module init for setting up
the device data struct.
Mark all of them as const and __initconst for a
smaller runtime memory footprint.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210814143637.11922-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:27 -07:00
Sebastian Andrzej Siewior e104d530f3 hwmon: Replace deprecated CPU-hotplug functions.
The functions get_online_cpus() and put_online_cpus() have been
deprecated during the CPU hotplug rework. They map directly to
cpus_read_lock() and cpus_read_unlock().

Replace deprecated CPU-hotplug functions with the official version.
The behavior remains unchanged.

Cc: Jean Delvare <jdelvare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Cc: linux-hwmon@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20210803141621.780504-14-bigeasy@linutronix.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Carlos Alberto Lopez Perez 95d88d054a hwmon: (dell-smm) Add Dell Precision 7510 to fan control whitelist
This allows manual PWM control without the BIOS fighting back on Dell
Precision 7510. Meanwhile at it, also sort alphabetically the entries
of the i8k_whitelist_fan_control struct.

Signed-off-by: Carlos Alberto Lopez Perez <clopez@igalia.com>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210802131538.8660-1-clopez@igalia.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf 2757269a7d hwmon: (dell-smm-hwmon) Fix fan mutliplier detection for 3rd fan
There are up to three fans, but the detection omits the 3rd one.
Fix that by using DELL_SMM_NO_FANS.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Fixes: 747bc8b063 (hwmon: (dell-smm) Detect fan with index=2)
Link: https://lore.kernel.org/r/20210728221557.8891-7-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf deeba244b0 hwmon: (dell-smm-hwmon) Convert to devm_hwmon_device_register_with_info()
Convert to new registration API to get rid of attribute magic
numbers and reduce module size.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210728221557.8891-6-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf ba04d73c26 hwmon: (dell-smm-hwmon) Move variables into a driver private data structure
Move Variables into a driver private data structure.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210728221557.8891-5-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf a2cb66b476 hwmon: (dell-smm-hwmon) Use devm_add_action_or_reset()
Use devm_add_action_or_reset() for calling i8k_exit_procfs()
so the remove() function in dell_smm_driver can be omitted.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210728221557.8891-4-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:26 -07:00
Armin Wolf c9363cdf3a hwmon: (dell-smm-hwmon) Mark functions as __init
i8k_get_dmi_data() and i8k_get_dell_signature() are
only called during module init and probe, which both
are marked as __init.
Also mark these function as __init to lower the runtime
memory footprint.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Tested-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210728221557.8891-3-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf 1492fa21c0 hwmon: (dell-smm-hwmon) Use platform device
Register a platform device for usage with
devm_hwmon_device_register_with_groups since
the platform device is necessary for future
changes.
Also fix some checkpatch warnings.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20210728221557.8891-2-W_Armin@gmx.de
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-08-17 14:54:25 -07:00
Armin Wolf 35d470b5fb hwmon: (dell-smm-hwmon) Fix index values
When support for up to 10 temp sensors and for disabling automatic BIOS
fan control was added, noone updated the index values used for
disallowing fan support and fan type calls.
Fix those values.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210513154546.12430-1-W_Armin@gmx.de
Fixes: 1bb46a20e7 ("hwmon: (dell-smm) Support up to 10 temp sensors")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-05-16 16:00:55 -07:00
Sebastian Oechsle 807b8c29db hwmon: (dell-smm) Add Dell Latitude E7440 to fan control whitelist
Allow manual PWM control on Dell Latitude E7440.

Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20210411095741.zmllsuc7pevdipvy@icloud.com
Signed-off-by: Sebastian Oechsle <setboolean@icloud.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-04-20 06:50:14 -07:00
Thomas Hebb 4008bc7d39 hwmon: (dell-smm) Add XPS 15 L502X to fan control blacklist
It has been reported[0] that the Dell XPS 15 L502X exhibits similar
freezing behavior to the other systems[1] on this blacklist. The issue
was exposed by a prior change of mine to automatically load
dell_smm_hwmon on a wider set of XPS models. To fix the regression, add
this model to the blacklist.

[0] https://bugzilla.kernel.org/show_bug.cgi?id=211081
[1] https://bugzilla.kernel.org/show_bug.cgi?id=195751

Fixes: b8a13e5e8f ("hwmon: (dell-smm) Use one DMI match for all XPS models")
Cc: stable@vger.kernel.org
Reported-by: Bob Hepple <bob.hepple@gmail.com>
Tested-by: Bob Hepple <bob.hepple@gmail.com>
Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/a09eea7616881d40d2db2fb5fa2770dc6166bdae.1611456351.git.tommyhebb@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2021-01-27 17:44:00 -08:00
Jeffrey Lin 0ca8bb2cc9 hwmon: (dell-smm) Add Latitude 5480 to fan control whitelist
This allows manual PWM control without the BIOS fighting back on Dell
Latitude 5480.

Signed-off-by: Jeffrey Lin <jeffrey@icurse.nl>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20200621045246.929649-1-jeffrey@icurse.nl
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-07-19 16:25:20 -07:00
Thomas Hebb b8a13e5e8f hwmon: (dell-smm) Use one DMI match for all XPS models
Currently, each new XPS has to be added manually for module autoloading
to work. Since fan multiplier autodetection should work fine on all XPS
models, just match them all with one block like is done for Precision
and Studio.

The only match we replace that doesn't already use autodetection is
"XPS13" which, according to Google, only matches the XPS 13 9333. (All
other XPS 13 models have "XPS" as its own word, surrounded by spaces.)
According to the thread at [1], autodetection works for the XPS 13 9333,
meaning this shouldn't regress it. I do not own one to confirm with,
though.

Tested on an XPS 13 9350 and confirmed the module now autoloads and
reports reasonable-looking data. I am using BIOS 1.12.2 and do not see
any freezes when querying fan speed.

[1] https://lore.kernel.org/patchwork/patch/525367/

Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Acked-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/5d7e498b83e89ce7c41a449b61919c65d0770b73.1586033337.git.tommyhebb@gmail.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2020-05-22 06:28:38 -07:00
Pali Rohár 149ed3d404 change email address for Pali Rohár
For security reasons I stopped using gmail account and kernel address is
now up-to-date alias to my personal address.

People periodically send me emails to address which they found in source
code of drivers, so this change reflects state where people can contact
me.

[ Added .mailmap entry as per Joe Perches  - Linus ]
Signed-off-by: Pali Rohár <pali@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Joe Perches <joe@perches.com>
Link: http://lkml.kernel.org/r/20200307104237.8199-1-pali@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-04-10 15:36:22 -07:00
Alexey Dobriyan 97a32539b9 proc: convert everything to "struct proc_ops"
The most notable change is DEFINE_SHOW_ATTRIBUTE macro split in
seq_file.h.

Conversion rule is:

	llseek		=> proc_lseek
	unlocked_ioctl	=> proc_ioctl

	xxx		=> proc_xxx

	delete ".owner = THIS_MODULE" line

[akpm@linux-foundation.org: fix drivers/isdn/capi/kcapi_proc.c]
[sfr@canb.auug.org.au: fix kernel/sched/psi.c]
  Link: http://lkml.kernel.org/r/20200122180545.36222f50@canb.auug.org.au
Link: http://lkml.kernel.org/r/20191225172546.GB13378@avx2
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-02-04 03:05:26 +00:00
Giovanni Mascellani afe45277ad hwmon: (dell-smm) Add support for disabling automatic BIOS fan control
This patch exports standard hwmon pwmX_enable sysfs attribute for
enabling or disabling automatic fan control by BIOS. Standard value
"1" is for disabling automatic BIOS fan control and value "2" for
enabling.

By default BIOS auto mode is enabled by laptop firmware.

When BIOS auto mode is enabled, custom fan speed value (set via hwmon
pwmX sysfs attribute) is overwritten by SMM in few seconds and
therefore any custom settings are without effect. So this is reason
why implementing option for disabling BIOS auto mode is needed.

So finally this patch allows kernel to set and control fan speed on
laptops, but it can be dangerous (like setting speed of other fans).

The SMM commands to enable or disable automatic fan control are not
documented and are not the same on all Dell laptops. Therefore a
whitelist is used to send the correct codes only on laptopts for which
they are known.

This patch was originally developed by Pali Rohár; later Giovanni
Mascellani implemented the whitelist.

Signed-off-by: Giovanni Mascellani <gio@debian.org>
Co-Developed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Link: https://lore.kernel.org/r/20191122101519.1246458-1-gio@debian.org
[groeck: Fixed checkpatch warnings]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-11-22 20:08:58 -08:00
Thomas Gleixner 3e0a4e8580 treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 118
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license as published by
  the free software foundation either version 2 or at your option any
  later version this program is distributed in the hope that it will
  be useful but without any warranty without even the implied warranty
  of merchantability or fitness for a particular purpose see the gnu
  general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-or-later

has been chosen to replace the boilerplate/reference in 44 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Richard Fontana <rfontana@redhat.com>
Reviewed-by: Allison Randal <allison@lohutok.net>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190523091651.032047323@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-05-24 17:39:02 +02:00
Michele Sorcinelli 1bb46a20e7 hwmon: (dell-smm) Support up to 10 temp sensors
Extend code to support up to 10 temperature sensors.

Signed-off-by: Michele Sorcinelli <michelesr@autistici.org>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
[groeck: Enter description, drop changelog from description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2019-02-18 14:23:29 -08:00
Guenter Roeck ba949ed62d hwmon: (dell-smm-hwmon) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readbility, and to reduce the chance of inconsistencies.

Also replace any remaining S_<PERMS> in the driver with octal values.

The conversion was done automatically with coccinelle. The semantic patches
and the scripts used to generate this commit log are available at
https://github.com/groeck/coccinelle-patches/hwmon/.

This patch does not introduce functional changes. It was verified by
compiling the old and new files and comparing text and data sizes.

Cc: "Pali Rohár" <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-12-16 15:13:42 -08:00
Michele Sorcinelli 162372b088 dell-smm-hwmon.c: Add XPS 9570 to supported devices list
Allow the module to be loaded on Dell XPS 9570, without having to
provide the "force=1" option.

Signed-off-by: Michele Sorcinelli <michelesr@autistici.org>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-12-16 15:13:16 -08:00
Helge Eichelberg 536e0019b7 hwmon: (dell-smm) Disable fan support for Dell XPS13 9333
Calling fan related SMM functions implemented by Dell BIOS firmware on Dell
XPS13 9333 freeze kernel for about 500ms. Until Dell fixes it we need to
disable fan support for Dell XPS13 9333.

Via "force" module param fan support can be enabled.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=195751
Signed-off-by: Helge Eichelberg <kernelorg@elchenberg.name>
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-06-16 16:40:36 -07:00
Oleksandr Natalenko 6fbc4232a5 hwmon: (dell-smm) Disable fan support for Dell Vostro 3360
Calling fan related SMM functions implemented by Dell BIOS firmware on Dell
Vostro 3360 freeze kernel for about 500ms.

Unfortunately, it is unlikely for Dell to fix this since the machine
is pretty old, so this commit just disables fan support to make the
system usable again.

Via "force" module param fan support can be enabled.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=195751
Link: http://lkml.iu.edu/hypermail/linux/kernel/1711.2/06083.html
Reviewed-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Oleksandr Natalenko <oleksandr@natalenko.name>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-01-27 09:34:22 -08:00
Pali Rohár f480ea90b9 hwmon: (dell-smm) Disable fan support for Dell Inspiron 7720
Calling fan related SMM functions implemented by Dell BIOS firmware on Dell
Inspiron 7720 freeze kernel for about 500ms. Until Dell fixes it we need to
disable fan support for Dell Inspiron 7720 as it makes system unusable.

Via "force" module param fan support can be enabled.

Reported-by: vova7890@mail.ru
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=195751
Cc: stable@vger.kernel.org # v4.0+, will need backport
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-01-27 09:34:03 -08:00
Pali Rohár 836ad11235 hwmon: (dell-smm) Enable broken functionality via "force" module param
Some Dell machines are broken and some functionality is disabled. Show
warning into dmesg about this fact and allow user via "force" module param
to override brokenness and enable broken functionality.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2018-01-27 09:33:38 -08:00
Christoph Hellwig 6faadbbb7f dmi: Mark all struct dmi_system_id instances const
... and __initconst if applicable.

Based on similar work for an older kernel in the Grsecurity patch.

[JD: fix toshiba-wmi build]
[JD: add htcpen]
[JD: move __initconst where checkscript wants it]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
2017-09-14 11:59:30 +02:00
Pali Rohár a4811b6cb4 hwmon: (dell-smm) Add Dell XPS 15 9560 into DMI list
It was reported that dell-smm-hwmon is working fine on Dell XPS 15 9560.

Link: http://www.spinics.net/lists/platform-driver-x86/msg10751.html
Reported-by: Vasile Dumitrescu <vasile.dumitrescu@undeva.eu>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2017-04-02 07:01:53 -07:00
Juergen Gross 27046a3ffb hwmon: Use smp_call_on_cpu() for dell-smm i8k
Use the smp_call_on_cpu() function to call system management
mode on CPU 0.
Make call secure by adding get_online_cpus() to avoid e.g. suspend
resume cycles in between.

Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Douglas_Warzecha@dell.com
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: akataria@vmware.com
Cc: boris.ostrovsky@oracle.com
Cc: chrisw@sous-sol.org
Cc: david.vrabel@citrix.com
Cc: hpa@zytor.com
Cc: jdelvare@suse.com
Cc: jeremy@goop.org
Cc: linux@roeck-us.net
Cc: pali.rohar@gmail.com
Cc: rusty@rustcorp.com.au
Cc: virtualization@lists.linux-foundation.org
Cc: xen-devel@lists.xenproject.org
Link: http://lkml.kernel.org/r/1472453327-19050-7-git-send-email-jgross@suse.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2016-09-05 13:52:41 +02:00
Pali Rohár 9d58bec096 hwmon: (dell-smm) In debug mode log duration of SMM calls
This allow us to debug how long take each SMM call and how long is system
frozen in SMM handler.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-27 18:58:03 -07:00
Pali Rohár 747bc8b063 hwmon: (dell-smm) Detect fan with index=2
Some Dell machines (e.g. Dell Precision M3800) have two fans, first with
index=0 and second with index=2. So export also attributes for third fan
device with index=2.

Reported-by: Tolga Cakir <cevelnet@gmail.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Tolga Cakir <cevelnet@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-27 18:58:03 -07:00
Pali Rohár 5ce91714b0 hwmon: (dell-smm) Cache fan_type() calls and change fan detection
On more Dell machines (e.g. Dell Precision M3800) fan_type() call is too
expensive (CPU is too long in SMM mode) and cause kernel to hang. This is
bug in Dell SMM or BIOS.

This patch caches type for each fan (as it should not change) and changes
the way how fan presense is detected. First it try function fan_status()
as was before commit f989e55452 ("i8k: Add support for fan labels"). And
if that fails fallback to fan_type(). *_status() functions can fail in case
fan is not currently accessible (e.g. present on GPU which is currently
turned off).

Reported-by: Tolga Cakir <cevelnet@gmail.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=112021
Cc: stable@vger.kernel.org # v4.0+, will need backport
Tested-by: Tolga Cakir <cevelnet@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-23 06:24:23 -07:00
Pali Rohár 2744d2fde0 hwmon: (dell-smm) Disallow fan_type() calls on broken machines
Some Dell machines have especially broken SMM or BIOS which cause that once
fan_type() is called then CPU fan speed going randomly up and down. And for
fixing this behaviour reboot is required.

So this patch creates fan_type blacklist of affected Dell machines and
disallow fan_type() call on them to prevent that erratic behaviour.

Old blacklist which disabled loading driver on some machines added in
commits a4b45b25f1 ("hwmon: (dell-smm) Blacklist Dell Studio XPS 8100")
and 6220f4ebd7 ("hwmon: (dell-smm) Blacklist Dell Studio XPS 8000") were
moved to FAN_TYPE blacklist.

Reported-by: Jan C Peters <jcpeters89@gmail.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Link: https://bugzilla.kernel.org/show_bug.cgi?id=100121
Cc: stable@vger.kernel.org # v4.0+, will need backport
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-18 13:03:29 -07:00
Pali Rohár 7613663cc1 hwmon: (dell-smm) Restrict fan control and serial number to CAP_SYS_ADMIN by default
For security reasons ordinary user must not be able to control fan speed
via /proc/i8k by default. Some malicious software running under "nobody"
user could be able to turn fan off and cause HW problems. So this patch
changes default value of "restricted" parameter to 1.

Also restrict reading of DMI_PRODUCT_SERIAL from /proc/i8k via "restricted"
parameter. It is because non root user cannot read DMI_PRODUCT_SERIAL from
sysfs file /sys/class/dmi/id/product_serial.

Old non secure behaviour of file /proc/i8k can be achieved by loading this
module with "restricted" parameter set to 0.

Note that this patch has effects only for kernels compiled with CONFIG_I8K
and only for file /proc/i8k. Hwmon interface provided by this driver was
not changed and root access for setting fan speed was needed also before.

Reported-by: Mario Limonciello <Mario_Limonciello@dell.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Cc: stable@vger.kernel.org # will need backport
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-18 12:59:58 -07:00
Pali Rohár 053ea64081 hwmon: (dell-smm) Fail in ioctl I8K_BIOS_VERSION when bios version is not a number
ABI of I8K_BIOS_VERSION ioctl can return only number. But new BIOS versions
contain also other characters, which does not fit into that ABI. So in case
of non digit values return -EINVAL.

Reported-by: Mario Limonciello <Mario_Limonciello@dell.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-06-18 12:55:20 -07:00
Thorsten Leemhuis 6220f4ebd7 hwmon: (dell-smm) Blacklist Dell Studio XPS 8000
Since Linux 4.0 the CPU fan speed is going up and down on Dell Studio
XPS 8000 and 8100 for unknown reasons. The 8100 was already
blacklisted in commit a4b45b25f1 ("hwmon: (dell-smm) Blacklist
Dell Studio XPS 8100"). This patch blacklists the XPS 8000.

Without further debugging on the affected machine, it is not possible
to find the problem. For more details see
https://bugzilla.kernel.org/show_bug.cgi?id=100121

Signed-off-by: Thorsten Leemhuis <linux@leemhuis.info>
Acked-by: Pali Rohár <pali.rohar@gmail.com>
Cc: stable@vger.kernel.org # v4.0+, will need backport
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2016-01-24 19:26:18 -08:00
Pali Rohár a4b45b25f1 hwmon: (dell-smm) Blacklist Dell Studio XPS 8100
CPU fan speed going up and down on Dell Studio XPS 8100 for
unknown reasons. Without further debugging on the affected
machine, it is not possible to find the problem.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=100121
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Tested-by: Jan C Peters <jcpeters89@gmail.com>
Cc: stable@vger.kernel.org # v4.0+, will need backport
[groeck: cleaned up description, comments]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2015-08-05 08:31:59 -07:00