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 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6DB31D25032 for ; Mon, 12 Jan 2026 07:30:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D9A2010E2E7; Mon, 12 Jan 2026 07:30:29 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=collabora.com header.i=@collabora.com header.b="ad7cpsYQ"; dkim-atps=neutral Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) by gabe.freedesktop.org (Postfix) with ESMTPS id C786610E2E7 for ; Mon, 12 Jan 2026 07:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1768203027; bh=76zyp142nntWg5LlS/nv3Nl2RH9S13/nhsMEPzRvEZA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=ad7cpsYQwtAGoKU1XwjMsU7sod3vJTSP319cM5veROpebmrd+kBreqRtkvn7tlLWy BzoTdxUllU56ErwcRjQPFWrPO3mVL1fB9JM18fBi2PSvkdXmOoL+M9NOm3P3Hy0mEn Q165wScn4C148E4DZHqQnYkcnYXaHTiSSCfa0qoOBmvX78LcuYP4OsLGo2+c75YH9t C4LelxiGyec83G/UtRoXShPiBISeZHXvCceP33DK6go5y/bvKaGyBkq6Ih2DefMlXm BuIyfmaHhQJa2KTLwUMEaUOcqXD3wNdqeg0hYDgAJ7uv9LRK6MgCekrnaFOeu+Wzh7 PgFYb5LDurGKw== Received: from fedora (unknown [IPv6:2a01:e0a:2c:6930:d919:a6e:5ea1:8a9f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id 5A0E217E0B8E; Mon, 12 Jan 2026 08:30:26 +0100 (CET) Date: Mon, 12 Jan 2026 08:30:14 +0100 From: Boris Brezillon To: "Danilo Krummrich" Cc: "Steven Price" , "Liviu Dudau" , =?UTF-8?B?QWRyacOhbg==?= Larumbe , , "David Airlie" , "Simona Vetter" , "Akash Goel" , "Rob Clark" , "Sean Paul" , "Konrad Dybcio" , "Akhil P Oommen" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "Dmitry Osipenko" , "Chris Diamand" , "Matthew Brost" , Thomas =?UTF-8?B?SGVsbHN0csO2?= =?UTF-8?B?bQ==?= , "Alice Ryhl" , Subject: Re: [PATCH v1 2/9] drm/gpuvm: Validate BOs in the extobj list when VM is resv protected Message-ID: <20260112083014.52fb8232@fedora> In-Reply-To: References: <20260109130801.1239558-1-boris.brezillon@collabora.com> <20260109130801.1239558-3-boris.brezillon@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.3.1 (GTK 3.24.51; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, 09 Jan 2026 20:38:37 +0100 "Danilo Krummrich" wrote: > On Fri Jan 9, 2026 at 2:07 PM CET, Boris Brezillon wrote: > > When the VM is protected with the root object resv, evicted extobjs > > are not inserted in the evict list. > > I'd rather say: "When the evicted object list is protected with the root object > reservation lock, ...". > > > Make sure we record when the extobj > > list contains evicted BOs that are not already in the evict list so we > > can validate those when drm_gpuvm_validate() is called. > > Why is this necessary in the first place? drm_gpuvm_prepare_objects() picks up > the affected external objects already. Oops, that's correct. Was looking for something calling ->vm_bo_validate() on evicted objects, but those are added to the evict list instead. I'll drop this patch. Thanks, Boris > > > Signed-off-by: Boris Brezillon > > --- > > drivers/gpu/drm/drm_gpuvm.c | 23 ++++++++++++++++++++++- > > include/drm/drm_gpuvm.h | 6 ++++++ > > 2 files changed, 28 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c > > index 0bb115b6b59c..95f0a1c843ad 100644 > > --- a/drivers/gpu/drm/drm_gpuvm.c > > +++ b/drivers/gpu/drm/drm_gpuvm.c > > @@ -1505,6 +1505,22 @@ drm_gpuvm_validate_locked(struct drm_gpuvm *gpuvm, struct drm_exec *exec) > > drm_gpuvm_bo_list_del_init(vm_bo, evict, false); > > } > > > > + if (READ_ONCE(gpuvm->extobj.check_evicted)) { > > + list_for_each_entry_safe(vm_bo, next, &gpuvm->extobj.list, > > + list.entry.extobj) { > > Running the external object list (again) seems wasteful given that this case can > never happen when drm_gpuvm_prepare_objects() is called before (which has to be > the case, given that somehow the objects have to be locked). > > And even if for some reason you open code this, it would be much better to add a > helper doing the check when the object is locked. > > > + dma_resv_assert_held(vm_bo->obj->resv); > > + > > + if (!vm_bo->evicted) > > + continue; > > + > > + ret = ops->vm_bo_validate(vm_bo, exec); > > + if (ret) > > + break; > > + } > > + > > + WRITE_ONCE(gpuvm->extobj.check_evicted, false); > > Why do we need READ_ONCE() and WRITE_ONCE() here? Don't we hold the object's > reservation lock whenever we touch check_evicted anyways? >