From: Benno Lossin <benno.lossin@proton.me>
To: Daniel Almeida <daniel.almeida@collabora.com>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Cc: "Miguel Ojeda" <ojeda@kernel.org>,
"Alex Gaynor" <alex.gaynor@gmail.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Sumit Semwal" <sumit.semwal@linaro.org>,
"Christian König" <christian.koenig@amd.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
dri-devel@lists.freedesktop.org,
"Asahi Lina" <lina@asahilina.net>
Subject: Re: [PATCH 2/2] rust: drm: Add GPUVM abstraction
Date: Mon, 24 Mar 2025 20:22:20 +0000 [thread overview]
Message-ID: <D8ORYL7ZZG8R.1LEAYI5807G9H@proton.me> (raw)
In-Reply-To: <509EADD7-607B-4DED-ADAC-152D7338EB50@collabora.com>
On Mon Mar 24, 2025 at 8:25 PM CET, Daniel Almeida wrote:
>> On 24 Mar 2025, at 14:36, Miguel Ojeda <miguel.ojeda.sandonis@gmail.com> wrote:
>>
>> Hi Daniel,
>>
>> A few quick notes for future versions on style/docs to try to keep
>> things consistent upstream -- not an actual review.
>>
>> On Mon, Mar 24, 2025 at 4:14 PM Daniel Almeida
>> <daniel.almeida@collabora.com> wrote:
>>>
>>> +#[allow(type_alias_bounds)]
>>
>> The documentation says this is highly discouraged -- it may be good to
>> mention why it is OK in this instance in a comment or similar.
>
> Someone correct me here, but I see no issue with this warning. That’s
> because we need the bound to make `<T::Driver as drv::Driver>` work in the
> first place. Otherwise, we’d get a compiler error saying that there’s
> no `Driver` associated type (assuming the case where a random T gets
> passed in)
>
> So, for this to be a problem, we would need to mix this up with something that
> also has a `Driver` associated type, and this associated type would also need a
> drv::Driver bound.
>
> In other words, we would need a lot of things to align for this to actually
> have a chance of being misused. When you consider that this is then only used
> in a few places, the balance tips heavily in favor of the convenience of having
> the type alias IMHO.
>
> In fact, the docs point to the exact thing I am trying to do, i.e.:
>
>> these bounds may have secondary effects such as enabling the use of “shorthand” associated type paths
>
>> I.e., paths of the form T::Assoc where T is a type parameter bounded by trait Trait which defines an associated type called Assoc as opposed to a fully qualified path of the form <T as Trait>::Assoc.
You can avoid the allow by using:
type DriverObject<T> = <<T as DriverGpuVm>::Driver as drv::Driver>::Object;
That is more wordy, but avoids the allow (it still errors when you put
in something that doesn't implement `DriverGpuVm`).
---
Cheers,
Benno
next prev parent reply other threads:[~2025-03-24 20:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-24 15:13 [PATCH 0/2] Add a Rust GPUVM abstraction Daniel Almeida
2025-03-24 15:13 ` [PATCH 1/2] rust: helpers: Add bindings/wrappers for dma_resv Daniel Almeida
2025-03-24 18:43 ` Miguel Ojeda
2025-03-24 15:13 ` [PATCH 2/2] rust: drm: Add GPUVM abstraction Daniel Almeida
2025-03-24 17:36 ` Miguel Ojeda
2025-03-24 19:25 ` Daniel Almeida
2025-03-24 19:38 ` Miguel Ojeda
2025-03-24 21:07 ` Miguel Ojeda
2025-03-24 20:22 ` Benno Lossin [this message]
2025-03-24 18:29 ` Charalampos Mitrodimas
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=D8ORYL7ZZG8R.1LEAYI5807G9H@proton.me \
--to=benno.lossin@proton.me \
--cc=a.hindborg@kernel.org \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=christian.koenig@amd.com \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gary@garyguo.net \
--cc=lina@asahilina.net \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sumit.semwal@linaro.org \
--cc=tmgross@umich.edu \
/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).