[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 16/16] nvme-pci: unmap MMIO pages with appropriate interface



From: Leon Romanovsky <leonro@xxxxxxxxxx>

Block layer maps MMIO memory through dma_map_phys() interface
with help of DMA_ATTR_MMIO attribute. There is a need to unmap
that memory with the appropriate unmap function, something which
wasn't possible before adding new REQ attribute to block layer in
previous patch.

Signed-off-by: Leon Romanovsky <leonro@xxxxxxxxxx>
---
 drivers/nvme/host/pci.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 2c6d9506b172..f8ecc0e0f576 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -682,11 +682,15 @@ static void nvme_free_prps(struct request *req)
 {
        struct nvme_iod *iod = blk_mq_rq_to_pdu(req);
        struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
+       unsigned int attrs = 0;
        unsigned int i;
 
+       if (req->cmd_flags & REQ_MMIO)
+               attrs = DMA_ATTR_MMIO;
+
        for (i = 0; i < iod->nr_dma_vecs; i++)
-               dma_unmap_page(nvmeq->dev->dev, iod->dma_vecs[i].addr,
-                               iod->dma_vecs[i].len, rq_dma_dir(req));
+               dma_unmap_phys(nvmeq->dev->dev, iod->dma_vecs[i].addr,
+                               iod->dma_vecs[i].len, rq_dma_dir(req), attrs);
        mempool_free(iod->dma_vecs, nvmeq->dev->dmavec_mempool);
 }
 
@@ -699,15 +703,19 @@ static void nvme_free_sgls(struct request *req)
        unsigned int sqe_dma_len = le32_to_cpu(iod->cmd.common.dptr.sgl.length);
        struct nvme_sgl_desc *sg_list = iod->descriptors[0];
        enum dma_data_direction dir = rq_dma_dir(req);
+       unsigned int attrs = 0;
+
+       if (req->cmd_flags & REQ_MMIO)
+               attrs = DMA_ATTR_MMIO;
 
        if (iod->nr_descriptors) {
                unsigned int nr_entries = sqe_dma_len / sizeof(*sg_list), i;
 
                for (i = 0; i < nr_entries; i++)
-                       dma_unmap_page(dma_dev, le64_to_cpu(sg_list[i].addr),
-                               le32_to_cpu(sg_list[i].length), dir);
+                       dma_unmap_phys(dma_dev, le64_to_cpu(sg_list[i].addr),
+                               le32_to_cpu(sg_list[i].length), dir, attrs);
        } else {
-               dma_unmap_page(dma_dev, sqe_dma_addr, sqe_dma_len, dir);
+               dma_unmap_phys(dma_dev, sqe_dma_addr, sqe_dma_len, dir, attrs);
        }
 }
 
-- 
2.50.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.