mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eugen Hristev <eugen.hristev@linaro.org>
To: Amin <amin.gattout@gmail.com>
Cc: vkoul@kernel.org, thomasandreatta2000@gmail.com,
	dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] shdmac: Remove misleading TODO comment in dmae_set_chcr
Date: Tue, 2 Dec 2025 14:01:52 +0200	[thread overview]
Message-ID: <cf5e2672-0aa4-43e9-a2d0-73010b81024a@linaro.org> (raw)
In-Reply-To: <CAHfa7xVxG48_qBXE8JcSNJgO1SG=Ge9qAyaCk2WLTvrKoH3NbQ@mail.gmail.com>



On 12/2/25 13:54, Amin wrote:
> 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
> the`dmae_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

> 
> Amin
> 
> 
> Le mar. 2 déc. 2025 à 11:12, Eugen Hristev <eugen.hristev@linaro.org> a écrit :
>>
>>
>>
>> On 11/28/25 17:29, Amin GATTOUT wrote:
>>> 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
>>
>>> it is active. Keeping it helps ensure transfer integrity and avoids
>>> unexpected hardware behavior in edge cases.
>>>
>>> Signed-off-by: Amin GATTOUT <amin.gattout@gmail.com>
>>> ---
>>>  drivers/dma/sh/shdmac.c | 1 -
>>>  1 file changed, 1 deletion(-)
>>>
>>> diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
>>> index 603e15102e45..d0e0437ad916 100644
>>> --- a/drivers/dma/sh/shdmac.c
>>> +++ b/drivers/dma/sh/shdmac.c
>>> @@ -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;
>>>
>>


      reply	other threads:[~2025-12-02 12:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-28 15:29 Amin GATTOUT
2025-12-02 10:12 ` Eugen Hristev
2025-12-02 11:54   ` Amin
2025-12-02 12:01     ` Eugen Hristev [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=cf5e2672-0aa4-43e9-a2d0-73010b81024a@linaro.org \
    --to=eugen.hristev@linaro.org \
    --cc=amin.gattout@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=thomasandreatta2000@gmail.com \
    --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

all inboxes | Powered by JetHome®