mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dario Binacchi <dario.binacchi@amarulasolutions.com>
To: Maxime Ripard <mripard@kernel.org>
Cc: michael@amarulasolutions.com, linux-amarula@amarulasolutions.com,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Andrzej Hajda <andrzej.hajda@intel.com>,
	David Airlie <airlied@gmail.com>,
	Jernej Skrabec <jernej.skrabec@gmail.com>,
	Jonas Karlman <jonas@kwiboo.se>,
	Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
	Luca Ceresoli <luca.ceresoli@bootlin.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Robert Foss <rfoss@kernel.org>, Simona Vetter <simona@ffwll.ch>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH 1/8] drm/bridge: Add atomic_sro_install_state hook
Date: Sun, 22 Nov 2026 16:30:01 +0100	[thread overview]
Message-ID: <20261122153032.2782768-2-dario.binacchi@amarulasolutions.com> (raw)
In-Reply-To: <20261122153032.2782768-1-dario.binacchi@amarulasolutions.com>

The CRTCs, planes, connectors and private objects can acquire the
resources needed to keep the hardware state active when a state read
out from the hardware is installed. Bridges can't, even though they
usually hold a runtime PM reference and track their enable state
while the pipeline is active.

Add the atomic_sro_install_state hook to the bridge funcs. It is
called only for the bridges of a pipeline that was read out as active.

Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
---

 drivers/gpu/drm/drm_bridge.c | 41 ++++++++++++++++++++++++++++++++++++
 include/drm/drm_bridge.h     | 20 ++++++++++++++++++
 2 files changed, 61 insertions(+)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 81174015309f..f4b66a3b38fc 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -637,6 +637,46 @@ drm_bridge_atomic_readout_priv_state(struct drm_private_obj *obj,
 	return 0;
 }
 
+/* The connector and CRTC states are installed before the bridge ones */
+static bool drm_bridge_sro_pipeline_is_active(struct drm_bridge *bridge)
+{
+	struct drm_connector_list_iter conn_iter;
+	struct drm_connector *connector;
+	bool active = false;
+
+	drm_connector_list_iter_begin(bridge->dev, &conn_iter);
+	drm_for_each_connector_iter(connector, &conn_iter) {
+		struct drm_connector_state *conn_state = connector->state;
+
+		if (!conn_state || conn_state->best_encoder != bridge->encoder)
+			continue;
+
+		if (conn_state->crtc && conn_state->crtc->state)
+			active = conn_state->crtc->state->active;
+
+		break;
+	}
+	drm_connector_list_iter_end(&conn_iter);
+
+	return active;
+}
+
+static void
+drm_bridge_atomic_install_priv_state(struct drm_private_obj *obj,
+				     struct drm_private_state *priv_state)
+{
+	struct drm_bridge *bridge = drm_priv_to_bridge(obj);
+
+	if (!bridge->funcs->atomic_sro_install_state)
+		return;
+
+	if (!drm_bridge_sro_pipeline_is_active(bridge))
+		return;
+
+	bridge->funcs->atomic_sro_install_state(bridge,
+						drm_priv_to_bridge_state(priv_state));
+}
+
 static bool drm_bridge_atomic_compare_priv_state(struct drm_private_obj *obj,
 						 struct drm_printer *p,
 						 struct drm_private_state *a,
@@ -682,6 +722,7 @@ static const struct drm_private_state_funcs drm_bridge_priv_state_funcs = {
 static const struct drm_private_state_funcs drm_bridge_priv_state_funcs_with_sro = {
 	.atomic_sro_compare_state = drm_bridge_atomic_compare_priv_state,
 	.atomic_sro_readout_state = drm_bridge_atomic_readout_priv_state,
+	.atomic_sro_install_state = drm_bridge_atomic_install_priv_state,
 	.atomic_create_state = drm_bridge_atomic_create_priv_state,
 	.atomic_duplicate_state = drm_bridge_atomic_duplicate_priv_state,
 	.atomic_destroy_state = drm_bridge_atomic_destroy_priv_state,
diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h
index b73f3424ed62..eb65e1807410 100644
--- a/include/drm/drm_bridge.h
+++ b/include/drm/drm_bridge.h
@@ -341,6 +341,26 @@ struct drm_bridge_funcs {
 					 struct drm_bridge_state *a,
 					 struct drm_bridge_state *b);
 
+	/**
+	 * @atomic_sro_install_state:
+	 *
+	 * This optional hook is called when a state read out from
+	 * hardware is about to be installed as the bridge's current
+	 * state, and the pipeline the bridge is part of was read out
+	 * as active.
+	 *
+	 * It allows drivers to acquire the resources needed to keep
+	 * the current hardware state active, such as power domains,
+	 * clocks, or interrupts, and to align their internal state
+	 * with what a regular enable sequence would have left.
+	 *
+	 * This hook cannot fail. It is called during
+	 * drm_atomic_sro_install_state(), which is part of the
+	 * hardware state readout initialization sequence.
+	 */
+	void (*atomic_sro_install_state)(struct drm_bridge *bridge,
+					 struct drm_bridge_state *bridge_state);
+
 	/**
 	 * @atomic_duplicate_state:
 	 *
-- 
2.43.0


  reply	other threads:[~2026-11-22 15:30 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-22 15:30 [RFC PATCH 0/8] drm: State readout for the i.MX8MN display pipeline Dario Binacchi
2026-11-22 15:30 ` Dario Binacchi [this message]
2026-11-22 15:30 ` [RFC PATCH 2/8] drm/panel: Add sro_install hook Dario Binacchi
2026-11-22 15:30 ` [RFC PATCH 3/8] drm/mxsfb: Use the bridge connector Dario Binacchi
2026-11-22 15:30 ` [RFC PATCH 4/8] drm/mxsfb: Switch to drm_mode_config_create_initial_state() Dario Binacchi
2026-11-22 15:30 ` [RFC PATCH 5/8] drm/mxsfb: Stop the controller in hw_reset Dario Binacchi
2026-11-22 15:30 ` [RFC PATCH 6/8] drm/mxsfb: Implement hw state readout Dario Binacchi
2026-11-22 15:30 ` [RFC PATCH 7/8] drm/bridge: samsung-dsim: " Dario Binacchi
2026-11-22 15:30 ` [RFC PATCH 8/8] drm/panel: synaptics-r63353: Support " Dario Binacchi

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=20261122153032.2782768-2-dario.binacchi@amarulasolutions.com \
    --to=dario.binacchi@amarulasolutions.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=linux-amarula@amarulasolutions.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.ceresoli@bootlin.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=michael@amarulasolutions.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=rfoss@kernel.org \
    --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®