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,
Sashiko <sashiko-bot@kernel.org>
Subject: Re: [PATCH v2 2/6] dmaengine: sun6i: handle the last partial interrupt bank
Date: Fri, 23 Oct 2026 15:05:03 -0500 [thread overview]
Message-ID: <atu97zfpnCHWPsMh@SMW015318> (raw)
In-Reply-To: <20261023-submit-sun6i-dma-lifetime-next-v1-v2-2-c9e07cc44bf8@gmail.com>
On Fri, Oct 23, 2026 at 12:42:36PM -0600, James Hilliard wrote:
> The number of physical channels need not be a multiple of the number
> covered by an interrupt-status register. H3 has twelve channels and
> eight channels per bank. Rounding down the number of banks leaves its
> channels 8 through 11 without completion handling.
>
> Round up the number of banks to visit, and stop processing the last bank
> at num_pchans so unused status bits cannot index past the physical-channel
> array. Use the controller's configured bank size for both limits and
> the physical-channel index.
>
> Fixes: f008db8c00c1 ("dmaengine: sun6i: Add support for Allwinner H3 (sun8i) variant")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/r/20260706065650.34B131F00A3A@smtp.kernel.org
> Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
> ---
> drivers/dma/sun6i-dma.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
> index 9d94a37fcf10..0a9645171180 100644
> --- a/drivers/dma/sun6i-dma.c
> +++ b/drivers/dma/sun6i-dma.c
> @@ -587,12 +587,13 @@ static void sun6i_dma_tasklet(struct tasklet_struct *t)
> static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id)
> {
> struct sun6i_dma_dev *sdev = dev_id;
> + u32 channels_per_reg = sdev->cfg->num_channels_per_reg;
> struct sun6i_vchan *vchan;
> struct sun6i_pchan *pchan;
> int i, j, ret = IRQ_NONE;
> u32 status;
>
> - for (i = 0; i < sdev->num_pchans / sdev->cfg->num_channels_per_reg; i++) {
> + for (i = 0; i < DIV_ROUND_UP(sdev->num_pchans, channels_per_reg); i++) {
> status = sun6i_read_irq_stat(sdev, i);
> if (!status)
> continue;
> @@ -602,8 +603,9 @@ static irqreturn_t sun6i_dma_interrupt(int irq, void *dev_id)
>
> sun6i_write_irq_stat(sdev, i, status);
>
> - for (j = 0; (j < sdev->cfg->num_channels_per_reg) && status; j++) {
> - pchan = sdev->pchans + i * sdev->cfg->num_channels_per_reg + j;
> + for (j = 0; j < channels_per_reg &&
> + i * channels_per_reg + j < sdev->num_pchans && status; j++) {
look like check status first is a little better
for (j = 0; status && j < channels_per_reg &&
i * channels_per_reg + j < sdev->num_pchans; j++)
Frank
> + pchan = sdev->pchans + i * channels_per_reg + j;
> vchan = pchan->vchan;
> if (vchan && (status & vchan->irq_type)) {
> if (vchan->cyclic) {
>
> --
> 2.53.0
>
next prev parent reply other threads:[~2026-10-23 20:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 18:42 [PATCH v2 0/6] dmaengine: sun6i: fix interrupt routing and channel lifetime James Hilliard
2026-10-23 18:42 ` [PATCH v2 1/6] dmaengine: sun6i: fix physical channel index in interrupt handler James Hilliard
2026-10-23 18:42 ` [PATCH v2 2/6] dmaengine: sun6i: handle the last partial interrupt bank James Hilliard
2026-10-23 20:05 ` Frank Li [this message]
2026-10-23 18:42 ` [PATCH v2 3/6] dmaengine: sun6i: serialize channel reassignment with interrupt handling James Hilliard
2026-10-23 20:32 ` Frank Li
2026-10-23 21:57 ` James Hilliard
2026-10-23 18:42 ` [PATCH v2 4/6] dmaengine: sun6i: track paused virtual channels James Hilliard
2026-10-23 18:42 ` [PATCH v2 5/6] dmaengine: sun6i: synchronize callbacks before releasing channel resources James Hilliard
2026-10-23 18:42 ` [PATCH v2 6/6] dmaengine: sun6i: keep cyclic state with the prepared descriptor James Hilliard
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=atu97zfpnCHWPsMh@SMW015318 \
--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=sashiko-bot@kernel.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®