From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B00E31E82E; Tue, 28 Apr 2026 15:32:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777390330; cv=none; b=XtQfHznkS5isFoTm8WRIYkxfzaO/T1pmK/tKcA9YH3/4bGN4IdrWefIk4IPGRyS4s9kaKoUOnoaMmXv1oivJW+OrGAqAuYSqkodbrTIYcPEjtVdLnExV/RJU7t+H+YtT1at8W4B5EzwGuYeUEZyABnGrn2tyM/j0lTVa3wW200k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777390330; c=relaxed/simple; bh=NFnes9hPw9+YZGzpGmpbzbNSp5KDvjc8VFMay/4D+Xk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qqwCqblKG0SjTzunyqmeKv99zFV+2a17aNn8CUccHCx9pjT/swdgqnxrfUbtSJgfNnH1E4ZybUyuOQ+4t+Tce4XAqsOZf/oWsz3+llC/M25leb4ueiRLBLQzza9jFnWSKr1PagmeoddYMG6c2oNe59+9teoPP95Vcx4Flsin+Ks= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=BYMXXYkJ; arc=none smtp.client-ip=185.246.84.56 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.b="BYMXXYkJ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id E5F161A3471; Tue, 28 Apr 2026 15:32:06 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id B8EA9601D0; Tue, 28 Apr 2026 15:32:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 21C8410728E23; Tue, 28 Apr 2026 17:32:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1777390325; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=cXFW+HyurNWz3ETP7aXjiecln1l4BuLQEFH1wXf1WXs=; b=BYMXXYkJkQMhYhtVmqzk060bU6GZcvRgSzw5iiSGTYkXSn4HB7DiU8MSN+Y76eccn+kAts oCh+Oye+xFQ8yzJlKDvS+7fMAiOz8p8pGdZY23Yd4MphB+TpSTiE6z4V+3uLbtvDUyQ9Nm NR7o766tASQKAhQTLTU4MH4gI79PvAc97iySBXtQaM8NEc70Zn5shqKLVxsatAW4oylptb VwQoPNkGh9cgYXF/Qe1mIrHMrPRcY8ks3zXlrhpLEWbNJ7h4C2xoJPPFDoOieLbsg0iSlk Jdg3T3JH6xt8FC2UO9J/PwjSyqyX9tRd4HV3/D50rSHjIzlzjt5gvVvcpf5PQQ== From: Luca Ceresoli Date: Tue, 28 Apr 2026 17:30:59 +0200 Subject: [PATCH v3 10/11] drm: zynqmp_dp: switch to of_drm_get_bridge_by_endpoint() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260428-drm-bridge-alloc-getput-panel_or_bridge-v3-10-a537b5567add@bootlin.com> References: <20260428-drm-bridge-alloc-getput-panel_or_bridge-v3-0-a537b5567add@bootlin.com> In-Reply-To: <20260428-drm-bridge-alloc-getput-panel_or_bridge-v3-0-a537b5567add@bootlin.com> To: Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , Xinliang Liu , Sumit Semwal , Yongqin Liu , John Stultz , Tomi Valkeinen , Michal Simek Cc: Hui Pu , Ian Ray , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, Luca Ceresoli X-Mailer: b4 0.15.2 X-Last-TLS-Session-Version: TLSv1.3 This driver calls drm_of_find_panel_or_bridge() with a NULL pointer in the @panel parameter, thus using a reduced feature set of that function. Replace this call with the simpler of_drm_get_bridge_by_endpoint(). Since of_drm_get_bridge_by_endpoint() increases the refcount of the returned bridge, ensure it is put on removal. To achieve this, instead of adding an explicit drm_bridge_put(), migrate to the bridge::next_bridge pointer which is automatically put when the bridge is eventually freed. Signed-off-by: Luca Ceresoli --- Changes in v3: - fix ERR_PTR deref when -ENODEV is returned --- drivers/gpu/drm/xlnx/zynqmp_dp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c index 379180fb3004..c5aa236d6b74 100644 --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c @@ -353,7 +353,6 @@ struct zynqmp_dp_train_set_priv { * @lock: Mutex protecting this struct and register access (but not AUX) * @irq: irq * @bridge: DRM bridge for the DP encoder - * @next_bridge: The downstream bridge * @test: Configuration for test mode * @config: IP core configuration from DTS * @aux: aux channel @@ -385,7 +384,6 @@ struct zynqmp_dp { struct completion aux_done; struct mutex lock; - struct drm_bridge *next_bridge; struct device *dev; struct zynqmp_dpsub *dpsub; void __iomem *iomem; @@ -1494,8 +1492,8 @@ static int zynqmp_dp_bridge_attach(struct drm_bridge *bridge, return ret; } - if (dp->next_bridge) { - ret = drm_bridge_attach(encoder, dp->next_bridge, + if (dp->bridge.next_bridge) { + ret = drm_bridge_attach(encoder, dp->bridge.next_bridge, bridge, flags); if (ret < 0) goto error; @@ -2461,10 +2459,15 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub) * Acquire the next bridge in the chain. Ignore errors caused by port@5 * not being connected for backward-compatibility with older DTs. */ - ret = drm_of_find_panel_or_bridge(dp->dev->of_node, 5, 0, NULL, - &dp->next_bridge); - if (ret < 0 && ret != -ENODEV) - goto err_reset; + dp->bridge.next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node, 5, 0); + if (IS_ERR(dp->bridge.next_bridge)) { + if (PTR_ERR(dp->bridge.next_bridge) == -ENODEV) { + dp->bridge.next_bridge; + } else { + ret = PTR_ERR(dp->bridge.next_bridge); + goto err_reset; + } + } /* Initialize the hardware. */ dp->config.misc0 &= ~ZYNQMP_DP_MAIN_STREAM_MISC0_SYNC_LOCK; -- 2.53.0