Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Apr 2024 20:25:59 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 4329e6ccfa4a - stable/13 - nvme: Firmware revisions in the firmware slot info logpage are ASCII strings
Message-ID:  <202404082025.438KPxuD040335@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=4329e6ccfa4a493933700d267dd4918ba3592a3f

commit 4329e6ccfa4a493933700d267dd4918ba3592a3f
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-01 22:18:43 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-04-08 18:01:07 +0000

    nvme: Firmware revisions in the firmware slot info logpage are ASCII strings
    
    In particular, don't try to byteswap the values as 64-bit integers and
    always print a non-empty version as a string.
    
    Reviewed by:    chuck, imp
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D44121
    
    (cherry picked from commit 7485926e09a08fbfe83a9bc908e7d43aaca4c172)
---
 sbin/nvmecontrol/logpage.c | 13 ++-----------
 sys/dev/nvme/nvme.h        | 14 ++------------
 sys/dev/nvme/nvme_ctrlr.c  |  4 ----
 3 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/sbin/nvmecontrol/logpage.c b/sbin/nvmecontrol/logpage.c
index 35944993b32f..ad96c973acdf 100644
--- a/sbin/nvmecontrol/logpage.c
+++ b/sbin/nvmecontrol/logpage.c
@@ -230,10 +230,6 @@ read_logpage(int fd, uint8_t log_page, uint32_t nsid, uint8_t lsp,
 		nvme_health_information_page_swapbytes(
 		    (struct nvme_health_information_page *)payload);
 		break;
-	case NVME_LOG_FIRMWARE_SLOT:
-		nvme_firmware_page_swapbytes(
-		    (struct nvme_firmware_page *)payload);
-		break;
 	case NVME_LOG_CHANGED_NAMESPACE:
 		nvme_ns_list_swapbytes((struct nvme_ns_list *)payload);
 		break;
@@ -424,15 +420,10 @@ print_log_firmware(const struct nvme_controller_data *cdata, void *buf, uint32_t
 		else
 			status = "Inactive";
 
-		if (fw->revision[i] == 0LLU)
+		if (fw->revision[i][0] == '\0')
 			printf("Empty\n");
 		else
-			if (isprint(*(char *)&fw->revision[i]))
-				printf("[%s] %.8s\n", status,
-				    (char *)&fw->revision[i]);
-			else
-				printf("[%s] %016jx\n", status,
-				    fw->revision[i]);
+			printf("[%s] %.8s\n", status, fw->revision[i]);
 	}
 }
 
diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h
index 298efb7a19ed..39f9ce1b5907 100644
--- a/sys/dev/nvme/nvme.h
+++ b/sys/dev/nvme/nvme.h
@@ -1420,7 +1420,8 @@ _Static_assert(sizeof(struct nvme_health_information_page) == 512, "bad size for
 struct nvme_firmware_page {
 	uint8_t			afi;
 	uint8_t			reserved[7];
-	uint64_t		revision[7]; /* revisions for 7 slots */
+	/* revisions for 7 slots */
+	uint8_t			revision[7][NVME_FIRMWARE_REVISION_LENGTH];
 	uint8_t			reserved2[448];
 } __packed __aligned(4);
 
@@ -1962,17 +1963,6 @@ void	nvme_health_information_page_swapbytes(
 #endif
 }
 
-static inline
-void	nvme_firmware_page_swapbytes(struct nvme_firmware_page *s __unused)
-{
-#if _BYTE_ORDER != _LITTLE_ENDIAN
-	int i;
-
-	for (i = 0; i < 7; i++)
-		s->revision[i] = le64toh(s->revision[i]);
-#endif
-}
-
 static inline
 void	nvme_ns_list_swapbytes(struct nvme_ns_list *s __unused)
 {
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index bcbc8dc26ee1..a3862113ed75 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -704,10 +704,6 @@ nvme_ctrlr_async_event_log_page_cb(void *arg, const struct nvme_completion *cpl)
 			nvme_health_information_page_swapbytes(
 			    (struct nvme_health_information_page *)aer->log_page_buffer);
 			break;
-		case NVME_LOG_FIRMWARE_SLOT:
-			nvme_firmware_page_swapbytes(
-			    (struct nvme_firmware_page *)aer->log_page_buffer);
-			break;
 		case NVME_LOG_CHANGED_NAMESPACE:
 			nvme_ns_list_swapbytes(
 			    (struct nvme_ns_list *)aer->log_page_buffer);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404082025.438KPxuD040335>