From 3a468f2010627cfb10fddab88eecbda66f4ee2ca Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Fri, 15 Apr 2022 14:41:20 -0600 Subject: [PATCH] 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 2bd6514d2a6..d78b46d043a 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 851405d7c9f..5db5ac6a16e 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.