Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4821148pxj; Tue, 22 Jun 2021 08:43:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwW8sw+7igESjQPgXGOPsDcr/vg7s09H1TY4vUFiskzphovO4cHSGVZWXQ+WIcQUXu1oP08 X-Received: by 2002:a5d:9414:: with SMTP id v20mr3440887ion.66.1624376585440; Tue, 22 Jun 2021 08:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624376585; cv=none; d=google.com; s=arc-20160816; b=KdD4K7SfjeBhySbJN3Fb4ml6fGUXk61LGl7L/0qh+D1hEniSJE47bk6ndcVlu5uZnS cTjKfCOzwMUbG2kDCeB+AQ1+baq3A8W95BYQl91mXP6JX/hNYN+YgWBV3OStWjMFUuG/ PR/LPtpqVXmchVcmiTUodCXA/iyPTLIbL5Jrih8GRq1YESo8jCPwgAwlRCXk8jhC6SUt 1HYLxp6oieu3y3hfWtpy7oOMQFAxsFYG+xS+lkjM9n07d+a3OukvXE0eP62XR3x7BAnI MDQY8SxKOkGbmsRWTzCWbvFfTNN9sURk3zyT/+AcINu4CvcGwIbtsh9WKPlC44HmtyJT IL2A== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=NZpdOHQdlbhRQUdadvChaP2QioJ6XoeMWnvncTZxFBo=; b=q1deEfddGQYautaCiC42CCaiMvrZcM170cFy+i0AakXnBbtelzzvTRqNn55ZCe/yKP DHez7uo6LRcVTDjiwfoFSTxYMxCnTVSlRVdxWQ0tLgA4llr6o4x75Zu1o3WDjaq8RCVA kYhHsZdWJG4ufscILIXI93fYWKumCCNLqoVO7K42X0HEg6z65OjPSR6xQf22ZhJjuK3U rWd6rgFlTurHPIBUe8vJkU/7vLa0MiYdDwvef34pvzFg/SJiGrby8o30UFv6d0AAa7+O zSdxVhxyYjt4iuG8JMFGqwYVVQI2UEkEqtwrz0LXA46O1SoV0vQVgcrGMkMVDyY5iU9i H9+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=bFrrHAW8; 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 r26si22160077jai.54.2021.06.22.08.42.52; Tue, 22 Jun 2021 08:43:05 -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=bFrrHAW8; 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 S232525AbhFVPn0 (ORCPT + 99 others); Tue, 22 Jun 2021 11:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232401AbhFVPmp (ORCPT ); Tue, 22 Jun 2021 11:42:45 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40DC5C0617AE for ; Tue, 22 Jun 2021 08:40:29 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id j12so1867660qtv.11 for ; Tue, 22 Jun 2021 08:40:29 -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:content-transfer-encoding:in-reply-to; bh=NZpdOHQdlbhRQUdadvChaP2QioJ6XoeMWnvncTZxFBo=; b=bFrrHAW8qxNFpB4w6q6y0m3wG93Brg5eP/2CDB60bxAwrbV9T0MwsuqH9FqvvIRVEl azco9BZHD+pLNHUOUPd0/YqiC7g1TkaOLuSEdEPEQsK/HsRy3mej/q89Q1WOFE2N+Ro6 7RjC3KVHi7qrQ6NaRAxH4v7ueHDnYI6mNr/5488SwgmJEmoF0yDk72Gp1+3yt3X1dN77 SwYTmPDOKjoJcVDChtw4TAWYHg4XwJrbCQOByfoyvt7j1+S/eNeqEnvPfIhPHwupoX/C fllP05M4t8g69iCpBGPz31XolXRyxDJerhlIIoTtJYVOwqMlMtDxL7QTh8S+XznoKv7T C9Zg== 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:content-transfer-encoding :in-reply-to; bh=NZpdOHQdlbhRQUdadvChaP2QioJ6XoeMWnvncTZxFBo=; b=DPx+vp/Q5r5ePGZz5LTz3QbrCalkJ6woB7C1hlJCEYGh68qQNV+ALAoipidEdK4Btg /c35Wd8qNzXDPtran+yCFKsE+Pr0raBIrjCcd31w8kFalaZy9nQD+PdK3G3L+W5Ux76S M3oEbf6bvk6+Hzq4fXPNqlnpndD4cdJ8ec25afb2nBTuMGlQAWZvj5mzNTLFdBElV3mE tGnM74G6iNHuYZozrychbrjH5cnBvhUzZPN4kAOf3ohL3N9Y6A6YUKf6J4ActqCV9F9a 4mV4zro9S+VOhDw+4Av+2vComeErXyuK9uyFwZhvfTa9FIHaO1eme6TuxC1qkcpKPflE gmuQ== X-Gm-Message-State: AOAM533Imt9PEfjATDIwWx7ZlrXAcWO/Gu8l/afeB4K7S3HJRT1FLeBY QbDllebz/VvzYbGCWij3WK+LGA== X-Received: by 2002:ac8:4241:: with SMTP id r1mr4000088qtm.121.1624376428220; Tue, 22 Jun 2021 08:40:28 -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 y18sm1761588qtj.53.2021.06.22.08.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Jun 2021 08:40:27 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lviVn-00ADW0-73; Tue, 22 Jun 2021 12:40:27 -0300 Date: Tue, 22 Jun 2021 12:40:27 -0300 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: Oded Gabbay , 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: <20210622154027.GS1096940@ziepe.ca> References: <20210621175511.GI1096940@ziepe.ca> <20210621232912.GK1096940@ziepe.ca> <20210622120142.GL1096940@ziepe.ca> <20210622152343.GO1096940@ziepe.ca> <3fabe8b7-7174-bf49-5ffe-26db30968a27@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3fabe8b7-7174-bf49-5ffe-26db30968a27@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 05:29:01PM +0200, Christian König wrote: > Am 22.06.21 um 17:23 schrieb Jason Gunthorpe: > > On Tue, Jun 22, 2021 at 02:23:03PM +0200, Christian König wrote: > > > Am 22.06.21 um 14:01 schrieb Jason Gunthorpe: > > > > On Tue, Jun 22, 2021 at 11:42:27AM +0300, Oded Gabbay wrote: > > > > > On Tue, Jun 22, 2021 at 9:37 AM Christian König > > > > > wrote: > > > > > > Am 22.06.21 um 01:29 schrieb Jason Gunthorpe: > > > > > > > On Mon, Jun 21, 2021 at 10:24:16PM +0300, Oded Gabbay wrote: > > > > > > > > > > > > > > > Another thing I want to emphasize is that we are doing p2p only > > > > > > > > through the export/import of the FD. We do *not* allow the user to > > > > > > > > mmap the dma-buf as we do not support direct IO. So there is no access > > > > > > > > to these pages through the userspace. > > > > > > > Arguably mmaping the memory is a better choice, and is the direction > > > > > > > that Logan's series goes in. Here the use of DMABUF was specifically > > > > > > > designed to allow hitless revokation of the memory, which this isn't > > > > > > > even using. > > > > > > The major problem with this approach is that DMA-buf is also used for > > > > > > memory which isn't CPU accessible. > > > > That isn't an issue here because the memory is only intended to be > > > > used with P2P transfers so it must be CPU accessible. > > > No, especially P2P is often done on memory resources which are not even > > > remotely CPU accessible. > > That is a special AMD thing, P2P here is PCI P2P and all PCI memory is > > CPU accessible. > > No absolutely not. NVidia GPUs work exactly the same way. > > And you have tons of similar cases in embedded and SoC systems where > intermediate memory between devices isn't directly addressable with the CPU. None of that is PCI P2P. It is all some specialty direct transfer. You can't reasonably call dma_map_resource() on non CPU mapped memory for instance, what address would you pass? Do not confuse "I am doing transfers between two HW blocks" with PCI Peer to Peer DMA transfers - the latter is a very narrow subcase. > No, just using the dma_map_resource() interface. Ik, but yes that does "work". Logan's series is better. > > > > > I'll go and read Logan's patch-set to see if that will work for us in > > > > > the future. Please remember, as Daniel said, we don't have struct page > > > > > backing our device memory, so if that is a requirement to connect to > > > > > Logan's work, then I don't think we will want to do it at this point. > > > > It is trivial to get the struct page for a PCI BAR. > > > Yeah, but it doesn't make much sense. Why should we create a struct page for > > > something that isn't even memory in a lot of cases? > > Because the iommu and other places need this handle to setup their > > stuff. Nobody has yet been brave enough to try to change those flows > > to be able to use a physical CPU address. > > Well that is certainly not true. I'm just not sure if that works with all > IOMMU drivers thought. Huh? All the iommu interfaces except for the dma_map_resource() are struct page based. dma_map_resource() is slow ad limited in what it can do. Jason