Commit 5b46903d authored by Guenter Roeck's avatar Guenter Roeck

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: default avatarLinus Walleij <linus.walleij@linaro.org>
Tested-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 74a71a83
.. SPDX-License-Identifier: GPL-2.0
Kernel driver drivetemp
=======================
References
----------
ANS T13/1699-D
Information technology - AT Attachment 8 - ATA/ATAPI Command Set (ATA8-ACS)
ANS Project T10/BSR INCITS 513
Information technology - SCSI Primary Commands - 4 (SPC-4)
ANS Project INCITS 557
Information technology - SCSI / ATA Translation - 5 (SAT-5)
Description
-----------
This driver supports reporting the temperature of disk and solid state
drives with temperature sensors.
If supported, it uses the ATA SCT Command Transport feature to read
the current drive temperature and, if available, temperature limits
as well as historic minimum and maximum temperatures. If SCT Command
Transport is not supported, the driver uses SMART attributes to read
the drive temperature.
Sysfs entries
-------------
Only the temp1_input attribute is always available. Other attributes are
available only if reported by the drive. All temperatures are reported in
milli-degrees Celsius.
======================= =====================================================
temp1_input Current drive temperature
temp1_lcrit Minimum temperature limit. Operating the device below
this temperature may cause physical damage to the
device.
temp1_min Minimum recommended continuous operating limit
temp1_max Maximum recommended continuous operating temperature
temp1_crit Maximum temperature limit. Operating the device above
this temperature may cause physical damage to the
device.
temp1_lowest Minimum temperature seen this power cycle
temp1_highest Maximum temperature seen this power cycle
======================= =====================================================
...@@ -47,6 +47,7 @@ Hardware Monitoring Kernel Drivers ...@@ -47,6 +47,7 @@ Hardware Monitoring Kernel Drivers
da9055 da9055
dell-smm-hwmon dell-smm-hwmon
dme1737 dme1737
drivetemp
ds1621 ds1621
ds620 ds620
emc1403 emc1403
......
...@@ -385,6 +385,16 @@ config SENSORS_ATXP1 ...@@ -385,6 +385,16 @@ config SENSORS_ATXP1
This driver can also be built as a module. If so, the module This driver can also be built as a module. If so, the module
will be called atxp1. will be called atxp1.
config SENSORS_DRIVETEMP
tristate "Hard disk drives with temperature sensors"
depends on SCSI && ATA
help
If you say yes you get support for the temperature sensor on
hard disk drives.
This driver can also be built as a module. If so, the module
will be called satatemp.
config SENSORS_DS620 config SENSORS_DS620
tristate "Dallas Semiconductor DS620" tristate "Dallas Semiconductor DS620"
depends on I2C depends on I2C
......
...@@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o ...@@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_DA9052_ADC)+= da9052-hwmon.o
obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o obj-$(CONFIG_SENSORS_DA9055)+= da9055-hwmon.o
obj-$(CONFIG_SENSORS_DELL_SMM) += dell-smm-hwmon.o obj-$(CONFIG_SENSORS_DELL_SMM) += dell-smm-hwmon.o
obj-$(CONFIG_SENSORS_DME1737) += dme1737.o obj-$(CONFIG_SENSORS_DME1737) += dme1737.o
obj-$(CONFIG_SENSORS_DRIVETEMP) += drivetemp.o
obj-$(CONFIG_SENSORS_DS620) += ds620.o obj-$(CONFIG_SENSORS_DS620) += ds620.o
obj-$(CONFIG_SENSORS_DS1621) += ds1621.o obj-$(CONFIG_SENSORS_DS1621) += ds1621.o
obj-$(CONFIG_SENSORS_EMC1403) += emc1403.o obj-$(CONFIG_SENSORS_EMC1403) += emc1403.o
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment