kernel/dma/direct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
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>
---
kernel/dma/direct.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 583c592..4391b79 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -476,7 +476,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
* must be mapped with CPU physical address and not PCI
* bus addresses.
*/
- break;
+ fallthrough;
case PCI_P2PDMA_MAP_NONE:
need_sync = true;
sg->dma_address = dma_direct_map_phys(dev, sg_phys(sg),
--
2.9.4
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!
> ---
> kernel/dma/direct.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> index 583c592..4391b79 100644
> --- a/kernel/dma/direct.c
> +++ b/kernel/dma/direct.c
> @@ -476,7 +476,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
> * must be mapped with CPU physical address and not PCI
> * bus addresses.
> */
> - break;
> + fallthrough;
> case PCI_P2PDMA_MAP_NONE:
> need_sync = true;
> sg->dma_address = dma_direct_map_phys(dev, sg_phys(sg),
Best regards
--
Marek Szyprowski, PhD
Samsung R&D Institute Poland
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.
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
>
>
> > ---
> > kernel/dma/direct.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> > index 583c592..4391b79 100644
> > --- a/kernel/dma/direct.c
> > +++ b/kernel/dma/direct.c
> > @@ -476,7 +476,7 @@ int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl, int nents,
> > * must be mapped with CPU physical address and not PCI
> > * bus addresses.
> > */
> > - break;
> > + fallthrough;
> > case PCI_P2PDMA_MAP_NONE:
> > need_sync = true;
> > sg->dma_address = dma_direct_map_phys(dev, sg_phys(sg),
>
> Best regards
> --
> Marek Szyprowski, PhD
> Samsung R&D Institute Poland
>
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
© 2016 - 2026 Red Hat, Inc.