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

Leon Romanovsky leon at kernel.org
Mon Oct 27 01:11:42 PDT 2025


On Mon, Oct 27, 2025 at 09:57:38AM +0200, Leon Romanovsky wrote:
> On Mon, Oct 27, 2025 at 08:49:22AM +0100, Christoph Hellwig wrote:
> > > +	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;
> > 
> > I almost wonder if we should just the pci_p2pdma_map_type values into
> > place.  But that's a future cleanup, I'd rather get this going now.
> 
> I thought about it, but decided to use flags as more space efficient.
> PCI_P2PDMA_MAP_BUS_ADDR == 3 and PCI_P2PDMA_MAP_THRU_HOST_BRIDGE == 4.
> It means that will need to occupy 6 bits (extra u8 IOD field), while
> this flags encoding takes only 4 bits (without extra IOD field).

BTW, one can reorganize pci_p2pdma_map_type to make sure that
PCI_P2PDMA_MAP_BUS_ADDR will be 2 and PCI_P2PDMA_MAP_THRU_HOST_BRIDGE
will be 3, so it will be possible to take 2 bits per-type instead of 3.

diff --git a/include/linux/pci-p2pdma.h b/include/linux/pci-p2pdma.h
index 951f81a38f3a..2280e5a55b1f 100644
--- a/include/linux/pci-p2pdma.h
+++ b/include/linux/pci-p2pdma.h
@@ -112,14 +112,6 @@ enum pci_p2pdma_map_type {
         */
        PCI_P2PDMA_MAP_NONE,

-       /*
-        * PCI_P2PDMA_MAP_NOT_SUPPORTED: Indicates the transaction will
-        * traverse the host bridge and the host bridge is not in the
-        * allowlist. DMA Mapping routines should return an error when
-        * this is returned.
-        */
-       PCI_P2PDMA_MAP_NOT_SUPPORTED,
-
        /*
         * PCI_P2PDMA_MAP_BUS_ADDR: Indicates that two devices can talk to
         * each other directly through a PCI switch and the transaction will
@@ -136,6 +128,14 @@ enum pci_p2pdma_map_type {
         * case of IOMMUs) should be used to program the DMA engine.
         */
        PCI_P2PDMA_MAP_THRU_HOST_BRIDGE,
+
+       /*
+        * PCI_P2PDMA_MAP_NOT_SUPPORTED: Indicates the transaction will
+        * traverse the host bridge and the host bridge is not in the
+        * allowlist. DMA Mapping routines should return an error when
+        * this is returned.
+        */
+       PCI_P2PDMA_MAP_NOT_SUPPORTED,
 };

 struct pci_p2pdma_map_state {

Thanks



More information about the Linux-nvme mailing list