Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luca Ceresoli" <luca.ceresoli@bootlin.com>
Cc: dri-devel@lists.freedesktop.org, imx@lists.linux.dev,
	Frank.Li@kernel.org
Subject: Re: [PATCH v4 32/32] drm/mxsfb/lcdif: enable bridge hotplug
Date: Wed, 25 Nov 2026 18:31:20 +0000	[thread overview]
Message-ID: <sashiko-outbox-233998@kernel.org> (raw)
In-Reply-To: <20261125-drm-bridge-hotplug-v4-32-822722850492@bootlin.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/mxsfb/lcdif: missing connector when last bridge lacks
  get_next_bridge()
- [High] drm/mxsfb/lcdif: missing client hotplug notification in
  lcdif_hotplug_event()
- [High] drm: double bridge attach in drm_hotplug_helper_try_complete()
- [Medium] drm/mxsfb/lcdif: poll_init and drmm_hotplug_helper_init
  lifetime mismatch
--

commit d0177b7f727becda395d8ff3eb1f0fa798651116
Author: Luca Ceresoli <luca.ceresoli@bootlin.com>

drm/mxsfb/lcdif: enable bridge hotplug

This commit switches the i.MX LCDIF driver to drmm_hotplug_helper_init() to
manage bridge attachment and dynamic connector creation, and moves
drm_kms_helper_poll_init() earlier in lcdif_load() so per-connector HPD
polling can be toggled from the hotplug callback.

> diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c
> index 2be5a76e936f6..591653b39310c 100644
> --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c
> +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c
[ ... ]
> @@ -44,6 +44,19 @@ static const struct drm_mode_config_helper_funcs lcdif_mode_config_helpers = {
>  	.atomic_commit_tail = drm_atomic_helper_commit_tail_rpm,
>  };
>  
> +static void lcdif_hotplug_event(enum drm_hotplug_helper_event event,
> +				struct drm_connector *connector)
> +{
> +	switch (event) {
> +	case DRM_HOTPLUG_HELPER_CONNECTOR_ADDED:
> +		drm_kms_helper_poll_enable_connector(connector);
> +	break;
> +	case DRM_HOTPLUG_HELPER_CONNECTOR_REMOVING:
> +		drm_kms_helper_poll_disable_connector(connector);
> +		break;
> +	}
> +}

[Severity: High]
Does lcdif_hotplug_event() miss notifying in-kernel DRM clients and running
initial HPD detection when a connector is added after lcdif_load()?

With drmm_hotplug_helper_init(), lcdif_attach_bridge() no longer defers
probe while waiting for downstream bridges, so drm_helper_hpd_irq_event()
and drm_client_setup() can run before any connector exists.  When the
bridge chain completes later, drm_bridge_connector_dynamic_add() registers
the connector (emitting a sysfs uevent without calling
drm_client_dev_hotplug()), and drm_kms_helper_poll_enable_connector() does
not schedule output_poll_work for fixed panels (polled == 0) or HPD-IRQ
connectors (polled == DRM_CONNECTOR_POLL_HPD).  As a result, fbdev/fbcon
is never set up and HPD-IRQ connectors stay in connector_status_unknown.

[ ... ]
> @@ -80,16 +86,10 @@ static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif)
>  
>  		encoder->possible_crtcs = drm_crtc_mask(&lcdif->crtc);
>  
> -		ret = drm_bridge_attach(encoder, bridge, NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR);
> -		if (ret)
> -			return dev_err_probe(dev, ret,
> -					     "Failed to attach bridge for endpoint%u\n",
> -					     of_ep.id);
> -
> -		connector = drm_bridge_connector_init(lcdif->drm, encoder);
> -		if (IS_ERR(connector))
> -			return dev_err_probe(dev, PTR_ERR(connector),
> -					     "Failed to init bridge_connector for endpoint%u\n",
> +		hotplug_helper = drmm_hotplug_helper_init(encoder, lcdif_hotplug_event, ep);
> +		if (IS_ERR(hotplug_helper))
> +			return dev_err_probe(dev, PTR_ERR(hotplug_helper),
> +					     "Failed to init hotplug_helper for endpoint%u\n",
>  					     of_ep.id);
>  	}

[Severity: High]
Will drmm_hotplug_helper_init() fail to create a connector on LCDIF
pipelines whose last bridge does not implement DRM_BRIDGE_OP_GET_NEXT_BRIDGE?

Previously, lcdif_attach_bridge() unconditionally created the connector
with drm_bridge_connector_init() after drm_bridge_attach().  Now connector
creation in drm_hotplug_helper_try_complete() is gated on
drm_hotplug_helper_bridge_chain_is_complete(), which calls
drm_bridge_get_next() on the last bridge and only returns true when that
returns NULL.  On i.MX8MP boards using tc358767 as a DisplayPort terminal
bridge (such as imx8mp-dhcom-pdk3-overlay-732-100-x36.dtso), tc358767 does
not set DRM_BRIDGE_OP_GET_NEXT_BRIDGE, so drm_bridge_get_next() warns and
returns ERR_PTR(-ENOENT) and the connector is never created.

[Severity: High]
Can switching to drmm_hotplug_helper_init() cause last_bridge->funcs->attach()
to be called a second time on an already-attached bridge?

When a downstream bridge in a multi-bridge chain is removed (or when the
terminal bridge lacks DRM_BRIDGE_OP_GET_NEXT_BRIDGE so
hotplug_helper->connector stays NULL), the upstream bridge remains attached
as last_bridge in encoder->bridge_chain.  On the next DRM_BRIDGE_ADDED or
DRM_MIPI_DSI_ATTACHED notification, drm_hotplug_helper_try_complete() hits
the if (last_bridge) branch:

drivers/gpu/drm/display/drm_hotplug_helper.c:drm_hotplug_helper_try_complete() {
    ...
	if (last_bridge) {
		dev_dbg(dev, "propagate attach after %ps\n", last_bridge->funcs);

		err = last_bridge->funcs->attach(last_bridge, hotplug_helper->encoder,
						 DRM_BRIDGE_ATTACH_NO_CONNECTOR);
    ...
}

Besides dereferencing last_bridge->funcs->attach without a NULL check,
re-invoking funcs->attach() on an already-attached bridge (such as
ti-sn65dsi86 or tc358767, which call drm_dp_aux_register() in their attach
callbacks before attaching the next bridge) re-registers an initialized
drm_dp_aux i2c adapter kobject and unregisters the active DP AUX channel if
downstream attachment fails.

> @@ -176,6 +176,8 @@ static int lcdif_load(struct drm_device *drm)
>  	/* Start with vertical blanking interrupt reporting disabled. */
>  	drm_crtc_vblank_off(&lcdif->crtc);
>  
> +	drm_kms_helper_poll_init(drm);
> +
>  	ret = lcdif_attach_bridge(lcdif);
>  	if (ret)
>  		return ret;

[Severity: Medium]
Does pairing unmanaged drm_kms_helper_poll_init() with
drmm_hotplug_helper_init() leave polling uncleaned on probe failure and
out of order with hotplug teardown on unbind?

If lcdif_attach_bridge(), drm_mode_config_create_initial_state() or IRQ
setup fails in lcdif_load(), lcdif_probe() jumps to err_free without
calling lcdif_unload() or drm_kms_helper_poll_fini().  On driver unbind,
lcdif_unload() runs drm_kms_helper_poll_fini() (setting poll_enabled = false)
before final drm_dev_put() releases drmm_hotplug_helper_init(); if
userspace holds an open DRM fd across unbind, a bridge hotplug event before
the fd closes will call lcdif_hotplug_event() ->
drm_kms_helper_poll_enable_connector() and hit
drm_WARN_ON_ONCE(dev, !dev->mode_config.poll_enabled).  Using
drmm_kms_helper_poll_init() before lcdif_attach_bridge() and dropping
drm_kms_helper_poll_fini() from lcdif_unload() would align both lifetimes.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-drm-bridge-hotplug-v4-0-822722850492@bootlin.com?part=32

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

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 17:50 [PATCH v4 00/32] drm bridge hotplug Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 01/32] drm/display: hdmi-cec-helper: use drmm_ prefix for drmm action Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 02/32] drm/display: hdmi-cec-helper: add non-drmm API variant Luca Ceresoli
2026-11-25 18:08   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 03/32] drm/display: hdmi-cec-notifier-helper: use drmm_ prefix for drmm action Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 04/32] drm/display: hdmi-cec-notifier-helper: add non-drmm API variant Luca Ceresoli
2026-11-25 18:07   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 05/32] drm/connector: split drmm_connector_hdmi_init() in 3 parts Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 06/32] drm/connector: add drm_connector_hdmi_dynamic_init() Luca Ceresoli
2026-11-25 18:10   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 07/32] drm/display: bridge-connector: split allocation code from initialization code Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 08/32] drm/display: bridge-connector: hoist error management to common code Luca Ceresoli
2026-11-25 18:03   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 09/32] drm/display: bridge-connector: use a dynamic connector Luca Ceresoli
2026-11-25 18:21   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 10/32] drm/display: bridge-connector: add APIs to add/remove the connector dynamically Luca Ceresoli
2026-11-25 18:14   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 11/32] drm/bridge: constify of_drm_find_and_get_bridge() device_node parameter Luca Ceresoli
2026-11-25 17:59   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 12/32] drm/bridge: initialize chain_node list head on allocation Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 13/32] drm/bridge: initialize chain_node list head on detach and attach errors Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 14/32] drm/bridge: ti-sn65dsi86: protect device resources on unplug Luca Ceresoli
2026-11-25 18:16   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 15/32] drm/atomic: drm_atomic_private_obj_fini: protect private_obj removal from list Luca Ceresoli
2026-11-25 18:12   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 16/32] drm/probe-helper: add per-connector polling enable/disable Luca Ceresoli
2026-11-25 18:10   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 17/32] drm: event-notifier: add mechanism to notify about hotplug events Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 18/32] drm/bridge: notify about added and detached bridges Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 19/32] drm/mipi-dsi: notify about DSI attach Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 20/32] drm/bridge: add drm_bridge_get_next() and supporting func Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 21/32] drm/panel: implement .get_next_bridge Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 22/32] drm/bridge: display-connector: " Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 23/32] drm/bridge: ti-sn65dsi83: " Luca Ceresoli
2026-11-25 18:14   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 24/32] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
2026-11-25 18:18   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 25/32] drm/bridge: samsung-dsim: " Luca Ceresoli
2026-11-25 18:15   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 26/32] drm/bridge: add drm_bridge_detach_from() Luca Ceresoli
2026-11-25 18:15   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 27/32] drm/atomic: add drm_atomic_shutdown_encoder() Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 28/32] drm/tests: atomic: add tests for drm_atomic_shutdown_encoder() Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 29/32] drm/bridge: clear bridge->encoder on detach Luca Ceresoli
2026-11-25 17:50 ` [PATCH v4 30/32] drm/bridge: shutdown encoder and detach downstream bridges on bridge unplug Luca Ceresoli
2026-11-25 18:28   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 31/32] drm: drm_hotplug_helper: new helper to implement bridge hotplug Luca Ceresoli
2026-11-25 18:30   ` sashiko-bot
2026-11-25 17:50 ` [PATCH v4 32/32] drm/mxsfb/lcdif: enable " Luca Ceresoli
2026-11-25 18:31   ` sashiko-bot [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=sashiko-outbox-233998@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=imx@lists.linux.dev \
    --cc=luca.ceresoli@bootlin.com \
    --cc=sashiko-reviews@lists.linux.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