Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp132075pxj; Wed, 23 Jun 2021 17:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykk+DlALZZH8jpg6Dq8N41m/S92K8DNkHawgXx55jvN24nDlkhEpxgxllM19VDg/l6bMLo X-Received: by 2002:a17:907:da4:: with SMTP id go36mr2544431ejc.21.1624495599829; Wed, 23 Jun 2021 17:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624495599; cv=none; d=google.com; s=arc-20160816; b=Hob8n2NgpSYa/xN2lJrZqV6WecNmz05nTpGb3M8vj4O2zxZyQSySPQgUZ0seJVMTyj Gy6y4MTVqdfl9cK/n5hU1CojE3MaJ6DYLTXfX9jSDB7apVLLWQdgTUdQ3XbA+QEAQudS iEdptglzrwvdwVfqxScQJOFFlOB4ZsHHeZpg1O4PSYK/LMbB70KqJBlKa0HCtVB5sXnX bIMvShoCZeZBLi8OzhIWR48kKk5+IDoo7lKxoH9NynzWiE3KiXd4L+L1OtMkntacStLm v/+7rF3lfs3958G+DvotnV86Yf0vyzJHH8zPrwbta3fnrBpHRbaGA5C5VSLyf2ZL4OG3 COlw== 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=EFcFEiW34m53hHVRH/hYAOinlbr3mbVvwuYYaYtTuh8=; b=F8ZjfhmJZo7ypHso5jHt0eP9EytjP3JQ++KCWCb2zhnNZQ6KvvW7sln0GYoc5Fpy9F 5m0lUamUSUkiRIjOexqacvf5gKorcpOmXphIJUZAdb4QMbRsOawAfujp7R7n9FgLtmi+ yImi42+q1YjEuPbJ0FPPTZc0Z3YhsHn7r3c9jBbZEPAXckOjo6uuapqa5bmWxiEMqEEH 9qD3lCWzcL4V2Xn1QsnK9YKhLY06ZiSiMRQJ427zvvgdnTUcHfYpskMOyBj3c9GL2Qxd BjSmopQE4TlBKpihCLTn+/f3ELV6QRS3OTLw0GWKP4g7SHwQMQGXAlPLYyIrm3qFcFMx TeJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=G1KDqzwp; 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 y23si1087710ejk.380.2021.06.23.17.46.14; Wed, 23 Jun 2021 17:46:39 -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=@ziepe.ca header.s=google header.b=G1KDqzwp; 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 S229850AbhFXArc (ORCPT + 99 others); Wed, 23 Jun 2021 20:47:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbhFXArc (ORCPT ); Wed, 23 Jun 2021 20:47:32 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4C2C061574 for ; Wed, 23 Jun 2021 17:45:13 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id j184so10093178qkd.6 for ; Wed, 23 Jun 2021 17:45:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EFcFEiW34m53hHVRH/hYAOinlbr3mbVvwuYYaYtTuh8=; b=G1KDqzwpGU22cmRZBgDHPWa87kbMIhmgX8Prq4EL0fmRPLBrFBeajfqHskFpu8RKTX yPnWNNhZxtgtf1LNFARLTco5JxjiV2oulGE5y/6osdL4RwXiUVMTAG5ut6nrvgtCxcyW WNdQQ1Be+uGC+xnXPFnIEB+CnxBIJjQavpHiEs+mnCS/UyCcFsHD23X3fg/71TBLMoTI hf7TgXvMgDwaZel4MR99dGUXP8aAPP1F5KANaExTx3B1Gzybwmv9QfKVsJCcbxExhAHC HBloe8ZRqPH9mLrrauCiklIS4IB5euV3NwN6tbG+Ga5k1mdv/+36MmqpccO7p5tm0V0m ZRWQ== 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:references :mime-version:content-disposition:in-reply-to; bh=EFcFEiW34m53hHVRH/hYAOinlbr3mbVvwuYYaYtTuh8=; b=MY7/1F3x72Hq85YvP9ox6hVNrlB/+sIYheSlpe0apVkBO1D8Ye39tciEnx4FG9bEVL LWTC9YeFWpzUib/Xg7s2hN03L19XD3Ksi+KeEqtyS0Uk9Wr3T8lKt65qO0pLwnbmfgVm uoH6oTXK1vtzBR/CrnLz4yL9Mwytgu9S/ENGivVc3UrERzLrM1qT8k8XR2dkjzUq1QTz zRUnmKMcq5l8LVD+oK8Qxr8qSLrbvUwz6RVHExV4QYjJJSvh9wbqtXbulARPVBCU2Lgr 1rarqI7yRP1lEYx9pBXpdf7GMXl5mhuYuMTZc2PEnk1qi1TpkKVhe9NH19tfailFtvVF UUBg== X-Gm-Message-State: AOAM532kpXiXV7ET+WSVJ0yRXC9kVT1zDI6CfkVAf6MfrXpzE9oceCQk qnLK4YshqKkj3fjrIszt+2x5Jw== X-Received: by 2002:a37:b205:: with SMTP id b5mr3007100qkf.208.1624495512436; Wed, 23 Jun 2021 17:45:12 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-47-55-113-94.dhcp-dynamic.fibreop.ns.bellaliant.net. [47.55.113.94]) by smtp.gmail.com with ESMTPSA id n207sm1169771qka.101.2021.06.23.17.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 17:45:11 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lwDUV-00Bris-8h; Wed, 23 Jun 2021 21:45:11 -0300 Date: Wed, 23 Jun 2021 21:45:11 -0300 From: Jason Gunthorpe To: Oded Gabbay Cc: Christian =?utf-8?B?S8O2bmln?= , Christian =?utf-8?B?S8O2bmln?= , Gal Pressman , sleybo@amazon.com, linux-rdma , Oded Gabbay , Christoph Hellwig , Linux Kernel Mailing List , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Doug Ledford , Tomer Tayar , amd-gfx list , Greg KH , Alex Deucher , Leon Romanovsky , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [Linaro-mm-sig] [PATCH v3 1/2] habanalabs: define uAPI to export FD for DMA-BUF Message-ID: <20210624004511.GA1096940@ziepe.ca> References: <20210622154027.GS1096940@ziepe.ca> <09df4a03-d99c-3949-05b2-8b49c71a109e@amd.com> <20210622160538.GT1096940@ziepe.ca> <20210623182435.GX1096940@ziepe.ca> <20210623185045.GY1096940@ziepe.ca> <20210623193456.GZ1096940@ziepe.ca> 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 Wed, Jun 23, 2021 at 10:39:48PM +0300, Oded Gabbay wrote: > On Wed, Jun 23, 2021 at 10:34 PM Jason Gunthorpe wrote: > > > > On Wed, Jun 23, 2021 at 10:00:29PM +0300, Oded Gabbay wrote: > > > On Wed, Jun 23, 2021 at 9:50 PM Jason Gunthorpe wrote: > > > > > > > > On Wed, Jun 23, 2021 at 09:43:04PM +0300, Oded Gabbay wrote: > > > > > > > > > Can you please explain why it is so important to (allow) access them > > > > > through the CPU ? > > > > > > > > It is not so much important, as it reflects significant design choices > > > > that are already tightly baked into alot of our stacks. > > > > > > > > A SGL is CPU accessible by design - that is baked into this thing and > > > > places all over the place assume it. Even in RDMA we have > > > > RXE/SWI/HFI1/qib that might want to use the CPU side (grep for sg_page > > > > to see) > > > > > > > > So, the thing at the top of the stack - in this case the gaudi driver > > > > - simply can't assume what the rest of the stack is going to do and > > > > omit the CPU side. It breaks everything. > > > > > > > > Logan's patch series is the most fully developed way out of this > > > > predicament so far. > > > > > > I understand the argument and I agree that for the generic case, the > > > top of the stack can't assume anything. > > > Having said that, in this case the SGL is encapsulated inside a dma-buf object. > > > > > > Maybe its a stupid/over-simplified suggestion, but can't we add a > > > property to the dma-buf object, > > > that will be set by the exporter, which will "tell" the importer it > > > can't use any CPU fallback ? Only "real" p2p ? > > > > The block stack has been trying to do something like this. > > > > The flag doesn't solve the DMA API/IOMMU problems though. > hmm, I thought using dma_map_resource will solve the IOMMU issues, > no ? dma_map_resource() will configure the IOMMU but it is not the correct API to use when building a SG list for DMA, that would be dma_map_sg or sgtable. So it works, but it is an API abuse to build things this way. > If I use dma_map_resource to set the addresses inside the SGL before I > export the dma-buf, and guarantee no one will use the SGL in the > dma-buf for any other purpose than device p2p, what else is needed ? You still have to check the p2p stuff to ensure that p2p is even possible And this approach is misusing all the APIs and has been NAK'd by Christoph, so up to Greg if he wants to take it or insist you work with Logan to get the proper generlized solution finished. Jason