kernel: backport and package drivetemp hwmon from v5.5
This patch backports the hwmon drivetemp sensor module from vanilla
linux 5.5 to be available on OpenWrt's 5.4 kernel.
Extract from The upstream commit by Guenter Roeck <linux@roeck-us.net>:
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 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<C2><B0>C (low = +0.0<C2><B0>C, high = +60.0<C2><B0>C)
(crit low = -41.0<C2><B0>C, crit = +85.0<C2><B0>C)
(lowest = +23.0<C2><B0>C, highest = +34.0<C2><B0>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."
This patch incorperates a patch made by Linus Walleij:
820-libata-Assign-OF-node-to-the-SCSI-device.patch
This patch is necessary in order to wire-up the drivetemp
sensor into the device tree's thermal-zones.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
2020-02-28 22:42:50 +00:00
|
|
|
From 43a93893eb33e996836b99fb3e1f7300c0132a51 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Linus Walleij <linus.walleij@linaro.org>
|
|
|
|
Date: Tue, 31 Dec 2019 18:15:33 +0100
|
|
|
|
Subject: [PATCH 5/7] libata: Assign OF node to the SCSI device
|
|
|
|
|
|
|
|
When we spawn a SCSI device from an ATA device in libata-scsi
|
|
|
|
the SCSI device had no relation to the device tree.
|
|
|
|
|
|
|
|
The DT binding allows us to define port nodes under a
|
|
|
|
PATA (IDE) or SATA host controller, so we can have proper device
|
|
|
|
nodes for these devices.
|
|
|
|
|
|
|
|
If OF is enabled, walk the children of the host controller node
|
|
|
|
to see if there is a valid device tree node to assign. The reg
|
|
|
|
is used to match to ID 0 for the master device and ID 1 for the
|
|
|
|
slave device.
|
|
|
|
|
|
|
|
The corresponding device tree bindings have been accepted by
|
|
|
|
the device tree maintainers.
|
|
|
|
|
|
|
|
Cc: Chris Healy <cphealy@gmail.com>
|
|
|
|
Cc: Martin K. Petersen <martin.petersen@oracle.com>
|
|
|
|
Cc: Bart Van Assche <bvanassche@acm.org>
|
|
|
|
Cc: Guenter Roeck <linux@roeck-us.net>
|
|
|
|
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
|
|
|
---
|
|
|
|
ChangeLog v1->v2:
|
|
|
|
- Use dev_dbg() for the debug print
|
|
|
|
- return immediately after finding a matching OF node
|
|
|
|
---
|
|
|
|
drivers/ata/libata-scsi.c | 30 ++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 30 insertions(+)
|
|
|
|
|
|
|
|
--- a/drivers/ata/libata-scsi.c
|
|
|
|
+++ b/drivers/ata/libata-scsi.c
|
|
|
|
@@ -35,6 +35,7 @@
|
|
|
|
#include <linux/suspend.h>
|
|
|
|
#include <asm/unaligned.h>
|
|
|
|
#include <linux/ioprio.h>
|
|
|
|
+#include <linux/of.h>
|
|
|
|
|
|
|
|
#include "libata.h"
|
|
|
|
#include "libata-transport.h"
|
2020-09-10 19:17:13 +00:00
|
|
|
@@ -4579,6 +4580,34 @@ int ata_scsi_add_hosts(struct ata_host *
|
kernel: backport and package drivetemp hwmon from v5.5
This patch backports the hwmon drivetemp sensor module from vanilla
linux 5.5 to be available on OpenWrt's 5.4 kernel.
Extract from The upstream commit by Guenter Roeck <linux@roeck-us.net>:
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 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<C2><B0>C (low = +0.0<C2><B0>C, high = +60.0<C2><B0>C)
(crit low = -41.0<C2><B0>C, crit = +85.0<C2><B0>C)
(lowest = +23.0<C2><B0>C, highest = +34.0<C2><B0>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."
This patch incorperates a patch made by Linus Walleij:
820-libata-Assign-OF-node-to-the-SCSI-device.patch
This patch is necessary in order to wire-up the drivetemp
sensor into the device tree's thermal-zones.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
2020-02-28 22:42:50 +00:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef CONFIG_OF
|
|
|
|
+static void ata_scsi_assign_ofnode(struct ata_device *dev, struct ata_port *ap)
|
|
|
|
+{
|
|
|
|
+ struct scsi_device *sdev = dev->sdev;
|
|
|
|
+ struct device *d = ap->host->dev;
|
|
|
|
+ struct device_node *np = d->of_node;
|
|
|
|
+ struct device_node *child;
|
|
|
|
+
|
|
|
|
+ for_each_available_child_of_node(np, child) {
|
|
|
|
+ int ret;
|
|
|
|
+ u32 val;
|
|
|
|
+
|
|
|
|
+ ret = of_property_read_u32(child, "reg", &val);
|
|
|
|
+ if (ret)
|
|
|
|
+ continue;
|
|
|
|
+ if (val == dev->devno) {
|
|
|
|
+ dev_dbg(d, "found matching device node\n");
|
|
|
|
+ sdev->sdev_gendev.of_node = child;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+#else
|
|
|
|
+static void ata_scsi_assign_ofnode(struct ata_device *dev, struct ata_port *ap)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
void ata_scsi_scan_host(struct ata_port *ap, int sync)
|
|
|
|
{
|
|
|
|
int tries = 5;
|
2020-09-10 19:17:13 +00:00
|
|
|
@@ -4604,6 +4633,7 @@ void ata_scsi_scan_host(struct ata_port
|
kernel: backport and package drivetemp hwmon from v5.5
This patch backports the hwmon drivetemp sensor module from vanilla
linux 5.5 to be available on OpenWrt's 5.4 kernel.
Extract from The upstream commit by Guenter Roeck <linux@roeck-us.net>:
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 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<C2><B0>C (low = +0.0<C2><B0>C, high = +60.0<C2><B0>C)
(crit low = -41.0<C2><B0>C, crit = +85.0<C2><B0>C)
(lowest = +23.0<C2><B0>C, highest = +34.0<C2><B0>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."
This patch incorperates a patch made by Linus Walleij:
820-libata-Assign-OF-node-to-the-SCSI-device.patch
This patch is necessary in order to wire-up the drivetemp
sensor into the device tree's thermal-zones.
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
2020-02-28 22:42:50 +00:00
|
|
|
NULL);
|
|
|
|
if (!IS_ERR(sdev)) {
|
|
|
|
dev->sdev = sdev;
|
|
|
|
+ ata_scsi_assign_ofnode(dev, ap);
|
|
|
|
scsi_device_put(sdev);
|
|
|
|
} else {
|
|
|
|
dev->sdev = NULL;
|