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] [day] [month] [year] [list]
Message-ID: <CAFCwf13yiJ=Ap7Rv7g1ef2pDF6F+4PJ=UkpBRkJf1q+aEGdTyg@mail.gmail.com>
Date:   Fri, 1 Apr 2022 14:31:12 +0300
From:   Oded Gabbay <ogabbay@...nel.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Max Filippov <jcmvbkbc@...il.com>,
        Ohad Sharabi <osharabi@...ana.ai>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] habanalabs: fix build warning

On Fri, Apr 1, 2022 at 10:53 AM Arnd Bergmann <arnd@...db.de> wrote:
>
> On Fri, Apr 1, 2022 at 8:55 AM Oded Gabbay <ogabbay@...nel.org> wrote:
> > On Fri, Apr 1, 2022 at 9:40 AM Arnd Bergmann <arnd@...db.de> wrote:
> > > On Fri, Apr 1, 2022 at 6:16 AM Max Filippov <jcmvbkbc@...il.com> wrote:
> >
> > We use gen_pool in this function to manage our device memory
> > allocations (this is why it is called alloc_device_memory).
>
> Ok, so it's none of the three I listed ;-)
>
> > Basically, we initialize the genpool with the total size of the device memory,
> > and each bit represents a page according to a fixed page size, which
> > is dependent on asic type.
> > The addresses represent the physical address of the device memory, as
> > our device sees them.
> > As these addresses are not accessible from the host, it is appropriate
> > to hold them in u64, imo.
> >
> > For future asics which will support multiple page sizes, we need to
> > use the gen_pool_dma_alloc_align() variant,
> > because then we need the allocation to be aligned to the page size as
> > requested by the user per allocation.
> >
> > We ignore the DMA address because this is device memory, not host memory.
> > Therefore, our device's dma engine addresses the memory using the
> > virtual memory addresses we assign to it in our device's MMU.
> >
> > Having said that, I'm wondering whether gen_pool_first_fit_align() can
> > also work here, which might be less confusing.
>
> Thank you for the explanation. I think the best way to make this less
> confusing and to avoid the type casts would be to define your own
> typedef for a device-internal address, and then wrap the allocator
> functions such as gen_pool_dma_alloc_align() in helper functions that
> do the type conversion safely.
>
>        Arnd

Thanks for the advice, we will prepare a patch accordingly.
Oded

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ