The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] drm/mipi-dsi: Only remove child devices that match the dsi device type
@ 2025-12-03 11:50 Chaoyi Chen
  2026-01-07 12:18 ` Heiko Stübner
  2026-04-13  3:19 ` Chaoyi Chen
  0 siblings, 2 replies; 3+ messages in thread
From: Chaoyi Chen @ 2025-12-03 11:50 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Sandy Huang, Andy Yan, Heiko Stuebner
  Cc: dri-devel, linux-kernel, linux-rockchip, Chaoyi Chen

From: Chaoyi Chen <chaoyi.chen@rock-chips.com>

This patch checks whether the device is a valid mipi_dsi_device before
accessing it in mipi_dsi_remove_device_fn().

The mipi_dsi_host_unregister() assumes that all child devices of the
host device are mipi_dsi_devices and uses mipi_dsi_remove_device_fn()
to perform subsequent operations specific to mipi_dsi_device.

In rockchip platform, for dw-mipi-dsi-rockchip.c, it creates a dphy
device, and it use the dsi host device as its parent device.

And when we call dw_mipi_dsi_remove() in
dw_mipi_dsi_rockchip_remove(), mipi_dsi_host_unregister() will get
such a dphy child device and treat it as an mipi_dsi_device, which
will lead to a further panic.

Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
---
 drivers/gpu/drm/drm_mipi_dsi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index a712e177b350..5b9cc799eb87 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -349,7 +349,12 @@ EXPORT_SYMBOL(mipi_dsi_host_register);
 
 static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
 {
-	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
+	struct mipi_dsi_device *dsi;
+
+	if (!dev_is_mipi_dsi(dev))
+		return 0;
+
+	dsi = to_mipi_dsi_device(dev);
 
 	if (dsi->attached)
 		mipi_dsi_detach(dsi);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/mipi-dsi: Only remove child devices that match the dsi device type
  2025-12-03 11:50 [PATCH] drm/mipi-dsi: Only remove child devices that match the dsi device type Chaoyi Chen
@ 2026-01-07 12:18 ` Heiko Stübner
  2026-04-13  3:19 ` Chaoyi Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Heiko Stübner @ 2026-01-07 12:18 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Sandy Huang, Andy Yan, Chaoyi Chen
  Cc: dri-devel, linux-kernel, linux-rockchip, Chaoyi Chen

Am Mittwoch, 3. Dezember 2025, 12:50:28 Mitteleuropäische Normalzeit schrieb Chaoyi Chen:
> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> 
> This patch checks whether the device is a valid mipi_dsi_device before
> accessing it in mipi_dsi_remove_device_fn().
> 
> The mipi_dsi_host_unregister() assumes that all child devices of the
> host device are mipi_dsi_devices and uses mipi_dsi_remove_device_fn()
> to perform subsequent operations specific to mipi_dsi_device.
> 
> In rockchip platform, for dw-mipi-dsi-rockchip.c, it creates a dphy
> device, and it use the dsi host device as its parent device.
> 
> And when we call dw_mipi_dsi_remove() in
> dw_mipi_dsi_rockchip_remove(), mipi_dsi_host_unregister() will get
> such a dphy child device and treat it as an mipi_dsi_device, which
> will lead to a further panic.
> 
> Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index a712e177b350..5b9cc799eb87 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -349,7 +349,12 @@ EXPORT_SYMBOL(mipi_dsi_host_register);
>  
>  static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
>  {
> -	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
> +	struct mipi_dsi_device *dsi;
> +
> +	if (!dev_is_mipi_dsi(dev))
> +		return 0;
> +
> +	dsi = to_mipi_dsi_device(dev);
>  
>  	if (dsi->attached)
>  		mipi_dsi_detach(dsi);
> 

This makes a lot of sense.

Reviewed-by: Heiko Stuebner <heiko@sntech.de>


For people reading along:
The DSI controllers on the RK3399 uses a phy that is _inside_ the
DW-DSI controller, instead of a separate IP block.

But this internal PHY can also work as a receiver for camera data
for the ISP block in the RK3399.

Heiko



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/mipi-dsi: Only remove child devices that match the dsi device type
  2025-12-03 11:50 [PATCH] drm/mipi-dsi: Only remove child devices that match the dsi device type Chaoyi Chen
  2026-01-07 12:18 ` Heiko Stübner
@ 2026-04-13  3:19 ` Chaoyi Chen
  1 sibling, 0 replies; 3+ messages in thread
From: Chaoyi Chen @ 2026-04-13  3:19 UTC (permalink / raw)
  To: dri-devel, linux-kernel, linux-rockchip
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Sandy Huang, Andy Yan, Heiko Stuebner

Hi,

On 12/3/2025 7:50 PM, Chaoyi Chen wrote:
> From: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> 
> This patch checks whether the device is a valid mipi_dsi_device before
> accessing it in mipi_dsi_remove_device_fn().
> 
> The mipi_dsi_host_unregister() assumes that all child devices of the
> host device are mipi_dsi_devices and uses mipi_dsi_remove_device_fn()
> to perform subsequent operations specific to mipi_dsi_device.
> 
> In rockchip platform, for dw-mipi-dsi-rockchip.c, it creates a dphy
> device, and it use the dsi host device as its parent device.
> 
> And when we call dw_mipi_dsi_remove() in
> dw_mipi_dsi_rockchip_remove(), mipi_dsi_host_unregister() will get
> such a dphy child device and treat it as an mipi_dsi_device, which
> will lead to a further panic.
> 
> Signed-off-by: Chaoyi Chen <chaoyi.chen@rock-chips.com>
> ---
>  drivers/gpu/drm/drm_mipi_dsi.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
> index a712e177b350..5b9cc799eb87 100644
> --- a/drivers/gpu/drm/drm_mipi_dsi.c
> +++ b/drivers/gpu/drm/drm_mipi_dsi.c
> @@ -349,7 +349,12 @@ EXPORT_SYMBOL(mipi_dsi_host_register);
>  
>  static int mipi_dsi_remove_device_fn(struct device *dev, void *priv)
>  {
> -	struct mipi_dsi_device *dsi = to_mipi_dsi_device(dev);
> +	struct mipi_dsi_device *dsi;
> +
> +	if (!dev_is_mipi_dsi(dev))
> +		return 0;
> +
> +	dsi = to_mipi_dsi_device(dev);
>  
>  	if (dsi->attached)
>  		mipi_dsi_detach(dsi);

Gentle ping about this.

Thanks!

-- 
Best, 
Chaoyi


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-04-13  3:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03 11:50 [PATCH] drm/mipi-dsi: Only remove child devices that match the dsi device type Chaoyi Chen
2026-01-07 12:18 ` Heiko Stübner
2026-04-13  3:19 ` Chaoyi Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox