OMAPDSS: Fix crash with DT boot
authorTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 23 May 2013 09:07:50 +0000 (12:07 +0300)
committerTomi Valkeinen <tomi.valkeinen@ti.com>
Thu, 23 May 2013 09:54:21 +0000 (12:54 +0300)
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>
drivers/gpu/drm/omapdrm/omap_drv.c
drivers/media/platform/omap/omap_vout.c
drivers/video/omap2/dss/core.c
drivers/video/omap2/omapfb/omapfb-main.c
include/video/omapdss.h

index 079c54c6f94c974c966a32524cbd95210ed2572f..902074bbd1f43c6bfd698510a8f1e18db9f48130 100644 (file)
@@ -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);
 }
index 96c4a17e42802df491df16cd4b74a9c4580987bb..0a489bd29d6bf077222b14d13b56d1162d24f6f6 100644 (file)
@@ -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");
index f8779d4750ba63f98908492f2b11b9bfe7cf4ea8..f49ddb9e7c8273fd33371011418ac6831bc290b3 100644 (file)
@@ -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;
@@ -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;
@@ -606,6 +614,8 @@ static int __init omap_dss_init(void)
                return r;
        }
 
+       dss_initialized = true;
+
        return 0;
 }
 
@@ -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);
index 717f13a9335174f502a7fbc7599fcd060ae9d583..bb5f9fee365929fd44ee3aaffeba77a1ce45cccf 100644 (file)
@@ -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;
index caefa093337d9da1d0ba440cdc98665d91bb1801..9b52340ec3ff31988634c05c89b308e092b1ef69 100644 (file)
@@ -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 *);