[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAK8P3a05=J6-utHZ682bVGb8bEZczLDEcFXsK7yXcbER5CRTDA@mail.gmail.com>
Date: Fri, 1 Apr 2022 09:53:00 +0200
From: Arnd Bergmann <arnd@...db.de>
To: Oded Gabbay <ogabbay@...nel.org>
Cc: Arnd Bergmann <arnd@...db.de>, 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 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
Powered by blists - more mailing lists