Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp502812pxk; Thu, 17 Sep 2020 08:35:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxylH9Se8vhCXFkvxgHVjnfs41Fxm+wmZinWvqAHas26mh6hEjI/C1+D0Qd0FewQeewiSZP X-Received: by 2002:a17:906:f1cf:: with SMTP id gx15mr30625715ejb.241.1600356955738; Thu, 17 Sep 2020 08:35:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600356955; cv=none; d=google.com; s=arc-20160816; b=JoFRaVztVLcl5n8XZ1TAijcmrk7bzpY1X0S5IAeIvcLYGV3hz0ic9J8TGV0y3mFPNj cCe6DDv1Qhtwqf/8si4h73n4gdKqO2annUoOwd4e1ciVdYrr8aXckKT83Byc6I0uF/Yk kwTYJeZOZNOFYjNXJPjNJ05m0PMoMKY/PwkycfEFfpkBb+8z9i/rjJ03Iql6SWRqUBOa INLD3JlBnJt3rzk+XyR6j6SzdzWfRb+6g6b2V7Xun+JMUUxpZvtB0VBobncpgyjONAA0 M3QlzGWCo/dfa7c6CQHqoN5irVsCXNCMXo+91rkCnuHgwo2G8IP6b2SPlk0LsDR17fPo iOww== 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=/MIjfA84FROcmh2Yr+++vHpa0nobfYfMg9k42KNVp2M=; b=jaSO0ko8EjDzZI/D2MJOvyU3HCxoq98c8sB1+ojgNr+cvO/vgPtT0cO1momAWKWGTM BVSkDa4wZ0di1/BT3Y4J2JQHIgkrco5sAiGyJ9KsiTqvlNkVJDer7znPTq5YD7vpaWcj cDz+UrO7LQkGVvD84Zi7YBohCX1SHycbbTYecPae5xGCF1cINffbN3HeeEA28ibKEcJY E8Q+uTuAVkgFqWOfo643hgREa55nA4Y/LyzfcxndeZzNdw7EUafRo+ikpzK/5/K6y45Y 8A+bbwldygUxCWeqTbDv/+jenj885qrAtAbRP7mTDi4fXMrr/VwYAwuzMU+Xc/DmfLv/ 0M2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=KItZq7TL; 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 u26si38263edv.154.2020.09.17.08.35.31; Thu, 17 Sep 2020 08:35: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; dkim=pass header.i=@ziepe.ca header.s=google header.b=KItZq7TL; 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 S1727418AbgIQPe2 (ORCPT + 99 others); Thu, 17 Sep 2020 11:34:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728183AbgIQPZG (ORCPT ); Thu, 17 Sep 2020 11:25:06 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7D73C06174A for ; Thu, 17 Sep 2020 08:24:58 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id 19so2184471qtp.1 for ; Thu, 17 Sep 2020 08:24:58 -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=/MIjfA84FROcmh2Yr+++vHpa0nobfYfMg9k42KNVp2M=; b=KItZq7TLRwXkeSUDV7TVakSYOYYpYVj1lFuOvU0VuV2nyeTZkDl+5SDk5YU6xRfdQb mmJrGXwRgXiqpqZBf8DLOJr/gMeGErqhZkM8rZSmNzY3KpK/NJt55cQb3C29WXfmsp40 KJdpWLxQBDyknwAoYt/ULy2EsSn//x6zNDDJW/sQmVP1idUubfNstwrhi9t017rZ3QZJ 3sDqFSKs5FzHiMnyyMyLtAnPX0Naf0m0oIbzEeYFHkliee0CZ1/6R0VN7TcyiVwxLFrO JOOOGOMacxM9ezg1v7YEt3scmLEmwNPGkyrd88i/jnPrnz/LvnJkdxDuuHZJUSvAh0TC tmSA== 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=/MIjfA84FROcmh2Yr+++vHpa0nobfYfMg9k42KNVp2M=; b=PLWxflWh2UkTADl3jUMP060BEYfifW7N0yd3UduT6c1pNn07tAbw9FSfhgb62bEsCw oE+bvek8qd/f/lY9M6DtJbs6DtcKnEzWJwGT35roD+ePTyvfmQq1S7O9pMm0v1Kx/skb HSYAM3NxI+iGXsIDL9pMSWvobXeads3Vu+fschEyH2dycYVAGyxdcjUSk28RiqXfSfYe H1LN3BUrax0h0YPUOizGv7m78koTdkZbsIxyzFK2RSooOOhicbiwWxn+p20K30SJLOjj aVQj/E/Thba24Bb7+elQsC/feDPsRyYP4d4HZ+a6ipRphGH5CR33x9TwdfVJyZJ+py6V ZNRQ== X-Gm-Message-State: AOAM531eoW7N9bJ/5VclHOSdQk0WxLiF74nyGL031seCGp64GamL8XCR eYsMYY3z6XepRtIMKJywE0DymQ== X-Received: by 2002:ac8:5d04:: with SMTP id f4mr16143583qtx.290.1600356297898; Thu, 17 Sep 2020 08:24:57 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-48-30.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.48.30]) by smtp.gmail.com with ESMTPSA id z74sm86638qkb.11.2020.09.17.08.24.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 08:24:57 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kIvmK-000VsL-KF; Thu, 17 Sep 2020 12:24:56 -0300 Date: Thu, 17 Sep 2020 12:24:56 -0300 From: Jason Gunthorpe To: christian.koenig@amd.com Cc: Linux Kernel Mailing List , dri-devel , "moderated list:DMA BUFFER SHARING FRAMEWORK" , Linux MM , Daniel Vetter , Andrew Morton , "open list:DMA BUFFER SHARING FRAMEWORK" Subject: Re: [Linaro-mm-sig] Changing vma->vm_file in dma_buf_mmap() Message-ID: <20200917152456.GH8409@ziepe.ca> References: <8d8693db-a3f0-4f5f-3e32-57d23ca620f8@amd.com> <20200917113110.GE8409@ziepe.ca> <6fd74b84-959c-8b3b-c27b-e9fbf66396c7@gmail.com> <20200917121858.GF8409@ziepe.ca> <20200917143551.GG8409@ziepe.ca> <5b330920-c789-fac7-e9b1-49f3bc1097a8@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5b330920-c789-fac7-e9b1-49f3bc1097a8@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 17, 2020 at 04:54:44PM +0200, Christian König wrote: > Am 17.09.20 um 16:35 schrieb Jason Gunthorpe: > > On Thu, Sep 17, 2020 at 02:24:29PM +0200, Christian König wrote: > > > Am 17.09.20 um 14:18 schrieb Jason Gunthorpe: > > > > On Thu, Sep 17, 2020 at 02:03:48PM +0200, Christian König wrote: > > > > > Am 17.09.20 um 13:31 schrieb Jason Gunthorpe: > > > > > > On Thu, Sep 17, 2020 at 10:09:12AM +0200, Daniel Vetter wrote: > > > > > > > > > > > > > Yeah, but it doesn't work when forwarding from the drm chardev to the > > > > > > > dma-buf on the importer side, since you'd need a ton of different > > > > > > > address spaces. And you still rely on the core code picking up your > > > > > > > pgoff mangling, which feels about as risky to me as the vma file > > > > > > > pointer wrangling - if it's not consistently applied the reverse map > > > > > > > is toast and unmap_mapping_range doesn't work correctly for our needs. > > > > > > I would think the pgoff has to be translated at the same time the > > > > > > vm->vm_file is changed? > > > > > > > > > > > > The owner of the dma_buf should have one virtual address space and FD, > > > > > > all its dma bufs should be linked to it, and all pgoffs translated to > > > > > > that space. > > > > > Yeah, that is exactly like amdgpu is doing it. > > > > > > > > > > Going to document that somehow when I'm done with TTM cleanups. > > > > BTW, while people are looking at this, is there a way to go from a VMA > > > > to a dma_buf that owns it? > > > Only a driver specific one. > > Sounds OK > > > > > For TTM drivers vma->vm_private_data points to the buffer object. Not sure > > > about the drivers using GEM only. > > Why are drivers in control of the vma? I would think dma_buf should be > > the vma owner. IIRC module lifetime correctness essentially hings on > > the module owner of the struct file > > Because the page fault handling is completely driver specific. > > We could install some DMA-buf vmops, but that would just be another layer of > redirection. If it is already taking a page fault I'm not sure the extra function call indirection is going to be a big deal. Having a uniform VMA sounds saner than every driver custom rolling something. When I unwound a similar mess in RDMA all the custom VMA stuff in the drivers turned out to be generally buggy, at least. Is vma->vm_file->private_data universally a dma_buf pointer at least? > > So, user VA -> find_vma -> dma_buf object -> dma_buf operations on the > > memory it represents > > Ah, yes we are already doing this in amdgpu as well. But only for DMA-bufs > or more generally buffers which are mmaped by this driver instance. So there is no general dma_buf service? That is a real bummer Jason