Skip to content

Commit 0194b65

Browse files
committed
nvme-pci: use blk_map_iter for p2p metadata
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 <[email protected]> Reviewed-by: Chaitanya Kulkarni <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Keith Busch <[email protected]>
1 parent 60ad1de commit 0194b65

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/nvme/host/pci.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,7 @@ static blk_status_t nvme_map_data(struct request *req)
10421042
return nvme_pci_setup_data_prp(req, &iter);
10431043
}
10441044

1045-
static blk_status_t nvme_pci_setup_meta_sgls(struct request *req)
1045+
static blk_status_t nvme_pci_setup_meta_iter(struct request *req)
10461046
{
10471047
struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
10481048
unsigned int entries = req->nr_integrity_segments;
@@ -1072,8 +1072,12 @@ static blk_status_t nvme_pci_setup_meta_sgls(struct request *req)
10721072
* descriptor provides an explicit length, so we're relying on that
10731073
* mechanism to catch any misunderstandings between the application and
10741074
* device.
1075+
*
1076+
* P2P DMA also needs to use the blk_dma_iter method, so mptr setup
1077+
* leverages this routine when that happens.
10751078
*/
1076-
if (entries == 1 && !(nvme_req(req)->flags & NVME_REQ_USERCMD)) {
1079+
if (!nvme_ctrl_meta_sgl_supported(&dev->ctrl) ||
1080+
(entries == 1 && !(nvme_req(req)->flags & NVME_REQ_USERCMD))) {
10771081
iod->cmd.common.metadata = cpu_to_le64(iter.addr);
10781082
iod->meta_total_len = iter.len;
10791083
iod->meta_dma = iter.addr;
@@ -1114,6 +1118,9 @@ static blk_status_t nvme_pci_setup_meta_mptr(struct request *req)
11141118
struct nvme_queue *nvmeq = req->mq_hctx->driver_data;
11151119
struct bio_vec bv = rq_integrity_vec(req);
11161120

1121+
if (is_pci_p2pdma_page(bv.bv_page))
1122+
return nvme_pci_setup_meta_iter(req);
1123+
11171124
iod->meta_dma = dma_map_bvec(nvmeq->dev->dev, &bv, rq_dma_dir(req), 0);
11181125
if (dma_mapping_error(nvmeq->dev->dev, iod->meta_dma))
11191126
return BLK_STS_IOERR;
@@ -1128,7 +1135,7 @@ static blk_status_t nvme_map_metadata(struct request *req)
11281135

11291136
if ((iod->cmd.common.flags & NVME_CMD_SGL_METABUF) &&
11301137
nvme_pci_metadata_use_sgls(req))
1131-
return nvme_pci_setup_meta_sgls(req);
1138+
return nvme_pci_setup_meta_iter(req);
11321139
return nvme_pci_setup_meta_mptr(req);
11331140
}
11341141

0 commit comments

Comments
 (0)