All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v7 8/8] dmaengine: dw-axi-dmac: guard shared IRQs across the controller lifetime
Date: Wed, 18 Nov 2026 00:32:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-219846@kernel.org> (raw)
In-Reply-To: <20261117-submit-dw-axi-dma-stop-pause-v1-v7-8-d5f2309afd72@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] dmaengine: dw-axi-dmac: unhandled IRQ storm in dw_probe()
  before irq_ready
- [Medium] dmaengine: dw-axi-dmac: unhandled IRQ in dw_remove() before
  masking DMAC
- [Medium] dmaengine: dw-axi-dmac: dw_axi_dma_interrupt() drops IRQs in
  PM transitions
--

commit 7c162a89d8b1aefab137f65050f65004c3cd340c
Author: James Hilliard <james.hilliard1@gmail.com>

dmaengine: dw-axi-dmac: guard shared IRQs across the controller lifetime

This commit gates the shared interrupt handler on an irq_ready flag and a
runtime PM active check, while updating probe, suspend, and remove paths
to drain and mask interrupts around power state transitions.

> diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> index 0116c44d3bef1..b1d7530367448 100644
> --- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
> +++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c

[ ... ]

> @@ -1166,6 +1167,14 @@ static irqreturn_t dw_axi_dma_interrupt(int irq, void *dev_id)
>  
>  	u32 status, i;
>  
> +	/* Pair with publication after channel registration in dw_probe(). */
> +	if (!smp_load_acquire(&chip->irq_ready))
> +		return IRQ_NONE;
> +
> +	/* Shared interrupts can arrive while the controller is suspended. */
> +	if (IS_ENABLED(CONFIG_PM) && pm_runtime_get_if_active(chip->dev) <= 0)
> +		return IRQ_NONE;

[Severity: Medium]
Can pm_runtime_get_if_active() drop valid controller interrupts during PM
transitions?

pm_runtime_get_if_active() returns 0 unless runtime_status is RPM_ACTIVE,
and returns -EINVAL when runtime PM is disabled (disable_depth > 0).
However, controller interrupts (INT_EN_MASK in DMAC_CFG) are enabled in
hardware during transition windows where those conditions do not hold:

- In rpm_resume(), runtime_status is still RPM_RESUMING when
  axi_dma_runtime_resume() -> axi_dma_resume() calls axi_dma_irq_enable().
- In rpm_suspend(), runtime_status is already RPM_SUSPENDING before
  axi_dma_runtime_suspend() -> axi_dma_quiesce_irqs() masks INT_EN_MASK.
- In pm_runtime_force_suspend() and pm_runtime_force_resume(),
  disable_depth is non-zero while hardware interrupts are still enabled
  before suspend or already re-enabled during resume.

If the controller asserts its level-triggered interrupt line during any of
these windows, dw_axi_dma_interrupt() returns IRQ_NONE without masking
DMAC_CFG or clearing CH_INTSTATUS, causing an unhandled IRQ storm that can
disable the shared IRQ line.

[ ... ]

> @@ -1661,16 +1687,23 @@ static int dw_probe(struct platform_device *pdev)
>  	pm_runtime_get_noresume(chip->dev);
>  	ret = axi_dma_resume(chip);
>  	if (ret < 0)
> -		goto err_pm_disable;
> +		goto err_pm_put;
>  
>  	axi_dma_hw_init(chip);
>  
> -	pm_runtime_put(chip->dev);
> +	ret = pm_runtime_set_active(chip->dev);
> +	if (ret)
> +		goto err_suspend;
> +	pm_runtime_enable(chip->dev);
>  
>  	ret = dmaenginem_async_device_register(&dw->dma);
>  	if (ret)
>  		goto err_pm_disable;
>  
> +	/* Publish initialized hardware and channel devices to the IRQ handler. */
> +	smp_store_release(&chip->irq_ready, true);
> +	pm_runtime_put(chip->dev);

[Severity: High]
Can dw_probe() trigger an unhandled interrupt storm before chip->irq_ready
is set to true?

axi_req_irqs() has already registered dw_axi_dma_interrupt() earlier in
dw_probe(), and there are two windows where hardware interrupts are enabled
while chip->irq_ready is still false:

1. axi_dma_resume() enables global DMAC interrupts via
   axi_dma_irq_enable() before axi_dma_hw_init() masks and clears the
   per-channel interrupts.  On platforms without a reset line, or after a
   kexec or prior unbind (since dw_remove() does not clear CH_INTSTATUS),
   any stale pending channel interrupt will immediately assert the IRQ
   line while chip->irq_ready is false.
2. dmaenginem_async_device_register() publishes the DMA_MEMCPY channels to
   in-kernel consumers before smp_store_release(&chip->irq_ready, true)
   runs, so a client on another CPU can allocate a channel and complete a
   transfer before chip->irq_ready becomes true.

In either window, dw_axi_dma_interrupt() returns IRQ_NONE without masking
or clearing the level-triggered interrupt, causing a hardirq storm until
note_interrupt() permanently disables the shared IRQ line.

[ ... ]

> @@ -1697,21 +1735,24 @@ static void dw_remove(struct platform_device *pdev)
>  	u32 i;
>  	int ret;
>  
> -	/* Enable clk before accessing to registers */
> -	ret = clk_bulk_prepare_enable(ARRAY_SIZE(chip->clks), chip->clks);
> -	if (ret)
> -		dev_warn(chip->dev, "failed to enable clocks before remove: %d\n",
> -			 ret);
> -	axi_dma_irq_disable(chip);
> -	for (i = 0; i < dw->hdata->nr_channels; i++) {
> -		axi_chan_disable(&chip->dw->chan[i]);
> -		axi_chan_irq_disable(&chip->dw->chan[i], DWAXIDMAC_IRQ_ALL);
> +	WRITE_ONCE(chip->irq_ready, false);
> +	ret = pm_runtime_resume_and_get(chip->dev);
> +	pm_runtime_disable(chip->dev);
> +	if (ret < 0) {
> +		dev_warn(chip->dev, "failed to resume before remove: %d\n", ret);
> +		goto free_irqs;
>  	}
> -	axi_dma_disable(chip);
>  
> -	pm_runtime_disable(chip->dev);
> -	axi_dma_suspend(chip);
> +	axi_dma_quiesce_irqs(chip);

[Severity: Medium]
Does clearing chip->irq_ready and disabling runtime PM before
axi_dma_quiesce_irqs() leave hardware interrupts unmasked while
dw_axi_dma_interrupt() refuses to handle them?

In dw_remove(), WRITE_ONCE(chip->irq_ready, false) and
pm_runtime_disable() both run before axi_dma_quiesce_irqs() masks
INT_EN_MASK in DMAC_CFG.  Furthermore, if the device was runtime-suspended,
pm_runtime_resume_and_get() calls axi_dma_resume() -> axi_dma_irq_enable()
and unmasks INT_EN_MASK while chip->irq_ready is already false.  Any
level-triggered DMAC interrupt firing in this window causes
dw_axi_dma_interrupt() to return IRQ_NONE without masking or clearing the
source, which can trigger a spurious IRQ storm and disable the shared IRQ
line.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-submit-dw-axi-dma-stop-pause-v1-v7-0-d5f2309afd72@gmail.com?part=8

      reply	other threads:[~2026-11-18  0:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-18  0:07 [PATCH v7 0/8] dmaengine: dw-axi-dmac: fix termination and pause acknowledgment James Hilliard
2026-11-18  0:07 ` [PATCH v7 1/8] dmaengine: dw-axi-dmac: keep cyclic mode in the descriptor James Hilliard
2026-11-18  0:07 ` [PATCH v7 2/8] dmaengine: dw-axi-dmac: poll the correct enable bit during termination James Hilliard
2026-11-18  0:07 ` [PATCH v7 3/8] dmaengine: dw-axi-dmac: retain descriptors when termination times out James Hilliard
2026-11-18  0:07 ` [PATCH v7 4/8] dmaengine: dw-axi-dmac: use atomic polling for suspend acknowledgment James Hilliard
2026-11-18  0:07 ` [PATCH v7 5/8] dmaengine: dw-axi-dmac: preserve pending pause requests James Hilliard
2026-11-18  0:07 ` [PATCH v7 6/8] dmaengine: dw-axi-dmac: retain descriptors until callbacks drain James Hilliard
2026-11-18  0:07 ` [PATCH v7 7/8] dmaengine: dw-axi-dmac: serialize interrupt status with channel reuse James Hilliard
2026-11-18  0:07 ` [PATCH v7 8/8] dmaengine: dw-axi-dmac: guard shared IRQs across the controller lifetime James Hilliard
2026-11-18  0:32   ` sashiko-bot [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=sashiko-outbox-219846@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --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.