From: Jean-Michel Hautbois via B4 Relay <devnull+jeanmichel.hautbois.yoseli.org@kernel.org>
To: Frank Li <Frank.Li@nxp.com>, Vinod Koul <vkoul@kernel.org>,
Angelo Dureghello <angelo@sysam.it>
Cc: Greg Ungerer <gerg@linux-m68k.org>,
imx@lists.linux.dev, dmaengine@vger.kernel.org,
linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org,
Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
Subject: [PATCH v2 3/5] dma: mcf-edma: Fix interrupt handler for 64 DMA channels
Date: Wed, 26 Nov 2025 09:36:04 +0100 [thread overview]
Message-ID: <20251126-dma-coldfire-v2-3-5b1e4544d609@yoseli.org> (raw)
In-Reply-To: <20251126-dma-coldfire-v2-0-5b1e4544d609@yoseli.org>
From: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
Fix the DMA completion interrupt handler to properly handle all 64
channels on MCF54418 ColdFire processors.
The previous code used BIT(ch) to test interrupt status bits, which
causes undefined behavior on 32-bit architectures when ch >= 32 because
unsigned long is 32 bits and the shift would exceed the type width.
Replace with bitmap_from_u64() and for_each_set_bit() which correctly
handle 64-bit values on 32-bit systems by using a proper bitmap
representation.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@yoseli.org>
---
drivers/dma/mcf-edma-main.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/dma/mcf-edma-main.c b/drivers/dma/mcf-edma-main.c
index 6a7d88895501..6353303df957 100644
--- a/drivers/dma/mcf-edma-main.c
+++ b/drivers/dma/mcf-edma-main.c
@@ -18,7 +18,8 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
{
struct fsl_edma_engine *mcf_edma = dev_id;
struct edma_regs *regs = &mcf_edma->regs;
- unsigned int ch;
+ unsigned long ch;
+ DECLARE_BITMAP(status_mask, 64);
u64 intmap;
intmap = ioread32(regs->inth);
@@ -27,11 +28,11 @@ static irqreturn_t mcf_edma_tx_handler(int irq, void *dev_id)
if (!intmap)
return IRQ_NONE;
- for (ch = 0; ch < mcf_edma->n_chans; ch++) {
- if (intmap & BIT(ch)) {
- iowrite8(EDMA_MASK_CH(ch), regs->cint);
- fsl_edma_tx_chan_handler(&mcf_edma->chans[ch]);
- }
+ bitmap_from_u64(status_mask, intmap);
+
+ for_each_set_bit(ch, status_mask, mcf_edma->n_chans) {
+ iowrite8(EDMA_MASK_CH(ch), regs->cint);
+ fsl_edma_tx_chan_handler(&mcf_edma->chans[ch]);
}
return IRQ_HANDLED;
--
2.39.5
next prev parent reply other threads:[~2025-11-26 8:36 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 8:36 [PATCH v2 0/5] dma: fsl/mcf-edma: Bug fixes and enhancements for ColdFire support Jean-Michel Hautbois via B4 Relay
2025-11-26 8:36 ` [PATCH v2 1/5] dma: fsl-edma: Add FSL_EDMA_DRV_MCF flag for ColdFire eDMA Jean-Michel Hautbois via B4 Relay
2025-11-26 8:36 ` [PATCH v2 2/5] dma: mcf-edma: Add per-channel IRQ naming for debugging Jean-Michel Hautbois via B4 Relay
2025-11-26 16:12 ` Frank Li
2025-12-16 15:26 ` Vinod Koul
2025-12-16 15:38 ` Frank Li
2025-12-17 6:34 ` Jean-Michel Hautbois
2025-12-17 16:21 ` Frank Li
2025-11-26 8:36 ` Jean-Michel Hautbois via B4 Relay [this message]
2025-11-26 8:36 ` [PATCH v2 4/5] dma: fsl-edma: Move error handler out of header file Jean-Michel Hautbois via B4 Relay
2025-11-26 8:36 ` [PATCH v2 5/5] dma: mcf-edma: Fix error handler for all 64 DMA channels Jean-Michel Hautbois via B4 Relay
2025-11-26 16:14 ` Frank Li
2025-12-16 15:27 ` [PATCH v2 0/5] dma: fsl/mcf-edma: Bug fixes and enhancements for ColdFire support Vinod Koul
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=20251126-dma-coldfire-v2-3-5b1e4544d609@yoseli.org \
--to=devnull+jeanmichel.hautbois.yoseli.org@kernel.org \
--cc=Frank.Li@nxp.com \
--cc=angelo@sysam.it \
--cc=dmaengine@vger.kernel.org \
--cc=gerg@linux-m68k.org \
--cc=imx@lists.linux.dev \
--cc=jeanmichel.hautbois@yoseli.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.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