Skip to content

Commit b632033

Browse files
keithbuschkawasaki
authored andcommitted
blk-mq-dma: require unmap caller provide p2p map type
In preparing for integrity dma mappings, we can't rely on the request flag because data and metadata may have different mapping types. Signed-off-by: Keith Busch <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
1 parent d92dc6e commit b632033

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

drivers/nvme/host/pci.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ enum nvme_iod_flags {
261261

262262
/* single segment dma mapping */
263263
IOD_SINGLE_SEGMENT = 1U << 2,
264+
265+
/* DMA mapped with PCI_P2PDMA_MAP_BUS_ADDR */
266+
IOD_P2P_BUS_ADDR = 1U << 3,
264267
};
265268

266269
struct nvme_dma_vec {
@@ -725,7 +728,8 @@ static void nvme_unmap_data(struct request *req)
725728
return;
726729
}
727730

728-
if (!blk_rq_dma_unmap(req, dma_dev, &iod->dma_state, iod->total_len)) {
731+
if (!blk_rq_dma_unmap(req, dma_dev, &iod->dma_state, iod->total_len,
732+
iod->flags & IOD_P2P_BUS_ADDR)) {
729733
if (nvme_pci_cmd_use_sgl(&iod->cmd))
730734
nvme_free_sgls(req);
731735
else
@@ -1000,6 +1004,9 @@ static blk_status_t nvme_map_data(struct request *req)
10001004
if (!blk_rq_dma_map_iter_start(req, dev->dev, &iod->dma_state, &iter))
10011005
return iter.status;
10021006

1007+
if (iter.p2pdma.map == PCI_P2PDMA_MAP_BUS_ADDR)
1008+
iod->flags |= IOD_P2P_BUS_ADDR;
1009+
10031010
if (use_sgl == SGL_FORCED ||
10041011
(use_sgl == SGL_SUPPORTED &&
10051012
(sgl_threshold && nvme_pci_avg_seg_size(req) >= sgl_threshold)))

include/linux/blk-mq-dma.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,15 @@ static inline bool blk_rq_dma_map_coalesce(struct dma_iova_state *state)
4343
* @dma_dev: device to unmap from
4444
* @state: DMA IOVA state
4545
* @mapped_len: number of bytes to unmap
46+
* @p2p: true if mapped with PCI_P2PDMA_MAP_BUS_ADDR
4647
*
4748
* Returns %false if the callers need to manually unmap every DMA segment
4849
* mapped using @iter or %true if no work is left to be done.
4950
*/
5051
static inline bool blk_rq_dma_unmap(struct request *req, struct device *dma_dev,
51-
struct dma_iova_state *state, size_t mapped_len)
52+
struct dma_iova_state *state, size_t mapped_len, bool p2p)
5253
{
53-
if (req->cmd_flags & REQ_P2PDMA)
54+
if (p2p)
5455
return true;
5556

5657
if (dma_use_iova(state)) {

0 commit comments

Comments
 (0)