drm/stm: Enable RPM during fbdev registration
Subsystems (4)
PATCH 1/1 drm/stm: Enable RPM during fbdev registration
Enable runtime PM before registering the fbdev emulation and disable it afterward, otherwise register access to the LTDC IP during the fbdev emulation registration might hang the system.
The problem happens because RPM is activated at the end of ltdc_load(), but the fbdev emulation registration happens only after that, and ends up calling ltdc_crtc_mode_set_nofb(), which checks whether RPM is active and only if it is not active, calls pm_runtime_get_sync() to enable the clock and so on. If the clock are not enabled, any register access in ltdc_crtc_mode_set_nofb() could hang the platform completely.
This patch makes sure that ltdc_crtc_mode_set_nofb() is called within pm_runtime_get_sync(), so with clock enabled.
--- drivers/gpu/drm/stm/drv.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/stm/drv.c +2 -0
@@ -197,7 +197,9 @@ static int stm_drm_platform_probe(struct platform_device *pdev)if (ret) goto err_put; +pm_runtime_get_sync (ddev->dev);drm_fbdev_generic_setup (ddev,16 ); +pm_runtime_put_sync (ddev->dev);return 0 ;
Signature · 7 lines
2.28.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 14 lines · Marek Vasut
Enable runtime PM before registering the fbdev emulation and disable it afterward, otherwise register access to the LTDC IP during the fbdev emulation registration might hang the system.
The problem happens because RPM is activated at the end of
ltdc_load(), but the fbdev emulation registration happens only after that, and ends up callingltdc_crtc_mode_set_nofb(), which checks whether RPM is active and only if it is not active, callspm_runtime_get_sync()to enable the clock and so on. If the clock are not enabled, any register access inltdc_crtc_mode_set_nofb()could hang the platform completely.This patch makes sure that
ltdc_crtc_mode_set_nofb()is called withinpm_runtime_get_sync(), so with clock enabled.
Quoted 8 lines
Signed-off-by Marek Vasut <[email protected]>Cc Alexandre Torgue <[email protected]>Cc Benjamin Gaignard <[email protected]>Cc Philippe Cornu <[email protected]>Cc Yannick Fertré <[email protected]>
This looks like you're papering over a bug in your modeset code. If userspace later on does a setpar on the fbdev chardev, the exact same thing could happen. You need to fix your modeset code to avoid this, not sprinkle temporary rpm_get/put all over some top level entry points, because you can't even patch those all.
-Daniel
Quoted 25 lines
--- drivers/gpu/drm/stm/drv.c | 2 ++ 1 file changed, 2 insertions(+)drivers/gpu/drm/stm/drv.c +2
-0@@ -197,7 +197,9 @@ static int stm_drm_platform_probe(struct platform_device *pdev)if (ret) goto err_put; +pm_runtime_get_sync (ddev->dev);drm_fbdev_generic_setup (ddev,16 ); +pm_runtime_put_sync (ddev->dev);return 0 ;Signature · 6 lines
2.28.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Marek Vasut
Enable runtime PM before registering the fbdev emulation and disable it afterward, otherwise register access to the LTDC IP during the fbdev emulation registration might hang the system.
The problem happens because RPM is activated at the end of
ltdc_load(), but the fbdev emulation registration happens only after that, and ends up callingltdc_crtc_mode_set_nofb(), which checks whether RPM is active and only if it is not active, callspm_runtime_get_sync()to enable the clock and so on. If the clock are not enabled, any register access inltdc_crtc_mode_set_nofb()could hang the platform completely.This patch makes sure that
ltdc_crtc_mode_set_nofb()is called withinpm_runtime_get_sync(), so with clock enabled.
[...]
Quoted 5 lines
This looks like you're papering over a bug in your modeset code. If userspace later on does a setpar on the fbdev chardev, the exact same thing could happen. You need to fix your modeset code to avoid this, not sprinkle temporary rpm_get/put all over some top level entry points, because you can't even patch those all.
I have a feeling all those pm_runtime_active() checks in the driver might be the root cause of this ? I wonder why the code doesn't use pm_runtime_{get,put}_sync() only when accessing registers. Thoughts?
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Hi Marek,
Quoted 24 lines · Marek Vasut
Quoted 14 lines · Daniel Vetter
Quoted 13 lines · Marek Vasut
Enable runtime PM before registering the fbdev emulation and disable it afterward, otherwise register access to the LTDC IP during the fbdev emulation registration might hang the system.
The problem happens because RPM is activated at the end of
ltdc_load(), but the fbdev emulation registration happens only after that, and ends up callingltdc_crtc_mode_set_nofb(), which checks whether RPM is active and only if it is not active, callspm_runtime_get_sync()to enable the clock and so on. If the clock are not enabled, any register access inltdc_crtc_mode_set_nofb()could hang the platform completely.This patch makes sure that
ltdc_crtc_mode_set_nofb()is called withinpm_runtime_get_sync(), so with clock enabled.[...]
Quoted 5 lines
This looks like you're papering over a bug in your modeset code. If userspace later on does a setpar on the fbdev chardev, the exact same thing could happen. You need to fix your modeset code to avoid this, not sprinkle temporary rpm_get/put all over some top level entry points, because you can't even patch those all.
Quoted 3 lines
I have a feeling all those
pm_runtime_active()checks in the driver might be the root cause of this ? I wonder why the code doesn't use pm_runtime_{get,put}_sync() only when accessing registers. Thoughts?
First line of function ltdc_crtc_mode_set_nofb check the pm_runtime to avoid to access registers without clock enabled.
static void ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc) {
...
if (!pm_runtime_active(ddev->dev)) {
ret = pm_runtime_get_sync(ddev->dev);I test the fb with framebuffer console, & it works fine on my side. Do you test fb on a old kernel?
How can I reproduce your issue?
Best regards
Yannick
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 1 line · Yannick FERTRE
Hi Marek,
Hi,
Quoted 37 lines · Marek Vasut
Quoted 24 lines · Daniel Vetter
Quoted 14 lines · Marek Vasut
Quoted 13 lines
Enable runtime PM before registering the fbdev emulation and disable it afterward, otherwise register access to the LTDC IP during the fbdev emulation registration might hang the system.
The problem happens because RPM is activated at the end of
ltdc_load(), but the fbdev emulation registration happens only after that, and ends up callingltdc_crtc_mode_set_nofb(), which checks whether RPM is active and only if it is not active, callspm_runtime_get_sync()to enable the clock and so on. If the clock are not enabled, any register access inltdc_crtc_mode_set_nofb()could hang the platform completely.This patch makes sure that
ltdc_crtc_mode_set_nofb()is called withinpm_runtime_get_sync(), so with clock enabled.[...]
Quoted 5 lines
This looks like you're papering over a bug in your modeset code. If userspace later on does a setpar on the fbdev chardev, the exact same thing could happen. You need to fix your modeset code to avoid this, not sprinkle temporary rpm_get/put all over some top level entry points, because you can't even patch those all.
Quoted 3 lines
I have a feeling all those
pm_runtime_active()checks in the driver might be the root cause of this ? I wonder why the code doesn't use pm_runtime_{get,put}_sync() only when accessing registers. Thoughts?First line of function
ltdc_crtc_mode_set_nofbcheck thepm_runtimeto avoid to access registers without clock enabled.static void
ltdc_crtc_mode_set_nofb(struct drm_crtc *crtc){
...
Quoted 6 lines
if (!pm_runtime_active(ddev->dev)) { ret = pm_runtime_get_sync(ddev->dev);I test the fb with framebuffer console, & it works fine on my side. Do you test fb on a old kernel?
How can I reproduce your issue?
I observed sporadic hangs and tracked it down to the fbdev registration, which calls this code. Note that pm_runtime_active() here will return 0, because it was already activated in ltdc_load().
My question in reply to Daniel was more geared toward why do we even have all these checks in the driver, wouldn't it be better to just always call pm_runtime_get_sync()/pm_runtime_put_sync() in the code which requires the hardware to be active ?
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel