Re: [PATCH v3 2/2] block-dma: properly take MMIO path

Keith Busch
2025-11-12T14:38:17Z

On Mon, Oct 27, 2025 at 09:30:21AM +0200, Leon Romanovsky wrote:
> @@ -732,13 +746,20 @@ static void nvme_unmap_metadata(struct request *req)
> return;
> }
>
> - if (!blk_rq_integrity_dma_unmap(req, dma_dev, &iod->meta_dma_state,
> - iod->meta_total_len)) {
> + if (iod->flags & IOD_META_P2P)
> + map = PCI_P2PDMA_MAP_BUS_ADDR;
> + if (iod->flags & IOD_META_MMIO) {
> + map = PCI_P2PDMA_MAP_THRU_HOST_BRIDGE;
> + attrs |= DMA_ATTR_MMIO;
> + }

This should be an 'else if' no?

> @@ -760,12 +783,20 @@ static void nvme_unmap_data(struct request *req)
> return;
> }
>
> - if (!blk_rq_dma_unmap(req, dma_dev, &iod->dma_state, iod->total_len)) {
> + if (iod->flags & IOD_DATA_P2P)
> + map = PCI_P2PDMA_MAP_BUS_ADDR;
> + if (iod->flags & IOD_DATA_MMIO) {
> + map = PCI_P2PDMA_MAP_THRU_HOST_BRIDGE;
> + attrs |= DMA_ATTR_MMIO;
> + }

Same here.

> @@ -1036,6 +1067,17 @@ static blk_status_t nvme_map_data(struct request *req)
> if (!blk_rq_dma_map_iter_start(req, dev->dev, &iod->dma_state, &iter))
> return iter.status;
>
> + switch (iter.p2pdma.map) {
> + case PCI_P2PDMA_MAP_BUS_ADDR:
> + iod->flags |= IOD_DATA_P2P;
> + break;
> + case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE:
> + iod->flags |= IOD_DATA_MMIO;
> + break;
> + default:
> + return BLK_STS_RESOURCE;
> + }

Why is it an error if the data isn't a P2PDMA type?

> @@ -1058,6 +1100,17 @@ static blk_status_t nvme_pci_setup_meta_sgls(struct request *req)
> &iod->meta_dma_state, &iter))
> return iter.status;
>
> + switch (iter.p2pdma.map) {
> + case PCI_P2PDMA_MAP_BUS_ADDR:
> + iod->flags |= IOD_META_P2P;
> + break;
> + case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE:
> + iod->flags |= IOD_META_MMIO;
> + break;
> + default:
> + return BLK_STS_RESOURCE;
> + }

Same here.