diff options
author | Christian Lamparter <chunkeey@gmail.com> | 2020-02-28 23:42:50 +0100 |
---|---|---|
committer | Christian Lamparter <chunkeey@gmail.com> | 2020-03-21 17:48:34 +0100 |
commit | d107aaa910dccf4c748b788eb9b248a399a761de (patch) | |
tree | cb41aa68e654667d1dc0cdb2c256a044368d33db /target/linux/generic/backport-5.4/800-v5.5-scsi-core-Add-sysfs-attributes-for-VPD-pages-0h-and-.patch | |
parent | dcef8d6093cd54aa990a5ae0099a16e88a18dfbd (diff) | |
download | upstream-d107aaa910dccf4c748b788eb9b248a399a761de.tar.gz upstream-d107aaa910dccf4c748b788eb9b248a399a761de.tar.bz2 upstream-d107aaa910dccf4c748b788eb9b248a399a761de.zip |
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>
Diffstat (limited to 'target/linux/generic/backport-5.4/800-v5.5-scsi-core-Add-sysfs-attributes-for-VPD-pages-0h-and-.patch')
-rw-r--r-- | target/linux/generic/backport-5.4/800-v5.5-scsi-core-Add-sysfs-attributes-for-VPD-pages-0h-and-.patch | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/target/linux/generic/backport-5.4/800-v5.5-scsi-core-Add-sysfs-attributes-for-VPD-pages-0h-and-.patch b/target/linux/generic/backport-5.4/800-v5.5-scsi-core-Add-sysfs-attributes-for-VPD-pages-0h-and-.patch new file mode 100644 index 0000000000..dc89b279e5 --- /dev/null +++ b/target/linux/generic/backport-5.4/800-v5.5-scsi-core-Add-sysfs-attributes-for-VPD-pages-0h-and-.patch @@ -0,0 +1,122 @@ +From d188b0675b21d5a6ca27b3e741381813983f4719 Mon Sep 17 00:00:00 2001 +From: Ryan Attard <ryanattard@ryanattard.info> +Date: Thu, 26 Sep 2019 11:22:17 -0500 +Subject: [PATCH] scsi: core: Add sysfs attributes for VPD pages 0h and 89h + +Add sysfs attributes for the ATA information page and Supported VPD Pages +page. + +Link: https://lore.kernel.org/r/20190926162216.56591-1-ryanattard@ryanattard.info +Signed-off-by: Ryan Attard <ryanattard@ryanattard.info> +Reviewed-by: Bart Van Assche <bvanassche@acm.org> +Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> +--- + drivers/scsi/scsi.c | 4 ++++ + drivers/scsi/scsi_sysfs.c | 19 +++++++++++++++++++ + include/scsi/scsi_device.h | 2 ++ + 3 files changed, 25 insertions(+) + +--- a/drivers/scsi/scsi.c ++++ b/drivers/scsi/scsi.c +@@ -465,10 +465,14 @@ void scsi_attach_vpd(struct scsi_device + return; + + for (i = 4; i < vpd_buf->len; i++) { ++ if (vpd_buf->data[i] == 0x0) ++ scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0); + if (vpd_buf->data[i] == 0x80) + scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80); + if (vpd_buf->data[i] == 0x83) + scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83); ++ if (vpd_buf->data[i] == 0x89) ++ scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89); + } + kfree(vpd_buf); + } +--- a/drivers/scsi/scsi_sysfs.c ++++ b/drivers/scsi/scsi_sysfs.c +@@ -437,6 +437,7 @@ static void scsi_device_dev_release_user + struct device *parent; + struct list_head *this, *tmp; + struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL; ++ struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL; + unsigned long flags; + + sdev = container_of(work, struct scsi_device, ew.work); +@@ -466,16 +467,24 @@ static void scsi_device_dev_release_user + sdev->request_queue = NULL; + + mutex_lock(&sdev->inquiry_mutex); ++ rcu_swap_protected(sdev->vpd_pg0, vpd_pg0, ++ lockdep_is_held(&sdev->inquiry_mutex)); + rcu_swap_protected(sdev->vpd_pg80, vpd_pg80, + lockdep_is_held(&sdev->inquiry_mutex)); + rcu_swap_protected(sdev->vpd_pg83, vpd_pg83, + lockdep_is_held(&sdev->inquiry_mutex)); ++ rcu_swap_protected(sdev->vpd_pg89, vpd_pg89, ++ lockdep_is_held(&sdev->inquiry_mutex)); + mutex_unlock(&sdev->inquiry_mutex); + ++ if (vpd_pg0) ++ kfree_rcu(vpd_pg0, rcu); + if (vpd_pg83) + kfree_rcu(vpd_pg83, rcu); + if (vpd_pg80) + kfree_rcu(vpd_pg80, rcu); ++ if (vpd_pg89) ++ kfree_rcu(vpd_pg89, rcu); + kfree(sdev->inquiry); + kfree(sdev); + +@@ -868,6 +877,8 @@ static struct bin_attribute dev_attr_vpd + + sdev_vpd_pg_attr(pg83); + sdev_vpd_pg_attr(pg80); ++sdev_vpd_pg_attr(pg89); ++sdev_vpd_pg_attr(pg0); + + static ssize_t show_inquiry(struct file *filep, struct kobject *kobj, + struct bin_attribute *bin_attr, +@@ -1200,12 +1211,18 @@ static umode_t scsi_sdev_bin_attr_is_vis + struct scsi_device *sdev = to_scsi_device(dev); + + ++ if (attr == &dev_attr_vpd_pg0 && !sdev->vpd_pg0) ++ return 0; ++ + if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80) + return 0; + + if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83) + return 0; + ++ if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89) ++ return 0; ++ + return S_IRUGO; + } + +@@ -1248,8 +1265,10 @@ static struct attribute *scsi_sdev_attrs + }; + + static struct bin_attribute *scsi_sdev_bin_attrs[] = { ++ &dev_attr_vpd_pg0, + &dev_attr_vpd_pg83, + &dev_attr_vpd_pg80, ++ &dev_attr_vpd_pg89, + &dev_attr_inquiry, + NULL + }; +--- a/include/scsi/scsi_device.h ++++ b/include/scsi/scsi_device.h +@@ -140,8 +140,10 @@ struct scsi_device { + const char * rev; /* ... "nullnullnullnull" before scan */ + + #define SCSI_VPD_PG_LEN 255 ++ struct scsi_vpd __rcu *vpd_pg0; + struct scsi_vpd __rcu *vpd_pg83; + struct scsi_vpd __rcu *vpd_pg80; ++ struct scsi_vpd __rcu *vpd_pg89; + unsigned char current_tag; /* current tag */ + struct scsi_target *sdev_target; /* used only for single_lun */ + |