Skip to content

Commit 5b46903

Browse files
committed
hwmon: Driver for disk and solid state drives with temperature sensors
Reading the temperature of ATA drives has been supported for years by userspace tools such as smarttools or hddtemp. The downside of such tools is that they need to run with super-user privilege, that the temperatures are not reported by standard tools such as 'sensors' or 'libsensors', and that drive temperatures are not available for use in the kernel's thermal subsystem. This driver solves this problem by adding support for reading the temperature of ATA drives from the kernel using the hwmon API and by adding a temperature zone for each drive. With this driver, the hard disk temperature can be read using the unprivileged 'sensors' application: $ sensors drivetemp-scsi-1-0 drivetemp-scsi-1-0 Adapter: SCSI adapter temp1: +23.0°C or directly from sysfs: $ grep . /sys/class/hwmon/hwmon9/{name,temp1_input} /sys/class/hwmon/hwmon9/name:drivetemp /sys/class/hwmon/hwmon9/temp1_input:23000 If the drive supports SCT transport and reports temperature limits, those are reported as well. drivetemp-scsi-0-0 Adapter: SCSI adapter temp1: +27.0°C (low = +0.0°C, high = +60.0°C) (crit low = -41.0°C, crit = +85.0°C) (lowest = +23.0°C, highest = +34.0°C) The driver attempts to use SCT Command Transport to read the drive temperature. If the SCT Command Transport feature set is not available, or if it does not report the drive temperature, drive temperatures may be readable through SMART attributes. Since SMART attributes are not well defined, this method is only used as fallback mechanism. Cc: Chris Healy <cphealy@gmail.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Bart Van Assche <bvanassche@acm.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Tested-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 74a71a8 commit 5b46903

File tree

5 files changed

+638
-0
lines changed

5 files changed

+638
-0
lines changed

Documentation/hwmon/drivetemp.rst

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
Kernel driver drivetemp
4+
=======================
5+
6+
7+
References
8+
----------
9+
10+
ANS T13/1699-D
11+
Information technology - AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
12+
13+
ANS Project T10/BSR INCITS 513
14+
Information technology - SCSI Primary Commands - 4 (SPC-4)
15+
16+
ANS Project INCITS 557
17+
Information technology - SCSI / ATA Translation - 5 (SAT-5)
18+
19+
20+
Description
21+
-----------
22+
23+
This driver supports reporting the temperature of disk and solid state
24+
drives with temperature sensors.
25+
26+
If supported, it uses the ATA SCT Command Transport feature to read
27+
the current drive temperature and, if available, temperature limits
28+
as well as historic minimum and maximum temperatures. If SCT Command
29+
Transport is not supported, the driver uses SMART attributes to read
30+
the drive temperature.
31+
32+
33+
Sysfs entries
34+
-------------
35+
36+
Only the temp1_input attribute is always available. Other attributes are
37+
available only if reported by the drive. All temperatures are reported in
38+
milli-degrees Celsius.
39+
40+
======================= =====================================================
41+
temp1_input Current drive temperature
42+
temp1_lcrit Minimum temperature limit. Operating the device below
43+
this temperature may cause physical damage to the
44+
device.
45+
temp1_min Minimum recommended continuous operating limit
46+
temp1_max Maximum recommended continuous operating temperature
47+
temp1_crit Maximum temperature limit. Operating the device above
48+
this temperature may cause physical damage to the
49+
device.
50+
temp1_lowest Minimum temperature seen this power cycle
51+
temp1_highest Maximum temperature seen this power cycle
52+
======================= =====================================================

Documentation/hwmon/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Hardware Monitoring Kernel Drivers
4747
da9055
4848
dell-smm-hwmon
4949
dme1737
50+
drivetemp
5051
ds1621
5152
ds620
5253
emc1403

drivers/hwmon/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,16 @@ config SENSORS_ATXP1
385385
This driver can also be built as a module. If so, the module
386386
will be called atxp1.
387387

388+
config SENSORS_DRIVETEMP
389+
tristate "Hard disk drives with temperature sensors"
390+
depends on SCSI && ATA
391+
help
392+
If you say yes you get support for the temperature sensor on
393+
hard disk drives.
394+
395+
This driver can also be built as a module. If so, the module
396+
will be called satatemp.
397+
388398
config SENSORS_DS620
389399
tristate "Dallas Semiconductor DS620"
390400
depends on I2C

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
5656
obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o
5757
obj-$(CONFIG_SENSORS_DELL_SMM) += dell-smm-hwmon.o
5858
obj-$(CONFIG_SENSORS_DME1737) += dme1737.o
59+
obj-$(CONFIG_SENSORS_DRIVETEMP) += drivetemp.o
5960
obj-$(CONFIG_SENSORS_DS620) += ds620.o
6061
obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
6162
obj-$(CONFIG_SENSORS_EMC1403) += emc1403.o

0 commit comments

Comments
 (0)