]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
nvme: allow for size limitations from transport drivers
authorChristoph Hellwig <hch@lst.de>
Mon, 6 Jun 2016 21:20:48 +0000 (23:20 +0200)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 1 Jun 2017 20:41:34 +0000 (13:41 -0700)
Some transport drivers may have a lower transfer size than
the controller. So allow the transport to set it in the
controller max_hw_sectors.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit a229dbf61e03b70d98f5ed46f476d6369870a6ab)

Orabug: 25130845

Signed-off-by: Ashok Vairavan <ashok.vairavan@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/nvme/host/core.c

index 54a2cc5a4b9f0cc240c0482fcb6b3ab6cc072675..bd1acb8d0e6bc42ca664e1877d7df81a592a33a5 100644 (file)
@@ -1069,6 +1069,7 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
        struct nvme_id_ctrl *id;
        u64 cap;
        int ret, page_shift;
+       u32 max_hw_sectors;
 
        ret = ctrl->ops->reg_read32(ctrl, NVME_REG_VS, &ctrl->vs);
        if (ret) {
@@ -1101,9 +1102,11 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
        memcpy(ctrl->model, id->mn, sizeof(id->mn));
        memcpy(ctrl->firmware_rev, id->fr, sizeof(id->fr));
        if (id->mdts)
-               ctrl->max_hw_sectors = 1 << (id->mdts + page_shift - 9);
+               max_hw_sectors = 1 << (id->mdts + page_shift - 9);
        else
-               ctrl->max_hw_sectors = UINT_MAX;
+               max_hw_sectors = UINT_MAX;
+       ctrl->max_hw_sectors =
+               min_not_zero(ctrl->max_hw_sectors, max_hw_sectors);
 
        if ((ctrl->quirks & NVME_QUIRK_STRIPE_SIZE) && id->vs[3]) {
                unsigned int max_hw_sectors;