Skip to contentSkip to conversation

shdmac: Remove misleading TODO comment in dmae_set_chcr

PATCH In review Amin GATTOUT 2 participants 4 messages Nov 28, 2025 – Dec 2, 2025 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 shdmac: Remove misleading TODO comment in dmae_set_chcr

The comment suggested that the dmae_is_busy() check in dmae_set_chcr() is superfluous and could be removed. However, this check serves as an important safety net to prevent configuration of a DMA channel while it is active. Keeping it helps ensure transfer integrity and avoids unexpected hardware behavior in edge cases.

---
 drivers/dma/sh/shdmac.c | 1 -
 1 file changed, 1 deletion(-)
drivers/dma/sh/shdmac.c +0 -1
index 603e15102e45..d0e0437ad916 100644
@@ -243,7 +243,6 @@ static void dmae_init(struct sh_dmae_chan *sh_chan)
 
 static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
 {
-	/* If DMA is active, cannot set CHCR. TODO: remove this superfluous check */
 	if (dmae_is_busy(sh_chan))
 		return -EBUSY;
 
Signature · 1 line
2.43.0
#1 lore raw
Quoted 3 lines · Amin GATTOUT

The comment suggested that the dmae_is_busy() check in dmae_set_chcr() is superfluous and could be removed. However, this check serves as an important safety net to prevent configuration of a DMA channel while

I find this a bit odd overall, because apparently nobody checks the result of dmae_set_chcr() .
So if it is such an important safety check, why is the result never checked ?
As it looks, the caller doesn't care and continue as usual. The difference would be that chcr is never actually written if the channel is busy. Which looks strange. And "unexpected hardware behavior in edge cases" is quite vague. Do you have a scenario when an issue would happen ? dmae_set_chcr() gets called on resume() and setup_xfer(). Is it possible that in fact dmae_set_chcr() is not called correctly then ? Maybe this chcr should be written at a different time when we are sure the dma is not busy ?
Or why is it even possible to have the dma busy when calling it ?

Eugen

Quoted 20 lines

it is active. Keeping it helps ensure transfer integrity and avoids unexpected hardware behavior in edge cases.

---
 drivers/dma/sh/shdmac.c | 1 -
 1 file changed, 1 deletion(-)
drivers/dma/sh/shdmac.c +0 -1
index 603e15102e45..d0e0437ad916 100644
@@ -243,7 +243,6 @@ static void dmae_init(struct sh_dmae_chan *sh_chan)
 
 static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
 {
-	/* If DMA is active, cannot set CHCR. TODO: remove this superfluous check */
 	if (dmae_is_busy(sh_chan))
 		return -EBUSY;
 
author
#2 lore raw

Thanks Eugen,

I could not reproduce any concrete issue, and after re-reading the flow I think your assessment is correct:
If the channel is busy, CHCR is indeed never written, so in that sense the TODO comment was accurate.

Given this, removing the busy check seems more consistent than removing the comment...
My patch was therefore not addressing the real problem, sorry for the noise.

If you agree, I can prepare a follow-up patch that removes thedmae_is_busy() check, or leave things as they are if that is preferred.

Amin

Quoted 45 lines · Eugen Hristev
Quoted 3 lines · Amin GATTOUT

The comment suggested that the dmae_is_busy() check in dmae_set_chcr() is superfluous and could be removed. However, this check serves as an important safety net to prevent configuration of a DMA channel while

I find this a bit odd overall, because apparently nobody checks the result of dmae_set_chcr() .
So if it is such an important safety check, why is the result never checked ?
As it looks, the caller doesn't care and continue as usual. The difference would be that chcr is never actually written if the channel is busy. Which looks strange. And "unexpected hardware behavior in edge cases" is quite vague. Do you have a scenario when an issue would happen ? dmae_set_chcr() gets called on resume() and setup_xfer(). Is it possible that in fact dmae_set_chcr() is not called correctly then ? Maybe this chcr should be written at a different time when we are sure the dma is not busy ?
Or why is it even possible to have the dma busy when calling it ?

Eugen

Quoted 20 lines

it is active. Keeping it helps ensure transfer integrity and avoids unexpected hardware behavior in edge cases.

---
 drivers/dma/sh/shdmac.c | 1 -
 1 file changed, 1 deletion(-)
drivers/dma/sh/shdmac.c +0 -1
index 603e15102e45..d0e0437ad916 100644
@@ -243,7 +243,6 @@ static void dmae_init(struct sh_dmae_chan *sh_chan)
 
 static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
 {
-     /* If DMA is active, cannot set CHCR. TODO: remove this superfluous check */
      if (dmae_is_busy(sh_chan))
              return -EBUSY;
 
#3 lore raw
Quoted 7 lines · Amin

Thanks Eugen,

I could not reproduce any concrete issue, and after re-reading the flow I think your assessment is correct:
If the channel is busy, CHCR is indeed never written, so in that sense the TODO comment was accurate.

Quoted 7 lines

Given this, removing the busy check seems more consistent than removing the comment...
My patch was therefore not addressing the real problem, sorry for the noise.

If you agree, I can prepare a follow-up patch that removes thedmae_is_busy() check, or leave things as they are if that is preferred.

I am not sure whether any of the solutions is right. The commit that introduced the comment is pretty old (2011) so it would be difficult to understand the reasoning.

Maybe someone else who is more involved in working with this driver could give more insight.

Eugen

Quoted 50 lines

Amin

Quoted 45 lines · Eugen Hristev
Quoted 3 lines · Amin GATTOUT

The comment suggested that the dmae_is_busy() check in dmae_set_chcr() is superfluous and could be removed. However, this check serves as an important safety net to prevent configuration of a DMA channel while

I find this a bit odd overall, because apparently nobody checks the result of dmae_set_chcr() .
So if it is such an important safety check, why is the result never checked ?
As it looks, the caller doesn't care and continue as usual. The difference would be that chcr is never actually written if the channel is busy. Which looks strange. And "unexpected hardware behavior in edge cases" is quite vague. Do you have a scenario when an issue would happen ? dmae_set_chcr() gets called on resume() and setup_xfer(). Is it possible that in fact dmae_set_chcr() is not called correctly then ? Maybe this chcr should be written at a different time when we are sure the dma is not busy ?
Or why is it even possible to have the dma busy when calling it ?

Eugen

Quoted 20 lines

it is active. Keeping it helps ensure transfer integrity and avoids unexpected hardware behavior in edge cases.

---
 drivers/dma/sh/shdmac.c | 1 -
 1 file changed, 1 deletion(-)
drivers/dma/sh/shdmac.c +0 -1
index 603e15102e45..d0e0437ad916 100644
@@ -243,7 +243,6 @@ static void dmae_init(struct sh_dmae_chan *sh_chan)
 
 static int dmae_set_chcr(struct sh_dmae_chan *sh_chan, u32 val)
 {
-     /* If DMA is active, cannot set CHCR. TODO: remove this superfluous check */
      if (dmae_is_busy(sh_chan))
              return -EBUSY;