From: Pierre Yves MORDRET <pierre-yves.mordret@st.com>
To: Robin Murphy <robin.murphy@arm.com>,
Vinod Koul <vinod.koul@intel.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Dan Williams <dan.j.williams@intel.com>,
"M'boumba Cedric Madianga" <cedric.madianga@gmail.com>,
<dmaengine@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/2] dmaengine: stm32-mdma: align TLEN and buffer length on burst
Date: Fri, 13 Apr 2018 14:30:41 +0200 [thread overview]
Message-ID: <847f092a-d1f9-8902-e1ae-f65dc2f0db7c@st.com> (raw)
In-Reply-To: <7ab2cfcd-07ed-e380-727a-727e78cc0336@arm.com>
On 04/13/2018 01:09 PM, Robin Murphy wrote:
> On 13/04/18 10:45, Pierre Yves MORDRET wrote:
>> Hi Robin
>>
>> On 04/11/2018 05:14 PM, Robin Murphy wrote:
>>> On 11/04/18 15:44, Pierre-Yves MORDRET wrote:
>>>> Both buffer Transfer Length (TLEN if any) and transfer size have to be
>>>> aligned on burst size (burst beats*bus width).
>>>>
>>>> Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
>>>> ---
>>>> Version history:
>>>> v1:
>>>> * Initial
>>>> v2:
>>>> ---
>>>> ---
>>>> drivers/dma/stm32-mdma.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c
>>>> index daa1602..fbcffa2 100644
>>>> --- a/drivers/dma/stm32-mdma.c
>>>> +++ b/drivers/dma/stm32-mdma.c
>>>> @@ -413,7 +413,7 @@ static u32 stm32_mdma_get_best_burst(u32 buf_len, u32 tlen, u32 max_burst,
>>>> u32 best_burst = max_burst;
>>>> u32 burst_len = best_burst * width;
>>>>
>>>> - while ((burst_len > 0) && (tlen % burst_len)) {
>>>> + while ((burst_len > 0) && (((tlen | buf_len) & (burst_len - 1)) != 0)) {
>>>> best_burst = best_burst >> 1;
>>>> burst_len = best_burst * width;
>>>> }
>>>
>>> FWIW, doesn't that whole loop come down to just:
>>>
>>> burst_len = min(ffs(tlen | buf_len), max_burst * width);
>>
>> No sure it ends as expected. or I miss something or don't understand this statement
>> I tried with "relevant value" : i.e. best_burst = 32, Tlen=128(default) and
>> buf_len = 64, width= 4. This statements gets me something wrong output => 7
>> instead of 16 * 4.
>> I doubt :)
>
> Heh, seems I confused myself halfway through and started thinking
> max_burst and width were the exponents x rather than the values 2^x...
>
> A more representative guess should be:
>
> min(1 << __ffs(tlen | buf_len), max_burst * width);
>
> but the general point I was trying to make is that a loop checking
> whether the bottom n bits of something are zero for different values of
> n is unnecessary when n can simply be calculated directly*.
>
> Robin.
Got the point. I figure how to compute this value with __ffs. Your last
statement doesn't provide the good value, but the spirit is here. I just have to
adjust with what I want.
Thx
>
>
> * in the case of this "just the lowest set bit" idiom there's also the
> shift-free ((x & (x - 1)) ^ x), but as well as being unreadable it's
> generally less efficient than (1 << __ffs(x)) for most modern ISAs.
>
next prev parent reply other threads:[~2018-04-13 12:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-11 14:44 [PATCH v2 0/2] Append some fixes and improvements Pierre-Yves MORDRET
2018-04-11 14:44 ` [PATCH v2 1/2] dmaengine: stm32-mdma: align TLEN and buffer length on burst Pierre-Yves MORDRET
2018-04-11 15:14 ` Robin Murphy
2018-04-13 9:45 ` Pierre Yves MORDRET
2018-04-13 11:09 ` Robin Murphy
2018-04-13 12:30 ` Pierre Yves MORDRET [this message]
2018-04-11 14:44 ` [PATCH v2 2/2] dmaengine: stm32-mdma: Fix incomplete Hw descriptors allocator Pierre-Yves MORDRET
2018-04-13 4:02 ` Vinod Koul
2018-04-13 8:39 ` Geert Uytterhoeven
2018-04-13 10:09 ` Vinod Koul
2018-04-13 10:40 ` Geert Uytterhoeven
2018-04-13 11:48 ` Robin Murphy
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=847f092a-d1f9-8902-e1ae-f65dc2f0db7c@st.com \
--to=pierre-yves.mordret@st.com \
--cc=alexandre.torgue@st.com \
--cc=cedric.madianga@gmail.com \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=robin.murphy@arm.com \
--cc=vinod.koul@intel.com \
/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;
as well as URLs for NNTP newsgroup(s).