* [PATCHv2] nvme-pci: use blk_map_iter for p2p metadata
@ 2025-10-21 15:18 Keith Busch
2025-10-22 3:18 ` Chaitanya Kulkarni
2025-10-22 6:00 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Keith Busch @ 2025-10-21 15:18 UTC (permalink / raw)
To: linux-nvme, hch; +Cc: Keith Busch, Leon Romanovsky
From: Keith Busch <kbusch@kernel.org>
The dma_map_bvec helper doesn't work for p2p data, so use the same
blk_map_iter method that sgl uses for this memory type.
Reported-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/pci.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index 3c1727df1e36f..4087a665fa2dc 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -1085,8 +1085,12 @@ static blk_status_t nvme_pci_setup_meta_sgls(struct request *req)
* descriptor provides an explicit length, so we're relying on that
* mechanism to catch any misunderstandings between the application and
* device.
+ *
+ * P2P DMA also needs to use the blk_dma_iter method, so mptr setup
+ * leverages this routine when that happens.
*/
- if (entries == 1 && !(nvme_req(req)->flags & NVME_REQ_USERCMD)) {
+ if (!nvme_ctrl_meta_sgl_supported(&dev->ctrl) ||
+ (entries == 1 && !(nvme_req(req)->flags & NVME_REQ_USERCMD))) {
iod->cmd.common.metadata = cpu_to_le64(iter.addr);
iod->meta_total_len = iter.len;
iod->meta_dma = iter.addr;
@@ -1127,6 +1131,9 @@ static blk_status_t nvme_pci_setup_meta_mptr(struct request *req)
struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
struct bio_vec bv = rq_integrity_vec(req);
+ if (is_pci_p2pdma_page(bv.bv_page))
+ return nvme_pci_setup_meta_sgls(req);
+
iod->meta_dma = dma_map_bvec(nvmeq->dev->dev, &bv, rq_dma_dir(req), 0);
if (dma_mapping_error(nvmeq->dev->dev, iod->meta_dma))
return BLK_STS_IOERR;
--
2.47.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCHv2] nvme-pci: use blk_map_iter for p2p metadata
2025-10-21 15:18 [PATCHv2] nvme-pci: use blk_map_iter for p2p metadata Keith Busch
@ 2025-10-22 3:18 ` Chaitanya Kulkarni
2025-10-22 6:00 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Chaitanya Kulkarni @ 2025-10-22 3:18 UTC (permalink / raw)
To: Keith Busch, linux-nvme@lists.infradead.org, hch@lst.de
Cc: Keith Busch, Leon Romanovsky
On 10/21/25 8:18 AM, Keith Busch wrote:
> From: Keith Busch<kbusch@kernel.org>
>
> The dma_map_bvec helper doesn't work for p2p data, so use the same
> blk_map_iter method that sgl uses for this memory type.
>
> Reported-by: Leon Romanovsky<leon@kernel.org>
> Signed-off-by: Keith Busch<kbusch@kernel.org>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCHv2] nvme-pci: use blk_map_iter for p2p metadata
2025-10-21 15:18 [PATCHv2] nvme-pci: use blk_map_iter for p2p metadata Keith Busch
2025-10-22 3:18 ` Chaitanya Kulkarni
@ 2025-10-22 6:00 ` Christoph Hellwig
2025-10-23 2:46 ` Keith Busch
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2025-10-22 6:00 UTC (permalink / raw)
To: Keith Busch; +Cc: linux-nvme, hch, Keith Busch, Leon Romanovsky
On Tue, Oct 21, 2025 at 08:18:31AM -0700, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
>
> The dma_map_bvec helper doesn't work for p2p data, so use the same
> blk_map_iter method that sgl uses for this memory type.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
Although I'd still rename nvme_pci_setup_meta_sgls as in my draft as
the name is a bit misleading now.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-10-23 2:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-21 15:18 [PATCHv2] nvme-pci: use blk_map_iter for p2p metadata Keith Busch
2025-10-22 3:18 ` Chaitanya Kulkarni
2025-10-22 6:00 ` Christoph Hellwig
2025-10-23 2:46 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox