git: 3086efe895d5 - main - nvme: Remove NVME_MAX_XFER_SIZE, replace inline calculation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 15 Apr 2022 20:46:48 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=3086efe895d5e7656c8a1a5343adf6de7c716b4d commit 3086efe895d5e7656c8a1a5343adf6de7c716b4d Author: Warner Losh <imp@FreeBSD.org> AuthorDate: 2022-04-15 20:41:30 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2022-04-15 20:46:18 +0000 nvme: Remove NVME_MAX_XFER_SIZE, replace inline calculation NVME_MAX_XFER_SIZE used to be a constant (back when MAXPHYS was a constant) to denote the smaller of MAXPHYS or the largest PRP we could encode with our prealloation scheme. However, it's no longer constant since MAXPHYS varies at runtime. In addition, the actual maximum is now based on the drive's currently in use page_size, which is also a runtime expression. As such, remove the define and expand it inline in the one place its used still in the tree. Sponsored by: Netflix Reviewed by: chuck Differential Revision: https://reviews.freebsd.org/D34870 --- sys/dev/nvme/nvme.h | 3 --- sys/dev/nvme/nvme_ctrlr.c | 3 ++- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/sys/dev/nvme/nvme.h b/sys/dev/nvme/nvme.h index e120656d0050..9aefc5c47973 100644 --- a/sys/dev/nvme/nvme.h +++ b/sys/dev/nvme/nvme.h @@ -59,9 +59,6 @@ */ #define NVME_GLOBAL_NAMESPACE_TAG ((uint32_t)0xFFFFFFFF) -/* Cap transfers by the maximum addressable by page-sized PRP (4KB -> 2MB). */ -#define NVME_MAX_XFER_SIZE MIN(maxphys, (PAGE_SIZE/8*PAGE_SIZE)) - /* Host memory buffer sizes are always in 4096 byte chunks */ #define NVME_HMB_UNITS 4096 diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c index d78b46d043ae..2a386269f21a 100644 --- a/sys/dev/nvme/nvme_ctrlr.c +++ b/sys/dev/nvme/nvme_ctrlr.c @@ -1454,7 +1454,8 @@ nvme_ctrlr_construct(struct nvme_controller *ctrlr, device_t dev) ctrlr->enable_aborts = 0; TUNABLE_INT_FETCH("hw.nvme.enable_aborts", &ctrlr->enable_aborts); - ctrlr->max_xfer_size = NVME_MAX_XFER_SIZE; + /* Cap transfers by the maximum addressable by page-sized PRP (4KB pages -> 2MB). */ + ctrlr->max_xfer_size = MIN(maxphys, (ctrlr->page_size / 8 * ctrlr->page_size)); if (nvme_ctrlr_construct_admin_qpair(ctrlr) != 0) return (ENXIO);