From: "Danilo Krummrich" <dakr@kernel.org>
To: "Benno Lossin" <lossin@kernel.org>
Cc: <lorenzo.stoakes@oracle.com>, <vbabka@suse.cz>,
<Liam.Howlett@oracle.com>, <urezki@gmail.com>, <ojeda@kernel.org>,
<alex.gaynor@gmail.com>, <boqun.feng@gmail.com>,
<gary@garyguo.net>, <bjorn3_gh@protonmail.com>,
<a.hindborg@kernel.org>, <aliceryhl@google.com>,
<tmgross@umich.edu>, <maarten.lankhorst@linux.intel.com>,
<mripard@kernel.org>, <tzimmermann@suse.de>, <airlied@gmail.com>,
<simona@ffwll.ch>, <rust-for-linux@vger.kernel.org>,
<dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/4] rust: drm: remove pin annotations from drm::Device
Date: Fri, 01 Aug 2025 10:21:49 +0200 [thread overview]
Message-ID: <DBQY1S7V8IIS.3NCGOZ8ALU7QG@kernel.org> (raw)
In-Reply-To: <DBQGW0NIQJRX.MU0QD5GMFJYM@kernel.org>
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<T::Data, Error> argument of
>> drm::Device::new().
>
> But you're still pinning `Device`, right?
A drm::Device instance never exists other than as ARef<drm::Device>.
>> Fixes: 1e4b8896c0f3 ("rust: drm: add device abstraction")
>> Signed-off-by: Danilo Krummrich <dakr@kernel.org>
>> ---
>> 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<T: drm::Driver> {
>> dev: Opaque<bindings::drm_device>,
>> - #[pin]
>> data: T::Data,
>
> Looking at this code again, I also noticed that it was wrong before this
> patch: `Device<T>` 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<drm::Device>.
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<drm::Device> directly from the raw pointer returned by __drm_dev_alloc().
> So good to see that fixed, thanks!
>
> ---
> Cheers,
> Benno
>
>> }
>>
next prev parent reply other threads:[~2025-08-01 8:21 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 15:48 [PATCH 0/4] Alloc and drm::Device fixes Danilo Krummrich
2025-07-31 15:48 ` [PATCH 1/4] rust: alloc: replace aligned_size() with Kmalloc::aligned_layout() Danilo Krummrich
2025-08-01 9:14 ` Alice Ryhl
2025-08-12 19:52 ` Miguel Ojeda
2025-08-12 20:00 ` Danilo Krummrich
2025-08-12 20:12 ` Miguel Ojeda
2025-08-12 20:35 ` Danilo Krummrich
2025-08-16 20:40 ` Miguel Ojeda
2025-08-16 23:44 ` Danilo Krummrich
2025-07-31 15:48 ` [PATCH 2/4] rust: drm: ensure kmalloc() compatible Layout Danilo Krummrich
2025-08-01 9:18 ` Alice Ryhl
2025-08-01 9:29 ` Danilo Krummrich
2025-08-04 13:44 ` Alice Ryhl
2025-08-04 14:00 ` Alice Ryhl
2025-07-31 15:48 ` [PATCH 3/4] rust: drm: remove pin annotations from drm::Device Danilo Krummrich
2025-07-31 18:54 ` Benno Lossin
2025-08-01 8:21 ` Danilo Krummrich [this message]
2025-08-01 9:00 ` Benno Lossin
2025-08-01 9:52 ` Benno Lossin
2025-07-31 15:48 ` [PATCH 4/4] rust: drm: don't pass the address of drm::Device to drm_dev_put() Danilo Krummrich
2025-08-01 9:13 ` Alice Ryhl
2025-08-11 21:41 ` [PATCH 0/4] Alloc and drm::Device fixes Danilo Krummrich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DBQY1S7V8IIS.3NCGOZ8ALU7QG@kernel.org \
--to=dakr@kernel.org \
--cc=Liam.Howlett@oracle.com \
--cc=a.hindborg@kernel.org \
--cc=airlied@gmail.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=lossin@kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tmgross@umich.edu \
--cc=tzimmermann@suse.de \
--cc=urezki@gmail.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).