From nobody Tue Feb 10 09:57:50 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 2818D339857 for ; Fri, 16 Jan 2026 17:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768584813; cv=none; b=hJ3h2WqaEy9g5MrKAHTIJ3MT8COjrxSym2VpxXeGPif3rzCBot05wjExb1A0SJXTRPb+hltZxMtwW5hwap6Waz3hNSwRH+kgQ86qUMViXWFcpEwXTbnWsu98z+tTiazg16NhMN80/Gn+kRkMfLlqr4zpgvBvwa1CwpOFL8qSiq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768584813; c=relaxed/simple; bh=ShRFWf1YL24jawc7E6qTAvPINLwJqZZgNut/y12/vXY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uEaJADg6p2hwVID3CrzeSXbsTqtsRARUpT1wwCrA1ZNAxw7wiY3GMplzo4zELlUpUpQuM3yNe+NtS5yWce8whzcnoESTT9BMypDjg5kaHFJTEcoVVzpGbEKSTAlzvjIC/la8IGYX+6qa9FcUZnHP2fhzMJWr30Uoyg7YTst8ZIk= 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=KAPTPmnn; arc=none smtp.client-ip=185.246.85.4 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="KAPTPmnn" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id C10114E42118; Fri, 16 Jan 2026 17:33:27 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 95A02606F9; Fri, 16 Jan 2026 17:33:27 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1134310B688E1; Fri, 16 Jan 2026 18:33:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1768584806; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=IPtDTV3UxlBAHCLMExW04W6Gb1rrw7CzH5qBCtmWqiA=; b=KAPTPmnnjRUqFzYQwlXrdMQ+txz0ssC2vFdma/o8WJHrCIABQVM0Ofy0BoP6lHmRFgl21Z V3djt9VSZXNAhv1Bo9Bacf9ceoZSc6GRONleOsY11fUK6Fo+CAvYndv+A2hNgov0waPRi/ hggNJU1ptHojmhF2njIOEGx7pG/DlnZOQuL4CaQRK2oHvC+zDyCAcvkkgEFdchA1mbATKD MILG36rIOmXr8raaVFwuCXv/qcdtJymaJh1kUWo2ASv6ri3w20prmnu5jc8Dh+uLZSItNP t444gsnAK03aqV7+Pu0UNEX1ZRuYGcAefe1ZVZUcGBmUMEx0NOXLstvX5r9fOg== From: Luca Ceresoli Date: Fri, 16 Jan 2026 18:32:40 +0100 Subject: [PATCH 5/6] drm: rcar-du: encoder: convert to of_drm_find_and_get_bridge() 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: quoted-printable Message-Id: <20260116-drm-bridge-alloc-getput-drm_of_find_bridge-4-v1-5-e34b38f50d27@bootlin.com> References: <20260116-drm-bridge-alloc-getput-drm_of_find_bridge-4-v1-0-e34b38f50d27@bootlin.com> In-Reply-To: <20260116-drm-bridge-alloc-getput-drm_of_find_bridge-4-v1-0-e34b38f50d27@bootlin.com> To: Biju Das , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Anitha Chrisanthus , Edmund Dea , Linus Walleij , Laurent Pinchart , Tomi Valkeinen , Kieran Bingham , Geert Uytterhoeven , Magnus Damm , Tomi Valkeinen Cc: Hui Pu , Ian Ray , Thomas Petazzoni , dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Luca Ceresoli X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 of_drm_find_bridge() is deprecated. Move to its replacement of_drm_find_and_get_bridge() which gets a bridge reference, and ensure it is put when done. We need to handle the two cases: when a panel_bridge is added and when it isn't. So: * in the 'else' case a panel_bridge is not added and bridge is found: use of_drm_find_and_get_bridge() to get a reference to the found bridge * in the 'then' case a panel_bridge is found using a devm function which already takes a refcount and will put it on removal, but we need to take another so the following code in this function always get exactly one reference that it needs to put In order to put the reference, add the needed drm_bridge_put() calls in the existing cleanup function. Signed-off-by: Luca Ceresoli --- drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c | 28 ++++++++++++++++++-= ---- drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h | 1 + drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c | 2 ++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c b/drivers/gp= u/drm/renesas/rcar-du/rcar_du_encoder.c index 7ecec7b04a8d..5789fc75092f 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.c @@ -51,7 +51,7 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, { struct rcar_du_encoder *renc; struct drm_connector *connector; - struct drm_bridge *bridge; + struct drm_bridge *bridge __free(drm_bridge_put) =3D NULL; int ret; =20 /* @@ -69,20 +69,26 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, =20 bridge =3D devm_drm_panel_bridge_add_typed(rcdu->dev, panel, DRM_MODE_CONNECTOR_DPI); - if (IS_ERR(bridge)) - return PTR_ERR(bridge); + if (IS_ERR(bridge)) { + // Inhibit the cleanup action on an ERR_PTR + ret =3D PTR_ERR(bridge); + bridge =3D NULL; + return ret; + } + + drm_bridge_get(bridge); } else { - bridge =3D of_drm_find_bridge(enc_node); + bridge =3D of_drm_find_and_get_bridge(enc_node); if (!bridge) return -EPROBE_DEFER; =20 if (output =3D=3D RCAR_DU_OUTPUT_LVDS0 || output =3D=3D RCAR_DU_OUTPUT_LVDS1) - rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =3D bridge; + rcdu->lvds[output - RCAR_DU_OUTPUT_LVDS0] =3D drm_bridge_get(bridge); =20 if (output =3D=3D RCAR_DU_OUTPUT_DSI0 || output =3D=3D RCAR_DU_OUTPUT_DSI1) - rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] =3D bridge; + rcdu->dsi[output - RCAR_DU_OUTPUT_DSI0] =3D drm_bridge_get(bridge); } =20 /* @@ -135,3 +141,13 @@ int rcar_du_encoder_init(struct rcar_du_device *rcdu, =20 return drm_connector_attach_encoder(connector, &renc->base); } + +void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu) +{ + int i; + + for (i =3D 0; i < RCAR_DU_MAX_LVDS; i++) + drm_bridge_put(rcdu->lvds[i]); + for (i =3D 0; i < RCAR_DU_MAX_DSI; i++) + drm_bridge_put(rcdu->dsi[i]); +} diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h b/drivers/gp= u/drm/renesas/rcar-du/rcar_du_encoder.h index e5ec8fbb3979..b2b5e93f30f8 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_encoder.h @@ -25,5 +25,6 @@ struct rcar_du_encoder { int rcar_du_encoder_init(struct rcar_du_device *rcdu, enum rcar_du_output output, struct device_node *enc_node); +void rcar_du_encoder_cleanup(struct rcar_du_device *rcdu); =20 #endif /* __RCAR_DU_ENCODER_H__ */ diff --git a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c b/drivers/gpu/dr= m/renesas/rcar-du/rcar_du_kms.c index 6294443f6068..15d301ab5eef 100644 --- a/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c @@ -836,6 +836,8 @@ static void rcar_du_modeset_cleanup(struct drm_device *= dev, void *res) =20 for (i =3D 0; i < ARRAY_SIZE(rcdu->cmms); ++i) platform_device_put(rcdu->cmms[i]); + + rcar_du_encoder_cleanup(rcdu); } =20 int rcar_du_modeset_init(struct rcar_du_device *rcdu) --=20 2.52.0