Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp7139pxv; Thu, 24 Jun 2021 01:14:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbbZKGE7aPhz3gOzJpcAD5xegJCZDeD9pNQ/XugrNouJzKWywq/0C3Hhc2DTwF1EJOUyoc X-Received: by 2002:a17:907:3d8e:: with SMTP id he14mr4133692ejc.374.1624522495377; Thu, 24 Jun 2021 01:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624522495; cv=none; d=google.com; s=arc-20160816; b=xoWkCrw2TEDIs/RCCz3Wg4w0auv64hDnORak93og/lbwuw9aDFGZpKid9GmKBp7M1c 1aSAVzCV2S25FUNZtVQqAxdEhJUF3uJsmX4UXWQJ/04eDS/cTYXQvklowsJwUr2e4wLW 8echQKyVfzDVl7y3UMFw4iNCX9om1QpfW+HRDCJ5VR+1wXKMsgHXjE+UvZu5iNDXoxFy sV+I0c2nTW1i/rycyYPefbbThU8sPnrjFbC043o7qNsZ311g9rGpj4S8EFBpfh36bD7V a3CfcBK6+bjOnU3neTsIf+FZVIEPYOeJpSY0EEVh50LIv0XaF7RAtyVEi/12yOgoxCf7 MB4w== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=150i5jQ/OyOr/k4Z0iD+QgaJmjrd9wogiXjv3+BYZBU=; b=FbLZERS9cPAtBYNFgIDHIx6T7Aogwio2tcP1THxY0g9KrQ27wrFG1B5Qa/PFFEYfjr kXxui5PU3WuCDRa85iN/XUIXrCPv8zmhK1M7m3eBfYhYJpKJmjm1TM81wiTuAjO7bCA1 kEPvhq8ObiFkWSeetNjfg7wDuaMYiuF/tuJ7w+PQ7AySA9GqYLKd+WtuDcFDUC8ZRC4w b9hD/akIETRcm6e8M5du1EGRmR0s6KUuk+YczM1TerE7bzu7hhNcDiKlIRJIIu+y0y0g nATSmMDPdf7nD00CK2cJDAuOJQMwv/nmRPPzjyp971t/8Zv0idHxcCRieOFk2cdzEHhV /Hww== 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 e11si2118309ejy.502.2021.06.24.01.14.31; Thu, 24 Jun 2021 01:14:55 -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 S231826AbhFXIPC (ORCPT + 99 others); Thu, 24 Jun 2021 04:15:02 -0400 Received: from verein.lst.de ([213.95.11.211]:53546 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231705AbhFXIPB (ORCPT ); Thu, 24 Jun 2021 04:15:01 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 01CD167373; Thu, 24 Jun 2021 10:12:38 +0200 (CEST) Date: Thu, 24 Jun 2021 10:12:37 +0200 From: Christoph Hellwig To: Christian =?iso-8859-1?Q?K=F6nig?= Cc: Christoph Hellwig , Oded Gabbay , Jason Gunthorpe , Christian =?iso-8859-1?Q?K=F6nig?= , Gal Pressman , sleybo@amazon.com, linux-rdma , Oded Gabbay , 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: <20210624081237.GA30289@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> <20210624053421.GA25165@lst.de> <9571ac7c-3a58-b013-b849-e26c3727e9b2@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9571ac7c-3a58-b013-b849-e26c3727e9b2@amd.com> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 24, 2021 at 10:07:14AM +0200, Christian K?nig wrote: > The key point is that accessing the underlying pages even when DMA-bufs are > backed by system memory is illegal. Daniel even created a patch which > mangles the page pointers in sg_tables used by DMA-buf to make sure that > people don't try to use them. Which is another goddamn layering violation of a subsystem that has no business at all poking into the scatterlist structure, yes. > So the conclusion is that using sg_table in the DMA-buf framework was just > the wrong data structure and we should have invented a new one. I think so. > But then people would have complained that we have a duplicated > infrastructure (which is essentially true). I doubt it. At least if you had actually talked to the relevant people. Which seems to be a major issue with what is going on GPU land. > My best plan to get out of this mess is that we change the DMA-buf > interface to use an array of dma_addresses instead of the sg_table object > and I have already been working on this actively the last few month. Awesome! I have a bit of related work on the DMA mapping subsystems, so let's sync up as soon as you have some first sketches. Btw, one thing I noticed when looking over the dma-buf instances is that there is a lot of duplicated code for creating a sg_table from pages, and then mapping it. It would be good if we could move toward common helpers instead of duplicating that all over again.