From mboxrd@z Thu Jan 1 00:00:00 1970 From: Daniel Vetter Subject: Re: [PATCH mm-unstable v1 14/20] drm/etnaviv: remove FOLL_FORCE usage Date: Wed, 16 Nov 2022 11:49:43 +0100 Message-ID: References: <20221116102659.70287-1-david@redhat.com> <20221116102659.70287-15-david@redhat.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=SB0xMxg7mb7arNhoP48cqWafxbk28Z1Lix7iS7Zkf4o=; b=G+yH7gGM79Kur0Iop0CPPA+qhziqzAzwIurg983ubYb3WshrhUBjt115nMP15JVtFB bCAGjPfacpREtOfp/xR/YX1SymsdQ1bgnCyPvMlgHC3mzRuO7K3B6poJkP/JWiUCmMWF GisY2xBmQqATnhhXA26BG81FXfyHx1zsVnNWg= Content-Disposition: inline In-Reply-To: <20221116102659.70287-15-david@redhat.com> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+glppe-linuxppc-embedded-2=m.gmane-mx.org@lists.ozlabs.org Sender: "Linuxppc-dev" Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: David Hildenbrand Cc: linux-ia64@vger.kernel.org, Greg Kroah-Hartman , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Nadav Amit , linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, Shuah Khan , Andrea Arcangeli , linux-samsung-soc@vger.kernel.org, linux-rdma@vger.kernel.org, David Airlie , x86@kernel.org, Hugh Dickins , Matthew Wilcox , Christoph Hellwig , Jason Gunthorpe , Vlastimil Babka , Russell King , linux-media@vger.kernel.org, Arnd Bergmann , John Hubbard , li nux-um@lists.infradead.org, etnaviv@lists.freedesktop.org, Alex Williamson On Wed, Nov 16, 2022 at 11:26:53AM +0100, David Hildenbrand wrote: > GUP now supports reliable R/O long-term pinning in COW mappings, such > that we break COW early. MAP_SHARED VMAs only use the shared zeropage so > far in one corner case (DAXFS file with holes), which can be ignored > because GUP does not support long-term pinning in fsdax (see > check_vma_flags()). > > commit cd5297b0855f ("drm/etnaviv: Use FOLL_FORCE for userptr") > documents that FOLL_FORCE | FOLL_WRITE was really only used for reliable > R/O pinning. > > Consequently, FOLL_FORCE | FOLL_WRITE | FOLL_LONGTERM is no longer required > for reliable R/O long-term pinning: FOLL_LONGTERM is sufficient. So stop > using FOLL_FORCE, which is really only for ptrace access. > > Cc: Daniel Vetter > Cc: Lucas Stach > Cc: Russell King > Cc: Christian Gmeiner > Cc: David Airlie > Signed-off-by: David Hildenbrand Reviewed-by: Daniel Vetter Also ack for merging through whatever tree suits best, since I guess this should all land together. -Daniel > --- > drivers/gpu/drm/etnaviv/etnaviv_gem.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c > index cc386f8a7116..efe2240945d0 100644 > --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c > +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c > @@ -638,6 +638,7 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj) > struct page **pvec = NULL; > struct etnaviv_gem_userptr *userptr = &etnaviv_obj->userptr; > int ret, pinned = 0, npages = etnaviv_obj->base.size >> PAGE_SHIFT; > + unsigned int gup_flags = FOLL_LONGTERM; > > might_lock_read(¤t->mm->mmap_lock); > > @@ -648,14 +649,15 @@ static int etnaviv_gem_userptr_get_pages(struct etnaviv_gem_object *etnaviv_obj) > if (!pvec) > return -ENOMEM; > > + if (!userptr->ro) > + gup_flags |= FOLL_WRITE; > + > do { > unsigned num_pages = npages - pinned; > uint64_t ptr = userptr->ptr + pinned * PAGE_SIZE; > struct page **pages = pvec + pinned; > > - ret = pin_user_pages_fast(ptr, num_pages, > - FOLL_WRITE | FOLL_FORCE | FOLL_LONGTERM, > - pages); > + ret = pin_user_pages_fast(ptr, num_pages, gup_flags, pages); > if (ret < 0) { > unpin_user_pages(pvec, pinned); > kvfree(pvec); > -- > 2.38.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch