* [PATCH] nvme/pci: Check segement valid for SGL use
@ 2018-01-15 13:07 Keith Busch
2018-01-15 13:11 ` Paul Menzel
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Keith Busch @ 2018-01-15 13:07 UTC (permalink / raw)
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(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index d53550e612bc..a7e94cc3c70e 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -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;
--
2.13.6
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH] nvme/pci: Check segement valid for SGL use
2018-01-15 13:07 [PATCH] nvme/pci: Check segement valid for SGL use Keith Busch
@ 2018-01-15 13:11 ` Paul Menzel
2018-01-15 15:21 ` Christoph Hellwig
2018-01-15 16:01 ` Christoph Hellwig
2 siblings, 0 replies; 7+ messages in thread
From: Paul Menzel @ 2018-01-15 13:11 UTC (permalink / raw)
Dear Keith,
On 01/15/18 14:07, Keith Busch wrote:
> 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(-)
>
> diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
> index d53550e612bc..a7e94cc3c70e 100644
> --- a/drivers/nvme/host/pci.c
> +++ b/drivers/nvme/host/pci.c
> @@ -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;
>
Thank you for the quick reaction.
Reviewed-by: Paul Menzel <pmenzel+linux-nvme at molgen.mpg.de>
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>
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH] nvme/pci: Check segement valid for SGL use
2018-01-15 13:07 [PATCH] nvme/pci: Check segement valid for SGL use Keith Busch
2018-01-15 13:11 ` Paul Menzel
@ 2018-01-15 15:21 ` Christoph Hellwig
2018-01-15 16:01 ` Christoph Hellwig
2 siblings, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2018-01-15 15:21 UTC (permalink / raw)
Thanks, applied. I'll rebase the changes to take the mapped
scatterlist length on top of this.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] nvme/pci: Check segement valid for SGL use
2018-01-15 13:07 [PATCH] nvme/pci: Check segement valid for SGL use Keith Busch
2018-01-15 13:11 ` Paul Menzel
2018-01-15 15:21 ` Christoph Hellwig
@ 2018-01-15 16:01 ` Christoph Hellwig
2018-01-15 16:20 ` Jens Axboe
2 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2018-01-15 16:01 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] nvme/pci: Check segement valid for SGL use
2018-01-15 16:01 ` Christoph Hellwig
@ 2018-01-15 16:20 ` Jens Axboe
2018-01-15 17:22 ` Christoph Hellwig
0 siblings, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2018-01-15 16:20 UTC (permalink / raw)
On 1/15/18 9:01 AM, Christoph Hellwig wrote:
> 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...
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] nvme/pci: Check segement valid for SGL use
2018-01-15 16:20 ` Jens Axboe
@ 2018-01-15 17:22 ` Christoph Hellwig
2018-01-15 17:25 ` Jens Axboe
0 siblings, 1 reply; 7+ messages in thread
From: Christoph Hellwig @ 2018-01-15 17:22 UTC (permalink / raw)
On Mon, Jan 15, 2018@09:20:40AM -0700, Jens Axboe wrote:
> On 1/15/18 9:01 AM, Christoph Hellwig wrote:
> > 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.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] nvme/pci: Check segement valid for SGL use
2018-01-15 17:22 ` Christoph Hellwig
@ 2018-01-15 17:25 ` Jens Axboe
0 siblings, 0 replies; 7+ messages in thread
From: Jens Axboe @ 2018-01-15 17:25 UTC (permalink / raw)
On 1/15/18 10:22 AM, Christoph Hellwig wrote:
> On Mon, Jan 15, 2018@09:20:40AM -0700, Jens Axboe wrote:
>> On 1/15/18 9:01 AM, Christoph Hellwig wrote:
>>> 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.
--
Jens Axboe
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-01-15 17:25 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-15 13:07 [PATCH] nvme/pci: Check segement valid for SGL use Keith Busch
2018-01-15 13:11 ` Paul Menzel
2018-01-15 15:21 ` Christoph Hellwig
2018-01-15 16:01 ` Christoph Hellwig
2018-01-15 16:20 ` Jens Axboe
2018-01-15 17:22 ` Christoph Hellwig
2018-01-15 17:25 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox