RE: [PATCH 1/2] habanalabs: support vmalloc memory mapping
From: Omer Shpigelman
Date: Thu Oct 10 2019 - 15:54:15 EST
On Thu, Oct 10, 2019 at 5:10 PM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
> On Thu, Oct 10, 2019 at 02:06:22PM +0000, Omer Shpigelman wrote:
> > This patch adds support in mapping of vmalloc memory.
> > In contrary to user memory, vmalloc memory is already pinned and has
> > no vm_area structure. Therefore a new capability was needed in order
> > to map this memory.
>
> Unless I am missing something you mix user and kernel pointers in your
> is_vmalloc_addr checks. That will break on those architectures that have
> separate kernel and user address spaces.
The is_vmalloc_addr checks are for user pointers and for memory which was allocated by the driver with vmalloc_user.
>
> > Mapping vmalloc memory is needed for Gaudi ASIC.
>
> How does that ASIC pass in the vmalloc memory? I don't fully understand
> the code, but it seems like the addresses are fed from ioctl, which means
> they only come from userspace.
The user pointers are indeed fed from ioctl for DMA purpose, but as I wrote above the vmalloc memory is allocated by the driver with vmalloc_user which will be mmapped later on in order to create a shared buffer between the driver and the userspace process.