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 45048C87FCB for ; Fri, 1 Aug 2025 08:21:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A077610E2F0; Fri, 1 Aug 2025 08:21:57 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="aJ1g6Ukl"; dkim-atps=neutral Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by gabe.freedesktop.org (Postfix) with ESMTPS id 07C9810E2F0 for ; Fri, 1 Aug 2025 08:21:56 +0000 (UTC) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2BEAC5C5EA7; Fri, 1 Aug 2025 08:21:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D855FC4CEE7; Fri, 1 Aug 2025 08:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1754036514; bh=EG1IipNgpyo8fGH1RjMBEme5aivIHxhO25P/hri0Swc=; h=Date:Subject:Cc:To:From:References:In-Reply-To:From; b=aJ1g6Ukl/rIfiZE32tISmRV3Y01llKNJXC3iF62e8/nZCWT3EnYligf3hqKlehipG YgKQK5InWKVZhyZJmCBcCEI6OOGMd9WscJXNsVBwU6GsVDBwhk8R2PHbDYhcQelgUZ mbLuXwmNBjLBYADzUnP9mmFWz18Wb2J5kq2XRjjuSyUfL5APGozxCpci9VffueSItO r7iO3cJe8OAdMl5AREqpCpGBfrvjYjrT2DABwX830dRD/TD2+IFTHI3igqML64+Rpj pYbTpyV2f/ae7BQBiQ5hbLCk5oU9Zr5JwuEA8HD5wjRVVzhL/TgdZnVu57XHRU+TrK z0Pw7CK8/CqGg== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 01 Aug 2025 10:21:49 +0200 Message-Id: Subject: Re: [PATCH 3/4] rust: drm: remove pin annotations from drm::Device Cc: , , , , , , , , , , , , , , , , , , , To: "Benno Lossin" From: "Danilo Krummrich" References: <20250731154919.4132-1-dakr@kernel.org> <20250731154919.4132-4-dakr@kernel.org> In-Reply-To: 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 Thu Jul 31, 2025 at 8:54 PM CEST, Benno Lossin wrote: > On Thu Jul 31, 2025 at 5:48 PM CEST, Danilo Krummrich wrote: >> The #[pin_data] and #[pin] annotations are not necessary for >> drm::Device, since we don't use any pin-init macros, but only >> __pinned_init() on the impl PinInit argument of >> drm::Device::new(). > > But you're still pinning `Device`, right? A drm::Device instance never exists other than as ARef. >> Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction") >> Signed-off-by: Danilo Krummrich >> --- >> rust/kernel/drm/device.rs | 2 -- >> 1 file changed, 2 deletions(-) >> >> diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs >> index d19410deaf6c..d0a9528121f1 100644 >> --- a/rust/kernel/drm/device.rs >> +++ b/rust/kernel/drm/device.rs >> @@ -54,10 +54,8 @@ macro_rules! drm_legacy_fields { >> /// >> /// `self.dev` is a valid instance of a `struct device`. >> #[repr(C)] >> -#[pin_data] >> pub struct Device { >> dev: Opaque, >> - #[pin] >> data: T::Data, > > Looking at this code again, I also noticed that it was wrong before this > patch: `Device` implemented `Unpin` if `T::Data` did which is most > likely wrong (or is `drm_device` not address sensitive?). It is, but as mentioned above a drm::Device only ever exists as ARef. So, in drm::Device::new() we allocate the drm::Device with __drm_dev_alloc(= ), initialize data in-place within this allocated memory and create an ARef directly from the raw pointer returned by __drm_dev_alloc= (). > So good to see that fixed, thanks! > > --- > Cheers, > Benno > >> } >> =20