From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 500D41C84C0; Tue, 20 May 2025 07:23:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747725793; cv=none; b=iSejR4/3BU2p5kmhRKbpLebMwEtMyPZifTb0l3uJV3WmOS785HAs1Vh90K7oiUWFYu3t/cYyAZAgbIRtumHhBUFBQxMpQrKj8pfmtbVNbhgATGammUfvIJHG9V+k1CufnUg8Q6XbELOM2t054t1GxH3GXMsVJQXnk2J4RCh+Cbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747725793; c=relaxed/simple; bh=axV148epcCnH8V4IUGh3tEhgUD1SmtDSAbyYQaGyLUY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=faHdx/6g9jMk4eiCl4ILbh87YmblOGEkHZEDoJaXS4JzhRV5dpEE+GHoBbE9Nui4RSbBqeK5SrxvapyoI+9SkYkqCgFWvQh5O9jYf8vx54Gu3omyyN5qSqfUTYgcIAxe5T//i1N8eY3Q9Bt7eBxeNJZMBym4JB87iqp2AceylqE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=utsHWFdp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="utsHWFdp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3DFF2C4CEE9; Tue, 20 May 2025 07:23:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747725792; bh=axV148epcCnH8V4IUGh3tEhgUD1SmtDSAbyYQaGyLUY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=utsHWFdp+aNZIybpy2w2/kulETWFThZUUGtwqTkkH59zikOi3fzIgH20T0ExBzDS/ vbe5Wq5brUWmJCyNOtMSIH8TkgPKhDRaaU1h/IivjV8dTKTv/Mg1thBbqJ/qr2s2Uk I07KmNQokCcfH2NFUAc5Qu2Y4lRhMjNIe4SdDid1tgbmDxWMRZkvsbpdsVicBS4TY/ G2Rq8A3zbns2w7FQkSiIH6g07DY7ESqpATWYJOWfD6hXH8uZBgaerRvq1TyxYvOk/T iupLImO3zK8kHdu66CVFNOI1hTVGN4kTB8CICzhVdgqXOzfKX0XxntGQ/LTwTtjOQN NlSai1pVNunDw== Date: Tue, 20 May 2025 09:23:07 +0200 From: Danilo Krummrich To: Rob Clark Cc: dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Connor Abbott , Rob Clark , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , open list Subject: Re: [PATCH v5 01/40] drm/gpuvm: Don't require obj lock in destructor path Message-ID: References: <20250519175348.11924-1-robdclark@gmail.com> <20250519175348.11924-2-robdclark@gmail.com> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250519175348.11924-2-robdclark@gmail.com> On Mon, May 19, 2025 at 10:51:24AM -0700, Rob Clark wrote: > From: Rob Clark > > See commit a414fe3a2129 ("drm/msm/gem: Drop obj lock in > msm_gem_free_object()") for justification. I asked for a proper commit message in v4. Only referring to a driver commit and let the people figure out how the driver works and what it does in order to motivate a change in the generic infrastructure is simply unreasonable. > Cc: Danilo Krummrich > Signed-off-by: Rob Clark > --- > drivers/gpu/drm/drm_gpuvm.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_gpuvm.c b/drivers/gpu/drm/drm_gpuvm.c > index f9eb56f24bef..1e89a98caad4 100644 > --- a/drivers/gpu/drm/drm_gpuvm.c > +++ b/drivers/gpu/drm/drm_gpuvm.c > @@ -1511,7 +1511,9 @@ drm_gpuvm_bo_destroy(struct kref *kref) > drm_gpuvm_bo_list_del(vm_bo, extobj, lock); > drm_gpuvm_bo_list_del(vm_bo, evict, lock); > > - drm_gem_gpuva_assert_lock_held(obj); > + if (kref_read(&obj->refcount) > 0) > + drm_gem_gpuva_assert_lock_held(obj); Again, this is broken. What if the reference count drops to zero right after the kref_read() check, but before drm_gem_gpuva_assert_lock_held() is called? Putting conditionals on a refcount is always suspicious. If you still really want this, please guard it with if (unlikely(gpuvm->flags & DRM_GPUVM_MSM_LEGACY_QUIRK)) and get an explicit waiver from Dave / Sima.