Chrome platform driver development
 help / color / mirror / Atom feed
From: Liu Ying <victor.liu@nxp.com>
To: Luca Ceresoli <luca.ceresoli@bootlin.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>
Cc: Anusha Srivatsa <asrivats@redhat.com>,
	Paul Kocialkowski <paulk@sys-base.io>,
	Dmitry Baryshkov <lumag@kernel.org>,
	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
Subject: Re: [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: convert to devm_drm_bridge_alloc() API
Date: Tue, 29 Apr 2025 10:10:55 +0800	[thread overview]
Message-ID: <553d62ed-976a-4e17-9678-cdc3d40ce4a7@nxp.com> (raw)
In-Reply-To: <20250424-drm-bridge-convert-to-alloc-api-v2-30-8f91a404d86b@bootlin.com>

Hi,

On 04/25/2025, Luca Ceresoli wrote:
> This is the new API for allocating DRM bridges.
> 
> This driver embeds an array of channels in the main struct, and each
> channel embeds a drm_bridge. This prevents dynamic, refcount-based
> deallocation of the bridges.
> 
> To make the new, dynamic bridge allocation possible:
> 
>  * change the array of channels into an array of channel pointers
>  * allocate each channel using devm_drm_bridge_alloc()
>  * adapt the code wherever using the channels
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
> 
> ---
> 
> Cc: Liu Ying <victor.liu@nxp.com>
> ---
>  drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c | 18 ++++++++++++------
>  1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
> index 1f6fd488e7039e943351006d3373009f0c15cb08..40a8a5a53a781137e722309ff91692cf90d881da 100644
> --- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
> +++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
> @@ -68,7 +68,7 @@ struct imx8qxp_pc_channel {
>  
>  struct imx8qxp_pc {
>  	struct device *dev;
> -	struct imx8qxp_pc_channel ch[2];
> +	struct imx8qxp_pc_channel *ch[2];
>  	struct clk *clk_apb;
>  	void __iomem *base;
>  };
> @@ -307,7 +307,14 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>  			goto free_child;
>  		}
>  
> -		ch = &pc->ch[i];
> +		ch = devm_drm_bridge_alloc(dev, struct imx8qxp_pc_channel, bridge,
> +					   &imx8qxp_pc_bridge_funcs);
> +		if (IS_ERR(ch)) {
> +			ret = PTR_ERR(ch);
> +			goto free_child;
> +		}
> +
> +		pc->ch[i] = ch;
>  		ch->pc = pc;
>  		ch->stream_id = i;
>  
> @@ -333,7 +340,6 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>  		of_node_put(remote);
>  
>  		ch->bridge.driver_private = ch;
> -		ch->bridge.funcs = &imx8qxp_pc_bridge_funcs;
>  		ch->bridge.of_node = child;
>  		ch->is_available = true;
>  
> @@ -345,8 +351,8 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
>  free_child:
>  	of_node_put(child);
>  
> -	if (i == 1 && pc->ch[0].next_bridge)
> -		drm_bridge_remove(&pc->ch[0].bridge);
> +	if (i == 1 && pc->ch[0]->next_bridge)

Since this patch makes pc->ch[0] and pc->ch[1] be allocated separately,
pc->ch[0] could be NULL if channel0 is not available, hence a NULL pointer
dereference here...

> +		drm_bridge_remove(&pc->ch[0]->bridge);
>  
>  	pm_runtime_disable(dev);
>  	return ret;
> @@ -359,7 +365,7 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
>  	int i;
>  
>  	for (i = 0; i < 2; i++) {
> -		ch = &pc->ch[i];
> +		ch = pc->ch[i];
>  
>  		if (!ch->is_available)

...and here too.

This is what I get when removing the imx8qxp_pixel_combiner module.
-8<-
Unable to handle kernel NULL pointer dereference at virtual address 0000000000000144
Mem abort info:
  ESR = 0x0000000096000004
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x04: level 0 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
user pgtable: 4k pages, 48-bit VAs, pgdp=000000089e613000
[0000000000000144] pgd=0000000000000000, p4d=0000000000000000
Internal error: Oops: 0000000096000004 [#1]  SMP
Modules linked in: mpl3115 isl29018 industrialio_triggered_buffer kfifo_buf cdns3 cdns_usb_common snd_soc_imx_audmix rtc_imx_sc imx_sc_wdt imx_sc_thermal imx_sc_key imx8qxp_pixel_link6
CPU: 1 UID: 0 PID: 528 Comm: modprobe Not tainted 6.15.0-rc3-next-20250424-00059-gee51752c256e #217 PREEMPT 
Hardware name: Freescale i.MX8QXP MEK (DT)
pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : imx8qxp_pc_bridge_remove+0x38/0x6c [imx8qxp_pixel_combiner]
lr : imx8qxp_pc_bridge_remove+0x30/0x6c [imx8qxp_pixel_combiner]
sp : ffff8000840f3c40
x29: ffff8000840f3c40 x28: ffff00081e75d780 x27: 0000000000000000
x26: 0000000000000000 x25: 0000000000000000 x24: 0000000000000000
x23: ffff0008100fc090 x22: ffff0008100fe490 x21: ffff00081e69de00
x20: 0000000000000000 x19: ffff0008100fe410 x18: 0000000000000000
x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
x14: 0000000000000013 x13: ffff000810049010 x12: 0000000000000000
x11: ffff0008182bc550 x10: ffff0008182bc490 x9 : ffff000810049010
x8 : 0101010101010101 x7 : 7f7f7f7f7f7f7f7f x6 : fefefeff6364626d
x5 : 8080808000000000 x4 : 0000000000000000 x3 : 0000000000000000
x2 : ffff00081e75d780 x1 : ffff00081e75d780 x0 : ffff80007af9bdc0
Call trace:
 imx8qxp_pc_bridge_remove+0x38/0x6c [imx8qxp_pixel_combiner] (P)
 platform_remove+0x28/0x44
 device_remove+0x4c/0x80
 device_release_driver_internal+0x1c8/0x224
 driver_detach+0x50/0x98
 bus_remove_driver+0x6c/0xbc
 driver_unregister+0x30/0x60
 platform_driver_unregister+0x14/0x20
 imx8qxp_pc_bridge_driver_exit+0x18/0x814 [imx8qxp_pixel_combiner]
 __arm64_sys_delete_module+0x184/0x264
 invoke_syscall+0x48/0x110
 el0_svc_common.constprop.0+0xc8/0xe8
 do_el0_svc+0x20/0x2c
 el0_svc+0x30/0xd0
 el0t_64_sync_handler+0x144/0x168
 el0t_64_sync+0x198/0x19c
Code: aa1503e0 97f547f8 390512bf f9400a94 (39451280) 
---[ end trace 0000000000000000 ]---
-8<-

On top of this patch series, this issue doesn't happen if I apply the below
change:
diff --git a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
index 40a8a5a53a78..2eb0ade65d89 100644
--- a/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
+++ b/drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c
@@ -63,7 +63,6 @@ struct imx8qxp_pc_channel {
        struct drm_bridge *next_bridge;
        struct imx8qxp_pc *pc;
        unsigned int stream_id;
-       bool is_available;
 };
 
 struct imx8qxp_pc {
@@ -341,7 +340,6 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
 
                ch->bridge.driver_private = ch;
                ch->bridge.of_node = child;
-               ch->is_available = true;
 
                drm_bridge_add(&ch->bridge);
        }
@@ -351,7 +349,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
 free_child:
        of_node_put(child);
 
-       if (i == 1 && pc->ch[0]->next_bridge)
+       if (i == 1 && pc->ch[0])
                drm_bridge_remove(&pc->ch[0]->bridge);
 
        pm_runtime_disable(dev);
@@ -367,11 +365,8 @@ static void imx8qxp_pc_bridge_remove(struct platform_device *pdev)
        for (i = 0; i < 2; i++) {
                ch = pc->ch[i];
 
-               if (!ch->is_available)
-                       continue;
-
-               drm_bridge_remove(&ch->bridge);
-               ch->is_available = false;
+               if (ch)
+                       drm_bridge_remove(&ch->bridge);
        }
 
        pm_runtime_disable(&pdev->dev);

>  			continue;
> 

-- 
Regards,
Liu Ying

  reply	other threads:[~2025-04-29  2:09 UTC|newest]

Thread overview: 81+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24 18:59 [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 01/34] drm: convert many bridge drivers from devm_kzalloc() to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 12:44   ` Andy Yan
2025-04-28 15:00     ` [PATCH " Luca Ceresoli
2025-04-28 20:59   ` Doug Anderson
2025-04-30 10:35     ` Luca Ceresoli
2025-04-30 15:51       ` Doug Anderson
2025-04-30 16:42         ` Luca Ceresoli
2025-04-29  2:19   ` Liu Ying
2025-04-29  7:07     ` Luca Ceresoli
2025-04-30  9:42   ` Manikandan.M
2025-04-30 10:36     ` Luca Ceresoli
2025-05-05  5:20       ` Manikandan.M
2025-04-24 18:59 ` [PATCH v2 02/34] platform: arm64: acer-aspire1-ec: convert " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 03/34] drm/bridge: analogix-anx6345: " Luca Ceresoli
2025-04-28 12:29   ` Andy Yan
2025-04-24 18:59 ` [PATCH v2 04/34] drm/bridge: anx7625: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 05/34] drm/bridge: cdns-dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 06/34] drm/bridge: display-connector: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 07/34] drm/bridge: lt9611uxc: " Luca Ceresoli
2025-04-29 12:09   ` Dmitry Baryshkov
2025-04-24 18:59 ` [PATCH v2 08/34] drm/bridge: megachips-stdpxxxx-ge-b850v3-fw: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 09/34] drm/bridge: nxp-ptn3460: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 10/34] drm/bridge: sii902x: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 11/34] drm/bridge: dw-hdmi: " Luca Ceresoli
2025-04-24 19:16   ` Cristian Ciocaltea
2025-04-24 18:59 ` [PATCH v2 12/34] drm/bridge: tda998x: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 13/34] drm/bridge: ti-sn65dsi86: " Luca Ceresoli
2025-04-28 20:53   ` Doug Anderson
2025-04-24 18:59 ` [PATCH v2 14/34] drm/exynos: mic: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 15/34] drm/mcde: " Luca Ceresoli
2025-04-29  8:40   ` Linus Walleij
2025-04-24 18:59 ` [PATCH v2 16/34] drm/msm/dp: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 17/34] drm/msm/dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 18/34] drm/msm/hdmi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 19/34] drm/omap: dss: dpi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 20/34] drm/omap: dss: dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 21/34] drm/omap: dss: hdmi4: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 22/34] drm/omap: dss: hdmi5: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 23/34] drm/omap: dss: sdi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 24/34] drm/omap: dss: venc: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 25/34] drm/rcar-du: dsi: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 26/34] drm/bridge: stm_lvds: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 27/34] drm/vc4: " Luca Ceresoli
2025-04-28 15:45   ` Dave Stevenson
2025-04-24 18:59 ` [PATCH v2 28/34] drm/sti: dvo: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 29/34] drm: zynqmp_dp: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 30/34] drm/bridge: imx8qxp-pixel-combiner: " Luca Ceresoli
2025-04-29  2:10   ` Liu Ying [this message]
2025-04-30  9:29     ` Luca Ceresoli
2025-05-06  2:24       ` Liu Ying
2025-05-06 20:47         ` Luca Ceresoli
2025-05-07  2:10           ` Liu Ying
2025-05-07  7:12             ` Luca Ceresoli
2025-05-07 10:16               ` Liu Ying
2025-05-07 14:13                 ` Luca Ceresoli
2025-05-22  3:01           ` Liu Ying
2025-05-26  7:20             ` Luca Ceresoli
2025-05-27  1:42               ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 31/34] drm/bridge: imx8*-ldb: " Luca Ceresoli
2025-04-29  2:35   ` Liu Ying
2025-04-24 18:59 ` [PATCH v2 32/34] drm/bridge: tc358767: " Luca Ceresoli
2025-04-24 18:59 ` [PATCH v2 33/34] drm/bridge: add devm_drm_put_bridge() Luca Ceresoli
2025-04-24 20:05 ` [PATCH v2 34/34] drm/bridge: panel: convert to devm_drm_bridge_alloc() API Luca Ceresoli
2025-04-28 11:39   ` Maxime Ripard
2025-04-28 15:25     ` Luca Ceresoli
2025-05-05  6:23       ` Maxime Ripard
2025-05-05 15:20         ` Luca Ceresoli
2025-04-28 15:24 ` [PATCH v2 00/34] drm: convert all bridges to devm_drm_bridge_alloc() Luca Ceresoli
2025-04-28 15:42   ` Maxime Ripard
2025-04-28 16:33     ` Luca Ceresoli
2025-04-29  9:27 ` (subset) " Louis Chauvet
2025-04-29 12:41   ` Louis Chauvet
2025-04-30  8:08     ` Maxime Ripard
2025-05-05 11:06       ` Luca Ceresoli
2025-05-05 11:58         ` Dmitry Baryshkov
2025-05-05 12:31           ` Luca Ceresoli
2025-04-29 14:42   ` Dmitry Baryshkov
2025-04-30  8:21     ` Louis Chauvet
2025-04-30 10:39       ` Maxime Ripard
2025-04-30 15:30         ` Louis Chauvet

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=553d62ed-976a-4e17-9678-cdc3d40ce4a7@nxp.com \
    --to=victor.liu@nxp.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=dri-devel@lists.freedesktop.org \
    --cc=festevam@gmail.com \
    --cc=freedreno@lists.freedesktop.org \
    --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=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 \
    /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