Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Apr 2022 20:46:47 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 3a468f201062 - main - nvme: Use saved mps when initializing drive
Message-ID:  <202204152046.23FKkl22079357@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=3a468f2010627cfb10fddab88eecbda66f4ee2ca

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

    nvme: Use saved mps when initializing drive
    
    Make sure we set the MPS we cached (currently the drives minimum mps) in
    CC (Controller Configuration) when reinitializing the drive. It must
    match the page_size that we're going to use. Also retire less specific
    NVME_PAGE_SHIFT since it's now unused.
    
    Sponsored by:           Netflix
    Reviewed by:            chuck
    Differential Revision:  https://reviews.freebsd.org/D34869
---
 sys/dev/nvme/nvme_ctrlr.c   | 8 ++++++--
 sys/dev/nvme/nvme_private.h | 5 -----
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 2bd6514d2a64..d78b46d043ae 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -388,8 +388,12 @@ nvme_ctrlr_enable(struct nvme_controller *ctrlr)
 	cc |= 6 << NVME_CC_REG_IOSQES_SHIFT; /* SQ entry size == 64 == 2^6 */
 	cc |= 4 << NVME_CC_REG_IOCQES_SHIFT; /* CQ entry size == 16 == 2^4 */
 
-	/* This evaluates to 0, which is according to spec. */
-	cc |= (PAGE_SHIFT - NVME_BASE_SHIFT) << NVME_CC_REG_MPS_SHIFT;
+	/*
+	 * Use the Memory Page Size selected during device initialization.  Note
+	 * that value stored in mps is suitable to use here without adjusting by
+	 * NVME_MPS_SHIFT.
+	 */
+	cc |= ctrlr->mps << NVME_CC_REG_MPS_SHIFT;
 
 	nvme_ctrlr_barrier(ctrlr, BUS_SPACE_BARRIER_WRITE);
 	nvme_mmio_write_4(ctrlr, cc, cc);
diff --git a/sys/dev/nvme/nvme_private.h b/sys/dev/nvme/nvme_private.h
index 851405d7c9f6..5db5ac6a16ed 100644
--- a/sys/dev/nvme/nvme_private.h
+++ b/sys/dev/nvme/nvme_private.h
@@ -96,11 +96,6 @@ MALLOC_DECLARE(M_NVME);
 /* Maximum log page size to fetch for AERs. */
 #define NVME_MAX_AER_LOG_SIZE		(4096)
 
-/*
- * Page size parameters
- */
-#define NVME_BASE_SHIFT		12	/* Several parameters (MSP) are 2^(12+x) */
-
 /*
  * Define CACHE_LINE_SIZE here for older FreeBSD versions that do not define
  *  it.



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