[PATCH v4 2/2] habanalabs: add support for dma-buf exporter

2021-07-05 Thread Oded Gabbay
From: Tomer Tayar Implement the calls to the dma-buf kernel api to create a dma-buf object backed by FD. We block the option to mmap the DMA-BUF object because we don't support DIRECT_IO and implicit P2P. We only implement support for explicit P2P through importing the FD of the DMA-BUF. In the

Re: [PATCH v4 2/2] habanalabs: add support for dma-buf exporter

2021-07-05 Thread Jason Gunthorpe
On Mon, Jul 05, 2021 at 04:03:14PM +0300, Oded Gabbay wrote: > + rc = sg_alloc_table(*sgt, nents, GFP_KERNEL | __GFP_ZERO); > + if (rc) > + goto error_free; If you are not going to include a CPU list then I suggest setting sg_table->orig_nents == 0 And using only the nents wh

Re: [PATCH v4 2/2] habanalabs: add support for dma-buf exporter

2021-07-06 Thread Oded Gabbay
On Mon, Jul 5, 2021 at 7:52 PM Jason Gunthorpe wrote: > > On Mon, Jul 05, 2021 at 04:03:14PM +0300, Oded Gabbay wrote: > > > + rc = sg_alloc_table(*sgt, nents, GFP_KERNEL | __GFP_ZERO); > > + if (rc) > > + goto error_free; > > If you are not going to include a CPU list then I s

Re: [PATCH v4 2/2] habanalabs: add support for dma-buf exporter

2021-07-06 Thread Jason Gunthorpe
On Tue, Jul 06, 2021 at 12:44:49PM +0300, Oded Gabbay wrote: > > > + /* In case we got a large memory area to export, we need to divide > > > it > > > + * to smaller areas because each entry in the dmabuf sgt can only > > > + * describe unsigned int. > > > + */ > > > > Huh? Thi

Re: [PATCH v4 2/2] habanalabs: add support for dma-buf exporter

2021-07-06 Thread Oded Gabbay
On Tue, Jul 6, 2021, 16:54 Jason Gunthorpe wrote: > On Tue, Jul 06, 2021 at 12:44:49PM +0300, Oded Gabbay wrote: > > > > > + /* In case we got a large memory area to export, we need to > divide it > > > > + * to smaller areas because each entry in the dmabuf sgt can > only > > > > +