git: 3a194eac3c99 - main - nvmecontrol: fix wrong temperature unit for INTEL SSDs.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 11 Nov 2022 19:19:34 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=3a194eac3c992c5d7c72ff512aa3b475f64ac579
commit 3a194eac3c992c5d7c72ff512aa3b475f64ac579
Author: Wanpeng Qian <wanpengqian@gmail.com>
AuthorDate: 2022-11-11 19:13:06 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-11-11 19:15:52 +0000
nvmecontrol: fix wrong temperature unit for INTEL SSDs.
Although intel's specification did not tell which unit for Temperature
Statistics (Log Identifier C5h), I believe it is based on Celsius
instead of Kelvin.
here is my P3700 SSDs result(before):
Intel Temperature Log
=====================
Current: 30 K, -243.15 C, -405.67 F
Overtemp Last Flags 0
Overtemp Lifetime Flags 0
Max Temperature 53 K, -220.15 C, -364.27 F
Min Temperature 17 K, -256.15 C, -429.07 F
Max Operating Temperature 63 K, -210.15 C, -346.27 F
Min Operating Temperature 0 K, -273.15 C, -459.67 F
Estimated Temperature Offset: 0 C/K
after apply the patch, result is
Intel Temperature Log
=====================
Current: 303.15 K, 30 C, 86.00 F
Overtemp Last Flags 0
Overtemp Lifetime Flags 0
Max Temperature 326.15 K, 53 C, 127.40 F
Min Temperature 290.15 K, 17 C, 62.60 F
Max Operating Temperature 336.15 K, 63 C, 145.40 F
Min Operating Temperature 273.15 K, 0 C, 32.00 F
Estimated Temperature Offset: 0 C/K
I also compare to smartctl's report. it match very well.
also tested on Intel P3600, it fixed the problem.
Signed-off-by: Wanpeng Qian <wanpengqian@gmail.com>
Reviewed by: imp (added tweak to samsung.c so it still compiles)
Differential Revision: https://reviews.freebsd.org/D32845
---
sbin/nvmecontrol/logpage.c | 11 ++++++++---
sbin/nvmecontrol/modules/intel/intel.c | 10 +++++-----
sbin/nvmecontrol/modules/samsung/samsung.c | 2 +-
sbin/nvmecontrol/nvmecontrol.h | 3 ++-
4 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c
index f7a6ef311a40..4ed941e5f045 100644
--- a/sbin/nvmecontrol/logpage.c
+++ b/sbin/nvmecontrol/logpage.c
@@ -319,11 +319,16 @@ print_log_error(const struct nvme_controller_data *cdata __unused, void *buf, ui
}
void
-print_temp(uint16_t t)
+print_temp_K(uint16_t t)
{
printf("%u K, %2.2f C, %3.2f F\n", t, (float)t - 273.15, (float)t * 9 / 5 - 459.67);
}
+void
+print_temp_C(uint16_t t)
+{
+ printf("%2.2f K, %u C, %3.2f F\n", (float)t + 273.15, t, (float)t * 9 / 5 + 32);
+}
static void
print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
@@ -350,7 +355,7 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u
printf(" Volatile memory backup: %d\n",
!!(warning & NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP));
printf("Temperature: ");
- print_temp(health->temperature);
+ print_temp_K(health->temperature);
printf("Available spare: %u\n",
health->available_spare);
printf("Available spare threshold: %u\n",
@@ -385,7 +390,7 @@ print_log_health(const struct nvme_controller_data *cdata __unused, void *buf, u
if (health->temp_sensor[i] == 0)
continue;
printf("Temperature Sensor %d: ", i + 1);
- print_temp(health->temp_sensor[i]);
+ print_temp_K(health->temp_sensor[i]);
}
printf("Temperature 1 Transition Count: %d\n", health->tmt1tc);
printf("Temperature 2 Transition Count: %d\n", health->tmt2tc);
diff --git a/sbin/nvmecontrol/modules/intel/intel.c b/sbin/nvmecontrol/modules/intel/intel.c
index 8e3ed9e06cb9..895ffe30683f 100644
--- a/sbin/nvmecontrol/modules/intel/intel.c
+++ b/sbin/nvmecontrol/modules/intel/intel.c
@@ -64,17 +64,17 @@ print_intel_temp_stats(const struct nvme_controller_data *cdata __unused, void *
printf("=====================\n");
printf("Current: ");
- print_temp(temp->current);
+ print_temp_C(temp->current);
printf("Overtemp Last Flags %#jx\n", (uintmax_t)temp->overtemp_flag_last);
printf("Overtemp Lifetime Flags %#jx\n", (uintmax_t)temp->overtemp_flag_life);
printf("Max Temperature ");
- print_temp(temp->max_temp);
+ print_temp_C(temp->max_temp);
printf("Min Temperature ");
- print_temp(temp->min_temp);
+ print_temp_C(temp->min_temp);
printf("Max Operating Temperature ");
- print_temp(temp->max_oper_temp);
+ print_temp_C(temp->max_oper_temp);
printf("Min Operating Temperature ");
- print_temp(temp->min_oper_temp);
+ print_temp_C(temp->min_oper_temp);
printf("Estimated Temperature Offset: %ju C/K\n", (uintmax_t)temp->est_offset);
}
diff --git a/sbin/nvmecontrol/modules/samsung/samsung.c b/sbin/nvmecontrol/modules/samsung/samsung.c
index 497acf46e01c..d07732967b54 100644
--- a/sbin/nvmecontrol/modules/samsung/samsung.c
+++ b/sbin/nvmecontrol/modules/samsung/samsung.c
@@ -143,7 +143,7 @@ print_samsung_extended_smart(const struct nvme_controller_data *cdata __unused,
uint128_to_str(to128(temp->lur), cbuf, sizeof(cbuf)));
printf(" Lifetime Retired Block Count : %u\n", le32dec(&temp->lrbc));
printf(" Current Temperature : ");
- print_temp(le16dec(&temp->ct));
+ print_temp_K(le16dec(&temp->ct));
printf(" Capacitor Health : %u\n", le16dec(&temp->ch));
printf(" Reserved Erase Block Count : %u\n", le32dec(&temp->luurb));
printf(" Read Reclaim Count : %ju\n", (uintmax_t) le64dec(&temp->rrc));
diff --git a/sbin/nvmecontrol/nvmecontrol.h b/sbin/nvmecontrol/nvmecontrol.h
index c1daaf6730d3..4b587c48d9a0 100644
--- a/sbin/nvmecontrol/nvmecontrol.h
+++ b/sbin/nvmecontrol/nvmecontrol.h
@@ -76,7 +76,8 @@ void print_hex(void *data, uint32_t length);
void print_namespace(struct nvme_namespace_data *nsdata);
void read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
uint16_t lsi, uint8_t rae, void *payload, uint32_t payload_size);
-void print_temp(uint16_t t);
+void print_temp_C(uint16_t t);
+void print_temp_K(uint16_t t);
void print_intel_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused);
/* Utility Routines */