From: Daniel Almeida <daniel.almeida@collabora.com>
To: Danilo Krummrich <dakr@kernel.org>
Cc: aliceryhl@google.com, airlied@gmail.com, simona@ffwll.ch,
lossin@kernel.org, gary@garyguo.net, ojeda@kernel.org,
boqun@kernel.org, bjorn3_gh@protonmail.com,
a.hindborg@kernel.org, tmgross@umich.edu, tamird@kernel.org,
acourbot@nvidia.com, work@onurozkan.dev,
dri-devel@lists.freedesktop.org, rust-for-linux@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 0/4] drm/tyr: use pin-init self-referential support
Date: Tue, 24 Nov 2026 20:03:50 -0300 [thread overview]
Message-ID: <BF029262-22D0-41EB-884B-8C64C6BAEBB8@collabora.com> (raw)
In-Reply-To: <DN2ZFO94BZMF.2XTCCKEUDLZSB@kernel.org>
> On 23 Nov 2026, at 20:34, Danilo Krummrich <dakr@kernel.org> wrote:
>
> On Mon Nov 23, 2026 at 11:20 PM CET, Daniel Almeida wrote:
>> Hi Danilo,
>>
>> Thanks for doing this.
>>
>> I spoke with Gary about this topic at Kangrejos and again a couple of weeks
>> ago. What worries me is that we might introduce some restrictions that might
>> paint us into a corner. IOW: we have significant downstream work, and I wonder
>> whether it will work with this series after whatever refactors are needed.
>
> The reason for the existence of the converted reference counts hasn't been that
> reference counting was needed as an ownership model, it just was that we haven't
> had a way to express borrowing from sibling fields that are already guaranteed
> to be longer lived in any case.
>
> The distinction is between A having an independent owner that keeps it alive for
> all B consumers, so the Bs can borrow A, and the Bs collectively owning A, so A
> is destroyed when the last B releases it. Reference counting expresses the
> latter ownership model. Both can still be subject to lifetime bounds.
>
> In the majority of cases, drivers acquire device resources in stages, keeping
> earlier resources alive until their dependants have been torn down. Where
> ownership follows this hierarchy, borrowing can express those relationships
> without reference counting.
Yeah, I understand the premise of self-ref pin init. My worry is precisely
whether most/all of the shared resources can indeed be modeled as a borrow on a
sibling or parent field. Especially resources created by userspace like user VMs
and CSF groups (equivalent to nouveau channels), or deferred work.
For example, your series does not have to consider user VMs because they are
not implemented yet. I wonder whether they can work under the proposed plan,
since user VMs will borrow the MMU, but struct Mmu is stored in the
registration data. Previously that was trivially solvable with Arc. You're
saying this is possible under the code you're proposing? Because at first
glance this looks like a shortening of 'iomem to 'a (from DriverFile<'a>),
which I assume the compiler would reject due to invariance?
>
>> To start with, Alvin's VM_BIND ioctl series [0] will need some changes, since
>> it keeps the VM pool in the file data. I think this is doable if we move the
>> pool into the registration data and have each file hold only an index to its
>> own entry? i.e.: something like an XArray<Pool<Vm>> indexed by a number
>> associated with the drm::File. Same for the group pool later. Is this what you
>> had in mind?
>
> No, the changes do not force XArray<Pool<Vm>> to be moved into the registration
> data; drm::File private data can borrow from DRM registration data. It can (and
> should) stay in the drm::File private data.
>
> (I'm also working on a generalization of this, as it is a repeating pattern in
> drivers. We want driver private data associated with an ioctl, e.g. VM_CREATE,
> which is shorter lived than the drm::File data and hence shorter lived than the
> drm::RegistrationData.
>
> Concurrent ioctls associated with a handle to this data, i.e. the VM in this
> example, need to be drained on either VM_DESTROY or drm::File private data
> destruction, e.g. caused by unregistration through driver unbind.)
>
>> Anything storing a KernelBo will also have to be outside of the file data,
>> IIUC, since it now stores a &Vm. Also, downstream we defer KernelBo drops to a
>> workqueue, because they can happen in the fence signalling path. I suppose we
>> can keep doing that using ScopedWork/ScopedQueue?
>
> I assume you refer to the Vm that lives in Firmware. If so, drm::File private
> data can borrow from it, as Firmware lives in the DRM registration data.
>
> The teardown has to happen in ScopedWork regardless, as they all carried device
> resource induced lifetimes already and hence can't go into unbounded work
> anyway.
FWIW I meant both that one and user VMs (WIP), we map KernelBos into both
downstream.
This seems like another instance of what I asked above. If you confirm this is
indeed possible even with the invariance I mentioned, then fine, I guess.
To be honest, however, I must admit that the more I look into it and try to
understand the code, the more it looks like an improvement over the Devres
approach we have downstream.
— Daniel
prev parent reply other threads:[~2026-11-24 23:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 23:37 Danilo Krummrich
2026-11-18 23:37 ` [PATCH 1/4] drm/tyr: name resource lifetimes after their types Danilo Krummrich
2026-11-19 2:08 ` Gary Guo
2026-11-19 10:34 ` Danilo Krummrich
2026-11-19 11:28 ` Gary Guo
2026-11-19 12:28 ` Danilo Krummrich
2026-11-19 12:56 ` Gary Guo
2026-11-19 13:57 ` Danilo Krummrich
2026-11-19 15:44 ` Alice Ryhl
2026-11-19 16:38 ` Danilo Krummrich
2026-11-23 16:26 ` Gary Guo
2026-11-18 23:37 ` [PATCH 2/4] rust: pin-init: internal: suppress multiple_bound_locations Danilo Krummrich
2026-11-19 2:23 ` Gary Guo
2026-11-18 23:37 ` [PATCH 3/4] drm/tyr: use pin-init self-referential support Danilo Krummrich
2026-11-18 23:37 ` [PATCH 4/4] drm/tyr: use ScopeGuard for firmware loading cleanup Danilo Krummrich
2026-11-23 22:20 ` [PATCH 0/4] drm/tyr: use pin-init self-referential support Daniel Almeida
2026-11-23 23:34 ` Danilo Krummrich
2026-11-24 23:03 ` Daniel Almeida [this message]
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=BF029262-22D0-41EB-884B-8C64C6BAEBB8@collabora.com \
--to=daniel.almeida@collabora.com \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=work@onurozkan.dev \
/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
all inboxes | Powered by JetHome®