mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Maxime Ripard <mripard@kernel.org>
To: Henry Zhang <henryzhang62@gmail.com>
Cc: dave.stevenson@raspberrypi.com, mcanal@igalia.com,
	 kernel-list@raspberrypi.com, maarten.lankhorst@linux.intel.com,
	tzimmermann@suse.de,  airlied@gmail.com, simona@ffwll.ch,
	dri-devel@lists.freedesktop.org,  linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/vc4: dsi: Allocate the encoder per DRM device
Date: Wed, 18 Nov 2026 11:09:59 +0100	[thread overview]
Message-ID: <av11cTfEuyFJW5h8@houat> (raw)
In-Reply-To: <20261117205902.1293962-1-henryzhang62@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2060 bytes --]

On Tue, Nov 17, 2026 at 12:59:02PM -0800, Henry Zhang wrote:
> The DSI encoder is embedded in struct vc4_dsi, which lives as long as
> the DSI platform device

That's not true.

It's allocated with devm_drm_bridge_alloc() that will *not* free it in
remove but give away its reference there.

We have another reference taken in vc4_dsi_bind, that is only given up
through a drm-managed action and thus will only be freed when the DRM
device is destroyed.

> but it is initialised with drmm_encoder_init() and so is only cleaned
> up when the DRM device is released. The DRM device can outlive the
> unbind of the vc4 components: unloading the DSI panel driver detaches
> from the DSI host, which deletes the DSI component and unbinds the
> whole vc4 DRM device, but a compositor that keeps the DRM device open
> keeps it alive.

All vc4 components should be tied to the DRM device lifetime so that's
not generally correct either. Something might have snuck back in though.

Also, generally speaking, unloading panel drivers is unsupported at this
point. It's a work in progress, but requires more changes to be safe.

> If the panel driver is loaded again before that, the new DRM device
> binds the DSI component and calls drmm_encoder_init() on the encoder
> that is still on the old DRM device's encoder list. The old device's
> release later cleans it up from under the new one. On a Raspberry Pi 4
> with a 6.18-based kernel, closing the old DRM device then gave:
> 
>   WARNING: drivers/gpu/drm/drm_encoder.c:214 at drmm_encoder_alloc_release+0x30/0x40 [drm]
>   Call trace: drmm_encoder_alloc_release <- drm_dev_put <- drm_gem_dmabuf_release <- __fput
>   Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008
>   pc : drm_mode_config_cleanup+0x5c/0x2f0 [drm]
>   Call trace: drm_mode_config_cleanup <- drm_managed_release <- drm_dev_put

This is surprising though. I'd like to see a detailed analysis of what's
actually going on on mainline because it doesn't look right.

Maxime

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 273 bytes --]

      reply	other threads:[~2026-11-18 10:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 20:59 Henry Zhang
2026-11-18 10:09 ` Maxime Ripard [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=av11cTfEuyFJW5h8@houat \
    --to=mripard@kernel.org \
    --cc=airlied@gmail.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=henryzhang62@gmail.com \
    --cc=kernel-list@raspberrypi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mcanal@igalia.com \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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®