Skip to content

Commit e4f31ad

Browse files
committed
drm: reset empty state in transitional helpers
Transitional drivers might not have all the state frobbing lined up yet. But since the initial code has been merged a lot more state was added, so we really need this. Cc: Daniel Stone <daniels@collabora.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Reviewed-by: Daniel Stone <daniels@collabora.com> Reported-and-tested-by: John Hunter <zhaojunwang@pku.edu.cn> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent ce14ec2 commit e4f31ad

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

drivers/gpu/drm/drm_crtc_helper.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,10 +927,12 @@ int drm_helper_crtc_mode_set(struct drm_crtc *crtc, struct drm_display_mode *mod
927927

928928
if (crtc->funcs->atomic_duplicate_state)
929929
crtc_state = crtc->funcs->atomic_duplicate_state(crtc);
930-
else if (crtc->state)
930+
else {
931+
if (!crtc->state)
932+
drm_atomic_helper_crtc_reset(crtc);
933+
931934
crtc_state = drm_atomic_helper_crtc_duplicate_state(crtc);
932-
else
933-
crtc_state = kzalloc(sizeof(*crtc_state), GFP_KERNEL);
935+
}
934936

935937
if (!crtc_state)
936938
return -ENOMEM;

drivers/gpu/drm/drm_plane_helper.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,12 @@ int drm_plane_helper_update(struct drm_plane *plane, struct drm_crtc *crtc,
525525

526526
if (plane->funcs->atomic_duplicate_state)
527527
plane_state = plane->funcs->atomic_duplicate_state(plane);
528-
else if (plane->state)
528+
else {
529+
if (!plane->state)
530+
drm_atomic_helper_plane_reset(plane);
531+
529532
plane_state = drm_atomic_helper_plane_duplicate_state(plane);
530-
else
531-
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
533+
}
532534
if (!plane_state)
533535
return -ENOMEM;
534536
plane_state->plane = plane;
@@ -572,10 +574,12 @@ int drm_plane_helper_disable(struct drm_plane *plane)
572574

573575
if (plane->funcs->atomic_duplicate_state)
574576
plane_state = plane->funcs->atomic_duplicate_state(plane);
575-
else if (plane->state)
577+
else {
578+
if (!plane->state)
579+
drm_atomic_helper_plane_reset(plane);
580+
576581
plane_state = drm_atomic_helper_plane_duplicate_state(plane);
577-
else
578-
plane_state = kzalloc(sizeof(*plane_state), GFP_KERNEL);
582+
}
579583
if (!plane_state)
580584
return -ENOMEM;
581585
plane_state->plane = plane;

0 commit comments

Comments
 (0)