summaryrefslogtreecommitdiff
path: root/drivers/hwmon/dell-smm-hwmon.c
AgeCommit message (Collapse)Author
2024-10-02move asm/unaligned.h to linux/unaligned.hAl Viro
asm/unaligned.h is always an include of asm-generic/unaligned.h; might as well move that thing to linux/unaligned.h and include that - there's nothing arch-specific in that header. auto-generated by the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done for i in `git grep -l -w asm-generic/unaligned.h`; do sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-07-31hwmon: (dell-smm) Add Dell Latitude 7320 to fan control whitelistArmin Wolf
Add the Dell Latitude 7320 to the fan control whitelist to allow for manual fan control. Closes: https://github.com/Wer-Wolf/i8kutils/issues/8 Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20240719203706.19466-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-07-15Merge tag 'hwmon-for-v6.11' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging Pull hwmon updates from Guenter Roeck: "Obsolete driver removals: - Removed obsolete adm1021 and max6642 drivers New drivers: - MPS MP2891, MP2993, MP9941, and MP5920 - SPD5118 (Temperature Sensor and EEPROM) Added device support to existing drivers: - g762: G761 - dell-smm: Dell OptiPlex 7060 - asus-ec-sensors: ProArt X670E-CREATOR WIFI - corsair-psu: HX1200i Series 2023 psu - nzxt-smart2: Additional USB IS for NZXT RGB & Fan Controller Notable enhancements and fixes: - Removed use of i2c_match_id() - Constified struct regmap_config where feasible - Cleaned up amc6821 driver, and converted to use regmap and with_info API - Converted max6639 driver to use with_info API; added support for additional sysfs attributes - Fixed various sysfs attribute underflows - Added PEC support to hwmon core, and use in lm90 and max31827 drivers And various other minor fixes and improvements" * tag 'hwmon-for-v6.11' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: (103 commits) hwmon: (max6697) Fix swapped temp{1,8} critical alarms hwmon: (max6697) Fix underflow when writing limit attributes hwmon: Remove obsolete adm1021 and max6642 drivers hwmon: (pmbus/ltc4286) Drop unused i2c device ids hwmon: (g762) Initialize fans after configuring clock hwmon: (amc6821) Add support for pwm1_mode attribute hwmon: (amc6821) Convert to with_info API hwmon: (amc6821) Convert to use regmap hwmon: (amc6821) Drop unnecessary enum chips hwmon: (amc6821) Use BIT() and GENMASK() hwmon: (amc6821) Use tabs for column alignment in defines hwmon: (amc6821) Reorder include files, drop unnecessary ones hwmon: (amc6821) Add support for fan1_target and pwm1_enable mode 4 hwmon: (amc6821) Rename fan1_div to fan1_pulses hwmon: (amc6821) Make reading and writing fan speed limits consistent hwmon: (amc6821) Stop accepting invalid pwm values hwmon: (w83627ehf) Fix underflows seen when writing limit attributes hwmon: (nct6775-core) Fix underflows seen when writing limit attributes hwmon: (lm95234) Fix underflows seen when writing limit attributes hwmon: (adc128d818) Fix underflows seen when writing limit attributes ...
2024-06-30hwmon: (dell-smm) Add Dell OptiPlex 7060 to DMI tableArmin Wolf
The BIOS on this machine is buggy and will in some cases return an error when trying to get the fan state, but reading of the RPM values and the temperature sensors still works. Closes: https://github.com/vitorafsr/i8kutils/issues/38 Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20240628214723.19665-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-05-29hwmon: (dell-smm) Add Dell G15 5511 to fan control whitelistArmin Wolf
A user reported that he needs to disable BIOS fan control on his Dell G15 5511 in order to be able to control the fans. Closes: https://github.com/Wer-Wolf/i8kutils/issues/5 Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20240522210809.294488-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-04-28hwmon: (dell-smm) Add Dell Precision 7540 to fan control whitelistSeiji Nishikawa
Add Precision 7540 to the fan control whitelist, in addition to 7510. Signed-off-by: Seiji Nishikawa <snishika@redhat.com> Link: https://lore.kernel.org/r/20240325045913.385853-2-snishika@redhat.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-04-28hwmon: (dell-smm) Add Dell G5 5505 to DMI tableTobias Jakobi
Enables reading the speed of the CPU and GPU fan on the G5. Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de> Reviewed-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20240310220710.896230-1-tjakobi@math.uni-bielefeld.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-03-14Merge tag 'mm-nonmm-stable-2024-03-14-09-36' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Pull non-MM updates from Andrew Morton: - Kuan-Wei Chiu has developed the well-named series "lib min_heap: Min heap optimizations". - Kuan-Wei Chiu has also sped up the library sorting code in the series "lib/sort: Optimize the number of swaps and comparisons". - Alexey Gladkov has added the ability for code running within an IPC namespace to alter its IPC and MQ limits. The series is "Allow to change ipc/mq sysctls inside ipc namespace". - Geert Uytterhoeven has contributed some dhrystone maintenance work in the series "lib: dhry: miscellaneous cleanups". - Ryusuke Konishi continues nilfs2 maintenance work in the series "nilfs2: eliminate kmap and kmap_atomic calls" "nilfs2: fix kernel bug at submit_bh_wbc()" - Nathan Chancellor has updated our build tools requirements in the series "Bump the minimum supported version of LLVM to 13.0.1". - Muhammad Usama Anjum continues with the selftests maintenance work in the series "selftests/mm: Improve run_vmtests.sh". - Oleg Nesterov has done some maintenance work against the signal code in the series "get_signal: minor cleanups and fix". Plus the usual shower of singleton patches in various parts of the tree. Please see the individual changelogs for details. * tag 'mm-nonmm-stable-2024-03-14-09-36' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm: (77 commits) nilfs2: prevent kernel bug at submit_bh_wbc() nilfs2: fix failure to detect DAT corruption in btree and direct mappings ocfs2: enable ocfs2_listxattr for special files ocfs2: remove SLAB_MEM_SPREAD flag usage assoc_array: fix the return value in assoc_array_insert_mid_shortcut() buildid: use kmap_local_page() watchdog/core: remove sysctl handlers from public header nilfs2: use div64_ul() instead of do_div() mul_u64_u64_div_u64: increase precision by conditionally swapping a and b kexec: copy only happens before uchunk goes to zero get_signal: don't initialize ksig->info if SIGNAL_GROUP_EXIT/group_exec_task get_signal: hide_si_addr_tag_bits: fix the usage of uninitialized ksig get_signal: don't abuse ksig->info.si_signo and ksig->sig const_structs.checkpatch: add device_type Normalise "name (ad@dr)" MODULE_AUTHORs to "name <ad@dr>" dyndbg: replace kstrdup() + strchr() with kstrdup_and_replace() list: leverage list_is_head() for list_entry_is_head() nilfs2: MAINTAINERS: drop unreachable project mirror site smp: make __smp_processor_id() 0-argument macro fat: fix uninitialized field in nostale filehandles ...
2024-03-14Merge tag 'platform-drivers-x86-v6.9-1' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86 Pull x86 platform driver updates from Ilpo Järvinen: - New acer-wmi HW support - Support for new revision of amd/pmf heartbeat notify - Correctly handle asus-wmi HW without LEDs - fujitsu-laptop battery charge control support - Support for new hp-wmi thermal profiles - Support ideapad-laptop refresh rate key - Put intel/pmc AI accelerator (GNA) into D3 if it has no driver to allow entry into low-power modes, and temporarily removed Lunar Lake SSRAM support due to breaking FW changes causing probe fail (further breaking FW changes are still pending) - Report pmc/punit_atom devices that prevent reacing low power levels - Surface Fan speed function support - Support for more sperial keys and complete the list of models with non-standard fan registers in thinkpad_acpi - New DMI touchscreen HW support - Continued modernization efforts of wmi - Removal of obsoleted ledtrig-audio call and the related dependency - Debug & metrics interface improvements - Miscellaneous cleanups / fixes / improvements * tag 'platform-drivers-x86-v6.9-1' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86: (87 commits) platform/x86/intel/pmc: Improve PKGC residency counters debug platform/x86: asus-wmi: Consider device is absent when the read is ~0 Documentation/x86/amd/hsmp: Updating urls platform/mellanox: mlxreg-hotplug: Remove redundant NULL-check platform/x86/amd/pmf: Update sps power thermals according to the platform-profiles platform/x86/amd/pmf: Add support to get sps default APTS index values platform/x86/amd/pmf: Add support to get APTS index numbers for static slider platform/x86/amd/pmf: Add support to notify sbios heart beat event platform/x86/amd/pmf: Add support to get sbios requests in PMF driver platform/x86/amd/pmf: Disable debugfs support for querying power thermals platform/x86/amd/pmf: Differentiate PMF ACPI versions x86/platform/atom: Check state of Punit managed devices on s2idle platform/x86: pmc_atom: Check state of PMC clocks on s2idle platform/x86: pmc_atom: Check state of PMC managed devices on s2idle platform/x86: pmc_atom: Annotate d3_sts register bit defines clk: x86: Move clk-pmc-atom register defines to include/linux/platform_data/x86/pmc_atom.h platform/x86: make fw_attr_class constant platform/x86/intel/tpmi: Change vsec offset to u64 platform/x86: intel_scu_pcidrv: Remove unused intel-mid.h platform/x86: intel_scu_wdt: Remove unused intel-mid.h ...
2024-03-12platform/x86: wmi: Do not instantiate older WMI drivers multiple timesArmin Wolf
Many older WMI drivers cannot be instantiated multiple times for two reasons: - they are using the legacy GUID-based WMI API - they are singletons (with global state) Prevent such WMI drivers from binding to WMI devices with a duplicated GUID, as this would mean that the WMI driver will be instantiated at least two times (one for the original GUID and one for the duplicated GUID). WMI drivers which can be instantiated multiple times can signal this by setting a flag inside struct wmi_driver. Tested on a ASUS Prime B650-Plus. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20240226193557.2888-2-W_Armin@gmx.de Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2024-03-10hwmon: (dell-smm) Add XPS 9315 to fan control whitelistArmin Wolf
A user reported that on this machine, disabling BIOS fan control is necessary in order to change the fan speed. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20240309212025.13758-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2024-03-06Normalise "name (ad@dr)" MODULE_AUTHORs to "name <ad@dr>"Ahelenia Ziemiańska
Found with git grep 'MODULE_AUTHOR(".*([^)]*@' Fixed with sed -i '/MODULE_AUTHOR(".*([^)]*@/{s/ (/ </g;s/)"/>"/;s/)and/> and/}' \ $(git grep -l 'MODULE_AUTHOR(".*([^)]*@') Also: in drivers/media/usb/siano/smsusb.c normalise ", INC" to ", Inc"; this is what every other MODULE_AUTHOR for this company says, and it's what the header says in drivers/sbus/char/openprom.c normalise a double-spaced separator; this is clearly copied from the copyright header, where the names are aligned on consecutive lines thusly: * Linux/SPARC PROM Configuration Driver * Copyright (C) 1996 Thomas K. Dyas (tdyas@noc.rutgers.edu) * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be) but the authorship branding is single-line Link: https://lkml.kernel.org/r/mk3geln4azm5binjjlfsgjepow4o73domjv6ajybws3tz22vb3@tarta.nabijaczleweli.xyz Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-12-11hwmon: (dell-smm) Add Optiplex 7000 to fan control whitelistArmin Wolf
A user reported that on this machine, disabling BIOS fan control is necessary in order to change the fan speed. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-10-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Add support for WMI SMM interfaceArmin Wolf
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: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-8-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Introduce helper function for data initArmin Wolf
In the future, multiple SMM calling backends will exist, with each backend being required to initialize its data. Introduce a helper function for this so the code necessary to initialize dell_smm_data is not duplicated between different backends. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-7-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Move config entries out of i8k_dmi_tableArmin Wolf
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: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-6-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Move DMI config handling to module initArmin Wolf
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: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-5-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Move whitelist handling to module initArmin Wolf
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: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-4-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Move blacklist handling to module initArmin Wolf
Future SMM calling backends will not be able to probe during module init, meaning the DMI tables used for backlisting broken features would have to drop their __initconst attribute. Prevent this by moving the blacklist handling to module init. Tested-by: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-3-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-12-11hwmon: (dell-smm) Prepare for multiple SMM calling backendsArmin Wolf
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: <serverror@serverror.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Pali Rohár <pali@kernel.org> Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20231123004820.50635-2-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2023-04-19hwmon: dell-smm: constify pointers to hwmon_channel_infoKrzysztof Kozlowski
Statically allocated array of pointed to hwmon_channel_info can be made const for safety. Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-12-04hwmon: (dell-smm) Move error message to make probing silentArmin Wolf
If dell-smm-hwmon loads on unsupported hardware like the Dell XPS 17 9710, an error message is printed. This might confuse users, as drivers are expected to be silent if no supported hardware is found. Reorder the error message so its only printed when the driver is loaded with the "force" option being set. Also reword the error message slightly. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20221130183418.357246-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-09-19hwmon: (dell-smm) Improve warning messagesArmin Wolf
When dell-smm-hwmon is loaded on a machine with a buggy BIOS with the option "force" being enabled, it wrongly prints that the buggy features where disabled. This may cause users to wrongly assume that the driver still protects them from these BIOS bugs even with "force" being enabled. Replace the messages with two messages each which are depending on the value of the "force" parameter. The messages which are being printed when "force" is not set use dev_notice() instead of dev_warn() since they only serve as a notice. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220822174053.8750-3-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (dell-smm) Improve assembly codeArmin Wolf
The new assembly code works on both 32 bit and 64 bit cpus and allows for more compiler optimisations. Since clang runs out of registers on 32 bit x86 when using CC_OUT, we need to execute "setc" ourself. Also modify the debug message so we can still see the result (eax) when the carry flag was set. Tested with 32 bit and 64 bit kernels on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220220190851.17965-1-W_Armin@gmx.de [groeck: Rebased to v5.19-rc3] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (dell-smm) Add Dell G5 5590 to DMI tableArmin Wolf
According to Bug 215983 at bugzilla.kernel.org, the Dell G5 5590 supports the SMM interface and can thus be loaded with ignore_dmi being set. Add the model the DMI table to allow for automatic loadig on this model. Compile-tested only. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20220612232208.27901-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-07-13hwmon: (dell-smm) Add Dell XPS 13 7390 to fan control whitelistArmin Wolf
A user reported that the program dell-bios-fan-control worked on his Dell XPS 13 7390 to switch off automatic fan control. Since it uses the same mechanism as the dell_smm_hwmon module, add this model to the fan control whitelist. Compile-tested only. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Acked-by: Pali Rohár <pali@kernel.org> Link: https://lore.kernel.org/r/20220612041806.11367-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-05-20hwmon: (dell-smm) Warn if SMM call took a very long time to executeArmin Wolf
If a particular SMM call takes a very long time to execute, the user might experience audio problems. Print a warning if a particular SMM call took over 0.250 seconds to execute, so the user can check whether or not possible audio problems are caused by this driver. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220426213154.724708-4-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-05-20hwmon: (dell-smm) Cleanup init codeArmin Wolf
The default values for i8k_fan_mult and i8k_fan_max should be assigend only if the values specified as module params or in DMI are invalid/missing. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220426213154.724708-3-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-05-20hwmon: (dell-smm) Avoid unnecessary SMM calls during initArmin Wolf
When the driver tries to detect the fan multiplier during module initialisation, it issues one SMM call for each fan. Those SMM calls are however redundant and also try to query fans which may not be present. Fix that by detecting the fan multiplier during hwmon initialisation when no extra SMM calls are needed. Also dont assume the last nominal speed entry to be the biggest and instead check all entries. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220426213154.724708-2-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-05-17hwmon: (dell-smm) Add cooling device supportArmin Wolf
Until now, only the temperature sensors where exported thru the thermal subsystem. Export the fans as "dell-smm-fan[1-3]" too to make them available as cooling devices. Also update Documentation and fix a minor issue with the alphabetic ordering of the includes. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220410163935.7840-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-03-18hwmon: (dell-smm) Add Inspiron 3505 to fan type blacklistArmin Wolf
Sadly, while firmware 1.5 fixed temperature labels on my Inspiron 3505, it also caused fan type calls to take ca. 4 seconds with the fan being at full speed. Fix the resulting delays by adding the model to the blacklist. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220318183408.13286-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-02-27hwmon: (dell-smm) Improve temperature sensors detectionArmin Wolf
On the Dell Inspiron 3505, three temperature sensors are available through the SMM interface. However since they do not have an associated type, they are not detected. Probe for those sensors in case no type was detected. _i8k_get_temp() is used instead of i8k_get_temp() since it is sometimes faster and the result is easier to check (no -ENODATA) since we do not care about the actual temp value. Tested on a Dell Inspiron 3505. Signed-off-by: Armin Wolf <W_Armin@gmx.de> Link: https://lore.kernel.org/r/20220215191113.16640-5-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-02-27hwmon: (dell-smm) Make fan/temp sensor number a u8Armin Wolf
Right now, we only use bits 0 to 7 of the fan/temp sensor number by doing number & 0xff. Passing the value as a u8 makes this step unnecessary. Also add checks to the ioctl handler since users might get confused when passing 0x00000101 does the same as passing 0x00000001. 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/20220215191113.16640-4-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-02-27hwmon: (dell-smm) Reword and mark parameter "force" as unsafeArmin Wolf
When enabling said module parameter, the driver ignores all feature blacklists on relevant models, which has the potential for strange side effects. Also there seems to be a slight chance for unsupported devices to behave badly when probed for features. In such cases, the kernel should be tainted to inform people that these issues might have been caused by the dell_smm_hwmon driver with "force" enabled. Also reword the parameter description to remind users that enabling "force" also enables blacklisted features. 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/20220215191113.16640-8-W_Armin@gmx.de Signed-off-by: Guenter Roeck <linux@roeck-us.net>
2022-01-22proc: remove PDE_DATA() completelyMuchun Song
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>
2021-12-26hwmon: (dell-smm) Pack the whole smm_regs structArmin Wolf
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-26hwmon: (dell-smm) Unify i8k_ioctl() and i8k_ioctl_unlocked()Armin Wolf
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-26hwmon: (dell-smm) Simplify ioctl handlerArmin Wolf
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-11-14hwmon: (dell-smm) Fix warning on /proc/i8k creation errorArmin Wolf
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: 039ae58503f3 ("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-10-21hwmon: (dell-smm) Speed up setting of fan speedArmin Wolf
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-21hwmon: (dell-smm) Add comment explaining usage of i8k_config_data[]Armin Wolf
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-21hwmon: (dell-smm) Return -ENOIOCTLCMD instead of -EINVALArmin Wolf
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-21hwmon: (dell-smm) Use strscpy_pad()Armin Wolf
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-21hwmon: (dell-smm) Sort includes in alphabetical orderArmin Wolf
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-16hwmon: (dell-smm) Add support for fanX_min, fanX_max and fanX_targetArmin Wolf
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-12hwmon: (dell-smm) Remove unnecessary includesArmin Wolf
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-08-17hwmon: (dell-smm) Rework SMM function debuggingArmin Wolf
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-17hwmon: (dell-smm) Mark i8k_get_fan_nominal_speed as __initArmin Wolf
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-17hwmon: (dell-smm) Mark tables as __initconstArmin Wolf
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-17hwmon: Replace deprecated CPU-hotplug functions.Sebastian Andrzej Siewior
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>