Received: by 10.192.165.156 with SMTP id m28csp653510imm; Mon, 16 Apr 2018 06:40:32 -0700 (PDT) X-Google-Smtp-Source: AIpwx48p59wFQw5cKWuhm4butwUrvdWHXeXs2W1Ox07/oSSTKWaw8ZbwcbLw/bHSaK3e2XTgs31T X-Received: by 10.98.215.81 with SMTP id v17mr9218168pfl.8.1523886032128; Mon, 16 Apr 2018 06:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523886032; cv=none; d=google.com; s=arc-20160816; b=rnejhXKtzuX1LjG8pvq5Z6t7SHNCkEOUdir6CFTApO571M2LL4KHAz2WdDx3HywCOb y0bvzaJbQGV7C4Dvatb1tnA+W3NKo217w/ZKDSy2z+abvq1KWbXrD7CnH53Img3u+Kw2 Vp5zJB5seW37k/yBT246lOLwGblmo75yCgGawVKZ68+1LUp5tSHsHjiit/SwUQIxHJsh fp3kbzn5UuLhXofvPVOu1gfuiunV60WMFrlPdDB8l2K/zkHBQeDo89AkxU0EBTFPxekA X0WSrRORsz1OHRAwniuJhvcVnLVTDUN50HvwAeY7W5iaidONUAUBy2WqEiSM6kscZXZn ryCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=A7aXrS/sBiiRlXKKv7CzD2DIiwQRt7FN2cuEhog0W3I=; b=afo+jAweWiHyJNvZY1vcmCimZXWhHoUGnoX76KwaGNaZnGC7My7/6KHtLhfk0CYT5c Gq9h/KTXz5vEF50jYjIAYJWJwl9v00YQNNC7cvE3kvUm35e6hUjhd0PakBoswi9TB1K/ IAWxbGb3TQTADM3xGBk+/kCs9dh+iXCbrpfmgYk9MuxdP6mH5Ay2fVUUtdnN6UbiAJXX vNURUZY2/PkxUrRo9O4zsLnhRMDLxBBpsNM0XpSaRQB+HeYf0uQYzVLh87tx72Ot1o1+ Vo4mcMzNvPmvcrCVz5llwokxyF7H26Y7bwTdB7a0hTh3OejHnhr7W+eFXd7LDjgA6B4Z YbSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=CXUJIsQe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m72si10950658pfi.236.2018.04.16.06.40.17; Mon, 16 Apr 2018 06:40:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@ffwll.ch header.s=google header.b=CXUJIsQe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755208AbeDPNjA (ORCPT + 99 others); Mon, 16 Apr 2018 09:39:00 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:50579 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753479AbeDPNi6 (ORCPT ); Mon, 16 Apr 2018 09:38:58 -0400 Received: by mail-it0-f65.google.com with SMTP id r19-v6so11407830itc.0 for ; Mon, 16 Apr 2018 06:38:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=A7aXrS/sBiiRlXKKv7CzD2DIiwQRt7FN2cuEhog0W3I=; b=CXUJIsQea5PWWAQLi/EKOCfQgphbwGvG9e4fVgH0ifxpzc2PinelowBamOy57B3AfN L0SocUR0u/mpUDZezUBy91MeD/Wq05H99u1NgGOy3wW2QEN6H7jSbVOsgjc30q3eeqXA vEwVMse3uVYGsVOUiRtmBCViOG6O+3MduaiRU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=A7aXrS/sBiiRlXKKv7CzD2DIiwQRt7FN2cuEhog0W3I=; b=BNHXZY5UeW5LC9DAP2oVP80d+EMfEfor6Cv/I84wjt14WS4fTzlL5GbwrisSyuJmWj +yIBNkjmO1TNUmTQ7gFDq8walrksY4X3bXEGO1RLaH0CQbd4ZfLLeR0DAWMDaK4VWfbk enCg6n/eaq7VFTyfp+zCWlEUjomqStjt6mMMs5vbz2wO2rAYpV299YjziWS4q3VCLp2w TZgdKokiPrIOPVK/wim2pG+fZ2uiQ7TXQGjuA2apiwuiW36+1dVXCJ7fUEuNHw1p2PXe P+gQWoYTbCUVKMszbTPy8aNH+r2O0R4LQCqcPD7lXKlb1ZFuf5P6++R5XRkrIde7V5OW p6UA== X-Gm-Message-State: ALQs6tBhZhsmBVvGPdNfC8icUTCYbM7G8+wn/uFHaRTbpWx5C5BhMty0 ekb7LFLPRTH3wvT+rNlcKsJK64w/FUQIRAicnrx6QQ== X-Received: by 2002:a24:dd82:: with SMTP id t124-v6mr15494414itf.2.1523885937406; Mon, 16 Apr 2018 06:38:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.79.134.193 with HTTP; Mon, 16 Apr 2018 06:38:56 -0700 (PDT) X-Originating-IP: [212.51.149.109] In-Reply-To: <20180416123937.GA9073@infradead.org> References: <20180325110000.2238-1-christian.koenig@amd.com> <20180325110000.2238-4-christian.koenig@amd.com> <20180329065753.GD3881@phenom.ffwll.local> <8b823458-8bdc-3217-572b-509a28aae742@gmail.com> <20180403090909.GN3881@phenom.ffwll.local> <20180403170645.GB5935@redhat.com> <20180403180832.GZ3881@phenom.ffwll.local> <20180416123937.GA9073@infradead.org> From: Daniel Vetter Date: Mon, 16 Apr 2018 15:38:56 +0200 X-Google-Sender-Auth: 4ZAPAsoeJLTEghJiqThFBfFFf_s Message-ID: Subject: Re: [PATCH 4/8] dma-buf: add peer2peer flag To: Christoph Hellwig Cc: Jerome Glisse , =?UTF-8?Q?Christian_K=C3=B6nig?= , "moderated list:DMA BUFFER SHARING FRAMEWORK" , "open list:DMA BUFFER SHARING FRAMEWORK" , dri-devel , amd-gfx list , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 16, 2018 at 2:39 PM, Christoph Hellwig wrote: > On Tue, Apr 03, 2018 at 08:08:32PM +0200, Daniel Vetter wrote: >> I did not mean you should dma_map_sg/page. I just meant that using >> dma_map_resource to fill only the dma address part of the sg table seems >> perfectly sufficient. > > But that is not how the interface work, especially facing sg_dma_len. > >> Assuming you get an sg table that's been mapping by calling dma_map_sg was >> always a bit a case of bending the abstraction to avoid typing code. The >> only thing an importer ever should have done is look at the dma addresses >> in that sg table, nothing else. > > The scatterlist is not a very good abstraction unfortunately, but it > it is spread all over the kernel. And we do expect that anyone who > gets passed a scatterlist can use sg_page() or sg_virt() (which calls > sg_page()) on it. Your changes would break that, and will cause major > trouble because of that. > > If you want to expose p2p memory returned from dma_map_resource in > dmabuf do not use scatterlists for this please, but with a new interface > that explicitly passes a virtual address, a dma address and a length > and make it very clear that virt_to_page will not work on the virtual > address. We've broken that assumption in i915 years ago. Not struct page backed gpu memory is very real. Of course we'll never feed such a strange sg table to a driver which doesn't understand it, but allowing sg_page == NULL works perfectly fine. At least for gpu drivers. If that's not acceptable then I guess we could go over the entire tree and frob all the gpu related code to switch over to a new struct sg_table_might_not_be_struct_page_backed, including all the other functions we added over the past few years to iterate over sg tables. But seems slightly silly, given that sg tables seem to do exactly what we need. -Daniel -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch