From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Frank.Li@oss.nxp.com
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Russell King" <linux@armlinux.org.uk>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Peter Griffin" <peter.griffin@linaro.org>,
"Alim Akhtar" <alim.akhtar@samsung.com>,
"Cunhao Lu" <1579567540@qq.com>, "Frank Li" <Frank.Li@nxp.com>,
"Raul E Rangel" <rrangel@chromium.org>,
"Moteen Shah" <m-shah@ti.com>, "Kendall Willis" <k-willis@ti.com>,
"Dhruva Gole" <d-gole@ti.com>,
"Matthias Feser" <mfe@kbsgmbhfr.onmicrosoft.com>,
"Kartik Rajput" <kkartik@nvidia.com>,
"Fan Wu" <fanwu01@zju.edu.cn>,
"Karl Mehltretter" <kmehltretter@gmail.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Stefan Dösinger" <stefandoesinger@gmail.com>,
"Haoxiang Li" <haoxiang_li2024@163.com>,
"Mike Rapoport (Microsoft)" <rppt@kernel.org>,
"Zhaoyang Yu" <2426767509@qq.com>, "Kees Cook" <kees@kernel.org>,
"John Ogness" <john.ogness@linutronix.de>,
"Biju Das" <biju.das.jz@bp.renesas.com>,
"Geert Uytterhoeven" <geert+renesas@glider.be>,
"Lad Prabhakar" <prabhakar.mahadev-lad.rj@bp.renesas.com>,
"Cosmin Tanislav" <cosmin-gabriel.tanislav.xa@renesas.com>,
"open list:TTY LAYER AND SERIAL DRIVERS"
<linux-kernel@vger.kernel.org>,
"open list:TTY LAYER AND SERIAL DRIVERS"
<linux-serial@vger.kernel.org>,
"moderated list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES"
<linux-arm-kernel@lists.infradead.org>,
"open list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES"
<linux-samsung-soc@vger.kernel.org>,
vkoul@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH 1/2] serial: use dmaengine_get_dma_device() instead of chan->device->dev
Date: Mon, 28 Sep 2026 11:51:37 +0300 [thread overview]
Message-ID: <aroqmVWSPd9YVDjM@ashevche-desk.local> (raw)
In-Reply-To: <20260925200850.1678179-1-Frank.Li@oss.nxp.com>
On Fri, Sep 25, 2026 at 04:08:30PM -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.
...
> /* RX buffer */
> if (!dma->rx_size)
> dma->rx_size = PAGE_SIZE;
>
> - dma->rx_buf = dma_alloc_coherent(dma->rxchan->device->dev, dma->rx_size,
> + dma->rx_buf = dma_alloc_coherent(rx_dev, dma->rx_size,
> &dma->rx_addr, GFP_KERNEL);
Now one parameter can be moved up and positive outcome the split becomes logical
(on a logic boundaries).
> if (!dma->rx_buf) {
> ret = -ENOMEM;
...
> /* TX buffer */
> - dma->tx_addr = dma_map_single(dma->txchan->device->dev,
> + dma->tx_addr = dma_map_single(tx_dev,
> p->port.state->port.xmit_buf,
> UART_XMIT_SIZE,
> DMA_TO_DEVICE);
You can fix indentation while at it.
> - if (dma_mapping_error(dma->txchan->device->dev, dma->tx_addr)) {
> - dma_free_coherent(dma->rxchan->device->dev, dma->rx_size,
> + if (dma_mapping_error(tx_dev, dma->tx_addr)) {
> + dma_free_coherent(rx_dev, dma->rx_size,
> dma->rx_buf, dma->rx_addr);
> ret = -ENOMEM;
...
> /* Release RX resources */
> dmaengine_terminate_sync(dma->rxchan);
> dma->rx_running = 0;
> - dma_free_coherent(dma->rxchan->device->dev, dma->rx_size, dma->rx_buf,
> + dma_free_coherent(dmaengine_get_dma_device(dma->rxchan), dma->rx_size, dma->rx_buf,
> dma->rx_addr);
And here the last parameter of the previous line can be moved to the next line.
...
> + db->buf = dma_alloc_coherent(dmaengine_get_dma_device(chan), PL011_DMA_BUFFER_SIZE,
> &db->dma, GFP_KERNEL);
^^^ (1)
> if (!db->buf)
> return -ENOMEM;
...
> {
> if (db->buf) {
> - dma_free_coherent(chan->device->dev,
> + dma_free_coherent(dmaengine_get_dma_device(chan),
> PL011_DMA_BUFFER_SIZE, db->buf, db->dma);
Perhaps you want both (1) and this be consistent, either (1) be rewrapped,
or this one
dma_free_coherent(dmaengine_get_dma_device(chan), PL011_DMA_BUFFER_SIZE,
db->buf, db->dma);
> }
...
> struct pch_dma_slave *param = slave;
>
> if ((chan->chan_id == param->chan_id) && (param->dma_dev ==
> - chan->device->dev)) {
> + dmaengine_get_dma_device(chan))) {
Even original code has broken indentation. What about rewrapping it?
if ((chan->chan_id == param->chan_id) &&
(param->dma_dev == dmaengine_get_dma_device(chan))) {
> chan->private = param;
> return true;
--
With Best Regards,
Andy Shevchenko
prev parent reply other threads:[~2026-09-28 8:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 20:08 [PATCH 1/2] serial: use dmaengine_get_dma_device() instead of chan->device->dev Frank.Li
2026-09-25 20:08 ` [PATCH 2/2] serial: amba-pl011: use dmaengine public API instead of raw ops Frank.Li
2026-09-25 20:16 ` sashiko-bot
2026-09-25 20:19 ` [PATCH 1/2] serial: use dmaengine_get_dma_device() instead of chan->device->dev sashiko-bot
2026-09-28 8:51 ` Andy Shevchenko [this message]
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=aroqmVWSPd9YVDjM@ashevche-desk.local \
--to=andriy.shevchenko@linux.intel.com \
--cc=1579567540@qq.com \
--cc=2426767509@qq.com \
--cc=Frank.Li@nxp.com \
--cc=Frank.Li@oss.nxp.com \
--cc=alim.akhtar@samsung.com \
--cc=biju.das.jz@bp.renesas.com \
--cc=cosmin-gabriel.tanislav.xa@renesas.com \
--cc=d-gole@ti.com \
--cc=fanwu01@zju.edu.cn \
--cc=geert+renesas@glider.be \
--cc=gregkh@linuxfoundation.org \
--cc=haoxiang_li2024@163.com \
--cc=imx@lists.linux.dev \
--cc=jirislaby@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=k-willis@ti.com \
--cc=kees@kernel.org \
--cc=kkartik@nvidia.com \
--cc=kmehltretter@gmail.com \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m-shah@ti.com \
--cc=mfe@kbsgmbhfr.onmicrosoft.com \
--cc=peter.griffin@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=rppt@kernel.org \
--cc=rrangel@chromium.org \
--cc=stefandoesinger@gmail.com \
--cc=vkoul@kernel.org \
/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.