diff options
author | Keith Busch <keith.busch@intel.com> | 2017-12-14 11:20:14 -0700 |
---|---|---|
committer | Christoph Hellwig <hch@lst.de> | 2017-12-15 15:18:07 +0100 |
commit | 249159c5f15812140fa216f9997d799ac0023a1f (patch) | |
tree | 014045698c78a35ce64e92edb00e0368126386ae /drivers/nvme | |
parent | bd9f5d65769b9fe5e72110d4cbc9097b53b01613 (diff) | |
download | linux-249159c5f15812140fa216f9997d799ac0023a1f.tar.gz linux-249159c5f15812140fa216f9997d799ac0023a1f.tar.bz2 linux-249159c5f15812140fa216f9997d799ac0023a1f.zip |
nvme: check hw sectors before setting chunk sectors
Some devices with IDs matching the "stripe" quirk don't actually have
this quirk, and don't have an MDTS value. When MDTS is not set, the
driver sets the max sectors to UINT_MAX, which is not a power of 2,
hitting a BUG_ON from blk_queue_chunk_sectors. This patch skips setting
chunk sectors for such devices.
Signed-off-by: Keith Busch <keith.busch@intel.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/nvme')
-rw-r--r-- | drivers/nvme/host/core.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 2cc6192ef275..eab812dd2429 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1705,7 +1705,8 @@ static void nvme_set_queue_limits(struct nvme_ctrl *ctrl, blk_queue_max_hw_sectors(q, ctrl->max_hw_sectors); blk_queue_max_segments(q, min_t(u32, max_segments, USHRT_MAX)); } - if (ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) + if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && + is_power_of_2(ctrl->max_hw_sectors)) blk_queue_chunk_sectors(q, ctrl->max_hw_sectors); blk_queue_virt_boundary(q, ctrl->page_size - 1); if (ctrl->vwc & NVME_CTRL_VWC_PRESENT) |