From nobody Fri Nov 11 19:19:34 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4N87n22vVvz4fj3c; Fri, 11 Nov 2022 19:19:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4N87n22LDZz4CHk; Fri, 11 Nov 2022 19:19:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668194374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kYd9KRE7ymLdPtOMttX9bE+rMylSXmdcimdtIGWJLTw=; b=j4tiLrSmCk6jaIc7mcoc4EQp2lqoY17fGr/MGPCa2wpROoCbF5jjBZn+2PYrxaod/mftYS hYbNcpwSZo1MlHD976otgJZabhJM0ZP7u1CmW7ymun5WbG/pf5E5uHtP2f5vw7xX4xR/aF QxVj3Nj+19TUhJNU9h1dKOcQee26VSnKK+DR8PdzLTbL8EUkG0GhbHf9zNZQaqK3wAr7gr xt0AryqDl7wWqb9qFC3jOqONRnXyhk8VB2KiRHzR4vHqTVP55IJJQ2oFSWZb3jurxCxwcC JjwsmY9fMEBpeIYDOPJYNPMGMALmMT2azVGgizK+tcWLby0fHq+oMpruAsuW3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668194374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=kYd9KRE7ymLdPtOMttX9bE+rMylSXmdcimdtIGWJLTw=; b=OjMklaT1ghMCxh6dbAQaAx7aXaF+mt5pxyUflhSYbELlshYCbW3RBQxp36qBJZA3bhDikj tzTdFdU23nmQITwBL4706DOL0e2u5H8voCkPkT+ECvJ2DKHHAXMSVovl7WCd244Y5ovFUz quHJTiW+3dNM455YBG53uJxTlrcc/vD1XGpU5jL4urTk98DIwgWrvAOC2VBXhSUZ+s1Qt3 rP7P0AkCFFI+cPo/dtWR2t2cvC/7+h1e1R45Qz8piJ0K7oiLM2sMIqDRW1M536tJYqWMXE NIV2aqXTTYS9Oqgsp1i9pox3BU7IYhEvT9tmk1sKZa6Zhv9JnU3GI0mR8zbM3A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668194374; a=rsa-sha256; cv=none; b=LochhQgkG0jFGvtApvLGp97QQF85S5I8rVrlbl5SUAgas4TQeSu9uQ0+WRMCtiuEzX7tgR AclKxgW7fXSX0BtzKTooNx2epbMF96PZS5kRlAG/036XwYQQIs/gqT5K6DafrsFx5nXpi4 clRK/ECLsh//YgPA24hUcW3vYsvzo++jbBvzNpsU4UuD6r9MnHrGz6QNTHzC4FOC8W6V7q OKIFsMkjPmwoxYdFX3R5qOBlhj17LGKMvAzi6RtbSJUVpDNpzgx8AA+1wjwMu+T95v3HsL iXXHW/oD4+is4rLrK17qznMesTLfBPtYzPtQWt4Zm/JB89l3K1ZZEz4m1cBaCQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4N87n21NpXzvN3; Fri, 11 Nov 2022 19:19:34 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2ABJJYbp062193; Fri, 11 Nov 2022 19:19:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2ABJJYcY062192; Fri, 11 Nov 2022 19:19:34 GMT (envelope-from git) Date: Fri, 11 Nov 2022 19:19:34 GMT Message-Id: <202211111919.2ABJJYcY062192@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 3a194eac3c99 - main - nvmecontrol: fix wrong temperature unit for INTEL SSDs. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3a194eac3c992c5d7c72ff512aa3b475f64ac579 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3a194eac3c992c5d7c72ff512aa3b475f64ac579 commit 3a194eac3c992c5d7c72ff512aa3b475f64ac579 Author: Wanpeng Qian AuthorDate: 2022-11-11 19:13:06 +0000 Commit: Warner Losh 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 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 */