On Wed, Mar 05, 2025 at 05:59:23PM -0500, Lyude Paul wrote:
> +unsafe extern "C" fn encoder_destroy_callback<T: DriverEncoder>(
> +    encoder: *mut bindings::drm_encoder,
> +) {
> +    // SAFETY: DRM guarantees that `encoder` points to a valid initialized 
> `drm_encoder`.
> +    unsafe { bindings::drm_encoder_cleanup(encoder) };
> +
> +    // SAFETY:
> +    // - DRM guarantees we are now the only one with access to this 
> [`drm_encoder`].
> +    // - This cast is safe via `DriverEncoder`s type invariants.
> +    unsafe { drop(KBox::from_raw(encoder as *mut Encoder<T>)) };
> +}

I'm not sure we should expose drm_encoder_cleanup() there, if only
because it's not really up to the driver to deal with it anymore. We're
switching to drmm_encoder_alloc/init where having a destroy hook is
explicitly rejected.

Maxime

Attachment: signature.asc
Description: PGP signature

Reply via email to