Skip to content

Commit 152694c

Browse files
Christoph Hellwigkeithbusch
authored andcommitted
nvme: set max_hw_sectors unconditionally
All transports set a max_hw_sectors value in the nvme_ctrl, so make the code using it unconditional and clean it up using a little helper. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Max Gurtovoy <mgurtovoy@nvidia.com> Reviewed-by: John Garry <john.g.garry@oracle.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
1 parent 4999568 commit 152694c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

drivers/nvme/host/core.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,19 +1944,19 @@ static int nvme_configure_metadata(struct nvme_ctrl *ctrl,
19441944
return 0;
19451945
}
19461946

1947+
static u32 nvme_max_drv_segments(struct nvme_ctrl *ctrl)
1948+
{
1949+
return ctrl->max_hw_sectors / (NVME_CTRL_PAGE_SIZE >> SECTOR_SHIFT) + 1;
1950+
}
1951+
19471952
static void nvme_set_queue_limits(struct nvme_ctrl *ctrl,
19481953
struct request_queue *q)
19491954
{
19501955
bool vwc = ctrl->vwc & NVME_CTRL_VWC_PRESENT;
19511956

1952-
if (ctrl->max_hw_sectors) {
1953-
u32 max_segments =
1954-
(ctrl->max_hw_sectors / (NVME_CTRL_PAGE_SIZE >> 9)) + 1;
1955-
1956-
max_segments = min_not_zero(max_segments, ctrl->max_segments);
1957-
blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
1958-
blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX));
1959-
}
1957+
blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors);
1958+
blk_queue_max_segments(q, min_t(u32, USHRT_MAX,
1959+
min_not_zero(nvme_max_drv_segments(ctrl), ctrl->max_segments)));
19601960
blk_queue_virt_boundary(q, NVME_CTRL_PAGE_SIZE - 1);
19611961
blk_queue_dma_alignment(q, 3);
19621962
blk_queue_write_cache(q, vwc, vwc);

0 commit comments

Comments
 (0)