Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3757687pxj; Mon, 21 Jun 2021 06:04:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWg3wGynTAe1hZL7CGeOV8jpTY0F33r6u+pKPEwtE/6WCcCsLbEwma+XsdoPT8PYjZERUY X-Received: by 2002:a5d:40c8:: with SMTP id b8mr28184834wrq.187.1624280646628; Mon, 21 Jun 2021 06:04:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624280646; cv=none; d=google.com; s=arc-20160816; b=RInMl54CyTcVz7THwJc4ivmYbCPQmba4oLzV7DBLzhgh7oCpUB4pqbCnHItahaVOdk u29f/eKmUnreiHlOVriWlBLK51agWCB/VQsDIsSfe+c/K90dxykg5o20uKViNWdRX1Fv nHp89B7GIJ4o+ed9bXvma313gcytRvndkA4m0vlGHOafiBh9N6JJ4Agqqn1DYkP8C4zs 58XaurVZvYClfNIeAKwicyICdvl1So6h7RqXzZg/av4RQ1n1+rqgXfKgsyRDK4CbL2qx qLEwCJ9eJGoW1LQlvMi/3M7X+lR0EbB7Ge+1jUTWZv72/7ZrL2tE5OHp3QVpA8RabMcl BXaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=oRJIkPrLkYplhzQ3wAJbWbuMty7ytl1fPe/RGVpitjk=; b=wOCiL7k3meKp6rY4cU2VY3GwmFy1fCu7qCf1OOJ+gzZpwAABcbM1Gbdn/2IOkOsEHG Y1y8TcYqBMADoEEcWMUBBmIxiD6aafi2pnHhRn8ROLIebBjB3NJF4eptuVNiHSuDdE0E R5CskKlosEPbiFPJzbMDZAEauEJcPs+mZhkoTkc0M9ZTP7Pzq3nkMnhV2mnBwWny8pA2 mMi8Pm6St/Juhjnqp+Fmt4/lsHLFD9F8QfZOdnoH42T1U9QpqWW25JXYbGRBbCgdWMta Fxfhk1B3DfEMzUt93603WvfA0/wkREPaRqyd5FC0su7diGs+ErUnDSpgTHxlpbfZ3ugo jtyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N9ZvxmN6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id fx14si10195431ejb.218.2021.06.21.06.03.44; Mon, 21 Jun 2021 06:04:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N9ZvxmN6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbhFUNE2 (ORCPT + 99 others); Mon, 21 Jun 2021 09:04:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:46106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbhFUNE1 (ORCPT ); Mon, 21 Jun 2021 09:04:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8026600D4; Mon, 21 Jun 2021 13:02:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624280533; bh=i0BoGd9phtcsE2N4w5S/NNcCyOLvsVmvubKDwfPIMew=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N9ZvxmN6kzyMcupSt5ch1urOqDBkE0Yg6zpYbUkiJjCrqT/WAfP0GZcwtdCxyIhN5 VJf2oNP6LasPeV9faVnguB0ItTYTqoiIi/KT6Spd+x7CVZUlDVNtQ1gqJ8z8De0PSa aehoznUR6BHHlVGF7/uMhhG8Rm1/YXbxpCs5Xms4= Date: Mon, 21 Jun 2021 15:02:10 +0200 From: Greg KH To: Daniel Vetter Cc: Oded Gabbay , Jason Gunthorpe , linux-rdma , "open list:DMA BUFFER SHARING FRAMEWORK" , Doug Ledford , "airlied@gmail.com" , Linux Kernel Mailing List , Sumit Semwal , Christian =?iso-8859-1?Q?K=F6nig?= , Gal Pressman , sleybo@amazon.com, dri-devel , Tomer Tayar , "moderated list:DMA BUFFER SHARING FRAMEWORK" , amd-gfx list , Alex Deucher , Leon Romanovsky , Christoph Hellwig Subject: Re: [PATCH v3 1/2] habanalabs: define uAPI to export FD for DMA-BUF Message-ID: References: <20210618123615.11456-1-ogabbay@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021 at 02:28:48PM +0200, Daniel Vetter wrote: > On Fri, Jun 18, 2021 at 2:36 PM Oded Gabbay wrote: > > User process might want to share the device memory with another > > driver/device, and to allow it to access it over PCIe (P2P). > > > > To enable this, we utilize the dma-buf mechanism and add a dma-buf > > exporter support, so the other driver can import the device memory and > > access it. > > > > The device memory is allocated using our existing allocation uAPI, > > where the user will get a handle that represents the allocation. > > > > The user will then need to call the new > > uAPI (HL_MEM_OP_EXPORT_DMABUF_FD) and give the handle as a parameter. > > > > The driver will return a FD that represents the DMA-BUF object that > > was created to match that allocation. > > > > Signed-off-by: Oded Gabbay > > Reviewed-by: Tomer Tayar > > Mission acomplished, we've gone full circle, and the totally-not-a-gpu > driver is now trying to use gpu infrastructure. And seems to have > gained vram meanwhile too. Next up is going to be synchronization > using dma_fence so you can pass buffers back&forth without stalls > among drivers. What's wrong with other drivers using dmabufs and even dma_fence? It's a common problem when shuffling memory around systems, why is that somehow only allowed for gpu drivers? There are many users of these structures in the kernel today that are not gpu drivers (tee, fastrpc, virtio, xen, IB, etc) as this is a common thing that drivers want to do (throw chunks of memory around from userspace to hardware). I'm not trying to be a pain here, but I really do not understand why this is a problem. A kernel api is present, why not use it by other in-kernel drivers? We had the problem in the past where subsystems were trying to create their own interfaces for the same thing, which is why you all created the dmabuf api to help unify this. > Also I'm wondering which is the other driver that we share buffers > with. The gaudi stuff doesn't have real struct pages as backing > storage, it only fills out the dma_addr_t. That tends to blow up with > other drivers, and the only place where this is guaranteed to work is > if you have a dynamic importer which sets the allow_peer2peer flag. > Adding maintainers from other subsystems who might want to chime in > here. So even aside of the big question as-is this is broken. From what I can tell this driver is sending the buffers to other instances of the same hardware, as that's what is on the other "end" of the network connection. No different from IB's use of RDMA, right? thanks, greg k-h