Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5904802pxj; Wed, 23 Jun 2021 11:28:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynDxFf+/LaPBj4I7prnI/RIUpa8C6MLWoN7/26i4B6k+MjV2MxgXdyQau3HjjtrLx1ACxt X-Received: by 2002:a17:906:d98:: with SMTP id m24mr1363807eji.159.1624472912949; Wed, 23 Jun 2021 11:28:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624472912; cv=none; d=google.com; s=arc-20160816; b=birZr5YyeCPQwtuGtpkghLcqrt2XJs2n3aQcJCXGtZwOhZFyoOETkreT5Gv4eGUzq0 39RA0ZV/u/SeBS2jG6cl7JiBy3fBtVS1LigD99cQ6jTk6I1zdi9OXnDALEOe+mBroJwu RC/4CUSwqzJdZ3vjPc0ziA8HkpSEw83KzB41VcwcRjx6wbDYXd6B6iXNW3j7308MqNyl +bRZRCxSpUA4VCnGLieqG2XqeQMM88ejcYyce8LQFYiyRkP8QZ4IOnMd+07nfKoQYYam Il9bcWQY5SaBTmpjollCtpV+olaGSm1aG6/MBmvdwUXd8I4TI33HWd0WQvHi6p9yf87w EC8w== 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=Ay2MFJ8k8M7R+vcG/EIgcKO9+a17Gdo2IRp61Ubbznw=; b=tUWTLEORng7rfzub5bLaZMkmADNorLSG1Z9F4dO1QPHP6y/Tgkibz3jb+VT0iHU/fE Lj1jNfv3hndak/gNkCxSqoSc4ILzw7JdGiRVYAIN2WAkCu89zRWk2ASDGrdpMJMLekE4 +9/pPfZWUGCv/5+3BTLRhLeGlT9iaFZ5DbbjCyeEqizswIkHAF07Dl285AMniyhVniQM W97ogTh6KXnz1QJMgtfRCou0K5UoqsJJ72DAsoxm+Aiu3Rl6Kz/ae5fbz/xIXNcuSZUu bE8mfedyb50V2/0EeyCequUZjJkzwubPzesBhmjahM5HBpgEBPDC4ZMqw46Z0m0BHXD1 qEIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=mCvqGy8+; 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 be3si585988edb.568.2021.06.23.11.28.09; Wed, 23 Jun 2021 11:28:32 -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=mCvqGy8+; 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 S229929AbhFWS1S (ORCPT + 99 others); Wed, 23 Jun 2021 14:27:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229915AbhFWS1A (ORCPT ); Wed, 23 Jun 2021 14:27:00 -0400 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C169AC061767 for ; Wed, 23 Jun 2021 11:24:37 -0700 (PDT) Received: by mail-qv1-xf32.google.com with SMTP id g19so1911119qvx.12 for ; Wed, 23 Jun 2021 11:24:37 -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=Ay2MFJ8k8M7R+vcG/EIgcKO9+a17Gdo2IRp61Ubbznw=; b=mCvqGy8+wtoV1fX/pyjo8KTMFPXZBXguyo9f6344j9Tuu6bvNitRH+6EMM391SPgX6 SQMYyLNce8QZVpU7zBjnXebtb+Q1dmFuIlrzFz1aYg4dzKB/BRgz4LB8VyLVDBN8SLbD /DnbLaMY7YnyWKxjMZMgiPK42h8fTN66ErFs85v1J8jFaHQ7sl2AsFzx96c0xf/l9U1g an4hgyfwGlZSu7q9rvwAQ11c2UHFj6bACLkguqt6g9SVPdmo2aTNRobeEQ+DP+d/WoQh ZrnVQWoPWeo+kqw9aoKL73cB5McCCDUOBzJRc7EqyhLF4fkeGZrtBUlGnWa8WWodzdtj vF9Q== 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=Ay2MFJ8k8M7R+vcG/EIgcKO9+a17Gdo2IRp61Ubbznw=; b=BgQD0hXQ4/LbjLLV89t3Dk695WJDQu73SDug27xOclj0kgf/GZfpIhHMCpSbpIvRvI WxBn5JezMixIftfuttv3VbSRGnQlRLv53GtkxHZpRibnzFKn8TcnsiYiJoTzlVMnVqXj zFr50gM05gT6KODDmq+MoaTlf6YygU+XrUNBNxw1k1ylBl0UTIDNr1f7KqzvPO1RjDdX sn0v7sclzHkcRZgv8SQlX6H2NmVGlO9cgPqppGZfLhgnVMuE4yHGtHtDxpvEfpua8taV xdYNZ+DKg1C9w8a7XGvv/z3kliPN1Fn0KRh0K44gYOJFNBZDGjxR1Lg36vDToI6rwhfr 2O/Q== X-Gm-Message-State: AOAM531oH8Le6MQ2WuMAzDNRtfDmDs/2BHGYhVFnWxOaY/XMRcc6KQSA wRJvoJ+s/HXKzxHl7gY9OC927g== X-Received: by 2002:a0c:f309:: with SMTP id j9mr1350376qvl.12.1624472676911; Wed, 23 Jun 2021 11:24:36 -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 85sm456567qkl.46.2021.06.23.11.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 11:24:36 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1lw7YB-00BlF7-OO; Wed, 23 Jun 2021 15:24:35 -0300 Date: Wed, 23 Jun 2021 15:24:35 -0300 From: Jason Gunthorpe To: Christian =?utf-8?B?S8O2bmln?= Cc: Christian =?utf-8?B?S8O2bmln?= , Oded Gabbay , 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: <20210623182435.GX1096940@ziepe.ca> References: <20210622120142.GL1096940@ziepe.ca> <20210622152343.GO1096940@ziepe.ca> <3fabe8b7-7174-bf49-5ffe-26db30968a27@amd.com> <20210622154027.GS1096940@ziepe.ca> <09df4a03-d99c-3949-05b2-8b49c71a109e@amd.com> <20210622160538.GT1096940@ziepe.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 23, 2021 at 10:57:35AM +0200, Christian König wrote: > > > No it isn't. It makes devices depend on allocating struct pages for their > > > BARs which is not necessary nor desired. > > Which dramatically reduces the cost of establishing DMA mappings, a > > loop of dma_map_resource() is very expensive. > > Yeah, but that is perfectly ok. Our BAR allocations are either in chunks of > at least 2MiB or only a single 4KiB page. And very small apparently > > > Allocating a struct pages has their use case, for example for exposing VRAM > > > as memory for HMM. But that is something very specific and should not limit > > > PCIe P2P DMA in general. > > Sure, but that is an ideal we are far from obtaining, and nobody wants > > to work on it prefering to do hacky hacky like this. > > > > If you believe in this then remove the scatter list from dmabuf, add a > > new set of dma_map* APIs to work on physical addresses and all the > > other stuff needed. > > Yeah, that's what I totally agree on. And I actually hoped that the new P2P > work for PCIe would go into that direction, but that didn't materialized. It is a lot of work and the only gain is to save a bit of memory for struct pages. Not a very big pay off. > But allocating struct pages for PCIe BARs which are essentially registers > and not memory is much more hacky than the dma_resource_map() approach. It doesn't really matter. The pages are in a special zone and are only being used as handles for the BAR memory. > By using PCIe P2P we want to avoid the round trip to the CPU when one device > has filled the ring buffer and another device must be woken up to process > it. Sure, we all have these scenarios, what is inside the memory doesn't realy matter. The mechanism is generic and the struct pages don't care much if they point at something memory-like or at something register-like. They are already in big trouble because you can't portably use CPU instructions to access them anyhow. Jason