dell-smm-hwmon.rst 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. .. SPDX-License-Identifier: GPL-2.0-or-later
  2. .. include:: <isonum.txt>
  3. Kernel driver dell-smm-hwmon
  4. ============================
  5. :Copyright: |copy| 2002-2005 Massimo Dal Zotto <[email protected]>
  6. :Copyright: |copy| 2019 Giovanni Mascellani <[email protected]>
  7. Description
  8. -----------
  9. On many Dell laptops the System Management Mode (SMM) BIOS can be
  10. queried for the status of fans and temperature sensors. Userspace
  11. utilities like ``sensors`` can be used to return the readings. The
  12. userspace suite `i8kutils`__ can also be used to read the sensors and
  13. automatically adjust fan speed (please notice that it currently uses
  14. the deprecated ``/proc/i8k`` interface).
  15. __ https://github.com/vitorafsr/i8kutils
  16. ``sysfs`` interface
  17. -------------------
  18. Temperature sensors and fans can be queried and set via the standard
  19. ``hwmon`` interface on ``sysfs``, under the directory
  20. ``/sys/class/hwmon/hwmonX`` for some value of ``X`` (search for the
  21. ``X`` such that ``/sys/class/hwmon/hwmonX/name`` has content
  22. ``dell_smm``). A number of other attributes can be read or written:
  23. =============================== ======= =======================================
  24. Name Perm Description
  25. =============================== ======= =======================================
  26. fan[1-3]_input RO Fan speed in RPM.
  27. fan[1-3]_label RO Fan label.
  28. fan[1-3]_min RO Minimal Fan speed in RPM
  29. fan[1-3]_max RO Maximal Fan speed in RPM
  30. fan[1-3]_target RO Expected Fan speed in RPM
  31. pwm[1-3] RW Control the fan PWM duty-cycle.
  32. pwm1_enable WO Enable or disable automatic BIOS fan
  33. control (not supported on all laptops,
  34. see below for details).
  35. temp[1-10]_input RO Temperature reading in milli-degrees
  36. Celsius.
  37. temp[1-10]_label RO Temperature sensor label.
  38. =============================== ======= =======================================
  39. Due to the nature of the SMM interface, each pwmX attribute controls
  40. fan number X.
  41. Disabling automatic BIOS fan control
  42. ------------------------------------
  43. On some laptops the BIOS automatically sets fan speed every few
  44. seconds. Therefore the fan speed set by mean of this driver is quickly
  45. overwritten.
  46. There is experimental support for disabling automatic BIOS fan
  47. control, at least on laptops where the corresponding SMM command is
  48. known, by writing the value ``1`` in the attribute ``pwm1_enable``
  49. (writing ``2`` enables automatic BIOS control again). Even if you have
  50. more than one fan, all of them are set to either enabled or disabled
  51. automatic fan control at the same time and, notwithstanding the name,
  52. ``pwm1_enable`` sets automatic control for all fans.
  53. If ``pwm1_enable`` is not available, then it means that SMM codes for
  54. enabling and disabling automatic BIOS fan control are not whitelisted
  55. for your hardware. It is possible that codes that work for other
  56. laptops actually work for yours as well, or that you have to discover
  57. new codes.
  58. Check the list ``i8k_whitelist_fan_control`` in file
  59. ``drivers/hwmon/dell-smm-hwmon.c`` in the kernel tree: as a first
  60. attempt you can try to add your machine and use an already-known code
  61. pair. If, after recompiling the kernel, you see that ``pwm1_enable``
  62. is present and works (i.e., you can manually control the fan speed),
  63. then please submit your finding as a kernel patch, so that other users
  64. can benefit from it. Please see
  65. :ref:`Documentation/process/submitting-patches.rst <submittingpatches>`
  66. for information on submitting patches.
  67. If no known code works on your machine, you need to resort to do some
  68. probing, because unfortunately Dell does not publish datasheets for
  69. its SMM. You can experiment with the code in `this repository`__ to
  70. probe the BIOS on your machine and discover the appropriate codes.
  71. __ https://github.com/clopez/dellfan/
  72. Again, when you find new codes, we'd be happy to have your patches!
  73. ``thermal`` interface
  74. ---------------------------
  75. The driver also exports the fans as thermal cooling devices with
  76. ``type`` set to ``dell-smm-fan[1-3]``. This allows for easy fan control
  77. using one of the thermal governors.
  78. Module parameters
  79. -----------------
  80. * force:bool
  81. Force loading without checking for supported
  82. models. (default: 0)
  83. * ignore_dmi:bool
  84. Continue probing hardware even if DMI data does not
  85. match. (default: 0)
  86. * restricted:bool
  87. Allow fan control only to processes with the
  88. ``CAP_SYS_ADMIN`` capability set or processes run
  89. as root when using the legacy ``/proc/i8k``
  90. interface. In this case normal users will be able
  91. to read temperature and fan status but not to
  92. control the fan. If your notebook is shared with
  93. other users and you don't trust them you may want
  94. to use this option. (default: 1, only available
  95. with ``CONFIG_I8K``)
  96. * power_status:bool
  97. Report AC status in ``/proc/i8k``. (default: 0,
  98. only available with ``CONFIG_I8K``)
  99. * fan_mult:uint
  100. Factor to multiply fan speed with. (default:
  101. autodetect)
  102. * fan_max:uint
  103. Maximum configurable fan speed. (default:
  104. autodetect)
  105. Legacy ``/proc`` interface
  106. --------------------------
  107. .. warning:: This interface is obsolete and deprecated and should not
  108. used in new applications. This interface is only
  109. available when kernel is compiled with option
  110. ``CONFIG_I8K``.
  111. The information provided by the kernel driver can be accessed by
  112. simply reading the ``/proc/i8k`` file. For example::
  113. $ cat /proc/i8k
  114. 1.0 A17 2J59L02 52 2 1 8040 6420 1 2
  115. The fields read from ``/proc/i8k`` are::
  116. 1.0 A17 2J59L02 52 2 1 8040 6420 1 2
  117. | | | | | | | | | |
  118. | | | | | | | | | +------- 10. buttons status
  119. | | | | | | | | +--------- 9. AC status
  120. | | | | | | | +-------------- 8. fan0 RPM
  121. | | | | | | +------------------- 7. fan1 RPM
  122. | | | | | +--------------------- 6. fan0 status
  123. | | | | +----------------------- 5. fan1 status
  124. | | | +-------------------------- 4. temp0 reading (Celsius)
  125. | | +---------------------------------- 3. Dell service tag (later known as 'serial number')
  126. | +-------------------------------------- 2. BIOS version
  127. +------------------------------------------ 1. /proc/i8k format version
  128. A negative value, for example -22, indicates that the BIOS doesn't
  129. return the corresponding information. This is normal on some
  130. models/BIOSes.
  131. For performance reasons the ``/proc/i8k`` doesn't report by default
  132. the AC status since this SMM call takes a long time to execute and is
  133. not really needed. If you want to see the ac status in ``/proc/i8k``
  134. you must explictitly enable this option by passing the
  135. ``power_status=1`` parameter to insmod. If AC status is not
  136. available -1 is printed instead.
  137. The driver provides also an ioctl interface which can be used to
  138. obtain the same information and to control the fan status. The ioctl
  139. interface can be accessed from C programs or from shell using the
  140. i8kctl utility. See the source file of ``i8kutils`` for more
  141. information on how to use the ioctl interface.
  142. SMM Interface
  143. -------------
  144. .. warning:: The SMM interface was reverse-engineered by trial-and-error
  145. since Dell did not provide any Documentation,
  146. please keep that in mind.
  147. The driver uses the SMM interface to send commands to the system BIOS.
  148. This interface is normally used by Dell's 32-bit diagnostic program or
  149. on newer notebook models by the buildin BIOS diagnostics.
  150. The SMM is triggered by writing to the special ioports ``0xb2`` and ``0x84``,
  151. and may cause short hangs when the BIOS code is taking too long to
  152. execute.
  153. The SMM handler inside the system BIOS looks at the contents of the
  154. ``eax``, ``ebx``, ``ecx``, ``edx``, ``esi`` and ``edi`` registers.
  155. Each register has a special purpose:
  156. =============== ==================================
  157. Register Purpose
  158. =============== ==================================
  159. eax Holds the command code before SMM,
  160. holds the first result after SMM.
  161. ebx Holds the arguments.
  162. ecx Unknown, set to 0.
  163. edx Holds the second result after SMM.
  164. esi Unknown, set to 0.
  165. edi Unknown, set to 0.
  166. =============== ==================================
  167. The SMM handler can signal a failure by either:
  168. - setting the lower sixteen bits of ``eax`` to ``0xffff``
  169. - not modifying ``eax`` at all
  170. - setting the carry flag
  171. SMM command codes
  172. -----------------
  173. =============== ======================= ================================================
  174. Command Code Command Name Description
  175. =============== ======================= ================================================
  176. ``0x0025`` Get Fn key status Returns the Fn key pressed after SMM:
  177. - 9th bit in ``eax`` indicates Volume up
  178. - 10th bit in ``eax`` indicates Volume down
  179. - both bits indicate Volume mute
  180. ``0xa069`` Get power status Returns current power status after SMM:
  181. - 1st bit in ``eax`` indicates Battery connected
  182. - 3th bit in ``eax`` indicates AC connected
  183. ``0x00a3`` Get fan state Returns current fan state after SMM:
  184. - 1st byte in ``eax`` holds the current
  185. fan state (0 - 2 or 3)
  186. ``0x01a3`` Set fan state Sets the fan speed:
  187. - 1st byte in ``ebx`` holds the fan number
  188. - 2nd byte in ``ebx`` holds the desired
  189. fan state (0 - 2 or 3)
  190. ``0x02a3`` Get fan speed Returns the current fan speed in RPM:
  191. - 1st byte in ``ebx`` holds the fan number
  192. - 1st word in ``eax`` holds the current
  193. fan speed in RPM (after SMM)
  194. ``0x03a3`` Get fan type Returns the fan type:
  195. - 1st byte in ``ebx`` holds the fan number
  196. - 1st byte in ``eax`` holds the
  197. fan type (after SMM):
  198. - 5th bit indicates docking fan
  199. - 1 indicates Processor fan
  200. - 2 indicates Motherboard fan
  201. - 3 indicates Video fan
  202. - 4 indicates Power supply fan
  203. - 5 indicates Chipset fan
  204. - 6 indicates other fan type
  205. ``0x04a3`` Get nominal fan speed Returns the nominal RPM in each fan state:
  206. - 1st byte in ``ebx`` holds the fan number
  207. - 2nd byte in ``ebx`` holds the fan state
  208. in question (0 - 2 or 3)
  209. - 1st word in ``eax`` holds the nominal
  210. fan speed in RPM (after SMM)
  211. ``0x05a3`` Get fan speed tolerance Returns the speed tolerance for each fan state:
  212. - 1st byte in ``ebx`` holds the fan number
  213. - 2nd byte in ``ebx`` holds the fan state
  214. in question (0 - 2 or 3)
  215. - 1st byte in ``eax`` returns the speed
  216. tolerance
  217. ``0x10a3`` Get sensor temperature Returns the measured temperature:
  218. - 1st byte in ``ebx`` holds the sensor number
  219. - 1st byte in ``eax`` holds the measured
  220. temperature (after SMM)
  221. ``0x11a3`` Get sensor type Returns the sensor type:
  222. - 1st byte in ``ebx`` holds the sensor number
  223. - 1st byte in ``eax`` holds the
  224. temperature type (after SMM):
  225. - 1 indicates CPU sensor
  226. - 2 indicates GPU sensor
  227. - 3 indicates SODIMM sensor
  228. - 4 indicates other sensor type
  229. - 5 indicates Ambient sensor
  230. - 6 indicates other sensor type
  231. ``0xfea3`` Get SMM signature Returns Dell signature if interface
  232. is supported (after SMM):
  233. - ``eax`` holds 1145651527
  234. (0x44494147 or "DIAG")
  235. - ``edx`` holds 1145392204
  236. (0x44454c4c or "DELL")
  237. ``0xffa3`` Get SMM signature Same as ``0xfea3``, check both.
  238. =============== ======================= ================================================
  239. There are additional commands for enabling (``0x31a3`` or ``0x35a3``) and
  240. disabling (``0x30a3`` or ``0x34a3``) automatic fan speed control.
  241. The commands are however causing severe sideeffects on many machines, so
  242. they are not used by default.
  243. On several machines (Inspiron 3505, Precision 490, Vostro 1720, ...), the
  244. fans supports a 4th "magic" state, which signals the BIOS that automatic
  245. fan control should be enabled for a specific fan.
  246. However there are also some machines who do support a 4th regular fan state too,
  247. but in case of the "magic" state, the nominal RPM reported for this state is a
  248. placeholder value, which however is not always detectable.
  249. Firmware Bugs
  250. -------------
  251. The SMM calls can behave erratic on some machines:
  252. ======================================================= =================
  253. Firmware Bug Affected Machines
  254. ======================================================= =================
  255. Reading of fan states return spurious errors. Precision 490
  256. Reading of fan types causes erratic fan behaviour. Studio XPS 8000
  257. Studio XPS 8100
  258. Inspiron 580
  259. Inspiron 3505
  260. Fan-related SMM calls take too long (about 500ms). Inspiron 7720
  261. Vostro 3360
  262. XPS 13 9333
  263. XPS 15 L502X
  264. ======================================================= =================
  265. In case you experience similar issues on your Dell machine, please
  266. submit a bugreport on bugzilla to we can apply workarounds.
  267. Limitations
  268. -----------
  269. The SMM calls can take too long to execute on some machines, causing
  270. short hangs and/or audio glitches.
  271. Also the fan state needs to be restored after suspend, as well as
  272. the automatic mode settings.
  273. When reading a temperature sensor, values above 127 degrees indicate
  274. a BIOS read error or a deactivated sensor.