git: 2a2682ee5330 - main - nvme: Add SMART WARNING for persistent memory region

From: Warner Losh <imp_at_FreeBSD.org>
Date: Thu, 07 Mar 2024 01:39:16 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=2a2682ee5330ec3803f349b85090577b2fd72987

commit 2a2682ee5330ec3803f349b85090577b2fd72987
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-03-07 01:22:44 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-03-07 01:38:59 +0000

    nvme: Add SMART WARNING for persistent memory region
    
    NVME 2.0 added persistent memory regions, and this bit reports critical
    warnings / errors with those regions.
    
    Sponsored by:           Netflix
    Reviewed by:            mav
    Differential Revision:  https://reviews.freebsd.org/D44213
---
 sys/dev/nvme/nvme.h       | 3 ++-
 sys/dev/nvme/nvme_ctrlr.c | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 137aff792868..9013e79b8882 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -553,8 +553,9 @@ enum nvme_critical_warning_state {
 	NVME_CRIT_WARN_ST_DEVICE_RELIABILITY		= 0x4,
 	NVME_CRIT_WARN_ST_READ_ONLY			= 0x8,
 	NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP	= 0x10,
+	NVME_CRIT_WARN_ST_PERSISTENT_MEMORY_REGION	= 0x20,
 };
-#define NVME_CRIT_WARN_ST_RESERVED_MASK			(0xE0)
+#define NVME_CRIT_WARN_ST_RESERVED_MASK			(0xC0)
 #define	NVME_ASYNC_EVENT_NS_ATTRIBUTE			(0x100)
 #define	NVME_ASYNC_EVENT_FW_ACTIVATE			(0x200)
 
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index ca26ca8e92d8..7334c7169efb 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -663,6 +663,9 @@ nvme_ctrlr_log_critical_warnings(struct nvme_controller *ctrlr,
 	if (state & NVME_CRIT_WARN_ST_VOLATILE_MEMORY_BACKUP)
 		nvme_printf(ctrlr, "SMART WARNING: volatile memory backup device failed\n");
 
+	if (state & NVME_CRIT_WARN_ST_PERSISTENT_MEMORY_REGION)
+		nvme_printf(ctrlr, "SMART WARNING: persistent memory read only or unreliable\n");
+
 	if (state & NVME_CRIT_WARN_ST_RESERVED_MASK)
 		nvme_printf(ctrlr, "SMART WARNING: unknown critical warning(s): state = 0x%02x\n",
 		    state & NVME_CRIT_WARN_ST_RESERVED_MASK);