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 DD7C6C87FC5 for ; Thu, 24 Jul 2025 20:03:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 612D310E29D; Thu, 24 Jul 2025 20:03:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="E8WwFdrC"; dkim-atps=neutral Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6F97510E29D; Thu, 24 Jul 2025 20:03:30 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 1FDAB44433; Thu, 24 Jul 2025 20:03:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D066AC4CEED; Thu, 24 Jul 2025 20:03:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753387410; bh=fP0jCPxK1T2Ab4oOBOWBx+XZP5UkwaWLafeWg2ZgBJs=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=E8WwFdrC0RZ8rN7KsoVsEMrz9EqPnn13H/y/P7tAdZ247z4YBdpzTMikLpK4D0B5d mckAPFE+mrBsKdgZehZsVF1LVj0xcckG9oVDGyDOKf3sP5m6uNCJ9bRhUZQ9VOH/F8 Olz0wT8gw1HaHi64LZXyA1unW6aNq+dVE0toyAZoe6dhlgfHE2MKd81Te/9ty/5vOQ seL1LFy8s0xfTYL5aJIN+IHPYw17vSqzbLN1OCYyr8dDQxFdrfjFr11Nksxt4SWA/T I5ivN9RjFm4i2abAKSt6c9ImLJOwQKIm0cgFzsDmzEGOrg6zoZpXy5HzD46w98A6KF 0fzCgFpZzfBaQ== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 24 Jul 2025 22:03:24 +0200 Message-Id: Subject: Re: [PATCH] Partially revert "rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically" Cc: , , , "Daniel Almeida" , "David Airlie" , "Simona Vetter" , "Maarten Lankhorst" , "Maxime Ripard" , "Thomas Zimmermann" , "Miguel Ojeda" , "Alex Gaynor" , "Boqun Feng" , "Gary Guo" , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , "Benno Lossin" , "Andreas Hindborg" , "Alice Ryhl" , "Trevor Gross" , "Asahi Lina" , "Alyssa Rosenzweig" , "open list" To: "Lyude Paul" From: "Danilo Krummrich" References: <20250724191523.561314-1-lyude@redhat.com> In-Reply-To: <20250724191523.561314-1-lyude@redhat.com> X-BeenThere: nouveau@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Nouveau development list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: nouveau-bounces@lists.freedesktop.org Sender: "Nouveau" On Thu Jul 24, 2025 at 9:15 PM CEST, Lyude Paul wrote: > -// SAFETY: All gem objects are refcounted. > -unsafe impl AlwaysRefCounted for T { > - fn inc_ref(&self) { > - // SAFETY: The existence of a shared reference guarantees that t= he refcount is non-zero. > - unsafe { bindings::drm_gem_object_get(self.as_raw()) }; > - } > - > - unsafe fn dec_ref(obj: NonNull) { > - // SAFETY: We either hold the only refcount on `obj`, or one of = many - meaning that no one > - // else could possibly hold a mutable reference to `obj` and thu= s this immutable reference > - // is safe. > - let obj =3D unsafe { obj.as_ref() }.as_raw(); > - > - // SAFETY: > - // - The safety requirements guarantee that the refcount is non-= zero. > - // - We hold no references to `obj` now, making it safe for us t= o potentially deallocate it. > - unsafe { bindings::drm_gem_object_put(obj) }; > - } > -} IIUC, you'll add rust/kernel/drm/gem/shmem.rs with a new type shmem::Object= that implements IntoGEMObject, right? If this is correct, I think that should work. Do I miss anything?