Linux IOMMU Development
 help / color / mirror / Atom feed
From: Pranjal Shrivastava <praan@google.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	lirongqing <lirongqing@baidu.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Logan Gunthorpe <logang@deltatee.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org, hch@lst.de
Subject: Re: [PATCH] dma-mapping: direct: fix missing mapping for THRU_HOST_BRIDGE segments
Date: Thu, 4 Jun 2026 07:46:45 +0000	[thread overview]
Message-ID: <aiEtZddAA1dDJ5RG@google.com> (raw)
In-Reply-To: <20260604071856.GA245424@unreal>

On Thu, Jun 04, 2026 at 10:18:56AM +0300, Leon Romanovsky wrote:
> On Wed, Jun 03, 2026 at 06:25:22PM +0200, Marek Szyprowski wrote:
> > On 03.06.2026 03:37, lirongqing wrote:
> > > From: Li RongQing <lirongqing@baidu.com>
> > >
> > > In dma_direct_map_sg(), the case PCI_P2PDMA_MAP_THRU_HOST_BRIDGE
> > > incorrectly used 'break' instead of falling through to MAP_NONE.
> > > As a result, segments traversing the host bridge skipped the required
> > > dma_direct_map_phys() call entirely, leaving sg->dma_address
> > > uninitialized and leading to DMA failures. Fix this by using
> > > 'fallthrough;'.
> > >
> > > Fixes: a25e7962db0d79 ("PCI/P2PDMA: Refactor the p2pdma mapping helpers")
> > > Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> > > Signed-off-by: Li RongQing <lirongqing@baidu.com>
> > 
> > Applied to dma-mapping-fixes, thanks!
> 
> The change looks correct, but it will be better if this change will
> improve d0d08f4bd7f6 ("dma-direct: Fix missing sg_dma_len assignment in
> P2PDMA bus mappings") too.

I was thinking the same and was about to post a fix.

> 
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index ec887f443741..e98b6547c950 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -489,9 +489,8 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
>                 case PCI_P2PDMA_MAP_BUS_ADDR:
>                         sg->dma_address = pci_p2pdma_bus_addr_map(
>                                 p2pdma_state.mem, sg_phys(sg));
> -                       sg_dma_len(sg) = sg->length;
>                         sg_dma_mark_bus_address(sg);
> -                       continue;
> +                       break;
>                 default:
>                         ret = -EREMOTEIO;
>                         goto out_unmap;
> 
> Thanks
> 

For this fix:
Reviewed-by: Pranjal Shrivastava <praan@google.com>

Thanks,
Praan

  reply	other threads:[~2026-06-04  7:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260603013739eucas1p2acd3cd59c1083639deb58723d57558af@eucas1p2.samsung.com>
2026-06-03  1:37 ` [PATCH] dma-mapping: direct: fix missing mapping for THRU_HOST_BRIDGE segments lirongqing
2026-06-03 16:25   ` Marek Szyprowski
2026-06-04  7:18     ` Leon Romanovsky
2026-06-04  7:46       ` Pranjal Shrivastava [this message]
2026-06-08  9:13       ` Marek Szyprowski

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=aiEtZddAA1dDJ5RG@google.com \
    --to=praan@google.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=bhelgaas@google.com \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lirongqing@baidu.com \
    --cc=logang@deltatee.com \
    --cc=m.szyprowski@samsung.com \
    --cc=mcgrof@kernel.org \
    --cc=robin.murphy@arm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox