Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3821974pxj; Mon, 21 Jun 2021 07:21:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwznelrGo7unKdNORGHqDUqpZB2xMLRgMc0XHigfF7/E9EQZ3qGQAzGEpXi8F6HpwhZqnPo X-Received: by 2002:a5d:934d:: with SMTP id i13mr20534159ioo.164.1624285305709; Mon, 21 Jun 2021 07:21:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624285305; cv=none; d=google.com; s=arc-20160816; b=zGVS4ZHlz33AYXLQ+JLb7z5ggQ1M6kehaXrkvYll37kKG8ewOtXwX+7NMiUPVR+rp/ RHvaWZkbOcqra5Cp+B7pElyPkPJbPSlERR/1gH0lQI0eROTh/PxjS33nfD97tDHZAwkX GTd8OgNgOockSnVf3L1HxgWVZHODRFSXdRTRkOAxbpzyYENbq2OfCALooqRTTPuQ/TuX hUbeDW1VeIRHSpO668JTPov2u+SXHCSPoeqBLVJNhkA+cgFgDYAy0A3hXF+ZCQv9R7UF keX31yGElWgMRrgETmQ7sl3DQ/NixCPOGbPOGXsVm5kwKKihC7XS7pa3gatpn2uAiODF 5wQg== 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:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Ec7hxlIB77SSjw/55RmOMCuUntyz8RSRzIK/yT10Dvk=; b=nXtKXU4lNn6Lf+wDR1ZBwPBs6zr7HsTxWWMOwF2Rt/4TlN8NECZSYIFhls4fffkehd 0WX2p2ImXjR74o/0CAV9z/9EA3r9DSk/jGfVeKBiPgmg4f1S0lo/AtADwl7PhBK4qg88 CKRrvyNVqFaCChMUPEfETnQVAFmqaGQqd/5DQiEP4gT4lrnPTObw7wBp+1HpP8BTE2t7 oXzMd1ARcMQkTguPeW2qkUx9ISjgLh4MIQviYuAJeFlySjB1mYQDnErSALrYEh80vQAK 6ZaELPoYz5YMI3KLh8mRXF840Yn4ixeJb3kQttWhMFz9wW71rbMCxLtsTdZ+39hViOrW K4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=hdjFmcsB; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f11si4478879ioq.12.2021.06.21.07.21.32; Mon, 21 Jun 2021 07:21:45 -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=@ffwll.ch header.s=google header.b=hdjFmcsB; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230059AbhFUOWz (ORCPT + 99 others); Mon, 21 Jun 2021 10:22:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbhFUOWx (ORCPT ); Mon, 21 Jun 2021 10:22:53 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31AEBC06175F for ; Mon, 21 Jun 2021 07:20:39 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id y7so19806196wrh.7 for ; Mon, 21 Jun 2021 07:20:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=Ec7hxlIB77SSjw/55RmOMCuUntyz8RSRzIK/yT10Dvk=; b=hdjFmcsB7YIei1isj+gSWLLnQe/OhKX1iiuoZJRIb0Y5ZjSRed91RUS0dHVk5ggMn5 RvzeIUS7C6AplN/c1p38QeXspMIbu1dx50vmfj9IfhRCU0PvQxRWsAQsLAtFcnCZeVTs LE5yRt50lgyFPVhoGDAul329GvtCpJQZUhgyk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=Ec7hxlIB77SSjw/55RmOMCuUntyz8RSRzIK/yT10Dvk=; b=WlV/nI3yR66JLicg/1DrGROhqLM6QiAAkG4h1OjCD39r6SD/e0ZWSbj4PAm64/Ulbs T9L0teXlInW8KDMwrDsDev5PG7MLs0OnVypv86CNUgPWcoxWtX3op86MKmDM+D3XpQi+ 0ju3C9NFiC2Ol3A7hqYhhIDuF9tt0R5nTgS2F7Y42KEGwf8+xUN5l9L1uA1KxPoRHnym gBaVrD14vhZlLkc+ziEzMTeTv8Iu/Ll4CGBQtDkB3Z+d9vXpLQPg2mcMOLvNa5TaaT4o Hv+yEgll+bjYDsLjRhw/QqgDbSbNFYov/9rW18IHvTxzIC/eJtK/C1IHyGnFjmxGhvAg mE0A== X-Gm-Message-State: AOAM533FPSnCfxIW6lCXjLJneGnGIe1882dwVqKLRjBI1xD+YjydtGBr rSldhoMTQkofk9H1K6TcOkmAdQ== X-Received: by 2002:a05:6000:12c7:: with SMTP id l7mr22475136wrx.161.1624285237673; Mon, 21 Jun 2021 07:20:37 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id 4sm17161648wry.74.2021.06.21.07.20.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 07:20:37 -0700 (PDT) Date: Mon, 21 Jun 2021 16:20:35 +0200 From: Daniel Vetter To: Greg KH Cc: Daniel Vetter , 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: Mail-Followup-To: Greg KH , 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 References: <20210618123615.11456-1-ogabbay@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Operating-System: Linux phenom 5.10.0-7-amd64 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 21, 2021 at 03:02:10PM +0200, Greg KH wrote: > 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. It's the same thing as ever. 90% of an accel driver are in userspace, that's where all the fun is, that's where the big picture review needs to happen, and we've very conveniently bypassed all that a few years back because it was too annoying. Once we have the full driver stack and can start reviewing it I have no objections to totally-not-gpus using all this stuff too. But until we can do that this is all just causing headaches. Ofc if you assume that userspace doesn't matter then you don't care, which is where this giantic disconnect comes from. Also unless we're actually doing this properly there's zero incentive for me to review the kernel code and check whether it follows the rules correctly, so you have excellent chances that you just break the rules. And dma_buf/fence are tricky enough that you pretty much guaranteed to break the rules if you're not involved in the discussions. Just now we have a big one where everyone involved (who's been doing this for 10+ years all at least) realizes we've fucked up big time. Anyway we've had this discussion, we're not going to move anyone here at all, so *shrug*. I'll keep seeing accelarators in drivers/misc as blantant bypassing of review by actual accelerator pieces, you keep seing dri-devel as ... well I dunno, people who don't know what they're talking about maybe. Or not relevant to your totally-not-a-gpu thing. > > 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? There's no import afaict, but maybe I missed it. Assuming I haven't missed it the importing necessarily has to happen by some other drivers. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch