From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A6FEC43461 for ; Thu, 17 Sep 2020 14:35:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5B3262068D for ; Thu, 17 Sep 2020 14:35:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="j5oYloPv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5B3262068D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A0B516B0003; Thu, 17 Sep 2020 10:35:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9BD748E0001; Thu, 17 Sep 2020 10:35:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AB976B0055; Thu, 17 Sep 2020 10:35:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 71C5D6B0003 for ; Thu, 17 Sep 2020 10:35:54 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 167643635 for ; Thu, 17 Sep 2020 14:35:54 +0000 (UTC) X-FDA: 77272802628.22.wood14_131788127123 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin22.hostedemail.com (Postfix) with ESMTP id E1A2E18038E60 for ; Thu, 17 Sep 2020 14:35:53 +0000 (UTC) X-HE-Tag: wood14_131788127123 X-Filterd-Recvd-Size: 5877 Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Thu, 17 Sep 2020 14:35:53 +0000 (UTC) Received: by mail-qk1-f195.google.com with SMTP id v123so2387901qkd.9 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=EWayMI6PgGaVFfvZs2C8H93NjGU1LCZEDDV44RfRxnSvFQkqA+15POANbyW26sCVV5 CFTHRwWbXFKAtzWWr5Yb8IlGqgZNt8ldo9HiCMRqm7joV8VEoKCi4WmtHzly82aCob7x bXcHOA6zc88WgsEiDnkTrivlCtExOXybyPPc5msRrrPNS3eJdETEoP9cXoA4i/NKQrHX Ek0mkZRclBjFeko1zPl7q/QQCOi4b4407v6tvXsOAu4i0d3IWHmwFYVxq7LXAKgjU4Xc BjQsliIhnOqDnoLipFxNULZ6iku9zXidUwY5zxHtYAdcMNVn+7AoCIptom8TNIIB1Jje 67nQ== X-Gm-Message-State: AOAM5322HIaTbRAP/zv3rPGtrSSeEaqlMV0v4UWYlote4hqUk3IWoAV8 4UcX6haN5Q6DDH3n7N6jxcMp7g== X-Google-Smtp-Source: ABdhPJzS5DvFjFRz09F8HD5ZwD/CTVt6TV63hE1mZt++JvtsXfCWDtAegDUHikgXHQCiEAeg2s8xdA== 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 In-Reply-To: X-Rspamd-Queue-Id: E1A2E18038E60 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 17, 2020 at 02:24:29PM +0200, Christian K=C3=B6nig wrote: > Am 17.09.20 um 14:18 schrieb Jason Gunthorpe: > > On Thu, Sep 17, 2020 at 02:03:48PM +0200, Christian K=C3=B6nig wrote: > > > Am 17.09.20 um 13:31 schrieb Jason Gunthorpe: > > > > On Thu, Sep 17, 2020 at 10:09:12AM +0200, Daniel Vetter wrote: > > > >=20 > > > > > 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 differe= nt > > > > > 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 fil= e > > > > > pointer wrangling - if it's not consistently applied the revers= e 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? > > > >=20 > > > > The owner of the dma_buf should have one virtual address space an= d FD, > > > > all its dma bufs should be linked to it, and all pgoffs translate= d to > > > > that space. > > > Yeah, that is exactly like amdgpu is doing it. > > >=20 > > > 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 VM= A > > to a dma_buf that owns it? >=20 > Only a driver specific one. Sounds OK > For TTM drivers vma->vm_private_data points to the buffer object. Not s= ure > 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