* [PATCH] zfcp: fix wrong data and display format of SFP+ temperature
@ 2020-02-19 15:09 Benjamin Block
2020-02-24 17:52 ` Martin K. Petersen
0 siblings, 1 reply; 2+ messages in thread
From: Benjamin Block @ 2020-02-19 15:09 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen
Cc: Benjamin Block, Steffen Maier, Fedor Loshakov, Jens Remus,
Julian Wiedmann, Heiko Carstens, Vasily Gorbik,
Christian Borntraeger, linux-scsi, linux-s390, stable
When implementing support for retrieval of local diagnostic data from
the FCP channel, the wrong data format was assumed for the temperature
of the local SFP+ connector. The Fibre Channel Link Services (FC-LS-3)
specification is not clear on the format of the stored integer, and only
after consulting the SNIA specification SFF-8472 did we realize it is
stored as two's complement. Thus, the used data and display format is
wrong, and highly misleading for users when the temperature should drop
below 0°C (however unlikely that may be).
To fix this, change the data format in `struct fsf_qtcb_bottom_port`
from unsigned to signed, and change the printf format string used to
generate `zfcp_sysfs_adapter_diag_sfp_temperature_show()` from `%hu` to
`%hd`.
Fixes: a10a61e807b0 ("scsi: zfcp: support retrieval of SFP Data via Exchange Port Data")
Fixes: 6028f7c4cd87 ("scsi: zfcp: introduce sysfs interface for diagnostics of local SFP transceiver")
Cc: <stable@vger.kernel.org> # 5.5+
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com>
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
---
Hello James, Martin,
please consider this patch to be included in scsi-fixes, I also tagged
it for stable. It fixes a bug I found with the exposed hardware
diagnostics we introduced with 5.5.
Tests have been done by injecting negative temperatures in the used data
structures, in the same format specified in SNIA's SFF-8472 (Table
9-2).
crash vmlinux /proc/kcore
p ((struct zfcp_adapter *)((struct ccw_device *)0x00000001be250800)->dev.driver_data)->diagnostics->port_data.data.temperature
$8 = 0xffff
crash> ^Z
[1]+ Stopped crash vmlinux /proc/kcore
~ # cat /sys/bus/ccw/drivers/zfcp/0.0.1900/diagnostics/temperature
-1
crash vmlinux /proc/kcore
p ((struct zfcp_adapter *)((struct ccw_device *)0x00000001be250800)->dev.driver_data)->diagnostics->port_data.data.temperature
$9 = 0xff00
crash> ^Z
[1]+ Stopped crash vmlinux /proc/kcore
~ # cat /sys/bus/ccw/drivers/zfcp/0.0.1900/diagnostics/temperature
-256
Reviews and comments are welcome :-).
drivers/s390/scsi/zfcp_fsf.h | 2 +-
drivers/s390/scsi/zfcp_sysfs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/s390/scsi/zfcp_fsf.h b/drivers/s390/scsi/zfcp_fsf.h
index 2b1e4da1944f..4bfb79f20588 100644
--- a/drivers/s390/scsi/zfcp_fsf.h
+++ b/drivers/s390/scsi/zfcp_fsf.h
@@ -410,7 +410,7 @@ struct fsf_qtcb_bottom_port {
u8 cb_util;
u8 a_util;
u8 res2;
- u16 temperature;
+ s16 temperature;
u16 vcc;
u16 tx_bias;
u16 tx_power;
diff --git a/drivers/s390/scsi/zfcp_sysfs.c b/drivers/s390/scsi/zfcp_sysfs.c
index 494b9fe9cc94..a711a0d15100 100644
--- a/drivers/s390/scsi/zfcp_sysfs.c
+++ b/drivers/s390/scsi/zfcp_sysfs.c
@@ -800,7 +800,7 @@ static ZFCP_DEV_ATTR(adapter_diag, b2b_credit, 0400,
static ZFCP_DEV_ATTR(adapter_diag_sfp, _name, 0400, \
zfcp_sysfs_adapter_diag_sfp_##_name##_show, NULL)
-ZFCP_DEFINE_DIAG_SFP_ATTR(temperature, temperature, 5, "%hu");
+ZFCP_DEFINE_DIAG_SFP_ATTR(temperature, temperature, 6, "%hd");
ZFCP_DEFINE_DIAG_SFP_ATTR(vcc, vcc, 5, "%hu");
ZFCP_DEFINE_DIAG_SFP_ATTR(tx_bias, tx_bias, 5, "%hu");
ZFCP_DEFINE_DIAG_SFP_ATTR(tx_power, tx_power, 5, "%hu");
--
2.24.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] zfcp: fix wrong data and display format of SFP+ temperature
2020-02-19 15:09 [PATCH] zfcp: fix wrong data and display format of SFP+ temperature Benjamin Block
@ 2020-02-24 17:52 ` Martin K. Petersen
0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2020-02-24 17:52 UTC (permalink / raw)
To: Benjamin Block
Cc: James E.J. Bottomley, Martin K. Petersen, Steffen Maier,
Fedor Loshakov, Jens Remus, Julian Wiedmann, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, linux-scsi, linux-s390,
stable
Benjamin,
> When implementing support for retrieval of local diagnostic data from
> the FCP channel, the wrong data format was assumed for the temperature
> of the local SFP+ connector. The Fibre Channel Link Services (FC-LS-3)
> specification is not clear on the format of the stored integer, and
> only after consulting the SNIA specification SFF-8472 did we realize
> it is stored as two's complement. Thus, the used data and display
> format is wrong, and highly misleading for users when the temperature
> should drop below 0°C (however unlikely that may be).
Applied to 5.6/scsi-fixes, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-24 17:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 15:09 [PATCH] zfcp: fix wrong data and display format of SFP+ temperature Benjamin Block
2020-02-24 17:52 ` Martin K. Petersen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.