Skip to content

Commit

Permalink
OMAPDSS: Fix crash with DT boot
Browse files Browse the repository at this point in the history
When booting with DT, there's a crash when omapfb is probed. This is
caused by the fact that omapdss+DT is not yet supported, and thus
omapdss is not probed at all. On the other hand, omapfb is always
probed. When omapfb tries to use omapdss, there's a NULL pointer
dereference crash. The same error should most likely happen with omapdrm
and omap_vout also.

To fix this, add an "initialized" state to omapdss. When omapdss has
been probed, it's marked as initialized. omapfb, omapdrm and omap_vout
check this state when they are probed to see that omapdss is actually
there.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Tested-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
  • Loading branch information
Tomi Valkeinen committed May 23, 2013
1 parent b358c6c commit 591a0ac
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions drivers/gpu/drm/omapdrm/omap_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,9 @@ static void pdev_shutdown(struct platform_device *device)

static int pdev_probe(struct platform_device *device)
{
if (omapdss_is_initialized() == false)
return -EPROBE_DEFER;

DBG("%s", device->name);
return drm_platform_init(&omap_drm_driver, device);
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/media/platform/omap/omap_vout.c
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,9 @@ static int __init omap_vout_probe(struct platform_device *pdev)
struct omap_dss_device *def_display;
struct omap2video_device *vid_dev = NULL;

if (omapdss_is_initialized() == false)
return -EPROBE_DEFER;

ret = omapdss_compat_init();
if (ret) {
dev_err(&pdev->dev, "failed to init dss\n");
Expand Down
20 changes: 19 additions & 1 deletion drivers/video/omap2/dss/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ static char *def_disp_name;
module_param_named(def_disp, def_disp_name, charp, 0);
MODULE_PARM_DESC(def_disp, "default display name");

static bool dss_initialized;

const char *omapdss_get_default_display_name(void)
{
return core.default_display_name;
Expand All @@ -66,6 +68,12 @@ enum omapdss_version omapdss_get_version(void)
}
EXPORT_SYMBOL(omapdss_get_version);

bool omapdss_is_initialized(void)
{
return dss_initialized;
}
EXPORT_SYMBOL(omapdss_is_initialized);

struct platform_device *dss_get_core_pdev(void)
{
return core.pdev;
Expand Down Expand Up @@ -606,6 +614,8 @@ static int __init omap_dss_init(void)
return r;
}

dss_initialized = true;

return 0;
}

Expand Down Expand Up @@ -636,7 +646,15 @@ static int __init omap_dss_init(void)

static int __init omap_dss_init2(void)
{
return omap_dss_register_drivers();
int r;

r = omap_dss_register_drivers();
if (r)
return r;

dss_initialized = true;

return 0;
}

core_initcall(omap_dss_init);
Expand Down
3 changes: 3 additions & 0 deletions drivers/video/omap2/omapfb/omapfb-main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2416,6 +2416,9 @@ static int __init omapfb_probe(struct platform_device *pdev)

DBG("omapfb_probe\n");

if (omapdss_is_initialized() == false)
return -EPROBE_DEFER;

if (pdev->num_resources != 0) {
dev_err(&pdev->dev, "probed for an unknown device\n");
r = -ENODEV;
Expand Down
1 change: 1 addition & 0 deletions include/video/omapdss.h
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,7 @@ struct omap_dss_driver {
};

enum omapdss_version omapdss_get_version(void);
bool omapdss_is_initialized(void);

int omap_dss_register_driver(struct omap_dss_driver *);
void omap_dss_unregister_driver(struct omap_dss_driver *);
Expand Down

0 comments on commit 591a0ac

Please sign in to comment.