From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (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 6164E224225; Thu, 24 Jul 2025 23:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753398847; cv=pass; b=swDQWluM5AhBNi7CZl2Bd0E8gtueCn7X9pN1eWDA+oqLE4I4u15RWvSNo5xuAwNGEMtUdV7etJoPvtzJWvhFghteXpngX+GxWHWJtARFQEgcNcdq5HCvwOXI91YMSgAlUfCyRIXWyaOoYwcWH43t9vA6z4a5FP6suWB8OlvUh8M= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1753398847; c=relaxed/simple; bh=qoS/nhvhWVOdRPR9TEbn27OPGAu9L7gp5BjJmNczgDE=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=l8Yj4dKkACAe0feqlQKfqwcV4xPZNGhbBDpB6Mh8gOzuDEhfuLLieofs0hBeay0s3vYZ9/YAZkeTG7hRfs48UY9xYpKuMm18179L+pn9phD4vyeOs4AZgOkGsCE+4U649G5ekCiTDAv57q0B/sW9bsCev7np/08DRkWie/eytXA= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=daniel.almeida@collabora.com header.b=GCfOorPL; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=daniel.almeida@collabora.com header.b="GCfOorPL" ARC-Seal: i=1; a=rsa-sha256; t=1753398813; cv=none; d=zohomail.com; s=zohoarc; b=QESqvU1fmd4n54OSgYaySl/CHEEEoQxkSlUqDEUi8sF6JOMkNcauBvwoQ8KZxJ1PJlDo9zTQyTiAl2GxAMxlHcz4axkPgse00BpNY696M+gsFlxlkprGaJ7NDKT9NN7cxjfnuRECQO1yUAlKUJEVFZ01CmUM7OTilcbqvn1Mjwo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1753398813; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=7WbypAsGzahsapPp7xQ+wrpUDPFjbToobgw0emJ/Uh0=; b=GTmoZeM60VZe5HMFwnBH1m8HS7S/xDkrnxl+oi0LrNMcs9Lrq5vOuR9G7wFC0Ri3mhd74tLSZJtIOYgQbAlqoHz4ctyPQS4ygF3ZOXaxj2dUwRfgfqZaK8YK+xl/68AjruM7aS/owRBZQRhbRkaG/Z4eRr3LVLCfXd4xEKytH5c= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=daniel.almeida@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1753398813; s=zohomail; d=collabora.com; i=daniel.almeida@collabora.com; h=Content-Type:Mime-Version:Subject:Subject:From:From:In-Reply-To:Date:Date:Cc:Cc:Content-Transfer-Encoding:Message-Id:Message-Id:References:To:To:Reply-To; bh=7WbypAsGzahsapPp7xQ+wrpUDPFjbToobgw0emJ/Uh0=; b=GCfOorPLfvxPBlXdRlkZIAIP+WniIjzJfghV7NedxL6/w1N/hLkhR6rLWs2AKytP oQORm30pGWwULQJ1+jh9YpWmwIuk/svILXJnvm8uMcx0KhstBhsGkZX42QfFlPNj1tz pICfiA7qVpB5ybSyRkCUQzZ+ndmpVgqwtF95OY6U= Received: by mx.zohomail.com with SMTPS id 1753398810537411.2389352606622; Thu, 24 Jul 2025 16:13:30 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.600.51.1.1\)) Subject: Re: [PATCH] Partially revert "rust: drm: gem: Implement AlwaysRefCounted for all gem objects automatically" From: Daniel Almeida In-Reply-To: Date: Thu, 24 Jul 2025 20:13:13 -0300 Cc: Lyude Paul , nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org, 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 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20250724191523.561314-1-lyude@redhat.com> To: Danilo Krummrich X-Mailer: Apple Mail (2.3826.600.51.1.1) X-ZohoMailClient: External > On 24 Jul 2025, at 19:27, Danilo Krummrich wrote: >=20 > On Thu Jul 24, 2025 at 11:06 PM CEST, Lyude Paul wrote: >> On Thu, 2025-07-24 at 22:03 +0200, Danilo Krummrich wrote: >>> 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 the 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 thus 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 to potentially deallocate it. >>>> - unsafe { bindings::drm_gem_object_put(obj) }; >>>> - } >>>> -} >>>=20 >>> IIUC, you'll add rust/kernel/drm/gem/shmem.rs with a new type = shmem::Object that >>> implements IntoGEMObject, right? >>>=20 >>> If this is correct, I think that should work. >>=20 >> Do you mean you think the blanket implementation that we had would = work, or >> that getting rid of it would work? >=20 > The former. >=20 >> Since the blanket implementation we have >> definitely doesn't compile on my machine once we add more then one >> IntoGEMObject impl. (before adding it, it works just fine) >=20 > Do you have a branch somewhere, where it doesn't compile? Hi Lyude, I=E2=80=99m somewhat surprised to be honest. Your gem-shmem = code works on tyr-next, which is currently on top of 6.16-rc2. What exactly doesn=E2=80=99= t compile? [0] = https://gitlab.freedesktop.org/panfrost/linux/-/tree/tyr-next?ref_type=3Dh= eads