* [PATCH 1/3] dmaengine: Use non-atomic bit ops for cap_mask manipulation
2026-09-03 14:16 [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe Peng Fan (OSS)
@ 2026-09-03 14:16 ` Peng Fan (OSS)
2026-09-03 14:16 ` [PATCH 2/3] dmaengine: imx-sdma: Use non-atomic __set_bit() for event_mask setup Peng Fan (OSS)
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Peng Fan (OSS) @ 2026-09-03 14:16 UTC (permalink / raw)
To: Vinod Koul, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam
Cc: dmaengine, linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
dma_cap_set() and dma_cap_clear() are called exclusively during driver
probe, before dma_async_device_register() makes the device visible to
the rest of the system. There is no concurrent access to cap_mask at
that point, so switch to the non-atomic __set_bit()/__clear_bit()
equivalents.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
include/linux/dmaengine.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
index fe33a20abc614..923d914691d06 100644
--- a/include/linux/dmaengine.h
+++ b/include/linux/dmaengine.h
@@ -1551,14 +1551,14 @@ static inline bool async_tx_test_ack(struct dma_async_tx_descriptor *tx)
static inline void
__dma_cap_set(enum dma_transaction_type tx_type, dma_cap_mask_t *dstp)
{
- set_bit(tx_type, dstp->bits);
+ __set_bit(tx_type, dstp->bits);
}
#define dma_cap_clear(tx, mask) __dma_cap_clear((tx), &(mask))
static inline void
__dma_cap_clear(enum dma_transaction_type tx_type, dma_cap_mask_t *dstp)
{
- clear_bit(tx_type, dstp->bits);
+ __clear_bit(tx_type, dstp->bits);
}
#define dma_cap_zero(mask) __dma_cap_zero(&(mask))
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/3] dmaengine: imx-sdma: Use non-atomic __set_bit() for event_mask setup
2026-09-03 14:16 [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe Peng Fan (OSS)
2026-09-03 14:16 ` [PATCH 1/3] dmaengine: Use non-atomic bit ops for cap_mask manipulation Peng Fan (OSS)
@ 2026-09-03 14:16 ` Peng Fan (OSS)
2026-09-03 14:16 ` [PATCH 3/3] dmaengine: imx-sdma: Use __assign_bit() for ownership configuration Peng Fan (OSS)
2026-09-03 19:29 ` [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe Frank Li
3 siblings, 0 replies; 5+ messages in thread
From: Peng Fan (OSS) @ 2026-09-03 14:16 UTC (permalink / raw)
To: Vinod Koul, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam
Cc: dmaengine, linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
In sdma_set_watermarklevel_for_p2p(), the event_mask[] fields are zeroed
in sdma_config_channel() right before this function is called, and the
channel has already been disabled. There is no concurrent access to
event_mask at this point, so replace set_bit() with __set_bit().
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/dma/imx-sdma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 36368835a845c..63261ab6402b9 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1241,8 +1241,8 @@ static void sdma_set_watermarklevel_for_p2p(struct sdma_channel *sdmac)
int lwml = sdmac->watermark_level & SDMA_WATERMARK_LEVEL_LWML;
int hwml = (sdmac->watermark_level & SDMA_WATERMARK_LEVEL_HWML) >> 16;
- set_bit(sdmac->event_id0 % 32, &sdmac->event_mask[1]);
- set_bit(sdmac->event_id1 % 32, &sdmac->event_mask[0]);
+ __set_bit(sdmac->event_id0 % 32, &sdmac->event_mask[1]);
+ __set_bit(sdmac->event_id1 % 32, &sdmac->event_mask[0]);
if (sdmac->event_id0 > 31)
sdmac->watermark_level |= SDMA_WATERMARK_LEVEL_LWE;
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] dmaengine: imx-sdma: Use __assign_bit() for ownership configuration
2026-09-03 14:16 [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe Peng Fan (OSS)
2026-09-03 14:16 ` [PATCH 1/3] dmaengine: Use non-atomic bit ops for cap_mask manipulation Peng Fan (OSS)
2026-09-03 14:16 ` [PATCH 2/3] dmaengine: imx-sdma: Use non-atomic __set_bit() for event_mask setup Peng Fan (OSS)
@ 2026-09-03 14:16 ` Peng Fan (OSS)
2026-09-03 19:29 ` [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe Frank Li
3 siblings, 0 replies; 5+ messages in thread
From: Peng Fan (OSS) @ 2026-09-03 14:16 UTC (permalink / raw)
To: Vinod Koul, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam
Cc: dmaengine, linux-kernel, imx, linux-arm-kernel, Peng Fan
From: Peng Fan <peng.fan@nxp.com>
Replace the if/else pairs of __set_bit()/__clear_bit() in
sdma_config_ownership() with __assign_bit(), which does exactly the
same conditional set-or-clear in a single call.
No functional change.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
drivers/dma/imx-sdma.c | 17 +++--------------
1 file changed, 3 insertions(+), 14 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index 63261ab6402b9..da565409beaaa 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -710,20 +710,9 @@ static int sdma_config_ownership(struct sdma_channel *sdmac,
mcu = readl_relaxed(sdma->regs + SDMA_H_HOSTOVR);
dsp = readl_relaxed(sdma->regs + SDMA_H_DSPOVR);
- if (dsp_override)
- __clear_bit(channel, &dsp);
- else
- __set_bit(channel, &dsp);
-
- if (event_override)
- __clear_bit(channel, &evt);
- else
- __set_bit(channel, &evt);
-
- if (mcu_override)
- __clear_bit(channel, &mcu);
- else
- __set_bit(channel, &mcu);
+ __assign_bit(channel, &dsp, !dsp_override);
+ __assign_bit(channel, &evt, !event_override);
+ __assign_bit(channel, &mcu, !mcu_override);
writel_relaxed(evt, sdma->regs + SDMA_H_EVTOVR);
writel_relaxed(mcu, sdma->regs + SDMA_H_HOSTOVR);
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe
2026-09-03 14:16 [PATCH 0/3] dmaengine: Use non-atomic bit ops where safe Peng Fan (OSS)
` (2 preceding siblings ...)
2026-09-03 14:16 ` [PATCH 3/3] dmaengine: imx-sdma: Use __assign_bit() for ownership configuration Peng Fan (OSS)
@ 2026-09-03 19:29 ` Frank Li
3 siblings, 0 replies; 5+ messages in thread
From: Frank Li @ 2026-09-03 19:29 UTC (permalink / raw)
To: Peng Fan (OSS)
Cc: Vinod Koul, Frank Li, Sascha Hauer, Pengutronix Kernel Team,
Fabio Estevam, dmaengine, linux-kernel, imx, linux-arm-kernel,
Peng Fan
On Thu, Sep 03, 2026 at 10:16:11PM +0800, Peng Fan (OSS) wrote:
> dma_cap_set()/dma_cap_clear() and imx-sdma event_mask setup use atomic
> set_bit()/clear_bit() in contexts where no concurrent access is
> possible:
>
> - dma_cap_set()/dma_cap_clear() are called exclusively during driver
> probe, before dma_async_device_register() makes the device visible.
> - imx-sdma event_mask[] is zeroed and configured during channel setup
> while the channel is disabled.
>
> Switch both to non-atomic __set_bit()/__clear_bit() equivalents.
Any benefit to switch?
Frank
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> ---
> Peng Fan (3):
> dmaengine: Use non-atomic bit ops for cap_mask manipulation
> dmaengine: imx-sdma: Use non-atomic __set_bit() for event_mask setup
> dmaengine: imx-sdma: Use __assign_bit() for ownership configuration
>
> drivers/dma/imx-sdma.c | 21 +++++----------------
> include/linux/dmaengine.h | 4 ++--
> 2 files changed, 7 insertions(+), 18 deletions(-)
> ---
> base-commit: 89c07d98716a13454ec3fd9f97689e812cc71bd4
> change-id: 20260903-dma-mask-ddf64d770f7d
>
> Best regards,
> --
> Peng Fan <peng.fan@nxp.com>
>
^ permalink raw reply [flat|nested] 5+ messages in thread