From: Frank Li <Frank.li@oss.nxp.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: "Viresh Kumar" <vireshk@kernel.org>,
"Andy Shevchenko" <andriy.shevchenko@linux.intel.com>,
"Vinod Koul" <vkoul@kernel.org>, "Frank Li" <Frank.Li@kernel.org>,
"Dan Williams" <djbw@kernel.org>,
"Serge Semin" <fancer.lancer@gmail.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Jiri Slaby" <jirislaby@kernel.org>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
dmaengine@vger.kernel.org, linux-serial@vger.kernel.org,
linux-kernel@vger.kernel.org, Sashiko <sashiko-bot@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>
Subject: Re: [PATCH v9 3/6] dmaengine: dw: use virt-dma for descriptor and callback ownership
Date: Wed, 18 Nov 2026 12:04:55 -0600 [thread overview]
Message-ID: <av3oxznSW_5oH8la@SMW015318> (raw)
In-Reply-To: <20261117-submit-dw-dma-synchronize-v1-v9-3-7dc066ed0bcf@gmail.com>
On Tue, Nov 17, 2026 at 03:48:38PM -0700, James Hilliard wrote:
> The status getter can invoke a client's completion callback while polling
> the hardware. An 8250 RX timeout calls it with the port lock held, and the
> callback takes that same lock. Termination also lacks a synchronization
> hook to wait for callbacks already detached from the channel's queues.
>
> Use virt-dma for transaction queues, cookie completion and callback
> delivery. Keep the active transaction and hardware state under vc.lock.
> Polling still processes RAW.XFER and advances software-LLP blocks, so
> clients such as catpt can complete transfers with the controller interrupt
> masked. Client callbacks run only from the per-channel virt-dma tasklet.
>
> Submit only the first block of each transaction to virt-dma. Its child
> LLIs remain on the driver's hardware-chain list and are freed together
> after the callback returns. Keep the controller tasklet for hardware
> event processing and error recovery.
>
> Complete cookies under vc.lock before handing descriptors to the callback
> tasklet. Complete terminated cookies in submission order without invoking
> their callbacks, so a concurrent termination cannot advance the completed
> cookie past an older completion that later moves it backwards. Newly
> submitted transactions become eligible to start when issue_pending()
> moves them to the issued queue.
>
> Implement device_synchronize with vchan_synchronize(), which drains only
> the selected channel's callbacks. Drain them before releasing channel
> resources as well. Exclude the controller tasklet while clearing channel
> configuration and powering down, and let a pending run return without
> register access after the last channel has been released.
>
> This implements the callback deferral proposed by Serge Semin using the
> shared infrastructure suggested by Andy Shevchenko.
>
> Fixes: 3bfb1d20b547 ("dmaengine: Driver for the Synopsys DesignWare DMA controller")
> Fixes: 69cea5a00d31 ("dmaengine/dw_dmac: Replace spin_lock* with irqsave variants and enable submission from callback")
> Fixes: b36f09c3c441 ("dmaengine: Add transfer termination synchronization support")
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Link: https://lore.kernel.org/r/20240911184710.4207-3-fancer.lancer@gmail.com
> Link: https://lore.kernel.org/r/avrHOJ-fVZOO32bI@ashevche-desk.local
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
...
>
> struct dw_dma_chan {
> - struct dma_chan chan;
> + struct virt_dma_chan vc;
This patch is too big to review.
Suggest create prepare patch change dma_chan to virt_dma_chan and remove
spinlock_t lock by using vc.lock.
So functional it is same.
Than base on prepare patch to switch to use vc's queue.
Frank
> void __iomem *ch_regs;
> u8 mask;
> u8 priority;
> @@ -273,14 +274,9 @@ struct dw_dma_chan {
> /* software emulation of the LLP transfers */
> struct list_head *tx_node_active;
>
> - spinlock_t lock;
> -
> - /* these other elements are all protected by lock */
> + /* these other elements are all protected by vc.lock */
> unsigned long flags;
> - struct list_head active_list;
> - struct list_head queue;
> -
> - unsigned int descs_allocated;
> + struct dw_desc *desc;
>
> /* hardware configuration */
> unsigned int block_size;
> @@ -307,7 +303,7 @@ __dwc_regs(struct dw_dma_chan *dwc)
>
> static inline struct dw_dma_chan *to_dw_dma_chan(struct dma_chan *chan)
> {
> - return container_of(chan, struct dw_dma_chan, chan);
> + return container_of(chan, struct dw_dma_chan, vc.chan);
> }
>
> struct dw_dma {
> @@ -391,18 +387,18 @@ struct dw_desc {
> #define lli_write(d, reg, v) ((d)->lli.reg = cpu_to_le32(v))
>
> /* THEN values for driver housekeeping */
> - struct list_head desc_node;
> + /* Only the first block is submitted to virt-dma. */
> struct list_head tx_list;
> - struct dma_async_tx_descriptor txd;
> + struct virt_dma_desc vd;
> size_t len;
> size_t total_len;
> u32 residue;
> };
>
> -#define to_dw_desc(h) list_entry(h, struct dw_desc, desc_node)
> +#define to_dw_desc(h) list_entry(h, struct dw_desc, vd.node)
>
> static inline struct dw_desc *
> -txd_to_dw_desc(struct dma_async_tx_descriptor *txd)
> +vd_to_dw_desc(struct virt_dma_desc *vd)
> {
> - return container_of(txd, struct dw_desc, txd);
> + return container_of(vd, struct dw_desc, vd);
> }
>
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-11-18 18:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 22:48 [PATCH v9 0/6] dmaengine: dw: serialize completion and termination James Hilliard
2026-11-17 22:48 ` [PATCH v9 1/6] dmaengine: dw: Fix XFER bit set, but channel not idle error James Hilliard
2026-11-17 23:03 ` sashiko-bot
2026-11-17 22:48 ` [PATCH v9 2/6] dmaengine: dw: serialize error recovery with channel termination James Hilliard
2026-11-17 22:54 ` sashiko-bot
2026-11-17 22:48 ` [PATCH v9 3/6] dmaengine: dw: use virt-dma for descriptor and callback ownership James Hilliard
2026-11-17 23:08 ` sashiko-bot
2026-11-18 18:04 ` Frank Li [this message]
2026-11-17 22:48 ` [PATCH v9 4/6] dmaengine: dw: extract hardware-LLP residue calculation James Hilliard
2026-11-17 22:54 ` sashiko-bot
2026-11-17 22:48 ` [PATCH v9 5/6] dmaengine: dw: calculate residue in the status getter James Hilliard
2026-11-17 23:03 ` sashiko-bot
2026-11-17 22:48 ` [PATCH v9 6/6] dmaengine: dw: report residue for queued transfers James Hilliard
2026-11-17 22:57 ` sashiko-bot
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=av3oxznSW_5oH8la@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=djbw@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=fancer.lancer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=james.hilliard1@gmail.com \
--cc=jirislaby@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=sashiko-bot@kernel.org \
--cc=vireshk@kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox