Home Home > GIT Browse > stable
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2018-01-19 10:13:51 +0100
committerTakashi Iwai <tiwai@suse.de>2018-01-19 10:13:51 +0100
commit849a2fef58bd2a647db164fea2c49b5b8cab64f6 (patch)
tree493c9f588e51dac9c39140d93616e9086bb361d4
parent0642e4e09a650d95088cebe14d79aa3994988ed3 (diff)
parentd73f2b86d24f635bf8ea358fe33e99abfe61e713 (diff)
-rw-r--r--patches.drivers/nvme-pci-take-sglist-coalescing-in-dma_map_sg-into-a.patch95
-rw-r--r--series.conf1
2 files changed, 96 insertions, 0 deletions
diff --git a/patches.drivers/nvme-pci-take-sglist-coalescing-in-dma_map_sg-into-a.patch b/patches.drivers/nvme-pci-take-sglist-coalescing-in-dma_map_sg-into-a.patch
new file mode 100644
index 0000000000..1c89388743
--- /dev/null
+++ b/patches.drivers/nvme-pci-take-sglist-coalescing-in-dma_map_sg-into-a.patch
@@ -0,0 +1,95 @@
+From: Christoph Hellwig <hch@lst.de>
+Date: Wed, 17 Jan 2018 22:04:38 +0100
+Subject: nvme-pci: take sglist coalescing in dma_map_sg into account
+Patch-mainline: Queued in subsystem maintainer repository
+Git-repo: git://git.kernel.dk/linux-block
+Git-commit: b0f2853b56a2acaff19cca2c6a608f8ec268d21a
+References: FATE#323952, FATE#322506
+
+Some iommu implementations can merge physically and/or virtually
+contiguous segments inside sg_map_dma. The NVMe SGL support does not take
+this into account and will warn because of falling off a loop. Pass the
+number of mapped segments to nvme_pci_setup_sgls so that the SGL setup
+can take the number of mapped segments into account.
+
+Reported-by: Fangjian (Turing) <f.fangjian@huawei.com>
+Fixes: a7a7cbe3 ("nvme-pci: add SGL support")
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Reviewed-by: Keith Busch <keith.busch@intel.com>
+Reviewed-by: Sagi Grimberg <sagi@rimberg.me>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Acked-by: Johannes Thumshirn <jthumshirn@suse.de>
+---
+ drivers/nvme/host/pci.c | 24 +++++++++++-------------
+ 1 file changed, 11 insertions(+), 13 deletions(-)
+
+--- a/drivers/nvme/host/pci.c
++++ b/drivers/nvme/host/pci.c
+@@ -705,22 +705,21 @@ static void nvme_pci_sgl_set_seg(struct
+ }
+
+ static blk_status_t nvme_pci_setup_sgls(struct nvme_dev *dev,
+- struct request *req, struct nvme_rw_command *cmd)
++ struct request *req, struct nvme_rw_command *cmd, int entries)
+ {
+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
+- int length = blk_rq_payload_bytes(req);
+ struct dma_pool *pool;
+ struct nvme_sgl_desc *sg_list;
+ struct scatterlist *sg = iod->sg;
+- int entries = iod->nents, i = 0;
+ dma_addr_t sgl_dma;
++ int i = 0;
+
+ iod->use_sgl = true;
+
+ /* setting the transfer type as SGL */
+ cmd->flags = NVME_CMD_SGL_METABUF;
+
+- if (length == sg_dma_len(sg)) {
++ if (entries == 1) {
+ nvme_pci_sgl_set_data(&cmd->dptr.sgl, sg);
+ return BLK_STS_OK;
+ }
+@@ -760,13 +759,9 @@ static blk_status_t nvme_pci_setup_sgls(
+ }
+
+ nvme_pci_sgl_set_data(&sg_list[i++], sg);
+-
+- length -= sg_dma_len(sg);
+ sg = sg_next(sg);
+- entries--;
+- } while (length > 0);
++ } while (--entries > 0);
+
+- WARN_ON(entries > 0);
+ return BLK_STS_OK;
+ }
+
+@@ -795,6 +790,7 @@ static blk_status_t nvme_map_data(struct
+ enum dma_data_direction dma_dir = rq_data_dir(req) ?
+ DMA_TO_DEVICE : DMA_FROM_DEVICE;
+ blk_status_t ret = BLK_STS_IOERR;
++ int nr_mapped;
+
+ sg_init_table(iod->sg, blk_rq_nr_phys_segments(req));
+ iod->nents = blk_rq_map_sg(q, req, iod->sg);
+@@ -802,12 +798,14 @@ static blk_status_t nvme_map_data(struct
+ goto out;
+
+ ret = BLK_STS_RESOURCE;
+- if (!dma_map_sg_attrs(dev->dev, iod->sg, iod->nents, dma_dir,
+- DMA_ATTR_NO_WARN))
++ nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents, dma_dir,
++ DMA_ATTR_NO_WARN);
++ if (!nr_mapped)
+ goto out;
+
+- if (nvme_pci_use_sgls(dev, req))
+- ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw);
++
++ if (iod->use_sgl)
++ ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw, nr_mapped);
+ else
+ ret = nvme_pci_setup_prps(dev, req, &cmnd->rw);
+
diff --git a/series.conf b/series.conf
index 0b67f10aa9..1de77a52fa 100644
--- a/series.conf
+++ b/series.conf
@@ -6583,6 +6583,7 @@
patches.drivers/ALSA-seq-Make-ioctls-race-free
patches.suse/bpf-array-fix-overflow-in-max_entries-and-undefined-.patch
patches.drivers/ibmvnic-Fix-pending-MAC-address-changes.patch
+ patches.drivers/nvme-pci-take-sglist-coalescing-in-dma_map_sg-into-a.patch
# davem/net-next
patches.drivers/net-ethtool-add-support-for-reset-of-AP-inside-NIC-i.patch