mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: James Hilliard <james.hilliard1@gmail.com>
Cc: Vinod Koul <vkoul@kernel.org>, Frank Li <Frank.Li@kernel.org>,
	Chen-Yu Tsai <wens@kernel.org>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Samuel Holland <samuel@sholland.org>,
	Arnd Bergmann <arnd@arndb.de>, Maxime Ripard <mripard@kernel.org>,
	Jens Kuske <jenskuske@gmail.com>,
	Jean-Francois Moine <moinejf@free.fr>,
	Hongling Zeng <zenghongling@kylinos.cn>,
	Chengfeng Ye <cyeaa@connect.ust.hk>,
	Nguyen Minh Tien <tien.nguyenminh@embeddedlinux.blog>,
	dmaengine@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 9/9] dmaengine: sun6i: keep cyclic state with the prepared descriptor
Date: Fri, 13 Nov 2026 15:26:30 -0500	[thread overview]
Message-ID: <avdydqA68HXljug8@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v3-9-ef1acb0be768@gmail.com>

On Fri, Oct 23, 2026 at 05:38:28PM -0600, James Hilliard wrote:
> Preparing a cyclic transfer sets vchan->cyclic before the descriptor is
> submitted. A finite transfer on that channel can then select package
> interrupts and take the cyclic callback path instead of completing its
> cookie. Merely preparing an unrelated future transfer must not change
> the active transfer or the meaning of queued descriptors.
>
> Store the flag in sun6i_desc and consult the active descriptor when
> selecting interrupts, completing a transfer and terminating it. Finite
> descriptors retain their zero-initialized flag. This also makes callback
> retirement depend on the descriptor whose lifetime is being ended.
>
> The shared state was identified during the H616 cyclic UART RX review.
>
> Fixes: a90e173f3faf ("dmaengine: sun6i: Add cyclic capability")
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  drivers/dma/sun6i-dma.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index b83138745bd1..2152979f72f2 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -191,6 +191,7 @@ struct sun6i_desc {
>  	struct virt_dma_desc	vd;
>  	dma_addr_t		p_lli;
>  	struct sun6i_dma_lli	*v_lli;
> +	bool			cyclic;
>  };
>
>  struct sun6i_pchan {
> @@ -207,7 +208,6 @@ struct sun6i_vchan {
>  	struct sun6i_pchan	*phy;
>  	u8			port;
>  	u8			irq_type;
> -	bool			cyclic;
>  	bool			paused;
>  };
>
> @@ -507,7 +507,7 @@ static int sun6i_dma_start_desc(struct sun6i_vchan *vchan)
>  			     (DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) <<
>  			     (irq_offset * DMA_IRQ_CHAN_WIDTH));
>
> -	vchan->irq_type = vchan->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE;
> +	vchan->irq_type = pchan->desc->cyclic ? DMA_IRQ_PKG : DMA_IRQ_QUEUE;
>
>  	irq_val = sun6i_read_irq_en(sdev, irq_reg);
>  	irq_val &= ~((DMA_IRQ_HALF | DMA_IRQ_PKG | DMA_IRQ_QUEUE) <<
> @@ -610,7 +610,7 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id)
>  			desc = pchan->desc;
>  			if (vchan && desc && (status & vchan->irq_type)) {
>  				spin_lock(&vchan->vc.lock);
> -				if (vchan->cyclic) {
> +				if (desc->cyclic) {
>  					vchan_cyclic_callback(&desc->vd);
>  				} else {
>  					/* Completion transfers ownership to virt-dma. */
> @@ -911,7 +911,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(
>
>  	prev->p_lli_next = txd->p_lli;		/* cyclic list */
>
> -	vchan->cyclic = true;
> +	txd->cyclic = true;
>
>  	return vchan_tx_prep(&vchan->vc, &txd->vd, flags);
>
> @@ -1000,13 +1000,12 @@ static int sun6i_dma_terminate_all(struct dma_chan *chan)
>  		struct virt_dma_desc *vd = &pchan->desc->vd;
>
>  		/* A cyclic callback may still hold this descriptor outside vc.lock. */
> -		if (vchan->cyclic)
> +		if (pchan->desc->cyclic)
>  			vchan_terminate_vdesc(vd);
>  		else
>  			list_add_tail(&vd->node, &head);
>  	}
>
> -	vchan->cyclic = false;
>  	vchan->paused = false;
>  	/* Leave terminated cyclic descriptors for the sleepable synchronize. */
>  	list_splice_tail_init(&vchan->vc.desc_allocated, &head);
>
> --
> 2.53.0
>

      reply	other threads:[~2026-11-13 20:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-23 23:38 [PATCH v3 0/9] dmaengine: sun6i: fix interrupt routing and channel lifetime James Hilliard
2026-10-23 23:38 ` [PATCH v3 1/9] dmaengine: sun6i: fix physical channel index in interrupt handler James Hilliard
2026-10-23 23:38 ` [PATCH v3 2/9] dmaengine: sun6i: handle the last partial interrupt bank James Hilliard
2026-10-26 20:57   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 3/9] dmaengine: sun6i: take the device lock before the virtual channel lock James Hilliard
2026-10-26 21:05   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 4/9] dmaengine: sun6i: serialize physical channel ownership James Hilliard
2026-10-26 21:14   ` Frank Li
2026-10-26 21:42     ` James Hilliard
2026-11-13 20:12   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 5/9] dmaengine: sun6i: detach completed descriptors before invoking callbacks James Hilliard
2026-11-13 20:17   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 6/9] dmaengine: sun6i: retire interrupt state before reusing physical channels James Hilliard
2026-11-13 20:18   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 7/9] dmaengine: sun6i: track paused virtual channels James Hilliard
2026-11-13 20:21   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 8/9] dmaengine: sun6i: synchronize callbacks before releasing channel resources James Hilliard
2026-11-13 20:24   ` Frank Li
2026-10-23 23:38 ` [PATCH v3 9/9] dmaengine: sun6i: keep cyclic state with the prepared descriptor James Hilliard
2026-11-13 20:26   ` Frank Li [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=avdydqA68HXljug8@lizhi-Precision-Tower-5810 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --cc=arnd@arndb.de \
    --cc=cyeaa@connect.ust.hk \
    --cc=dmaengine@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=jenskuske@gmail.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=moinejf@free.fr \
    --cc=mripard@kernel.org \
    --cc=samuel@sholland.org \
    --cc=tien.nguyenminh@embeddedlinux.blog \
    --cc=vkoul@kernel.org \
    --cc=wens@kernel.org \
    --cc=zenghongling@kylinos.cn \
    /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

all inboxes | Powered by JetHome®