DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: tumic@gpxsee.org
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH] dmaengine: xilinx: xdma: Fix broken PM suspend/resume
Date: Fri, 20 Nov 2026 13:10:49 +0000	[thread overview]
Message-ID: <sashiko-outbox-225187@kernel.org> (raw)
In-Reply-To: <20261120125254.8678-1-tumic@gpxsee.org>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] dmaengine: xilinx: xdma: missing user IRQ mask restore in
  xdma_irq_reconfig()
- [Low] dmaengine: xilinx: xdma: unused function warnings when
  CONFIG_PM_SLEEP=n
- [Low] dmaengine: xilinx: xdma: incomplete kernel-doc on
  xdma_reconfig_channels()
- [Low] dmaengine: xilinx: xdma: duplicated IRQ setup in
  xdma_irq_reconfig()
--

commit 0974145b10560ba9aa27c85ae11ed4e81e50da07
Author: Martin Tůma <martin.tuma@digiteqautomotive.com>

dmaengine: xilinx: xdma: Fix broken PM suspend/resume

This commit adds system sleep PM suspend and resume callbacks to disable
XDMA channel interrupts on suspend and reconfigure the DMA channels and
IRQ registers on resume.

> diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c
> index 9d827c9a12674..779a5f4b9db70 100644
> --- a/drivers/dma/xilinx/xdma.c
> +++ b/drivers/dma/xilinx/xdma.c
> @@ -398,6 +398,27 @@ static int xdma_xfer_stop(struct xdma_chan *xchan)
>  			    CHAN_CTRL_RUN_STOP);
>  }
>  
> +/**
> + * xdma_reconfig_channels - Reconfigure DMA channels
> + * @xdev: DMA device pointer
> + * @chans: channels configuration
> + */
> +static int xdma_reconfig_channels(struct xdma_device *xdev,
> +				  struct xdma_chan *chans,
> +				  u32 chan_num)
> +{
> +	int i, ret;
> +
> +	for (i = 0; i < chan_num; i++) {
> +		/* init channel hardware */
> +		ret = xdma_channel_init(&(chans[i]));
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}

[Severity: Low]
The kernel-doc comment for xdma_reconfig_channels() omits @chan_num, which
causes a W=1 kernel-doc warning.  Also, @xdev is unused here since
xdma_channel_init() retrieves it from chan->xdev_hdl.

> @@ -1018,6 +1039,45 @@ static int xdma_set_vector_reg(struct xdma_device *xdev, u32 vec_tbl_start,
>  	return 0;
>  }
>  
> +/**
> + * xdma_irq_reconfig - Reconfigure IRQs
> + * @xdev: DMA device pointer
> + */
> +static int xdma_irq_reconfig(struct xdma_device *xdev)
> +{
> +	u32 user_irq_start;
> +	int ret;
> +
> +	/* config hardware IRQ registers */
> +	ret = xdma_set_vector_reg(xdev, XDMA_IRQ_CHAN_VEC_NUM, 0,
> +				  XDMA_CHAN_NUM(xdev));
> +	if (ret) {
> +		xdma_err(xdev, "failed to set channel vectors: %d", ret);
> +		return ret;
> +	}
> +
> +	/* config user IRQ registers if needed */
> +	user_irq_start = XDMA_CHAN_NUM(xdev);
> +	if (xdev->irq_num > user_irq_start) {
> +		ret = xdma_set_vector_reg(xdev, XDMA_IRQ_USER_VEC_NUM,
> +					  user_irq_start,
> +					  xdev->irq_num - user_irq_start);
> +		if (ret) {
> +			xdma_err(xdev, "failed to set user vectors: %d", ret);
> +			return ret;
> +		}
> +	}
> +
> +	/* enable interrupt */
> +	ret = regmap_write(xdev->rmap, XDMA_IRQ_CHAN_INT_EN_W1S, ~0);

[Severity: High]
Does xdma_irq_reconfig() leave user interrupts disabled after resume?
It reprograms XDMA_IRQ_USER_VEC_NUM and re-enables channel interrupts via
XDMA_IRQ_CHAN_INT_EN_W1S, but never restores XDMA_IRQ_USER_INT_EN (and
xdma_suspend() does not mask or save it).  When the PCIe device loses
register state across suspend/resume, any user IRQs previously enabled via
xdma_enable_user_irq() (such as the SPI, I2C and video error IRQs enabled
during probe by mgb4) remain masked after resume.

> +	if (ret) {
> +		xdma_err(xdev, "failed to enable interrupt: %d", ret);
> +		return ret;
> +	}
> +
> +	return 0;
> +}

[Severity: Low]
This isn't a bug, but xdma_irq_reconfig() duplicates the vector and
interrupt enable register setup at the end of xdma_irq_init().  Could
xdma_irq_init() call xdma_irq_reconfig() instead?

[ ... ]

> @@ -1297,15 +1357,57 @@ static int xdma_probe(struct platform_device *pdev)

[ ... ]

> +static const struct dev_pm_ops xdma_dev_pm_ops = {
> +	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(xdma_suspend, xdma_resume)
> +};
> +
>  static struct platform_driver xdma_driver = {
>  	.driver		= {
>  		.name = "xdma",
> +		.pm = &xdma_dev_pm_ops,
>  	},

[Severity: Low]
When CONFIG_PM_SLEEP is disabled, SET_NOIRQ_SYSTEM_SLEEP_PM_OPS() expands
to nothing and leaves xdma_suspend() and xdma_resume() unused, triggering
-Wunused-function warnings.  Using DEFINE_NOIRQ_DEV_PM_OPS() and
pm_sleep_ptr(&xdma_dev_pm_ops) avoids the warning.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261120125254.8678-1-tumic@gpxsee.org?part=1

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 12:52 [PATCH] dmaengine: xilinx: xdma: Fix broken PM suspend/resume tumic
2026-11-20 13:10 ` 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-225187@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tumic@gpxsee.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