Commit 06dd1888 authored by Nicholas Kazlauskas's avatar Nicholas Kazlauskas Committed by Alex Deucher

drm/amd/display: Add NULL checks for vblank workqueue

[Why]
If we're running a headless config with 0 links then the vblank
workqueue will be NULL - causing a NULL pointer exception during
any commit.

[How]
Guard access to the workqueue if it's NULL and don't queue or flush
work if it is.
Reported-by: default avatarMike Lothian <mike@fireburn.co.uk>
BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1700
Fixes: 58aa1c50 ("drm/amd/display: Use vblank control events for PSR enable/disable")
Signed-off-by: default avatarNicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: default avatarHarry Wentland <Harry.Wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 8a4d393e
...@@ -6185,21 +6185,23 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable) ...@@ -6185,21 +6185,23 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
return 0; return 0;
#if defined(CONFIG_DRM_AMD_DC_DCN) #if defined(CONFIG_DRM_AMD_DC_DCN)
work = kzalloc(sizeof(*work), GFP_ATOMIC); if (dm->vblank_control_workqueue) {
if (!work) work = kzalloc(sizeof(*work), GFP_ATOMIC);
return -ENOMEM; if (!work)
return -ENOMEM;
INIT_WORK(&work->work, vblank_control_worker); INIT_WORK(&work->work, vblank_control_worker);
work->dm = dm; work->dm = dm;
work->acrtc = acrtc; work->acrtc = acrtc;
work->enable = enable; work->enable = enable;
if (acrtc_state->stream) { if (acrtc_state->stream) {
dc_stream_retain(acrtc_state->stream); dc_stream_retain(acrtc_state->stream);
work->stream = acrtc_state->stream; work->stream = acrtc_state->stream;
} }
queue_work(dm->vblank_control_workqueue, &work->work); queue_work(dm->vblank_control_workqueue, &work->work);
}
#endif #endif
return 0; return 0;
...@@ -8809,7 +8811,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, ...@@ -8809,7 +8811,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
* If PSR or idle optimizations are enabled then flush out * If PSR or idle optimizations are enabled then flush out
* any pending work before hardware programming. * any pending work before hardware programming.
*/ */
flush_workqueue(dm->vblank_control_workqueue); if (dm->vblank_control_workqueue)
flush_workqueue(dm->vblank_control_workqueue);
#endif #endif
bundle->stream_update.stream = acrtc_state->stream; bundle->stream_update.stream = acrtc_state->stream;
...@@ -9144,7 +9147,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state) ...@@ -9144,7 +9147,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
/* if there mode set or reset, disable eDP PSR */ /* if there mode set or reset, disable eDP PSR */
if (mode_set_reset_required) { if (mode_set_reset_required) {
#if defined(CONFIG_DRM_AMD_DC_DCN) #if defined(CONFIG_DRM_AMD_DC_DCN)
flush_workqueue(dm->vblank_control_workqueue); if (dm->vblank_control_workqueue)
flush_workqueue(dm->vblank_control_workqueue);
#endif #endif
amdgpu_dm_psr_disable_all(dm); amdgpu_dm_psr_disable_all(dm);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment