From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795020732; b=XGIPk8r/jvkJOOylLHMi61HQdFoOPkUepbx9xDQKnJHw66jU5NYjdrnXK9Jcq8QKISlO G88pVJ15jwy2wp+MzsDfQensIcp12Fwok+JCbQ6XgwNGgi8EFJmx34JbajyOrtZlw99mf PLrjOUFXGaIrrASY89tzi4RsHsDkUsgpXC2ilBcELt5Iu3H+Q6+UFWA1IV2Pbb7vxy1jl jSjKUR6g0lmEK7THCQ/Tc9ly/Oh50aCaVcOlAHwSCiDyHsD3diCLu+0Yu/y0sGQFIvrzj DyWaHm+5C4kX2vxeqT96Jgd/kvuJIg/i03018GzLEeleXazTFpDiV6YwMK2UpoiRSXw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795020732; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Last-TLS-Session-Version; bh=2HLVIjfVNg5rhW25oP8mGOOhTAy3zo5GlIBaKlN+WIU=; b=VbKbzNbu6gaXaMNUKv4QOaOCNd5jR088CZf4WSTAeN+geqqiJRU9Bgh7rYggwsQdwV4B G0Ozu45Vy/pcKLT8DW3dITERnGI26Oriud2WoVX6GdcGp4wXyocYZJHYhYYu/STcn4wMW zEbgUtrIpKswlzqcbaMn+fgVR0FDb8yHOLlIT2JqQ6f19LmnBDV3HnowvfYH3irgk9uye WLKbw8EUs+3GuLefcdcklaDvLRP43DU1opfJzjlwZD1RGmCWdqM2VfVWbrbQdbkEuIyTr S/40Ti63KkOGM2VVHfWjaVs0hq8fN7CwzRGG4MgkWSOHE0bp8Dn6wft4gP6K2s1xa+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=lKvP6lwP; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B677606A33D for ; Wed, 18 Nov 2026 16:52:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1B677606A33D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=lKvP6lwP Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id B71A34E40546; Wed, 18 Nov 2026 16:52:10 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 865E95FE9B; Wed, 18 Nov 2026 16:52:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 533F511BC28EF; Wed, 18 Nov 2026 17:52:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795020728; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=2HLVIjfVNg5rhW25oP8mGOOhTAy3zo5GlIBaKlN+WIU=; b=lKvP6lwPWFqTADj5kmqaNtDYJSgXfC73X0pWwQvh2hnAUK35Xf3O061QdsIQyrux7G5bsK Mk7Pcj1nb896DaX/1gkQ1+Q0myWX1LW+64Jzl29sFKyFkFhJbWmT1bvPUkrf9pzJ9DLDC/ ibM9qSCHrrtbBwoldrWulLPMqvfLFW68kHMbMvtY1gkz3t5FgiXVwzWl79rZctTj4Eh6y6 SwJRCdtwkcpg6Ie7Tahx9vnKBD8XYiIIYbOYiuXNaB6HQSNiaxQLFXE1bzYO5BI/yq61/u tof3Z3ee7yPvRfd6vQBVBHAf1tcb5YKkZBYsG2+reCaFAuGyrSrlTyKuJAulVQ== From: Luca Ceresoli Date: Wed, 18 Nov 2026 17:50:02 +0100 Subject: [PATCH RFC v3 19/31] drm/bridge: add drm_bridge_get_next() and supporting func X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261118-drm-bridge-hotplug-v3-19-44bb3b4a828f@bootlin.com> References: <20261118-drm-bridge-hotplug-v3-0-44bb3b4a828f@bootlin.com> In-Reply-To: <20261118-drm-bridge-hotplug-v3-0-44bb3b4a828f@bootlin.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Inki Dae , Jagan Teki , Marek Szyprowski , Jessica Zhang , Douglas Anderson , Marek Vasut , Stefan Agner , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: Hui Pu , Ian Ray , Luca Ceresoli , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org X-Mailer: b4 0.16.0 X-Last-TLS-Session-Version: TLSv1.3 For bridge hotplug we need to successfully probe a card with an incomplete bridge chain, i.e. a chain whose last bridge currently in bridge_chain needs another bridge at its output. Such a card would have no connector, and be able to add one as soon as the following bridges are added up to the bridge that requires no further ones (like a panel or a connector_bridge). So we need a way to know whether the pipeline is complete in the hardware (all bridges probed), in order to complete it in software (attach all bridges not yet attached). Currently common DRM code has no way to know that. Add drm_bridge_get_next() and a supporting get_next_bridge func so each bridge can expose its next bridge, and whether there's supposed to be one. A subsequent commit will use this function to detect whether the pipeline is complete in the hardware or not. Link: https://lore.kernel.org/r/20260624-vagabond-neon-gorilla-cd6487@houat Suggested-by: Maxime Ripard Signed-off-by: Luca Ceresoli --- Changes in v3: - fix and improve kerneldoc New patch in v2, replacing the is_tail patch in v1 --- drivers/gpu/drm/drm_bridge.c | 30 ++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 25 +++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index bcf65cddbd6e..e0a1e016b37c 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -705,6 +705,36 @@ void drm_bridge_detach(struct drm_bridge *bridge) drm_bridge_put(bridge); } +/** + * drm_bridge_get_next - return the bridge at this bridge's output port + * @bridge: the bridge to query + * + * Return the next bridge, i.e. the bridge that is connected at the output + * port of @bridge. Unlike drm_bridge_get_next_bridge(), the next bridge + * might or not be in the encoder chain. + * + * Returns: + * * Pointer to a bridge connected to the output port of this bridge, + * with refcount incremented; call drm_bridge_put() when done + * * ERR_PTR(-ENODEV): this bridge has an output port where a next bridge + * needs to be present for video output, but the next + * bridge is not currently available + * * NULL: this bridge does not have an output port where a next bridge + * is expected + * * ERR_PTR(-ENOENT): the bridge does not implement the func + * * Another negative error returned by the bridge func + */ +struct drm_bridge *drm_bridge_get_next(struct drm_bridge *bridge) +{ + if (!(bridge->ops & DRM_BRIDGE_OP_GET_NEXT_BRIDGE)) { + drm_warn_once(bridge->dev, "get_next_bridge func not implemented!"); + return ERR_PTR(-ENOENT); + } + + return bridge->funcs->get_next_bridge(bridge); +} +EXPORT_SYMBOL(drm_bridge_get_next); + /** * DOC: bridge operations * diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index c88532998aae..32962224a6e7 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -62,6 +62,25 @@ enum drm_bridge_attach_flags { * struct drm_bridge_funcs - drm_bridge control functions */ struct drm_bridge_funcs { + /** + * @get_next_bridge: + * + * Return a pointer to the bridge connected at the output port of + * this bridge. + * + * Returns: + * * Pointer to a bridge connected to the output port of this bridge, + * with refcount incremented; call drm_bridge_put() when done + * * ERR_PTR(-ENODEV): this bridge has an output port where a next + * bridge needs to be present for video output, + * but the next bridge is not currently + * available + * * NULL: this bridge does not have an output port where a next + * bridge is expected (e.g. a panel) + * * Another negative error returned by the bridge func + */ + struct drm_bridge *(*get_next_bridge)(struct drm_bridge *bridge); + /** * @attach: * @@ -1021,6 +1040,11 @@ enum drm_bridge_ops { * &drm_bridge_funcs->hdmi_clear_spd_infoframe callbacks. */ DRM_BRIDGE_OP_HDMI_SPD_INFOFRAME = BIT(10), + /** + * @DRM_BRIDGE_OP_GET_NEXT_BRIDGE: The bridge implements the + * &drm_bridge_funcs->get_next_bridge callback. + */ + DRM_BRIDGE_OP_GET_NEXT_BRIDGE = BIT(11), }; /** @@ -1270,6 +1294,7 @@ void drm_bridge_remove(struct drm_bridge *bridge); int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, struct drm_bridge *previous, enum drm_bridge_attach_flags flags); +struct drm_bridge *drm_bridge_get_next(struct drm_bridge *bridge); #ifdef CONFIG_OF struct drm_bridge *of_drm_find_and_get_bridge(const struct device_node *np); -- 2.56.1