Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp465932pxk; Thu, 17 Sep 2020 07:45:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDL+7O0suQKRnHNTwf0Vok3NQgzXdZsZXEHqtvkCOzNtqrVo5qMJ8D5BLZLcHyJDDDSp9B X-Received: by 2002:a17:906:4819:: with SMTP id w25mr30873247ejq.300.1600353925290; Thu, 17 Sep 2020 07:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600353925; cv=none; d=google.com; s=arc-20160816; b=ukPwzOXbLApbRVK/w5Zieevlzw/2vEfttjojzZOS3RjFWWRE8VTBPhasFXPLgL2/Ns pLK8jqs9d8GJrS3syv0pQToObOs7hYqAJxyu42wXTg9ORW685vNWf9xjf0c/0mFtrwOq v1PqpoHkGxXmsiSMJ4Cfwle+my+Ppe7zvwRPfS0UPt81rvymkA3K5AOJxCErHl2h8+MX Dm7mFZo+6Uxn1XlHkrD9L/JJUHzb/jxI1OKYGrby3kdOjgI4SghXjknJ9xxfq/vGsbz1 HLwSBVsEZgJSqLD6bL4ucP3bH+gmsL2usLKeIXLrPEMBvJltM4yps5p/D9i6Kx4b6D5y fSlA== 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=4FMmUqw3Ogf5DWfrcaBYE+88tcXzyk3qcn9Gd5hl3YQ=; b=JsREMLXrYodGtFUC6sTzvx4g72xoDAVuPYCJoztoRggJfQGppvKtFRwMO5yWHMLo3Y FHhcRNuJCCWqVIRa80IY+qBZbqPXAqwzYJ0QDgRMWm77vZDor8VKNPcFzXrF311OPUTU mZisNZyRHENdiWXp6mvz9ufm1GqlaTZSEThA8E8j3PMye01Rsctx8wFu1D/CU8l+Lp5h FUKbBsuy6u3Wss+JOJo7ISG6k/OV8OTorojYTGR76yGjgtvoveSyA5Jykg4hHRpyFgbO d7wUpRsDlyVo6IW9TVn6XtQpBkAPuP32VeodAaZTDugs7YuK1ia3hoRXzWyoHDtVHmX0 DgOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=j5oYloPv; 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 m13si10314988edi.602.2020.09.17.07.45.00; Thu, 17 Sep 2020 07:45:25 -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=j5oYloPv; 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 S1727356AbgIQOiB (ORCPT + 99 others); Thu, 17 Sep 2020 10:38:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727298AbgIQOgr (ORCPT ); Thu, 17 Sep 2020 10:36:47 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EDECC061354 for ; Thu, 17 Sep 2020 07:35:53 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id t138so2445749qka.0 for ; Thu, 17 Sep 2020 07:35:53 -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=4FMmUqw3Ogf5DWfrcaBYE+88tcXzyk3qcn9Gd5hl3YQ=; b=j5oYloPvYL7s4CPTt81wv4olgyoI/6IlhT6aI8lDvNqHADWP/JsUZ4WNwSAnarJJVd Jdd7y5LK3H4qrJDXIzo4GzxtRtRdSn74TO+sPmBQ+A3UTKrWoV2qqwIgla/t6cN1mEzh YgB03e2F1hYq89gJy2In7h5LX8mfdp/lJ8vauS8eQJrPZEuv9vFNxus3W1QS8aEEh2jU aNgxQzkQEHZvN34u0lGhLEgUFKJXoYCaI/tF+nC0CovO/q9P121VcOoAOdmqbPSwPlwQ 9k8ecPtmJZWZCMPSONUM47C13l3uQbZ64/zvk+EFKCwijs/wPUYHVUJBOSzB9UTR274e bIsg== 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=4FMmUqw3Ogf5DWfrcaBYE+88tcXzyk3qcn9Gd5hl3YQ=; b=lby5ZXfCJCogmiE3Jp+lI0p+4sta80FwaZ6ycSyPbHDaeZsxGK26UX0r5J8iPwE+gM oTZw9Fmg3FbyApuYEUwvo4yeAlr2D+0/zJSwl7ppeQDYVdAj7vCkLjc0X5eoY3qTS680 h6SD+xKsWQEwMHCraOq2XzAYvKbUW/XlUdrToIKRSbnWMTR99ivb2jm1MAANakW1dj0U 4iCwXvg0sqCiedycqAJrdL67GkRTWmrkEavwCeCE7qUp5TVvZnc0swtbRS+7bJT/QhVp Vy/eWYm3lxfikh7fmhxojrwvtfMU8K7wcbzju8VBkbsUxfzAhEn3scxVj2EpEPSJHVaC GwEg== X-Gm-Message-State: AOAM532WsPWEDIXiUhINSVG9es6KSecZQdFBFL6Xb/6u4CCpVQ3jwWqw AxZf8fFLR6GbbyNpZbRbqacKlg== X-Received: by 2002:a05:620a:15ac:: with SMTP id f12mr27633534qkk.19.1600353352699; Thu, 17 Sep 2020 07:35:52 -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 m36sm20906770qtd.10.2020.09.17.07.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Sep 2020 07:35:52 -0700 (PDT) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kIv0p-000VC1-Ed; Thu, 17 Sep 2020 11:35:51 -0300 Date: Thu, 17 Sep 2020 11:35:51 -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: <20200917143551.GG8409@ziepe.ca> References: <8db2474f-ecb7-0e17-5f5b-145708fe44d5@amd.com> <8d8693db-a3f0-4f5f-3e32-57d23ca620f8@amd.com> <20200917113110.GE8409@ziepe.ca> <6fd74b84-959c-8b3b-c27b-e9fbf66396c7@gmail.com> <20200917121858.GF8409@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 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 > Why are you asking? I'm thinking about using find_vma on something that is not get_user_pages()'able to go to the underlying object, in this case dma buf. So, user VA -> find_vma -> dma_buf object -> dma_buf operations on the memory it represents Jason