mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 16:53:59 -04:00
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: Mike Lothian <mike@fireburn.co.uk>
BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1700
Fixes: 58aa1c50e5 ("drm/amd/display: Use vblank control events for PSR enable/disable")
Signed-off-by: Nicholas Kazlauskas <nicholas.kazlauskas@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
committed by
Alex Deucher
parent
b04ce53eac
commit
b3a7b268c1
@@ -6024,21 +6024,23 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
|
||||
return 0;
|
||||
|
||||
#if defined(CONFIG_DRM_AMD_DC_DCN)
|
||||
work = kzalloc(sizeof(*work), GFP_ATOMIC);
|
||||
if (!work)
|
||||
return -ENOMEM;
|
||||
if (dm->vblank_control_workqueue) {
|
||||
work = kzalloc(sizeof(*work), GFP_ATOMIC);
|
||||
if (!work)
|
||||
return -ENOMEM;
|
||||
|
||||
INIT_WORK(&work->work, vblank_control_worker);
|
||||
work->dm = dm;
|
||||
work->acrtc = acrtc;
|
||||
work->enable = enable;
|
||||
INIT_WORK(&work->work, vblank_control_worker);
|
||||
work->dm = dm;
|
||||
work->acrtc = acrtc;
|
||||
work->enable = enable;
|
||||
|
||||
if (acrtc_state->stream) {
|
||||
dc_stream_retain(acrtc_state->stream);
|
||||
work->stream = acrtc_state->stream;
|
||||
if (acrtc_state->stream) {
|
||||
dc_stream_retain(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
|
||||
|
||||
return 0;
|
||||
@@ -8648,7 +8650,8 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
|
||||
* If PSR or idle optimizations are enabled then flush out
|
||||
* any pending work before hardware programming.
|
||||
*/
|
||||
flush_workqueue(dm->vblank_control_workqueue);
|
||||
if (dm->vblank_control_workqueue)
|
||||
flush_workqueue(dm->vblank_control_workqueue);
|
||||
#endif
|
||||
|
||||
bundle->stream_update.stream = acrtc_state->stream;
|
||||
@@ -8983,7 +8986,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
|
||||
/* if there mode set or reset, disable eDP PSR */
|
||||
if (mode_set_reset_required) {
|
||||
#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
|
||||
amdgpu_dm_psr_disable_all(dm);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user