* Re: [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
[not found] <20260923184612.3583132-1-Frank.Li@oss.nxp.com>
@ 2026-09-23 18:50 ` Frank Li
2026-09-23 18:57 ` Arnd Bergmann
1 sibling, 0 replies; 5+ messages in thread
From: Frank Li @ 2026-09-23 18:50 UTC (permalink / raw)
To: Ulf Hansson, Aubin Constans, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Paul Cercueil, Russell King, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Aaro Koskinen, Andreas Färber, Manivannan Sadhasivam,
Wolfram Sang, Jesper Nilsson, Lars Persson, Arnd Bergmann,
Johan Hovold, Ge Gordon, Vinod Koul, Albert Yang, Jared Kangas,
Brian Masney, Martin Blumenstingl, Linus Walleij, Fan Wu,
Rosen Penev, Pengpeng Hou, Marco Crivellari, Pedro Demarchi Gomes,
Zhan Xusheng, Pan Chuang, Khalid Aziz, Ethan Nelson-Moore,
Rakuram Eswaran, Takashi Sakamoto, Runyu Xiao,
Matthew Wilcox (Oracle), Uwe Kleine-König,
open list:MULTIMEDIA CARD (MMC), SECURE DIGITAL (SD) AND...,
open list, moderated list:ARM/Microchip (AT91) SoC support,
open list:INGENIC JZ47xx SoCs,
open list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
open list:OMAP MMC SUPPORT,
moderated list:ARM/ACTIONS SEMI ARCHITECTURE,
open list:TMIO/SDHI MMC DRIVER,
open list:ARM/ARTPEC MACHINE SUPPORT
On Wed, Sep 23, 2026 at 02:45:47PM -0400, Frank.Li@oss.nxp.com wrote:
> From: Frank Li <Frank.Li@nxp.com>
>
> Replace direct dma_chan::device::dev access with the proper
> dmaengine_get_dma_device() for consumer API
>
> chan->device->dev is not always the device used for DMA mapping.
> Some DMA engines support per-channel IOMMU mappings, so different
> channels may use different DMA devices. dmaengine_get_dma_device()
> returns the correct device for each channel.
>
> This also prepares for making the DMA engine provider data structures
> private. DMA consumers should not access DMA engine internals directly.
>
> mxs-mmc.c wrong use mmc host device when do DMA map. Fix it by use
> dmaengine_get_dma_device().
>
> Assisted-by: LLM
> Reviewed-by: Linus Walleij <linusw@kernel.org>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Reviewed-by: Vinod Koul <vkoul@kernel.org>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
> Change in v4
> - Fix miss "R" at Reviewed-by tags.
> - Fix error path unmap dev at mxs-mmc.c (sashakio reported)
> - move dmaengine_get_dma_device(host->dma) after mxcmci_use_dma() to avoid
> defer host->dma if use pio mode (sashakio reported)
>
> Change in v3
> - add Linus Walleij and Vinod Koul's review by tags
> - Add missed omap and mxs-mmc.c (sashakio reported)
>
> Change in v2
> - find more place, which use device->dev for dma mapping. This time should
> clean all.
> - Reviewed-by: Linus Walleij <linusw@kernel.org>
>
> Cc: imx@lists.linux.dev
> Cc: vkoul@kernel.org
> ---
> drivers/mmc/host/Kconfig | 2 +-
Please forget this version, I make misstake to include a debug code, sorry
for annoise.
Frank
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
[not found] <20260923184612.3583132-1-Frank.Li@oss.nxp.com>
2026-09-23 18:50 ` [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev Frank Li
@ 2026-09-23 18:57 ` Arnd Bergmann
2026-09-23 19:33 ` Frank Li
1 sibling, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2026-09-23 18:57 UTC (permalink / raw)
To: Frank Li, Ulf Hansson, Aubin Constans, Nicolas Ferre,
Alexandre Belloni, Claudiu Beznea, Paul Cercueil, Russell King,
Frank Li, Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Aaro Koskinen, Andreas Färber, Manivannan Sadhasivam,
Wolfram Sang, Jesper Nilsson, Lars Persson, Johan Hovold,
gordon.ge, Vinod Koul, yangzh0906@thundersoft.com, Jared Kangas,
Brian Masney, Martin Blumenstingl, Linus Walleij, Fan Wu,
Rosen Penev, Pengpeng Hou, Marco Crivellari, Pedro Demarchi Gomes,
Zhan Xusheng, Pan Chuang, Khalid Aziz, Ethan Nelson-Moore,
Rakuram Eswaran, Takashi Sakamoto, Runyu Xiao, Matthew Wilcox,
Uwe Kleine-König, linux-mmc @ vger . kernel . org, open list,
moderated list:ARM/Microchip (AT91) SoC support,
open list:INGENIC JZ47xx SoCs,
open list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
Linux-OMAP, moderated list:ARM/ACTIONS SEMI ARCHITECTURE,
Linux-Renesas, open list:ARM/ARTPEC MACHINE SUPPORT
On Wed, Sep 23, 2026, at 20:45, Frank.Li@oss.nxp.com wrote:
> @@ -214,7 +214,7 @@ config MMC_SDHCI_OF_AT91
> config MMC_SDHCI_OF_ESDHC
> tristate "SDHCI OF support for the Freescale eSDHC controller"
> depends on MMC_SDHCI_PLTFM
> - depends on PPC || ARCH_MXC || ARCH_LAYERSCAPE || COMPILE_TEST
> + depends on PPC || ARCHMXC || ARCH_LAYERSCAPE || COMPILE_TEST
> select MMC_SDHCI_IO_ACCESSORS
> select FSL_GUTS
This looks like an accidental bug that should be removed from the patch.
> @@ -961,7 +961,7 @@ static void atmci_dma_cleanup(struct atmel_mci *host)
> struct mmc_data *data = host->data;
>
> if (data)
> - dma_unmap_sg(host->dma.chan->device->dev,
> + dma_unmap_sg(dmaengine_get_dma_device(host->dma.chan),
> data->sg, data->sg_len,
> mmc_get_dma_dir(data));
Since you have the exact construct in a lot of drivers, would
it make sense to take this one step further and introduce
a new set of helpers in drivers/dma/dmaengine.h, such as
unsigned int dmaengine_map_sg(struct dma_chan *chan, struct scatterlist *sg, ...);
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
2026-09-23 18:57 ` Arnd Bergmann
@ 2026-09-23 19:33 ` Frank Li
2026-09-23 21:40 ` Frank Li
0 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2026-09-23 19:33 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Ulf Hansson, Aubin Constans, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Paul Cercueil, Russell King, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Aaro Koskinen, Andreas Färber, Manivannan Sadhasivam,
Wolfram Sang, Jesper Nilsson, Lars Persson, Johan Hovold,
gordon.ge, Vinod Koul, yangzh0906@thundersoft.com, Jared Kangas,
Brian Masney, Martin Blumenstingl, Linus Walleij, Fan Wu,
Rosen Penev, Pengpeng Hou, Marco Crivellari, Pedro Demarchi Gomes,
Zhan Xusheng, Pan Chuang, Khalid Aziz, Ethan Nelson-Moore,
Rakuram Eswaran, Takashi Sakamoto, Runyu Xiao, Matthew Wilcox,
Uwe Kleine-König, linux-mmc @ vger . kernel . org, open list,
moderated list:ARM/Microchip (AT91) SoC support,
open list:INGENIC JZ47xx SoCs,
open list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
Linux-OMAP, moderated list:ARM/ACTIONS SEMI ARCHITECTURE,
Linux-Renesas, open list:ARM/ARTPEC MACHINE SUPPORT
On Wed, Sep 23, 2026 at 08:57:04PM +0200, Arnd Bergmann wrote:
> On Wed, Sep 23, 2026, at 20:45, Frank.Li@oss.nxp.com wrote:
> > @@ -214,7 +214,7 @@ config MMC_SDHCI_OF_AT91
> > config MMC_SDHCI_OF_ESDHC
> > tristate "SDHCI OF support for the Freescale eSDHC controller"
> > depends on MMC_SDHCI_PLTFM
> > - depends on PPC || ARCH_MXC || ARCH_LAYERSCAPE || COMPILE_TEST
> > + depends on PPC || ARCHMXC || ARCH_LAYERSCAPE || COMPILE_TEST
> > select MMC_SDHCI_IO_ACCESSORS
> > select FSL_GUTS
>
> This looks like an accidental bug that should be removed from the patch.
It is accidently including my local change to build test. I found it when
post it.
>
> > @@ -961,7 +961,7 @@ static void atmci_dma_cleanup(struct atmel_mci *host)
> > struct mmc_data *data = host->data;
> >
> > if (data)
> > - dma_unmap_sg(host->dma.chan->device->dev,
> > + dma_unmap_sg(dmaengine_get_dma_device(host->dma.chan),
> > data->sg, data->sg_len,
> > mmc_get_dma_dir(data));
>
> Since you have the exact construct in a lot of drivers, would
> it make sense to take this one step further and introduce
> a new set of helpers in drivers/dma/dmaengine.h, such as
>
> unsigned int dmaengine_map_sg(struct dma_chan *chan, struct scatterlist *sg, ...);
If add this, suppose should be set of map_*, like dmaengine_map_single(),
Vinod:
Is it add new APIs like thats?
Frank
>
> Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
2026-09-23 19:33 ` Frank Li
@ 2026-09-23 21:40 ` Frank Li
2026-09-23 23:01 ` Arnd Bergmann
0 siblings, 1 reply; 5+ messages in thread
From: Frank Li @ 2026-09-23 21:40 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Ulf Hansson, Aubin Constans, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Paul Cercueil, Russell King, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Aaro Koskinen, Andreas Färber, Manivannan Sadhasivam,
Wolfram Sang, Jesper Nilsson, Lars Persson, Johan Hovold,
gordon.ge, Vinod Koul, yangzh0906@thundersoft.com, Jared Kangas,
Brian Masney, Martin Blumenstingl, Linus Walleij, Fan Wu,
Rosen Penev, Pengpeng Hou, Marco Crivellari, Pedro Demarchi Gomes,
Zhan Xusheng, Pan Chuang, Khalid Aziz, Ethan Nelson-Moore,
Rakuram Eswaran, Takashi Sakamoto, Runyu Xiao, Matthew Wilcox,
Uwe Kleine-König, linux-mmc @ vger . kernel . org, open list,
moderated list:ARM/Microchip (AT91) SoC support,
open list:INGENIC JZ47xx SoCs,
open list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
Linux-OMAP, moderated list:ARM/ACTIONS SEMI ARCHITECTURE,
Linux-Renesas, open list:ARM/ARTPEC MACHINE SUPPORT
On Wed, Sep 23, 2026 at 02:33:35PM -0500, Frank Li wrote:
> On Wed, Sep 23, 2026 at 08:57:04PM +0200, Arnd Bergmann wrote:
> > On Wed, Sep 23, 2026, at 20:45, Frank.Li@oss.nxp.com wrote:
> > > @@ -214,7 +214,7 @@ config MMC_SDHCI_OF_AT91
> > > config MMC_SDHCI_OF_ESDHC
> > > tristate "SDHCI OF support for the Freescale eSDHC controller"
> > > depends on MMC_SDHCI_PLTFM
> > > - depends on PPC || ARCH_MXC || ARCH_LAYERSCAPE || COMPILE_TEST
> > > + depends on PPC || ARCHMXC || ARCH_LAYERSCAPE || COMPILE_TEST
> > > select MMC_SDHCI_IO_ACCESSORS
> > > select FSL_GUTS
> >
> > This looks like an accidental bug that should be removed from the patch.
>
> It is accidently including my local change to build test. I found it when
> post it.
>
> >
> > > @@ -961,7 +961,7 @@ static void atmci_dma_cleanup(struct atmel_mci *host)
> > > struct mmc_data *data = host->data;
> > >
> > > if (data)
> > > - dma_unmap_sg(host->dma.chan->device->dev,
> > > + dma_unmap_sg(dmaengine_get_dma_device(host->dma.chan),
> > > data->sg, data->sg_len,
> > > mmc_get_dma_dir(data));
> >
> > Since you have the exact construct in a lot of drivers, would
> > it make sense to take this one step further and introduce
> > a new set of helpers in drivers/dma/dmaengine.h, such as
> >
> > unsigned int dmaengine_map_sg(struct dma_chan *chan, struct scatterlist *sg, ...);
>
> If add this, suppose should be set of map_*, like dmaengine_map_single(),
>
> Vinod:
> Is it add new APIs like thats?
Maybe we can enhence dmaengine_prep_slave_sg(),
Most patten like
sglen = dma_map_sg(chan->device->dev, data->sg,
data->sg_len, mmc_get_dma_dir(data));
dmaengine_slave_config(chan, &host->dma_conf);
desc = dmaengine_prep_slave_sg(chan,
data->sg, sglen, slave_dirn,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
let dmaengine_prep_slave_sg() include dma_map_sg(), which also reduce
error handle when return desc is NULL.
after call complete, auto ummap_sg(). We may add DMA_PREP_MAP flags to
keep back compatiblity.
after enhancement
consumer just need call
dmaengine_prep_slave_sg(chan, data->sg, data->sg_len, slave_dirn,
DMA_PREP_INTERRUPT | DMA_CTRL_ACK |
DMA_PREP_MAP)
Frank
>
> Frank
>
> >
> > Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev
2026-09-23 21:40 ` Frank Li
@ 2026-09-23 23:01 ` Arnd Bergmann
0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2026-09-23 23:01 UTC (permalink / raw)
To: Frank Li
Cc: Ulf Hansson, Aubin Constans, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Paul Cercueil, Russell King, Frank Li,
Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
Aaro Koskinen, Andreas Färber, Manivannan Sadhasivam,
Wolfram Sang, Jesper Nilsson, Lars Persson, Johan Hovold,
gordon.ge, Vinod Koul, yangzh0906@thundersoft.com, Jared Kangas,
Brian Masney, Martin Blumenstingl, Linus Walleij, Fan Wu,
Rosen Penev, Pengpeng Hou, Marco Crivellari, Pedro Demarchi Gomes,
Zhan Xusheng, Pan Chuang, Khalid Aziz, Ethan Nelson-Moore,
Rakuram Eswaran, Takashi Sakamoto, Runyu Xiao, Matthew Wilcox,
Uwe Kleine-König, linux-mmc @ vger . kernel . org, open list,
moderated list:ARM/Microchip (AT91) SoC support,
open list:INGENIC JZ47xx SoCs,
open list:ARM/FREESCALE IMX / MXC / LAYERSCAPE ARM ARCHIT...,
Linux-OMAP, moderated list:ARM/ACTIONS SEMI ARCHITECTURE,
Linux-Renesas, open list:ARM/ARTPEC MACHINE SUPPORT
On Wed, Sep 23, 2026, at 23:40, Frank Li wrote:
> On Wed, Sep 23, 2026 at 02:33:35PM -0500, Frank Li wrote:
>> On Wed, Sep 23, 2026 at 08:57:04PM +0200, Arnd Bergmann wrote:
> after enhancement
> consumer just need call
>
> dmaengine_prep_slave_sg(chan, data->sg, data->sg_len, slave_dirn,
> DMA_PREP_INTERRUPT | DMA_CTRL_ACK |
> DMA_PREP_MAP)
If that works, I think that would be perfect, good idea!
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-23 23:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260923184612.3583132-1-Frank.Li@oss.nxp.com>
2026-09-23 18:50 ` [PATCH v4 1/1] mmc: use dmaengine_get_dma_device() instead of chan->device->dev Frank Li
2026-09-23 18:57 ` Arnd Bergmann
2026-09-23 19:33 ` Frank Li
2026-09-23 21:40 ` Frank Li
2026-09-23 23:01 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox