Hello Anusha, thanks for quickly addressing this issue!
On Tue, 24 Jun 2025 15:13:05 -0500 Anusha Srivatsa <[email protected]> wrote: > Currently driver is checking for desc == &panel_dpi to do the DPI > specific panel desc allocations. This looks hacky. > > The panel allocation in panel_simple_probe() breaks due to not having > the desc for DPI scenario. This patch does the following: > > - Rename panel_dpi_probe() to panel_dpi_get_desc() and call it before > panel allocation. panel_dpi_get_desc() returns a panel desc unlike > panel_dpi_probe() which returned an int. This way driver has a known > connector type while allocating the panel. > - panel_dpi_get_desc() returns a panel desc > - Add a simple helper is_panel_dpi() to identify a simple DPI panel from > a simple panel based on .compatible field > > Fixes: de04bb0089a9 ("drm/panel/panel-simple: Use the new allocation in place > of devm_kzalloc()") Please add a mention to the discussion: Closes: https://lore.kernel.org/all/20250612081834.GA248237@francesco-nb/ and also: Reported-by: Francesco Dolcini <[email protected]> > Suggested-by: Luca Ceresoli <[email protected]> > Suggested-by: Maxime Ripard <[email protected]> > Cc: Francesco Dolcini <[email protected]> > Cc: Luca Ceresoli <[email protected]> > Cc: Maxime Ripard <[email protected]> > Signed-off-by: Anusha Srivatsa <[email protected]> > --- > Seeing the below trace due to the changes introduced by: > Commit de04bb0089a9 ("drm/panel/panel-simple: Use the new allocation in place > of devm_kzalloc()") > > [ 12.089274] ------------[ cut here ]------------ > [ 12.089303] WARNING: CPU: 0 PID: 96 at drivers/gpu/drm/bridge/panel.c:377 > devm_drm_of_get_bridge+0xac/0xb8 > [ 12.130808] Modules linked in: v4l2_jpeg pwm_imx27(+) imx_vdoa gpu_sched > panel_simple imx6_media(C) imx_media_common > (C) videobuf2_dma_contig pwm_bl gpio_keys v4l2_mem2mem fuse ipv6 autofs4 > [ 12.147774] CPU: 0 UID: 0 PID: 96 Comm: kworker/u8:3 Tainted: G C > 6.16.0-rc1+ #1 PREEMPT > [ 12.157446] Tainted: [C]=CRAP > [ 12.160418] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) > [ 12.166953] Workqueue: events_unbound deferred_probe_work_func > [ 12.172805] Call trace: > [ 12.172815] unwind_backtrace from show_stack+0x10/0x14 > [ 12.180598] show_stack from dump_stack_lvl+0x68/0x74 > [ 12.185674] dump_stack_lvl from __warn+0x7c/0xe0 > [ 12.190407] __warn from warn_slowpath_fmt+0x1b8/0x1c0 > [ 12.195567] warn_slowpath_fmt from devm_drm_of_get_bridge+0xac/0xb8 > [ 12.201949] devm_drm_of_get_bridge from imx_pd_probe+0x58/0x164 > [ 12.207976] imx_pd_probe from platform_probe+0x5c/0xb0 > [ 12.213220] platform_probe from really_probe+0xd0/0x3a4 > [ 12.218551] really_probe from __driver_probe_device+0x8c/0x1d4 > [ 12.224486] __driver_probe_device from driver_probe_device+0x30/0xc0 > [ 12.230942] driver_probe_device from __device_attach_driver+0x98/0x10c > [ 12.237572] __device_attach_driver from bus_for_each_drv+0x90/0xe4 > [ 12.243854] bus_for_each_drv from __device_attach+0xa8/0x1c8 > [ 12.249614] __device_attach from bus_probe_device+0x88/0x8c > [ 12.255285] bus_probe_device from deferred_probe_work_func+0x8c/0xcc > [ 12.261739] deferred_probe_work_func from process_one_work+0x154/0x2dc > [ 12.268371] process_one_work from worker_thread+0x250/0x3f0 > [ 12.274043] worker_thread from kthread+0x12c/0x24c > [ 12.278940] kthread from ret_from_fork+0x14/0x28 > [ 12.283660] Exception stack(0xd0be9fb0 to 0xd0be9ff8) > [ 12.288720] 9fa0: 00000000 00000000 > 00000000 00000000 > [ 12.296906] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 > 00000000 00000000 > [ 12.305089] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 > [ 12.312050] ---[ end trace 0000000000000000 ]--- > --- > drivers/gpu/drm/panel/panel-simple.c | 38 > +++++++++++++++++++++--------------- > 1 file changed, 22 insertions(+), 16 deletions(-) > > diff --git a/drivers/gpu/drm/panel/panel-simple.c > b/drivers/gpu/drm/panel/panel-simple.c > index > 0a3b26bb4d731c54614e24e38018c308acd5367a..2e6fd545100388a9d53183a5621e7b8fdb4148ae > 100644 > --- a/drivers/gpu/drm/panel/panel-simple.c > +++ b/drivers/gpu/drm/panel/panel-simple.c > @@ -26,6 +26,7 @@ > #include <linux/i2c.h> > #include <linux/media-bus-format.h> > #include <linux/module.h> > +#include <linux/of_device.h> > #include <linux/of_platform.h> > #include <linux/platform_device.h> > #include <linux/pm_runtime.h> > @@ -432,8 +433,7 @@ static const struct drm_panel_funcs panel_simple_funcs = { > > static struct panel_desc panel_dpi; > > -static int panel_dpi_probe(struct device *dev, > - struct panel_simple *panel) > +static struct panel_desc *panel_dpi_get_desc(struct device *dev) > { > struct display_timing *timing; > const struct device_node *np; > @@ -445,17 +445,17 @@ static int panel_dpi_probe(struct device *dev, > np = dev->of_node; > desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); > if (!desc) > - return -ENOMEM; > + return NULL; > > timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL); > if (!timing) > - return -ENOMEM; > + return NULL; > > ret = of_get_display_timing(np, "panel-timing", timing); > if (ret < 0) { > dev_err(dev, "%pOF: no panel-timing node found for > \"panel-dpi\" binding\n", > np); > - return ret; > + return NULL; > } > > desc->timings = timing; > @@ -473,9 +473,7 @@ static int panel_dpi_probe(struct device *dev, > /* We do not know the connector for the DT node, so guess it */ > desc->connector_type = DRM_MODE_CONNECTOR_DPI; > > - panel->desc = desc; > - > - return 0; > + return desc; > } > > #define PANEL_SIMPLE_BOUNDS_CHECK(to_check, bounds, field) \ > @@ -570,6 +568,15 @@ static int > panel_simple_override_nondefault_lvds_datamapping(struct device *dev, > return 0; > } > > +static bool is_panel_dpi(struct device *dev) > +{ > + const struct of_device_id *match; > + > + match = of_match_device(dev->driver->of_match_table, dev); > + > + return strcmp(match->compatible, "panel_dpi"); The compatible is panel-dpi, not panel_dpi. > +} > + > static int panel_simple_probe(struct device *dev, const struct panel_desc > *desc) > { > struct panel_simple *panel; > @@ -579,6 +586,10 @@ static int panel_simple_probe(struct device *dev, const > struct panel_desc *desc) > u32 bus_flags; > int err; > > + /* Is this simple panel a DPI panel */ > + if (is_panel_dpi(dev)) > + desc = panel_dpi_get_desc(dev); > + > panel = devm_drm_panel_alloc(dev, struct panel_simple, base, > &panel_simple_funcs, desc->connector_type); > if (IS_ERR(panel)) > @@ -611,16 +622,11 @@ static int panel_simple_probe(struct device *dev, const > struct panel_desc *desc) > return -EPROBE_DEFER; > } > > - if (desc == &panel_dpi) { > - /* Handle the generic panel-dpi binding */ > - err = panel_dpi_probe(dev, panel); > - if (err) > - goto free_ddc; > - desc = panel->desc; > - } else { > + if (is_panel_dpi(dev)) > + goto free_ddc; > + else > if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) > panel_simple_parse_panel_timing_node(dev, panel, &dt); > - } The 'else' becomes unnecessary after a 'if () goto xyz;' With your changes you should now be able to remove both this entry in platform_of_match: /* Must be the last entry */ .compatible = "panel-dpi", .data = &panel_dpi, and finally this line: static struct panel_desc panel_dpi; Otherwise LGTM. Luca -- Luca Ceresoli, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
