git: 55412ef90ad1 - main - nvme: Rename min_page_size to page_size and save mps

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 15 Apr 2022 20:46:46 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=55412ef90ad1b03ea8124af7537307a49f52fab3

commit 55412ef90ad1b03ea8124af7537307a49f52fab3
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-04-15 20:41:13 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-04-15 20:46:18 +0000

    nvme: Rename min_page_size to page_size and save mps
    
    The Memory Page Size sets the basic unit of operation for the drive. We
    currently set this to the drive's minimum page size, but we could set it
    to any page size the drive supports in the future. Replace min_page_size
    (it's now unused for that purpose) with page_size to reflect this and
    cache the MPS we want to use. Use NVME_MPS_SHIFT to compute page_size.
    
    Sponsored by:           Netflix
    Reviewed by:            chuck
    Differential Revision:  https://reviews.freebsd.org/D34868
---
 sys/dev/nvme/nvme_ctrlr.c   | 5 ++---
 sys/dev/nvme/nvme_private.h | 5 +++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 21e33f991749..2bd6514d2a64 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1380,7 +1380,6 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev)
 	uint32_t	cap_lo;
 	uint32_t	cap_hi;
 	uint32_t	to, vs, pmrcap;
-	uint8_t		mpsmin;
 	int		status, timeout_period;
 
 	ctrlr->dev = dev;
@@ -1432,8 +1431,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev)
 
 	ctrlr->dstrd = NVME_CAP_HI_DSTRD(cap_hi) + 2;
 
-	mpsmin = NVME_CAP_HI_MPSMIN(cap_hi);
-	ctrlr->min_page_size = 1 << (12 + mpsmin);
+	ctrlr->mps = NVME_CAP_HI_MPSMIN(cap_hi);
+	ctrlr->page_size = 1 << (NVME_MPS_SHIFT + ctrlr->mps);
 
 	/* Get ready timeout value from controller, in units of 500ms. */
 	to = NVME_CAP_LO_TO(cap_lo) + 1;
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index eaf0468096c4..851405d7c9f6 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -288,8 +288,9 @@ struct nvme_controller {
 	uint32_t		cap_lo;
 	uint32_t		cap_hi;
 
-	/** minimum page size supported by this controller in bytes */
-	uint32_t		min_page_size;
+	/** Page size and log2(page_size) - 12 that we're currently using */
+	uint32_t		page_size;
+	uint32_t		mps;
 
 	/** interrupt coalescing time period (in microseconds) */
 	uint32_t		int_coal_time;