From: Christoph Hellwig <hch@lst.de>
To: Leon Romanovsky <leon@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>, Keith Busch <kbusch@kernel.org>,
Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-nvme@lists.infradead.org
Subject: Re: [PATCH v2 2/2] block-dma: properly take MMIO path
Date: Wed, 22 Oct 2025 08:21:35 +0200 [thread overview]
Message-ID: <20251022062135.GD4317@lst.de> (raw)
In-Reply-To: <20251020-block-with-mmio-v2-2-147e9f93d8d4@nvidia.com>
On Mon, Oct 20, 2025 at 08:00:21PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> In commit eadaa8b255f3 ("dma-mapping: introduce new DMA attribute to
> indicate MMIO memory"), DMA_ATTR_MMIO attribute was added to describe
> MMIO addresses, which require to avoid any memory cache flushing, as
> an outcome of the discussion pointed in Link tag below.
>
> In case of PCI_P2PDMA_MAP_THRU_HOST_BRIDGE transfer, blk-mq-dm logic
> treated this as regular page and relied on "struct page" DMA flow.
> That flow performs CPU cache flushing, which shouldn't be done here,
> and doesn't set IOMMU_MMIO flag in DMA-IOMMU case.
>
> Link: https://lore.kernel.org/all/f912c446-1ae9-4390-9c11-00dce7bf0fd3@arm.com/
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
> ---
> block/blk-mq-dma.c | 6 ++++--
> drivers/nvme/host/pci.c | 23 +++++++++++++++++++++--
> include/linux/blk-integrity.h | 7 ++++---
> include/linux/blk-mq-dma.h | 11 +++++++----
> 4 files changed, 36 insertions(+), 11 deletions(-)
>
> diff --git a/block/blk-mq-dma.c b/block/blk-mq-dma.c
> index 4ba7b0323da4..3ede8022b41c 100644
> --- a/block/blk-mq-dma.c
> +++ b/block/blk-mq-dma.c
> @@ -94,7 +94,7 @@ static bool blk_dma_map_direct(struct request *req, struct device *dma_dev,
> struct blk_dma_iter *iter, struct phys_vec *vec)
> {
> iter->addr = dma_map_phys(dma_dev, vec->paddr, vec->len,
> - rq_dma_dir(req), 0);
> + rq_dma_dir(req), iter->attrs);
> if (dma_mapping_error(dma_dev, iter->addr)) {
> iter->status = BLK_STS_RESOURCE;
> return false;
> @@ -116,7 +116,7 @@ static bool blk_rq_dma_map_iova(struct request *req, struct device *dma_dev,
>
> do {
> error = dma_iova_link(dma_dev, state, vec->paddr, mapped,
> - vec->len, dir, 0);
> + vec->len, dir, iter->attrs);
> if (error)
> break;
> mapped += vec->len;
> @@ -184,6 +184,8 @@ static bool blk_dma_map_iter_start(struct request *req, struct device *dma_dev,
> * P2P transfers through the host bridge are treated the
> * same as non-P2P transfers below and during unmap.
> */
> + iter->attrs |= DMA_ATTR_MMIO;
DMA_ATTR_MMIO is the only flags in iter->attrs, and I can't see any other
DMA mapping flag that would fit here. So I'd rather store the
enum pci_p2pdma_map_type here, which also removes the need for REQ_P2PDMA
and BIP_P2P_DMA when propagating that to nvme.
next prev parent reply other threads:[~2025-10-22 6:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-20 17:00 [PATCH v2 0/2] block: Enable proper MMIO memory handling for P2P DMA Leon Romanovsky
2025-10-20 17:00 ` [PATCH v2 1/2] nvme-pci: migrate to dma_map_phys instead of map_page Leon Romanovsky
2025-10-20 23:36 ` Chaitanya Kulkarni
2025-10-22 6:14 ` Christoph Hellwig
2025-10-26 12:38 ` Leon Romanovsky
2025-10-27 6:49 ` Christoph Hellwig
2025-10-20 17:00 ` [PATCH v2 2/2] block-dma: properly take MMIO path Leon Romanovsky
2025-10-20 23:37 ` Chaitanya Kulkarni
2025-10-22 6:21 ` Christoph Hellwig [this message]
2025-10-26 13:30 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251022062135.GD4317@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=kbusch@kernel.org \
--cc=leon@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.