Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp297330pxj; Wed, 23 Jun 2021 22:41:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytyUVxliXo12lQlYSzLqHdEulE/DSfAX+BTOn1Rn1S6eCcsKI80yqJvvvS8W2gBjJ5wjmR X-Received: by 2002:a05:6402:430d:: with SMTP id m13mr4712567edc.283.1624513293442; Wed, 23 Jun 2021 22:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624513293; cv=none; d=google.com; s=arc-20160816; b=p9YI6Ok5nrVuYnJBfjjvHEikgzcrfgwlSV+61u9DWtpAsxsjkXbipYOiDzBsFwRnyG iDnJr935EAiq1tQnVRRF9aBg9ZDtVZ2ERtffSPHypBeStZXyWhj2LrSRnL6jLEe2eJha 3YBEj7RqjMf5CzsTiwmmUoWvN2dz/iI/j0Q1sYD9sRmMaghoJL9obHvfyC8lihAAKzc3 KHS+2nQ05xXuOp389BZwzT4phcZdKqlwyNDMCqGCWX4kSeg9ZgE0aV60rYMKcRJe+JnH A981C/eL5I3mfqGgeSQtPHTa9i7enDWLfgWJ4PTl8p9THQiwXuAoS6VRo/iKla/qjyG4 1wzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=3BHTX7/CMriQlcf9+gF49nm8ZF2izmfaBDB3n7i5TMg=; b=o23Ncfy7lwIMgA/0Ru9+vV9Nge5jCxRJMGjLxJOmUpgDB0tHDIcQOgDu1imRZk8oNE 9r7+xdBLxqMzHslgxpKfe3kqE/qlQCqv5U3KI1g6C8xrLX7hCpB2PNyi/5/vw6rogvgb YHgx7b9g0r2s0nAPJy6/HYitEDqhm3NAzfrZsyCcF05XX8S93+uoA46NzDT8uHJ9yFK5 nYDGbjQ/7YKZryrZ9PWq4yTc0p7dCmNdB2gl45+5eBUasoYntkExYRDZRE5fOtTHhzKw NaF9ZYqMGQQUVJ9cxGIcp4H0Fq4UHiaSezuQ3fCv1qRUAEkviIdqDqG2SkmQ+IzkYSZB UIDw== ARC-Authentication-Results: i=1; mx.google.com; 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 c7si1688986ejz.386.2021.06.23.22.41.08; Wed, 23 Jun 2021 22:41:33 -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; 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 S230252AbhFXFm1 (ORCPT + 99 others); Thu, 24 Jun 2021 01:42:27 -0400 Received: from verein.lst.de ([213.95.11.211]:53084 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229448AbhFXFm1 (ORCPT ); Thu, 24 Jun 2021 01:42:27 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 5BF4867373; Thu, 24 Jun 2021 07:40:04 +0200 (CEST) Date: Thu, 24 Jun 2021 07:40:03 +0200 From: Christoph Hellwig To: Oded Gabbay Cc: Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Christian =?iso-8859-1?Q?K=F6nig?= , 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: <20210624054003.GB25165@lst.de> 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: User-Agent: Mutt/1.5.17 (2007-11-01) 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: > hmm, I thought using dma_map_resource will solve the IOMMU issues, no ? > We talked about it yesterday, and you said that it will "work" > (although I noticed a tone of reluctance when you said that). > > 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 ? dma_map_resource works in the sense of that helps with mapping an arbitrary phys_addr_t for DMA. It does not take various pitfalls of PCI P2P into account, such as the offset between the CPU physical address and the PCIe bus address, or the whole support of mapping between two devices behding a switch and not going through the limited root port support. Comparing dma_direct_map_resource/iommu_dma_map_resource with with pci_p2pdma_map_sg_attrs/__pci_p2pdma_map_sg should make that very clear. So if you want a non-page based mapping you need a "resource"-level version of pci_p2pdma_map_sg_attrs. Which totall doable, and in fact mostly trivial. But no one has even looked into providing one and just keeps arguing.