Chrome platform driver development
 help / color / mirror / Atom feed
From: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
To: Luca Ceresoli <luca.ceresoli@bootlin.com>
Cc: "Anusha Srivatsa" <asrivats@redhat.com>,
	"Paul Kocialkowski" <paulk@sys-base.io>,
	"Dmitry Baryshkov" <lumag@kernel.org>,
	"Hervé Codina" <herve.codina@bootlin.com>,
	"Hui Pu" <Hui.Pu@gehealthcare.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	dri-devel@lists.freedesktop.org, asahi@lists.linux.dev,
	linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	linux-amlogic@lists.infradead.org,
	linux-renesas-soc@vger.kernel.org,
	platform-driver-x86@vger.kernel.org,
	linux-samsung-soc@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	freedreno@lists.freedesktop.org,
	linux-stm32@st-md-mailman.stormreply.com,
	"Michal Simek" <michal.simek@amd.com>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Andrzej Hajda" <andrzej.hajda@intel.com>,
	"Neil Armstrong" <neil.armstrong@linaro.org>,
	"Robert Foss" <rfoss@kernel.org>,
	"Laurent Pinchart" <Laurent.pinchart@ideasonboard.com>,
	"Jonas Karlman" <jonas@kwiboo.se>,
	"Jernej Skrabec" <jernej.skrabec@gmail.com>,
	"Jagan Teki" <jagan@amarulasolutions.com>,
	"Shawn Guo" <shawnguo@kernel.org>,
	"Sascha Hauer" <s.hauer@pengutronix.de>,
	"Pengutronix Kernel Team" <kernel@pengutronix.de>,
	"Fabio Estevam" <festevam@gmail.com>,
	"Douglas Anderson" <dianders@chromium.org>,
	"Chun-Kuang Hu" <chunkuang.hu@kernel.org>,
	"Krzysztof Kozlowski" <krzk@kernel.org>,
	"Dmitry Baryshkov" <dmitry.baryshkov@linaro.org>,
	"Sagar, Vishal" <vishal.sagar@amd.com>
Subject: Re: [PATCH 29/34] drm: zynqmp_dp: convert to devm_drm_bridge_alloc() API
Date: Wed, 16 Apr 2025 15:26:17 +0300	[thread overview]
Message-ID: <f5880400-ab7b-4cae-81e4-893ce34a0460@ideasonboard.com> (raw)
In-Reply-To: <20250407-drm-bridge-convert-to-alloc-api-v1-29-42113ff8d9c0@bootlin.com>

Hi,

On 07/04/2025 17:23, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
> 
> This driver has a peculiar structure. zynqmp_dpsub.c is the actual driver,
> which delegates to a submodule (zynqmp_dp.c) the allocation of a
> sub-structure embedding the drm_bridge and its initialization, however it
> does not delegate the drm_bridge_add(). Hence, following carefully the code
> flow, it is correct to change the allocation function and .funcs assignment
> in the submodule, while the drm_bridge_add() is not in that submodule.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> ---
> 
> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Cc: Michal Simek <michal.simek@amd.com>
> Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>   drivers/gpu/drm/xlnx/zynqmp_dp.c | 7 +++----
>   1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> index 11d2415fb5a1f7fad03421898331289f2295d68b..de22b6457a78a7a2110f9f308d0b5a8700544010 100644
> --- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
> +++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
> @@ -2439,9 +2439,9 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
>   	struct zynqmp_dp *dp;
>   	int ret;
>   
> -	dp = kzalloc(sizeof(*dp), GFP_KERNEL);
> -	if (!dp)
> -		return -ENOMEM;
> +	dp = devm_drm_bridge_alloc(&pdev->dev, struct zynqmp_dp, bridge, &zynqmp_dp_bridge_funcs);
> +	if (IS_ERR(dp))
> +		return PTR_ERR(dp);
>   
>   	dp->dev = &pdev->dev;
>   	dp->dpsub = dpsub;
> @@ -2488,7 +2488,6 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub)
>   
>   	/* Initialize the bridge. */
>   	bridge = &dp->bridge;
> -	bridge->funcs = &zynqmp_dp_bridge_funcs;
>   	bridge->ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID
>   		    | DRM_BRIDGE_OP_HPD;
>   	bridge->type = DRM_MODE_CONNECTOR_DisplayPort;
> 

I haven't had time to look at this more, but jfyi: I got this when 
unloading modules, but it doesn't seem to happen every time:

[  103.010533] ------------[ cut here ]------------
[  103.015415] refcount_t: underflow; use-after-free.
[  103.020657] WARNING: CPU: 2 PID: 392 at lib/refcount.c:28 
refcount_warn_saturate+0xf4/0x148
[  103.029056] Modules linked in: zynqmp_dpsub(-) display_connector 
drm_display_helper drm_dma_helper drm_kms_helper drm drm_p
anel_orientation_quirks
[  103.042437] CPU: 2 UID: 0 PID: 392 Comm: rmmod Not tainted 
6.15.0-rc2+ #3 PREEMPT
[  103.050035] Hardware name: ZynqMP ZCU106 RevA (DT)
[  103.054836] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS 
BTYPE=--)
[  103.061814] pc : refcount_warn_saturate+0xf4/0x148
[  103.066632] lr : refcount_warn_saturate+0xf4/0x148
[  103.071441] sp : ffff800083b5bbb0
[  103.074766] x29: ffff800083b5bbb0 x28: ffff000806b23780 x27: 
0000000000000000
[  103.081953] x26: 0000000000000000 x25: 0000000000000000 x24: 
ffff000801a68400
[  103.089141] x23: ffff800081311a20 x22: ffff800083b5bc38 x21: 
ffff000801a68010
[  103.096329] x20: ffff0008040676c0 x19: ffff000804067240 x18: 
0000000000000006
[  103.103517] x17: 2e30303030303464 x16: 662d7968703a7968 x15: 
ffff800083b5b5a0
[  103.110705] x14: 0000000000000000 x13: 00000000000c0000 x12: 
0000000000000000
[  103.117892] x11: ffff80008163d6bc x10: 0000000000000028 x9 : 
ffff800080ead38c
[  103.125080] x8 : ffff800083b5b908 x7 : 0000000000000000 x6 : 
ffff800083b5b9c0
[  103.132268] x5 : ffff800083b5b948 x4 : 0000000000000001 x3 : 
00000000000000db
[  103.139455] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 
ffff000806b23780
[  103.146644] Call trace:
[  103.149102]  refcount_warn_saturate+0xf4/0x148 (P)
[  103.153918]  drm_bridge_put.part.0+0x88/0xa0 [drm]
[  103.159188]  drm_bridge_put_void+0x1c/0x38 [drm]
[  103.164231]  devm_action_release+0x1c/0x30
[  103.168354]  release_nodes+0x68/0xa8
[  103.171957]  devres_release_all+0x98/0xf0
[  103.175993]  device_unbind_cleanup+0x20/0x70
[  103.180291]  device_release_driver_internal+0x208/0x250
[  103.185542]  driver_detach+0x54/0xa8
[  103.189145]  bus_remove_driver+0x78/0x108
[  103.193181]  driver_unregister+0x38/0x70
[  103.197131]  platform_driver_unregister+0x1c/0x30
[  103.201862]  zynqmp_dpsub_driver_exit+0x18/0x1100 [zynqmp_dpsub]
[  103.207931]  __arm64_sys_delete_module+0x1a8/0x2d0
[  103.212748]  invoke_syscall+0x50/0x120
[  103.216524]  el0_svc_common.constprop.0+0x48/0xf0
[  103.221256]  do_el0_svc+0x24/0x38
[  103.224598]  el0_svc+0x48/0x128
[  103.227766]  el0t_64_sync_handler+0x10c/0x138
[  103.232150]  el0t_64_sync+0x1a4/0x1a8
[  103.235841] irq event stamp: 7936
[  103.239173] hardirqs last  enabled at (7935): [<ffff8000800aaf78>] 
finish_task_switch.isra.0+0xb0/0x2a0
[  103.248600] hardirqs last disabled at (7936): [<ffff800080eaac74>] 
el1_dbg+0x24/0x90
[  103.256369] softirqs last  enabled at (7930): [<ffff800080066f98>] 
handle_softirqs+0x4a0/0x4c0
[  103.265007] softirqs last disabled at (7905): [<ffff800080010224>] 
__do_softirq+0x1c/0x28
[  103.273211] ---[ end trace 0000000000000000 ]---

  Tomi


  reply	other threads:[~2025-04-16 12:26 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-07 14:23 [PATCH 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-07 14:23 ` [PATCH 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-05-25 12:58   ` Adam Ford
2025-04-07 14:23 ` [PATCH 02/34] platform: arm64: acer-aspire1-ec: convert " Luca Ceresoli
2025-04-07 16:46   ` Ilpo Järvinen
2025-04-07 19:27     ` Luca Ceresoli
2025-04-07 14:23 ` [PATCH 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 04/34] drm/bridge: anx7625: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 05/34] drm/bridge: cdns-dsi: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 06/34] drm/bridge: display-connector: " Luca Ceresoli
2025-04-08 12:06   ` Dmitry Baryshkov
2025-04-07 14:23 ` [PATCH 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
2025-04-08 12:07   ` Dmitry Baryshkov
2025-04-07 14:23 ` [PATCH 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 09/34] drm/bridge: nxp-ptn3460: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 10/34] drm/bridge: sii902x: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 12/34] drm/bridge: tda998x: " Luca Ceresoli
2025-04-08 12:07   ` Dmitry Baryshkov
2025-04-07 14:23 ` [PATCH 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
2025-04-07 15:25   ` Herve Codina
2025-04-07 14:23 ` [PATCH 14/34] drm/exynos: mic: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 15/34] drm/mcde: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 16/34] drm/msm/dp: " Luca Ceresoli
2025-04-08 11:59   ` Dmitry Baryshkov
2025-04-07 14:23 ` [PATCH 17/34] drm/msm/dsi: " Luca Ceresoli
2025-04-08 11:59   ` Dmitry Baryshkov
2025-04-07 14:23 ` [PATCH 18/34] drm/msm/hdmi: " Luca Ceresoli
2025-04-08 11:59   ` Dmitry Baryshkov
2025-04-07 14:23 ` [PATCH 19/34] drm/omap: dss: dpi: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 20/34] drm/omap: dss: dsi: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 21/34] drm/omap: dss: hdmi4: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 22/34] drm/omap: dss: hdmi5: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 23/34] drm/omap: dss: sdi: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 24/34] drm/omap: dss: venc: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 25/34] drm/rcar-du: dsi: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 26/34] drm/bridge: stm_lvds: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 27/34] drm/vc4: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 28/34] drm/sti: dvo: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 29/34] drm: zynqmp_dp: " Luca Ceresoli
2025-04-16 12:26   ` Tomi Valkeinen [this message]
2025-04-16 12:31   ` Tomi Valkeinen
2025-04-24 11:28     ` Luca Ceresoli
2025-04-07 14:23 ` [PATCH 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
2025-04-07 14:23 ` [PATCH 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
2025-04-07 15:24 ` [PATCH 32/34] drm/bridge: tc358767: " Luca Ceresoli
2025-04-07 15:27 ` [PATCH 33/34] drm/bridge: add devm_drm_put_bridge() Luca Ceresoli
2025-04-07 15:27 ` [PATCH 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-08 15:51   ` Maxime Ripard
2025-04-24 15:18     ` Luca Ceresoli

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=f5880400-ab7b-4cae-81e4-893ce34a0460@ideasonboard.com \
    --to=tomi.valkeinen@ideasonboard.com \
    --cc=Hui.Pu@gehealthcare.com \
    --cc=Laurent.pinchart@ideasonboard.com \
    --cc=airlied@gmail.com \
    --cc=andrzej.hajda@intel.com \
    --cc=asahi@lists.linux.dev \
    --cc=asrivats@redhat.com \
    --cc=chrome-platform@lists.linux.dev \
    --cc=chunkuang.hu@kernel.org \
    --cc=dianders@chromium.org \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=freedreno@lists.freedesktop.org \
    --cc=herve.codina@bootlin.com \
    --cc=imx@lists.linux.dev \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=jonas@kwiboo.se \
    --cc=kernel@pengutronix.de \
    --cc=krzk@kernel.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=luca.ceresoli@bootlin.com \
    --cc=lumag@kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=michal.simek@amd.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=paulk@sys-base.io \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rfoss@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=tzimmermann@suse.de \
    --cc=vishal.sagar@amd.com \
    /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