From: Leon Romanovsky <leon@kernel.org>
To: Jens Axboe <axboe@kernel.dk>, Keith Busch <kbusch@kernel.org>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org
Subject: [PATCH 2/3] nvme-pci: unmap MMIO pages with appropriate interface
Date: Fri, 17 Oct 2025 08:31:59 +0300 [thread overview]
Message-ID: <20251017-block-with-mmio-v1-2-3f486904db5e@nvidia.com> (raw)
In-Reply-To: <20251017-block-with-mmio-v1-0-3f486904db5e@nvidia.com>
From: Leon Romanovsky <leonro@nvidia.com>
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.
Reviewed-by: Keith Busch <kbusch@kernel.org>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
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 c916176bd9f0..2e9fb3c7bc09 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -689,11 +689,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);
}
@@ -704,16 +708,20 @@ static void nvme_free_sgls(struct request *req, struct nvme_sgl_desc *sge,
enum dma_data_direction dir = rq_dma_dir(req);
unsigned int len = le32_to_cpu(sge->length);
struct device *dma_dev = nvmeq->dev->dev;
+ unsigned int attrs = 0;
unsigned int i;
+ if (req->cmd_flags & REQ_MMIO)
+ attrs |= DMA_ATTR_MMIO;
+
if (sge->type == (NVME_SGL_FMT_DATA_DESC << 4)) {
- dma_unmap_page(dma_dev, le64_to_cpu(sge->addr), len, dir);
+ dma_unmap_phys(dma_dev, le64_to_cpu(sge->addr), len, dir, attrs);
return;
}
for (i = 0; i < len / sizeof(*sg_list); 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);
}
static void nvme_unmap_metadata(struct request *req)
--
2.51.0
next prev parent reply other threads:[~2025-10-17 5:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 5:31 [PATCH 0/3] block: Enable proper MMIO memory handling for P2P DMA Leon Romanovsky
2025-10-17 5:31 ` [PATCH 1/3] blk-mq-dma: migrate to dma_map_phys instead of map_page Leon Romanovsky
2025-10-17 6:18 ` Christoph Hellwig
2025-10-19 14:40 ` Leon Romanovsky
2025-10-17 5:31 ` Leon Romanovsky [this message]
2025-10-17 6:20 ` [PATCH 2/3] nvme-pci: unmap MMIO pages with appropriate interface Christoph Hellwig
2025-10-20 7:53 ` Leon Romanovsky
2025-10-17 5:32 ` [PATCH 3/3] block-dma: properly take MMIO path Leon Romanovsky
2025-10-17 6:25 ` Christoph Hellwig
2025-10-20 8:52 ` Leon Romanovsky
2025-10-20 12:30 ` Christoph Hellwig
2025-10-20 14:53 ` Leon Romanovsky
2025-10-20 8:56 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251017-block-with-mmio-v1-2-3f486904db5e@nvidia.com \
--to=leon@kernel.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).