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

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
Loading
Loading
Loading
Loading
+18 −14
Original line number Diff line number Diff line
@@ -6185,6 +6185,7 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
		return 0;

#if defined(CONFIG_DRM_AMD_DC_DCN)
	if (dm->vblank_control_workqueue) {
		work = kzalloc(sizeof(*work), GFP_ATOMIC);
		if (!work)
			return -ENOMEM;
@@ -6200,6 +6201,7 @@ static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
		}

		queue_work(dm->vblank_control_workqueue, &work->work);
	}
#endif

	return 0;
@@ -8809,6 +8811,7 @@ 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.
		 */
		if (dm->vblank_control_workqueue)
			flush_workqueue(dm->vblank_control_workqueue);
#endif

@@ -9144,6 +9147,7 @@ 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)
			if (dm->vblank_control_workqueue)
				flush_workqueue(dm->vblank_control_workqueue);
#endif
			amdgpu_dm_psr_disable_all(dm);