drm: omap: fix: Defer probe if an omapdss device requests for it at connect
Subsystems (3)
PATCH 1/1 drm: omap: fix: Defer probe if an omapdss device requests for it at connect
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.
Checking whether the panel has a driver or whether it has get_timing/read_edid ops in omap_modeset_init() are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have a get_timings op.
This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 ++++ drivers/gpu/drm/omapdrm/omap_drv.c | 51 +++++++++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)
drivers/gpu/drm/omapdrm/omap_crtc.c +5 -0
@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)
drivers/gpu/drm/omapdrm/omap_drv.c +29 -22
79 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_drv.h +1 -0
@@ -158,6 +158,7 @@ enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);int omap_crtc_apply (struct drm_crtc *crtc,struct omap_drm_apply *apply);void omap_crtc_pre_init (void ); +void omap_crtc_pre_uninit (void );struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id);
Signature · 1 line
1.8.1.2
Quoted 13 lines · Archit Taneja
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter
omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.
Quoted 8 lines
Checking whether the panel has a driver or whether it has get_timing/read_edid ops in
omap_modeset_init()are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have aget_timingsop.This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
Copying dri-devel list.
Quoted 124 lines
Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 ++++ drivers/gpu/drm/omapdrm/omap_drv.c | 51 +++++++++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)drivers/gpu/drm/omapdrm/omap_crtc.c +5
-0@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)drivers/gpu/drm/omapdrm/omap_drv.c +29
-22@@ -87,6 +87,24 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static int omap_connect_dssdevs (void ) +{ +int r; +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) { + r = dssdev->driver->connect (dssdev); +if (r == -EPROBE_DEFER ) { +return r; + }else if (r) { +dev_warn (dssdev->dev,"could not connect display: %s\n" , + dssdev->name); + } + } + +return 0 ; +} +static int omap_modeset_init (struct drm_device *dev) {struct omap_drm_private *priv = dev->dev_private;@@ -95,9 +113,6 @@ static int omap_modeset_init(struct drm_device *dev)int num_mgrs =dss_feat_get_num_mgrs ();int num_crtcs;int i, id =0 ; -int r; - -omap_crtc_pre_init ();drm_mode_config_init (dev);@@ -119,26 +134,8 @@ static int omap_modeset_init(struct drm_device *dev)enum omap_channel channel;struct omap_overlay_manager *mgr; -if (!dssdev->driver) { -dev_warn (dev->dev,"%s has no driver.. skipping it\n" , - dssdev->name); +if (!omapdss_device_is_connected (dssdev))continue ; - } - -if (!(dssdev->driver->get_timings || - dssdev->driver->read_edid)) { -dev_warn (dev->dev,"%s driver does not support " -"get_timings or read_edid.. skipping it!\n" , - dssdev->name); -continue ; - } - - r = dssdev->driver->connect (dssdev); -if (r) { -dev_err (dev->dev,"could not connect display: %s\n" , - dssdev->name); -continue ; - } encoder =omap_encoder_init (dev, dssdev);@@ -656,9 +653,19 @@ static void pdev_shutdown(struct platform_device *device)static int pdev_probe (struct platform_device *device) { +int r; +if (omapdss_is_initialized () == false)return -EPROBE_DEFER ; +omap_crtc_pre_init (); + + r =omap_connect_dssdevs (); +if (r) { +omap_crtc_pre_uninit (); +return r; + } +DBG ("%s" , device->name);return drm_platform_init (&omap_drm_driver, device); }drivers/gpu/drm/omapdrm/omap_drv.h +1
-0@@ -158,6 +158,7 @@ enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);int omap_crtc_apply (struct drm_crtc *crtc,struct omap_drm_apply *apply);void omap_crtc_pre_init (void ); +void omap_crtc_pre_uninit (void );struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id);
Quoted 60 lines · Archit Taneja
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter
omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.Checking whether the panel has a driver or whether it has get_timing/read_edid ops in
omap_modeset_init()are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have aget_timingsop.This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 ++++ drivers/gpu/drm/omapdrm/omap_drv.c | 51 +++++++++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)drivers/gpu/drm/omapdrm/omap_crtc.c +5
-0@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)drivers/gpu/drm/omapdrm/omap_drv.c +7
-0@@ -87,6 +87,24 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static int omap_connect_dssdevs (void ) +{ +int r; +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) { + r = dssdev->driver->connect (dssdev);
drivers/gpu/drm/omapdrm/omap_drv.c static bool channel_used(struct drm_device *dev, enum omap_channel channel) · line 106
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+if (r == -EPROBE_DEFER ) { +return r; + }else if (r) { +dev_warn (dssdev->dev,"could not connect display: %s\n" , + dssdev->name); + } + } + +return 0 ; +}
There are two issues with this one:
for_each_dss_dev() uses omap_dss_get_next_device(), and that will increase the ref count of the current dssdev. If you interrupt the loop, the ref count won't be decreased. I have a hunch that we could have similar bugs elsewhere too...
Second, in case of error, the dssdevs that were already connected should be disconnected. Although maybe that's not important, as they'll end up being connected again when the omapdrm is probed the next time.
I had a quick test with this, and it seemed to fix the probe issue. I'll do some more testing.
Tomi
Quoted 74 lines · Tomi Valkeinen
Quoted 60 lines · Archit Taneja
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter
omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.Checking whether the panel has a driver or whether it has get_timing/read_edid ops in
omap_modeset_init()are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have aget_timingsop.This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 ++++ drivers/gpu/drm/omapdrm/omap_drv.c | 51 +++++++++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)drivers/gpu/drm/omapdrm/omap_crtc.c +5
-0@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)drivers/gpu/drm/omapdrm/omap_drv.c +7
-0@@ -87,6 +87,24 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static int omap_connect_dssdevs (void ) +{ +int r; +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) { + r = dssdev->driver->connect (dssdev);drivers/gpu/drm/omapdrm/omap_drv.c static bool channel_used(struct drm_device *dev, enum omap_channel channel) · line 106
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+if (r == -EPROBE_DEFER ) { +return r; + }else if (r) { +dev_warn (dssdev->dev,"could not connect display: %s\n" , + dssdev->name); + } + } + +return 0 ; +}There are two issues with this one:
Quoted 4 lines
for_each_dss_dev()usesomap_dss_get_next_device(), and that will increase the ref count of the current dssdev. If you interrupt the loop, the ref count won't be decreased. I have a hunch that we could have similar bugs elsewhere too...
You are saying that the ref counts will be correct only if for_each_dss_dev() is fully completed?
Maybe we can save the first dssdev which doesn't connect, save that dssdev and let the loop continue for the refcount to get decremented again.
Or maybe use omap_dss_get_next_device in a custom loop, which takes care of doing a put() for the device before returning.
Quoted 4 lines
Second, in case of error, the dssdevs that were already connected should be disconnected. Although maybe that's not important, as they'll end up being connected again when the omapdrm is probed the next time.
The one's that were already connected won't connect again and return an error which isn't EPROBE_DEFER, so that should be okay right?
Archit
Quoted 90 lines · Archit Taneja
Quoted 89 lines · Tomi Valkeinen
Quoted 75 lines · Archit Taneja
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require
regulators. The output's connect op tries to get a regulator which may not exist
yet because it might get registered later in the kernel boot.omapdrm currently ignores those panels which return a non zero value when
connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.The connecting of panels is moved very early in the the drm device's probe
before anything else is initialized. When we enteromap_modeset_init(), we have
a set of panels that have been connected. We now proceed with registering only
those panels which are already connected.Checking whether the panel has a driver or whether it has get_timing/read_edid
ops inomap_modeset_init()are redundant with the new display model. These can
be removed since a dssdev device will always have a driver associated with it,
and all dssdev drivers have aget_timingsop.This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by
HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized
as it's pins are not configured because pinctrl is yet to probe.Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 ++++ drivers/gpu/drm/omapdrm/omap_drv.c | 51 +++++++++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)drivers/gpu/drm/omapdrm/omap_crtc.c +5
-0@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)drivers/gpu/drm/omapdrm/omap_drv.c +7
-0@@ -87,6 +87,24 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static int omap_connect_dssdevs (void ) +{ +int r; +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) { + r = dssdev->driver->connect (dssdev);drivers/gpu/drm/omapdrm/omap_drv.c static bool channel_used(struct drm_device *dev, · line 107
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+if (r == -EPROBE_DEFER ) { +return r; + }else if (r) { +dev_warn (dssdev->dev,"could not connect display: %s\n" , + dssdev->name); + } + } + +return 0 ; +}There are two issues with this one:
Quoted 7 lines
Quoted 4 lines
for_each_dss_dev()usesomap_dss_get_next_device(), and that will increase the ref count of the current dssdev. If you interrupt the loop, the ref count won't be decreased. I have a hunch that we could have similar bugs elsewhere too...You are saying that the ref counts will be correct only if
for_each_dss_dev()is fully completed?
Right.
Quoted 5 lines
Maybe we can save the first dssdev which doesn't connect, save that dssdev and let the loop continue for the refcount to get decremented again.
Or maybe use
omap_dss_get_next_devicein a custom loop, which takes care of doing aput()for the device before returning.
Well, you can just use omap_dss_put_device(dssdev) before the return. That should fix it.
Check drivers/video/omap2/dss/display.c:omap_dss_get_next_device().
Quoted 6 lines
Quoted 3 lines
Second, in case of error, the dssdevs that were already connected should be disconnected. Although maybe that's not important, as they'll end up being connected again when the omapdrm is probed the next time.
The one's that were already connected won't connect again and return an error which isn't
EPROBE_DEFER, so that should be okay right?
Right, in practice it doesn't matter. The only issue here is that it's not very nice if you don't clean up after getting an error =). And, well, with modules there could be issues in some particular cases, where leaving things connected would prevent unloading of modules.
omapdrm doesn't seem to disconnect even when it's removed normally. I guess it'd be nicer to have similar disconnect loop as in omapfb, i.e. just go over all the displays and disconnect them all.
Tomi
PATCH v2 1/2 drm: omap: fix: Defer probe if an omapdss device requests for it at connect
In reply to Archit TanejaSome omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.
Checking whether the panel has a driver or whether it has get_timing/read_edid ops in omap_modeset_init() are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have a get_timings op.
This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 +++ drivers/gpu/drm/omapdrm/omap_drv.c | 64 ++++++++++++++++++++++++------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 48 insertions(+), 22 deletions(-)
drivers/gpu/drm/omapdrm/omap_crtc.c +5 -0
@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)
drivers/gpu/drm/omapdrm/omap_drv.c +42 -22
92 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_drv.h +1 -0
@@ -158,6 +158,7 @@ enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);int omap_crtc_apply (struct drm_crtc *crtc,struct omap_drm_apply *apply);void omap_crtc_pre_init (void ); +void omap_crtc_pre_uninit (void );struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id);
Signature · 1 line
1.8.1.2
PATCH v2 2/2 drm: omap: disconnect devices when omapdrm module is removed
In reply to Archit Tanejaomapdrm established connections for omap_dss_device devices when probed. It should also be responsible to disconnect the devices. Keeping the devices connected can prevent the panel driver modules from unloading, it can also cause problems when omapdrm is re-inserted.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +10 -4
@@ -86,6 +86,13 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static void omap_disconnect_dssdevs (void ) +{ +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) + dssdev->driver->disconnect (dssdev); +}static int omap_connect_dssdevs (void ) {
@@ -110,10 +117,7 @@ cleanup:* if we are deferring probe, we disconnect the devices we previously * connected */ - dssdev =NULL ; - -for_each_dss_dev (dssdev) - dssdev->driver->disconnect (dssdev); +omap_disconnect_dssdevs ();return r; }
@@ -688,6 +692,8 @@ static int pdev_remove(struct platform_device *device)DBG ("" );drm_platform_exit (&omap_drm_driver, device); +omap_disconnect_dssdevs (); +platform_driver_unregister (&omap_dmm_driver);return 0 ; }
Signature · 1 line
1.8.1.2
Re: [PATCH 2/2] drm: omap: disconnect devices when omapdrm module is removed
Quoted 15 lines · Archit Taneja
omapdrm established connections for
omap_dss_devicedevices when probed. It should also be responsible to disconnect the devices. Keeping the devices connected can prevent the panel driver modules from unloading, it can also cause problems when omapdrm is re-inserted.Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/omapdrm/omap_drv.c +0
-0
drivers/gpu/drm/omapdrm/omap_drv.c static bool channel_used(struct drm_device *dev, enum omap_channel channel) · line 95
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +7
-0@@ -86,6 +86,13 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static void omap_disconnect_dssdevs (void ) +{ +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) + dssdev->driver->disconnect (dssdev); +}
With a quick test, it looks like omapdrm leaves the displays enabled when exiting. This can be fixed by adding to the above loop:
if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) dssdev->driver->disable(dssdev);
However... omapdrm still crashes when unloading, and it could be somehow related to leaving something un-removed. Disabling a CRTC should disable the display, and maybe omapdrm should disable (and clean-up) all CRTCs on exit, and maybe that would remove the crash, and also fix the issue of leaving displays enabled.
But I'm just guessing there, I have no idea how the process of unloading a drm driver goes.
Tomi
Re: [PATCH 2/2] drm: omap: disconnect devices when omapdrm module is removed
Hi,
Quoted 33 lines · Tomi Valkeinen
Quoted 15 lines · Archit Taneja
omapdrm established connections for
omap_dss_devicedevices when probed. It should also be responsible to disconnect the devices. Keeping the devices connected can prevent the panel driver modules from unloading, it can also cause problems when omapdrm is re-inserted.Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_drv.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)drivers/gpu/drm/omapdrm/omap_drv.c +0
-0drivers/gpu/drm/omapdrm/omap_drv.c static bool channel_used(struct drm_device *dev, enum omap_channel channel) · line 95
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +7
-0@@ -86,6 +86,13 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static void omap_disconnect_dssdevs (void ) +{ +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) + dssdev->driver->disconnect (dssdev); +}With a quick test, it looks like omapdrm leaves the displays enabled when exiting. This can be fixed by adding to the above loop:
if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) dssdev->driver->disable(dssdev);
Quoted 8 lines
However... omapdrm still crashes when unloading, and it could be somehow related to leaving something un-removed. Disabling a CRTC should disable the display, and maybe omapdrm should disable (and clean-up) all CRTCs on exit, and maybe that would remove the crash, and also fix the issue of leaving displays enabled.
But I'm just guessing there, I have no idea how the process of unloading a drm driver goes.
It seems like dev_unload is the place where we should disconnect the dssdevs.
omap_modeset_free() calls drm_mode_config_cleanup() which calls omapdrm specific destroy funcs for connectors, encoders and crtcs.
I don't think crtcs should disable the device. I think it's the encoder(and connector) which is mapped to a display. The omap_encoder's destroy op should disable the dssdev device.
I'm not sure about this though. Rob, do you have any comment on this?
Archit
Quoted 60 lines · Archit Taneja
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter
omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.Checking whether the panel has a driver or whether it has get_timing/read_edid ops in
omap_modeset_init()are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have aget_timingsop.This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
Signed-off-by Archit Taneja <[email protected]>--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 ++++ drivers/gpu/drm/omapdrm/omap_drv.c | 51 +++++++++++++++++++++---------------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 35 insertions(+), 22 deletions(-)drivers/gpu/drm/omapdrm/omap_crtc.c +5
-0@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)drivers/gpu/drm/omapdrm/omap_drv.c +7
-0@@ -87,6 +87,24 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static int omap_connect_dssdevs (void ) +{ +int r; +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) { + r = dssdev->driver->connect (dssdev);
drivers/gpu/drm/omapdrm/omap_drv.c static bool channel_used(struct drm_device *dev, enum omap_channel channel) · line 106
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +10
-0+if (r == -EPROBE_DEFER ) { +return r; + }else if (r) { +dev_warn (dssdev->dev,"could not connect display: %s\n" , + dssdev->name); + } + } + +return 0 ; +}
Beagle-xm with DT boot doesn't work with this. There are no displays at omapdrm probe time, so omapdrm doesn't find any displays. I added the changes below, which made it work.
Tomi
drivers/gpu/drm/omapdrm/omap_drv.c +6 -0
@@ -91,6 +91,7 @@ static int omap_connect_dssdevs(void) {int r;struct omap_dss_device *dssdev =NULL ; +bool no_displays = true;for_each_dss_dev (dssdev) { r = dssdev->driver->connect (dssdev);
@@ -99,9 +100,14 @@ static int omap_connect_dssdevs(void) }else if (r) {dev_warn (dssdev->dev,"could not connect display: %s\n" , dssdev->name); + }else { + no_displays = false; } } +if (no_displays) +return -EPROBE_DEFER ; +return 0 ; }
On Friday 20 September 2013 01:39 PM, Tomi Valkeinen wrote:
<snip>
Quoted 40 lines
Quoted 7 lines
(quoted diff) +7
-0+static int omap_connect_dssdevs(void) +{ + int r; + struct omap_dss_device *dssdev = NULL; + + for_each_dss_dev(dssdev) { + r = dssdev->driver->connect(dssdev);Review
Quoted 10 lines
(quoted diff) +10
-0+ if (r == -EPROBE_DEFER) { + return r; + } else if (r) { + dev_warn(dssdev->dev, "could not connect display: %s\n", + dssdev->name); + } + } + + return 0; +}Beagle-xm with DT boot doesn't work with this. There are no displays at omapdrm probe time, so omapdrm doesn't find any displays. I added the changes below, which made it work.
Tomi
drivers/gpu/drm/omapdrm/omap_drv.c +1
-0@@ -91,6 +91,7 @@ static int omap_connect_dssdevs(void) {int r;struct omap_dss_device *dssdev =NULL ; +bool no_displays = true;for_each_dss_dev (dssdev) { r = dssdev->driver->connect (dssdev);@@ -99,9 +100,14 @@ static int omap_connect_dssdevs(void) }else if (r) {dev_warn (dssdev->dev,"could not connect display: %s\n" , dssdev->name);
drivers/gpu/drm/omapdrm/omap_drv.c static int omap_connect_dssdevs(void) · line 112
Quoted 10 lines
drivers/gpu/drm/omapdrm/omap_drv.c +5
-0+ }else { + no_displays = false; } } +if (no_displays) +return -EPROBE_DEFER ; +return 0 ; }
I suppose we would hit this case if all of the displays are deferred because of some dependency and are probed after omapdrm probes.
Is that the case with beagle-xm?
I think we need to move this from pdev_probe() anyway. I don't see other drivers doing much in pdev_probe(), they do most of their stuff in dev_load() itself. I'll try with that along with disabling of the dssdevs in encoder's destroy.
Archit
Quoted 4 lines · Archit Taneja
I suppose we would hit this case if all of the displays are deferred because of some dependency and are probed after omapdrm probes.
Is that the case with beagle-xm?
Yes, DVI is probed after omapdrm. There's also analog TV out on beagle. I'm not sure why that wasn't ready earlier, or was it available at all. I didn't study it further.
If the analog tv would've been available, omapdrm would have started with only tv out, and DVI would have been left out. So it's still not perfect.
Quoted 4 lines
I think we need to move this from
pdev_probe()anyway. I don't see other drivers doing much inpdev_probe(), they do most of their stuff indev_load()itself. I'll try with that along with disabling of the dssdevs in encoder's destroy.
Ok. The dssdevs are disabled in omap_connector already, though.
Tomi
Quoted 7 lines · Tomi Valkeinen
Quoted 4 lines · Archit Taneja
I suppose we would hit this case if all of the displays are deferred because of some dependency and are probed after omapdrm probes.
Is that the case with beagle-xm?
Quoted 7 lines
Yes, DVI is probed after omapdrm. There's also analog TV out on beagle. I'm not sure why that wasn't ready earlier, or was it available at all. I didn't study it further.
If the analog tv would've been available, omapdrm would have started with only tv out, and DVI would have been left out. So it's still not perfect.
Right, I suppose omapdrm should be probed only after all the dssdevs are probed. That's a bit tough to do.
Quoted 7 lines
Quoted 5 lines
I think we need to move this from
pdev_probe()anyway. I don't see other drivers doing much inpdev_probe(), they do most of their stuff indev_load()itself. I'll try with that along with disabling of the dssdevs in encoder's destroy.Ok. The dssdevs are disabled in
omap_connectoralready, though.
I couldn't find where it is disabled in omap_connector. The only function which calls dssdrv->disable is omap_connector_set_enabled(). That doesn't seem to be called in omap_connector.
Archit
Quoted 12 lines · Archit Taneja
Quoted 11 lines · Tomi Valkeinen
Quoted 4 lines · Archit Taneja
I suppose we would hit this case if all of the displays are deferred because of some dependency and are probed after omapdrm probes.
Is that the case with beagle-xm?
Yes, DVI is probed after omapdrm. There's also analog TV out on beagle. I'm not sure why that wasn't ready earlier, or was it available at all. I didn't study it further.
Quoted 6 lines
Quoted 3 lines
If the analog tv would've been available, omapdrm would have started with only tv out, and DVI would have been left out. So it's still not perfect.
Right, I suppose omapdrm should be probed only after all the dssdevs are probed. That's a bit tough to do.
Yes. Omapfb has the same issue.
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
I think we need to move this from
pdev_probe()anyway. I don't see other drivers doing much inpdev_probe(), they do most of their stuff indev_load()itself. I'll try with that along with disabling of the dssdevs in encoder's destroy.Ok. The dssdevs are disabled in
omap_connectoralready, though.I couldn't find where it is disabled in
omap_connector. The only function which callsdssdrv->disableisomap_connector_set_enabled(). That doesn't seem to be called inomap_connector.
Ah, right. Sorry, it seems I remembered totally wrong. I guess I was thinking about omap_dss_put_device instead.
Tomi
v2 cover drm: omap: Fix omapdrm probe and module insertion/removal issues
In reply to Archit TanejaWith the new omapdss device model. The user(omapdrm/omapfb) of a omap_dss_device has to call connect() to use the device. A connect() call can request to defer probe if the device(or the previous entities in the chain) have missing resources like a regulator or an I2C bus.
We make omapdrm defer probe by trying to first connect all panels, and request for deferral if any panel requests for a defer. This makes sure that all the panels are set up correctly when we finally proceed with omapdrm initialization.
In order for omapdrm module to be removed successfully, we need to disconnect the panels which omapdrm connected. Another thing noticed was that omapdrm insertion followed by some usage results in panels getting enabled.
Trying to remove omapdrm with a panel enabled results in failure while disconnecting. This leaves omapdss panels in a bad state. I have added an explicit panel disable in the omap_encoder_destroy() op, I needed some suggestions on whether there is a better way to do this.
changes in v2:
- Add special case when no panels are available to connect.
- Make sure panels are diabled (and then disconnected) when omapdrm is removed
Archit Taneja (2):
drm: omap: fix: Defer probe if an omapdss device requests for it at
connect
drm: omap: disconnect devices when omapdrm module is removed
drivers/gpu/drm/omapdrm/omap_crtc.c | 5 +++ drivers/gpu/drm/omapdrm/omap_drv.c | 77 ++++++++++++++++++++++++---------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + drivers/gpu/drm/omapdrm/omap_encoder.c | 3 ++ 4 files changed, 64 insertions(+), 22 deletions(-)
Signature · 1 line
1.8.1.2
PATCH v2 1/2 drm: omap: fix: Defer probe if an omapdss device requests for it at connect
Some omapdss panels are connected to outputs/encoders(HDMI/DSI/DPI) that require regulators. The output's connect op tries to get a regulator which may not exist yet because it might get registered later in the kernel boot.
omapdrm currently ignores those panels which return a non zero value when connected. A better approach would be for omapdrm to request for probe deferral if a panel's connect op returns -EPROBE_DEFER.
A special case has to be considered when no panels are available to connect when omapdrm probes. In this case too, we defer probe and expect that a panel will be available to connect the next time.
The connecting of panels is moved very early in the the drm device's probe before anything else is initialized. When we enter omap_modeset_init(), we have a set of panels that have been connected. We now proceed with registering only those panels which are already connected.
Checking whether the panel has a driver or whether it has get_timing/read_edid ops in omap_modeset_init() are redundant with the new display model. These can be removed since a dssdev device will always have a driver associated with it, and all dssdev drivers have a get_timings op.
This fixes boot with omapdrm on an omap4 panda ES board. The regulators used by HDMI aren't initialized because I2c isn't initialized, I2C isn't initialized as it's pins are not configured because pinctrl is yet to probe.
--- drivers/gpu/drm/omapdrm/omap_crtc.c | 5 +++ drivers/gpu/drm/omapdrm/omap_drv.c | 70 +++++++++++++++++++++++++------------ drivers/gpu/drm/omapdrm/omap_drv.h | 1 + 3 files changed, 54 insertions(+), 22 deletions(-)
drivers/gpu/drm/omapdrm/omap_crtc.c +5 -0
@@ -623,6 +623,11 @@ void omap_crtc_pre_init(void)dss_install_mgr_ops (&mgr_ops); } +void omap_crtc_pre_uninit (void ) +{ +dss_uninstall_mgr_ops (); +} +/* initialize crtc */ struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id)
drivers/gpu/drm/omapdrm/omap_drv.c +48 -22
98 lines not on this page · raw message
drivers/gpu/drm/omapdrm/omap_drv.h +1 -0
@@ -158,6 +158,7 @@ enum omap_channel omap_crtc_channel(struct drm_crtc *crtc);int omap_crtc_apply (struct drm_crtc *crtc,struct omap_drm_apply *apply);void omap_crtc_pre_init (void ); +void omap_crtc_pre_uninit (void );struct drm_crtc *omap_crtc_init (struct drm_device *dev,struct drm_plane *plane,enum omap_channel channel,int id);
Signature · 1 line
1.8.1.2
PATCH v2 2/2 drm: omap: disconnect devices when omapdrm module is removed
In reply to Archit Tanejaomapdrm establishes connections for omap_dss_device devices when probed. It should also be responsible to disconnect the devices. Keeping the devices connected can prevent the panel driver modules from unloading, it also causes issues when we try to remove or re-insert omapdrm module.
Before omapdrm module is removed, we need to make sure that all the connectors are disabled. Without this, the omap_dss_devices won't disconnect, and cause issues when we try to re-insert omapdrm.
For now, disable encoders in omap_encoder_destroy. We are not clear if this is the best place to disable an encoder. This makes successive module insertions and removal work unlike before. But it leads to warning backtraces when the module is removed. The func omap_crtc_destroy() gves a warning because omap_crtc->apply_irq.registered is still set when we try to disable the crtc. I haven't figured out a way to prevent this, would appreciate some help here.
--- drivers/gpu/drm/omapdrm/omap_drv.c | 15 +++++++++++---- drivers/gpu/drm/omapdrm/omap_encoder.c | 3 +++ 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/omapdrm/omap_drv.c +11 -4
@@ -86,6 +86,13 @@ static bool channel_used(struct drm_device *dev, enum omap_channel channel)return false; } +static void omap_disconnect_dssdevs (void ) +{ +struct omap_dss_device *dssdev =NULL ; + +for_each_dss_dev (dssdev) + dssdev->driver->disconnect (dssdev); +}static int omap_connect_dssdevs (void ) {
@@ -116,10 +123,7 @@ cleanup:* if we are deferring probe, we disconnect the devices we previously * connected */ - dssdev =NULL ; - -for_each_dss_dev (dssdev) - dssdev->driver->disconnect (dssdev); +omap_disconnect_dssdevs ();return r; }
@@ -694,6 +698,9 @@ static int pdev_remove(struct platform_device *device)DBG ("" );drm_platform_exit (&omap_drm_driver, device); +omap_disconnect_dssdevs (); +omap_crtc_pre_uninit (); +platform_driver_unregister (&omap_dmm_driver);return 0 ; }
drivers/gpu/drm/omapdrm/omap_encoder.c +3 -0
@@ -51,6 +51,9 @@ struct omap_dss_device *omap_encoder_get_dssdev(struct drm_encoder *encoder)static void omap_encoder_destroy (struct drm_encoder *encoder) {struct omap_encoder *omap_encoder =to_omap_encoder (encoder); + +omap_encoder_set_enabled (encoder, false); +drm_encoder_cleanup (encoder);kfree (omap_encoder); }
Signature · 1 line
1.8.1.2
Re: [PATCH v2 0/2] drm: omap: Fix omapdrm probe and module insertion/removal issues
In reply to Archit TanejaHi Rob,
Quoted 13 lines · Archit Taneja
With the new omapdss device model. The user(omapdrm/omapfb) of a
omap_dss_devicehas to callconnect()to use the device. Aconnect()call can request to defer probe if the device(or the previous entities in the chain) have missing resources like a regulator or an I2C bus.We make omapdrm defer probe by trying to first connect all panels, and request for deferral if any panel requests for a defer. This makes sure that all the panels are set up correctly when we finally proceed with omapdrm initialization.
In order for omapdrm module to be removed successfully, we need to disconnect the panels which omapdrm connected. Another thing noticed was that omapdrm insertion followed by some usage results in panels getting enabled.
Quoted 8 lines
Trying to remove omapdrm with a panel enabled results in failure while disconnecting. This leaves omapdss panels in a bad state. I have added an explicit panel disable in the
omap_encoder_destroy()op, I needed some suggestions on whether there is a better way to do this.changes in v2:
- Add special case when no panels are available to connect.
- Make sure panels are diabled (and then disconnected) when omapdrm is removed
omapdrm fails when built-in in 3.12, the first patch fixes this. The second one fixes issues seen with successive module insertion and removals.
It'll be great if the first one can at least make it to 3.12. Could you have a look at it?
Thanks,
Archit
Re: [PATCH v2 0/2] drm: omap: Fix omapdrm probe and module insertion/removal issues
In reply to Archit TanejaQuoted 27 lines · Archit Taneja
With the new omapdss device model. The user(omapdrm/omapfb) of a
omap_dss_devicehas to callconnect()to use the device. Aconnect()call can request to defer probe if the device(or the previous entities in the chain) have missing resources like a regulator or an I2C bus.We make omapdrm defer probe by trying to first connect all panels, and request for deferral if any panel requests for a defer. This makes sure that all the panels are set up correctly when we finally proceed with omapdrm initialization.
In order for omapdrm module to be removed successfully, we need to disconnect the panels which omapdrm connected. Another thing noticed was that omapdrm insertion followed by some usage results in panels getting enabled.
Trying to remove omapdrm with a panel enabled results in failure while disconnecting. This leaves omapdss panels in a bad state. I have added an explicit panel disable in the
omap_encoder_destroy()op, I needed some suggestions on whether there is a better way to do this.changes in v2:
- Add special case when no panels are available to connect.
- Make sure panels are diabled (and then disconnected) when omapdrm is removedArchit Taneja (2):
drm: omap: fix: Defer probe if an omapdss device requests for it at
connect
drm: omap: disconnect devices when omapdrm module is removed
Quoted 6 lines
drivers/gpu/drm/omapdrm/omap_crtc.c | 5 +++ drivers/gpu/drm/omapdrm/omap_drv.c | 77 ++++++++++++++++++++++++---------- drivers/gpu/drm/omapdrm/omap_drv.h | 1 + drivers/gpu/drm/omapdrm/omap_encoder.c | 3 ++ 4 files changed, 64 insertions(+), 22 deletions(-)
If it's not too late, it'd be nice to get these two fixes for 3.12.
Tomi