mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pierre Yves MORDRET <pierre-yves.mordret@st.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Benjamin Gaignard <benjamin.gaignard@linaro.org>
Cc: Vinod Koul <vinod.koul@intel.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	<dmaengine@vger.kernel.org>,
	"M'boumba Cedric Madianga" <cedric.madianga@gmail.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] dmaengine: stm32-mdma: avoid 64-bit division
Date: Wed, 11 Oct 2017 17:53:28 +0200	[thread overview]
Message-ID: <6e0215da-40f7-128e-5781-00b7d2acbd94@st.com> (raw)
In-Reply-To: <CAK8P3a3j5Awh9V6+PHZf-79TM_7wdQ0GkZZv75a3ztewrw6CmQ@mail.gmail.com>



On 10/11/2017 05:13 PM, Arnd Bergmann wrote:
> On Wed, Oct 11, 2017 at 4:46 PM, Benjamin Gaignard
> <benjamin.gaignard@linaro.org> wrote:
>> 2017-10-11 16:39 GMT+02:00 Arnd Bergmann <arnd@arndb.de>:
>>> On Wed, Oct 11, 2017 at 4:27 PM, Benjamin Gaignard
>>> <benjamin.gaignard@linaro.org> wrote:
>>>> 2017-10-11 16:01 GMT+02:00 Arnd Bergmann <arnd@arndb.de>:
>>>>
>>>>> @@ -398,6 +400,9 @@ static enum dma_slave_buswidth stm32_mdma_get_max_width(u32 buf_len, u32 tlen)
>>>>>                         break;
>>>>>         }
>>>>>
>>>>> +       if (addr % max_width)
>>>>> +               max_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
>>>>> +
>>>>
>>>> I'm only half-convince by the implicite 32 bits cast done into
>>>> function prototype.
>>>> If we keep using dma_addr_t and use do_div() instead of %
>>>> does compiler can still optimize the code ?
>>>>
>>>
>>> I wouldn't want to add a do_div() here, since it's guaranteed
>>> not to be needed. Would you prefer an explicit cast here
>>> and leave the argument as dma_addr_t?
>>>
>>> We could also use a bit mask here like
>>>
>>>   if (addr & (max_width-1))
>>
>> That sound better for me since it doesn't limit the code to 32 bits architecture
> 
> FWIW, I used the u32 type here because that's the limit of the
> dma driver, the dma_addr_t gets converted to that anyway
> later.
> 
>>>
>>> or we could combined it with the check above:
>>>
>>>                 if ((((buf_len | addr) & (max_width - 1)) == 0) &&
>>>                    (tlen >= max_width))
>>
>> No it is more simple to read with two checks
> 
> I should have mentioned that this variant would also change
> behavior: the current code falls back to byte access when
> the address alignment is less than the length alignment.
> The change I suggested here would change that to use
> the maximum possible address width that fits the alignment
> of either size or address.

Both alignment are required on address and length.
The main advantage result is maximized in term of width. As for now I don't see
any drawback except a short explanation.
Nonetheless I need to think a little bit more about this change.

> 
> I don't know what behavior we actually want though, or
> if that change would be correct.
> 
>       Arnd
> 

Regards
Py

      reply	other threads:[~2017-10-11 15:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-11 14:01 Arnd Bergmann
2017-10-11 14:27 ` Benjamin Gaignard
2017-10-11 14:39   ` Arnd Bergmann
2017-10-11 14:46     ` Benjamin Gaignard
2017-10-11 15:13       ` Arnd Bergmann
2017-10-11 15:53         ` Pierre Yves MORDRET [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=6e0215da-40f7-128e-5781-00b7d2acbd94@st.com \
    --to=pierre-yves.mordret@st.com \
    --cc=alexandre.torgue@st.com \
    --cc=arnd@arndb.de \
    --cc=benjamin.gaignard@linaro.org \
    --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=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

all inboxes | Powered by JetHome®