[PATCH 3/4] block-dma: properly take MMIO path

Christoph Hellwig hch at lst.de
Tue Oct 14 21:18:46 PDT 2025


On Mon, Oct 13, 2025 at 01:34:30PM -0600, Keith Busch wrote:
> On Mon, Oct 13, 2025 at 10:29:40PM +0300, Leon Romanovsky wrote:
> > On Mon, Oct 13, 2025 at 01:01:18PM -0600, Keith Busch wrote:
> > > On Mon, Oct 13, 2025 at 06:34:11PM +0300, Leon Romanovsky wrote:
> > > >  static bool blk_dma_map_direct(struct request *req, struct device *dma_dev,
> > > >  		struct blk_dma_iter *iter, struct phys_vec *vec)
> > > >  {
> > > > +	unsigned int attrs = 0;
> > > > +
> > > > +	if (req->cmd_flags & REQ_MMIO)
> > > > +		attrs |= DMA_ATTR_MMIO;
> > > 
> > > Since data and integrity paylods use these same functions and may point
> > > to different kinds of memory, I think you'd have to pass the 'attrs'
> > > from the caller since it knows which flags to check for MMIO dma.
> > 
> > I think that hunk will fix it.
> > 
> > diff --git a/block/blk-mq-dma.c b/block/blk-mq-dma.c
> > index 38f5c34ca223..8af88ba97c7a 100644
> > --- a/block/blk-mq-dma.c
> > +++ b/block/blk-mq-dma.c
> > @@ -88,9 +88,11 @@ static bool blk_dma_map_bus(struct blk_dma_iter *iter, struct phys_vec *vec)
> >  static bool blk_dma_map_direct(struct request *req, struct device *dma_dev,
> >                 struct blk_dma_iter *iter, struct phys_vec *vec)
> >  {
> > +       struct bio_integrity_payload *bip = bio_integrity(req->bio);
> >         unsigned int attrs = 0;
> > 
> > -       if (req->cmd_flags & REQ_MMIO)
> > +       if ((!bip && req->cmd_flags & REQ_MMIO) ||
> > +           bio_integrity_flagged(req->bio, BIP_MMIO))
> >                 attrs |= DMA_ATTR_MMIO;
> 
> If cmd_flags has REQ_MMIO set, but the integrity flag doesn't have
> BIP_MMIO set, you will skip setting DMA_ATTR_MMIO, but I think we need
> that set when this is called for the data payload.

Yes, we just need to check the relevant flag in the caller
and pass it in.  Or maybe just stash it in  struct blk_dma_iter.



More information about the Linux-nvme mailing list