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
This commit is contained in:
Warner Losh 2022-04-15 14:41:20 -06:00
parent 55412ef90a
commit 3a468f2010
2 changed files with 6 additions and 7 deletions

View file

@ -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);

View file

@ -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.