nvme/pci: Check segement valid for SGL use
PATCH 1/1 nvme/pci: Check segement valid for SGL use
The driver needs to verify there is a payload with a command before seeing if it should use SGLs to map it.
--- drivers/nvme/host/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/nvme/host/pci.c +5 -2
@@ -451,10 +451,13 @@ static void **nvme_pci_iod_list(struct request *req)static inline bool nvme_pci_use_sgls (struct nvme_dev *dev,struct request *req) {struct nvme_iod *iod =blk_mq_rq_to_pdu (req); +int nseg =blk_rq_nr_phys_segments (req);unsigned int avg_seg_size; - avg_seg_size =DIV_ROUND_UP (blk_rq_payload_bytes (req), -blk_rq_nr_phys_segments (req)); +if (nseg ==0 ) +return false; + + avg_seg_size =DIV_ROUND_UP (blk_rq_payload_bytes (req), nseg);if (!(dev->ctrl.sgls & ((1 <<0 ) | (1 <<1 ))))return false;
Signature · 1 line
2.13.6
PATCH 1/1 nvme/pci: Check segement valid for SGL use
Dear Keith,
Quoted 22 lines · Keith Busch
The driver needs to verify there is a payload with a command before seeing if it should use SGLs to map it.
Fixes 955b1b5a00ba ("nvme-pci: move use_sgl initialization to nvme_init_iod()")Reported-by Paul Menzel <pmenzel+linux-nvme at molgen.mpg.de>Signed-off-by Keith Busch <keith.busch at intel.com>--- drivers/nvme/host/pci.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/nvme/host/pci.c +1
-0@@ -451,10 +451,13 @@ static void **nvme_pci_iod_list(struct request *req)static inline bool nvme_pci_use_sgls (struct nvme_dev *dev,struct request *req) {struct nvme_iod *iod =blk_mq_rq_to_pdu (req); +int nseg =blk_rq_nr_phys_segments (req);unsigned int avg_seg_size;
drivers/nvme/host/pci.c static void **nvme_pci_iod_list(struct request *req) · line 463
Quoted 10 lines
drivers/nvme/host/pci.c +4
-2- avg_seg_size =DIV_ROUND_UP (blk_rq_payload_bytes (req), -blk_rq_nr_phys_segments (req)); +if (nseg ==0 ) +return false; + + avg_seg_size =DIV_ROUND_UP (blk_rq_payload_bytes (req), nseg);if (!(dev->ctrl.sgls & ((1 <<0 ) | (1 <<1 ))))return false;
Thank you for the quick reaction.
Kind regards,
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5174 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.infradead.org/pipermail/linux-nvme/attachments/20180115/51c8b8d8/attachment.p7s>
PATCH 1/1 nvme/pci: Check segement valid for SGL use
In reply to Keith BuschThanks, applied. I'll rebase the changes to take the mapped scatterlist length on top of this.
Christoph Hellwig
maintainerPATCH 1/1 nvme/pci: Check segement valid for SGL use
In reply to Keith BuschActually this needs to go into nvme-4.15. The offending commit is only in 4.15-rc, and not in nvme-4.16 or Jens' for-4.16 tree.
Jens Axboe
maintainerPATCH 1/1 nvme/pci: Check segement valid for SGL use
Quoted 2 lines · Christoph Hellwig
Actually this needs to go into nvme-4.15. The offending commit is only in 4.15-rc, and not in nvme-4.16 or Jens' for-4.16 tree.
I can queue it up for 4.15, there's already been one report of this...
Signature · 1 line
Jens Axboe
Christoph Hellwig
maintainerPATCH 1/1 nvme/pci: Check segement valid for SGL use
Quoted 6 lines · Jens Axboe
Quoted 2 lines · Christoph Hellwig
Actually this needs to go into nvme-4.15. The offending commit is only in 4.15-rc, and not in nvme-4.16 or Jens' for-4.16 tree.
I can queue it up for 4.15, there's already been one report of this...
I think we'll need at least another related fix as well. I'll send you a pull request by tomorrow or so.
Jens Axboe
maintainerPATCH 1/1 nvme/pci: Check segement valid for SGL use
Quoted 10 lines · Christoph Hellwig
Quoted 6 lines · Jens Axboe
Quoted 2 lines · Christoph Hellwig
Actually this needs to go into nvme-4.15. The offending commit is only in 4.15-rc, and not in nvme-4.16 or Jens' for-4.16 tree.
I can queue it up for 4.15, there's already been one report of this...
I think we'll need at least another related fix as well. I'll send you a pull request by tomorrow or so.
Sounds good, thanks.
Signature · 1 line
Jens Axboe