Re: [PATCH RFC 18/18] drm/asahi: Add the Asahi driver for Apple AGX GPUs
From: Daniel Vetter
Date: Wed Apr 05 2023 - 10:44:22 EST
On Tue, Mar 07, 2023 at 11:25:43PM +0900, Asahi Lina wrote:
> +/// Look up a GEM object handle for a `File` and return an `ObjectRef` for it.
> +pub(crate) fn lookup_handle(file: &DrmFile, handle: u32) -> Result<ObjectRef> {
> + Ok(ObjectRef::new(shmem::Object::lookup_handle(file, handle)?))
> +}
So maybe my expectations for rust typing is a bit too much, but I kinda
expected this to be fully generic:
- trait Driver (drm_driver) knows the driver's object type
- a generic create_handle function could ensure that for drm_file (which
is always for a specific drm_device and hence Driver) can ensure at the
type level that you only put the right objects into the drm_file
- a generic lookup_handle function on the drm_file knows the Driver trait
and so can give you back the right type right away.
Why the wrapping, what do I miss?
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch