lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a2RsCXq7L6w5K+KmhP1Q2b1=SjnG2Xws2w232vmyj=yEA@mail.gmail.com>
Date:   Wed, 11 Oct 2017 16:39:04 +0200
From:   Arnd Bergmann <arnd@...db.de>
To:     Benjamin Gaignard <benjamin.gaignard@...aro.org>
Cc:     Vinod Koul <vinod.koul@...el.com>,
        Maxime Coquelin <mcoquelin.stm32@...il.com>,
        Alexandre Torgue <alexandre.torgue@...com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Pierre-Yves MORDRET <pierre-yves.mordret@...com>,
        dmaengine@...r.kernel.org,
        "M'boumba Cedric Madianga" <cedric.madianga@...il.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>
Subject: Re: [PATCH] dmaengine: stm32-mdma: avoid 64-bit division

On Wed, Oct 11, 2017 at 4:27 PM, Benjamin Gaignard
<benjamin.gaignard@...aro.org> wrote:
> 2017-10-11 16:01 GMT+02:00 Arnd Bergmann <arnd@...db.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))

or we could combined it with the check above:

                if ((((buf_len | addr) & (max_width - 1)) == 0) &&
                   (tlen >= max_width))

       Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ