drm/drm_atomic: duplicate colorop states if plane color pipeline in use
Subsystems (2)
PATCH v2 1/1 drm/drm_atomic: duplicate colorop states if plane color pipeline in use
For suspend/resume to work correctly, do for colorop state the same we do for plane/crtc/connector states: duplicate the state of colorops in a color pipeline if it's in use by a given plane when suspending and restore cached colorop states when resuming.
---
Changes from v1 (https://lore.kernel.org/dri-devel/[email protected]/):
- keep the object hierarchy (Chaitanya)
- add r-b from Harry, Alex H. and Chaitanya (pending to confirm)
Chaitanya,
I kept the fix for unused-variable warning together because the warning only appears with this new usage of for_each_new_colorop_in_state() in drm_atomic_helper_commit_duplicated_state() here. Let me know if you don't agree with this approach.
Melissa
--- drivers/gpu/drm/drm_atomic_helper.c | 12 ++++++++++++ include/drm/drm_atomic.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_atomic_helper.c +12 -0
@@ -3751,6 +3751,13 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev, err =PTR_ERR (plane_state); goto free; } + +if (plane_state->color_pipeline) { + err =drm_atomic_add_affected_colorops (state, plane); +if (err) + goto free; + } + }drm_connector_list_iter_begin (dev, &conn_iter);
@@ -3856,6 +3863,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,int i, ret;struct drm_plane *plane;struct drm_plane_state *new_plane_state; +struct drm_colorop *colorop; +struct drm_colorop_state *new_colorop_state;struct drm_connector *connector;struct drm_connector_state *new_conn_state;struct drm_crtc *crtc;
@@ -3863,6 +3872,9 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) + state->colorops[i].old_state = colorop->state; +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state;
include/drm/drm_atomic.h +2 -1
@@ -1102,7 +1102,8 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);for_each_if ((__state)->colorops[__i].ptr && \ ((colorop) = (__state)->colorops[__i].ptr, \ (void )(colorop)/* Only to avoid unused-but-set-variable warning */ , \ - (new_colorop_state) = (__state)->colorops[__i].new_state,1 )) + (new_colorop_state) = (__state)->colorops[__i].new_state,\ + (void )(new_colorop_state)/* Only to avoid unused-but-set-variable warning */ ,1 ))/** * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update
Signature · 1 line
2.51.0
Quoted 16 lines · Melissa Wen
For suspend/resume to work correctly, do for colorop state the same we do for plane/crtc/connector states: duplicate the state of colorops in a color pipeline if it's in use by a given plane when suspending and restore cached colorop states when resuming.
Fixes 2afc3184f3b3 ("drm/plane: Add COLOR PIPELINE property")Reviewed-by Harry Wentland <[email protected]>Reviewed-by Alex Hung <[email protected]>Reviewed-by Chaitanya Kumar Borah <[email protected]>Signed-off-by Melissa Wen <[email protected]>---
Changes from v1 (https://lore.kernel.org/dri-devel/[email protected]/):
- keep the object hierarchy (Chaitanya)
- add r-b from Harry, Alex H. and Chaitanya (pending to confirm)
Quoted 7 lines
Chaitanya,
I kept the fix for unused-variable warning together because the warning only appears with this new usage of
for_each_new_colorop_in_state()indrm_atomic_helper_commit_duplicated_state()here. Let me know if you don't agree with this approach.
Please go ahead. Just add a "while at it" to the commit message.
Quoted 58 lines
Melissa
--- drivers/gpu/drm/drm_atomic_helper.c | 12 ++++++++++++ include/drm/drm_atomic.h | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +12
-0@@ -3751,6 +3751,13 @@ drm_atomic_helper_duplicate_state(struct drm_device *dev, err =PTR_ERR (plane_state); goto free; } + +if (plane_state->color_pipeline) { + err =drm_atomic_add_affected_colorops (state, plane); +if (err) + goto free; + } + }drm_connector_list_iter_begin (dev, &conn_iter);@@ -3856,6 +3863,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state,int i, ret;struct drm_plane *plane;struct drm_plane_state *new_plane_state; +struct drm_colorop *colorop; +struct drm_colorop_state *new_colorop_state;struct drm_connector *connector;struct drm_connector_state *new_conn_state;struct drm_crtc *crtc;@@ -3863,6 +3872,9 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; +for_each_new_colorop_in_state (state, colorop, new_colorop_state, i) + state->colorops[i].old_state = colorop->state; +for_each_new_plane_in_state (state, plane, new_plane_state, i) state->planes[i].old_state = plane->state;include/drm/drm_atomic.h +2
-1@@ -1102,7 +1102,8 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p);for_each_if ((__state)->colorops[__i].ptr && \ ((colorop) = (__state)->colorops[__i].ptr, \ (void )(colorop)/* Only to avoid unused-but-set-variable warning */ , \ - (new_colorop_state) = (__state)->colorops[__i].new_state,1 )) + (new_colorop_state) = (__state)->colorops[__i].new_state,\ + (void )(new_colorop_state)/* Only to avoid unused-but-set-variable warning */ ,1 ))/** * for_each_oldnew_plane_in_state - iterate over all planes in an atomic update
Melissa Wen
AppliedQuoted 21 lines · Chaitanya Kumar
Quoted 18 lines · Melissa Wen
For suspend/resume to work correctly, do for colorop state the same we do for plane/crtc/connector states: duplicate the state of colorops in a color pipeline if it's in use by a given plane when suspending and restore cached colorop states when resuming.
Fixes 2afc3184f3b3 ("drm/plane: Add COLOR PIPELINE property")Reviewed-by Harry Wentland <[email protected]>Reviewed-by Alex Hung <[email protected]>Reviewed-by Chaitanya Kumar Borah <[email protected]>Signed-off-by Melissa Wen <[email protected]>---
Changes from v1 (https://lore.kernel.org/dri-devel/[email protected]/):
- keep the object hierarchy (Chaitanya)
- add r-b from Harry, Alex H. and Chaitanya (pending to confirm)Chaitanya,
Quoted 7 lines
Quoted 5 lines
I kept the fix for unused-variable warning together because the warning only appears with this new usage of
for_each_new_colorop_in_state()indrm_atomic_helper_commit_duplicated_state()here. Let me know if you don't agree with this approach.Please go ahead. Just add a "while at it" to the commit message.
Applied to drm-misc-fixes with the suggested change in the commit message.
Thanks!
Melissa
Quoted 62 lines
Quoted 61 lines
Melissa
---
drivers/gpu/drm/drm_atomic_helper.c| 12 ++++++++++++ include/drm/drm_atomic.h | 3 ++-2 files changed, 14 insertions(+), 1 deletion(-)drivers/gpu/drm/drm_atomic_helper.c +9
-0@@ -3751,6 +3751,13 @@ drm_atomic_helper_duplicate_state(structdrm_device *dev, err = PTR_ERR(plane_state); goto free; } + + if (plane_state->color_pipeline) { + err = drm_atomic_add_affected_colorops(state, plane); + if (err) + goto free; + } + } drm_connector_list_iter_begin(dev, &conn_iter);@@ -3856,6 +3863,8 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, int i, ret; struct drm_plane *plane; struct drm_plane_state *new_plane_state; + struct drm_colorop *colorop; + struct drm_colorop_state *new_colorop_state; struct drm_connector *connector; struct drm_connector_state *new_conn_state;struct
drm_crtc*crtc;drivers/gpu/drm/drm_atomic_helper.c +2
-0@@ -3863,6 +3872,9 @@ int drm_atomic_helper_commit_duplicated_state(struct drm_atomic_state *state, state->acquire_ctx = ctx; + for_each_new_colorop_in_state(state, colorop, new_colorop_state, i) + state->colorops[i].old_state = colorop->state; + for_each_new_plane_in_state(state, plane, new_plane_state, i) state->planes[i].old_state = plane->state;diff --git
a/include/drm/drm_atomic.hb/include/drm/drm_atomic.hindex0b1b32bcd2bd..96fd32a3e92c100644include/drm/drm_atomic.h +2
-1@@ -1102,7 +1102,8 @@ void drm_state_dump(struct drm_device *dev, struct drm_printer *p); for_each_if ((__state)->colorops[__i].ptr && \ ((colorop) = (__state)->colorops[__i].ptr, \ (void)(colorop) /* Only to avoid unused-but-set-variable warning */, \ - (new_colorop_state) = (__state)->colorops[__i].new_state,1 )) + (new_colorop_state) = (__state)->colorops[__i].new_state,\ + (void)(new_colorop_state) /* Only to avoidunused-but-set-variable warning */, 1))
/**
*for_each_oldnew_plane_in_state- iterate over all planes in an atomic update
Maxime Ripard
maintainerHi Melissa,
Quoted 10 lines · Melissa Wen
For suspend/resume to work correctly, do for colorop state the same we do for plane/crtc/connector states: duplicate the state of colorops in a color pipeline if it's in use by a given plane when suspending and restore cached colorop states when resuming.
Fixes 2afc3184f3b3 ("drm/plane: Add COLOR PIPELINE property")Reviewed-by Harry Wentland <[email protected]>Reviewed-by Alex Hung <[email protected]>Reviewed-by Chaitanya Kumar Borah <[email protected]>Signed-off-by Melissa Wen <[email protected]>
Only slightly related to this patch itself, so this discussion must not block merging this patch.
I've been looking at revamping the state allocation / reset recently and came across the colorop. It's not clear to me if it's something that should be expected to be reset across a suspend/resume cycle or if it's something that should be maintained across that cycle.
What is your opinion on that?
Thanks!
Maxime
Quoted 16 lines · Maxime Ripard
Hi Melissa,
Quoted 10 lines · Melissa Wen
For suspend/resume to work correctly, do for colorop state the same we do for plane/crtc/connector states: duplicate the state of colorops in a color pipeline if it's in use by a given plane when suspending and restore cached colorop states when resuming.
Fixes 2afc3184f3b3 ("drm/plane: Add COLOR PIPELINE property")Reviewed-by Harry Wentland <[email protected]>Reviewed-by Alex Hung <[email protected]>Reviewed-by Chaitanya Kumar Borah <[email protected]>Signed-off-by Melissa Wen <[email protected]>Only slightly related to this patch itself, so this discussion must not block merging this patch.
Quoted 6 lines
I've been looking at revamping the state allocation / reset recently and came across the colorop. It's not clear to me if it's something that should be expected to be reset across a suspend/resume cycle or if it's something that should be maintained across that cycle.
What is your opinion on that?
Hi Maxime,
I understand colorop should follow the same lifecycle of plane, since colorop is associated with a plane and represent the color configuration of a given plane state. So, I think it should be preserved and restored in a suspend/resume cycle.
You mentioned about "revamping state allocation/reset", is there already a public link for this work that I can take a look?
Melissa
Quoted 3 lines
Thanks!
Maxime
Maxime Ripard
maintainerHi Melissa,
Thanks for your answer
Quoted 22 lines · Melissa Wen
Quoted 21 lines · Maxime Ripard
Hi Melissa,
Quoted 10 lines · Melissa Wen
For suspend/resume to work correctly, do for colorop state the same we do for plane/crtc/connector states: duplicate the state of colorops in a color pipeline if it's in use by a given plane when suspending and restore cached colorop states when resuming.
Fixes 2afc3184f3b3 ("drm/plane: Add COLOR PIPELINE property")Reviewed-by Harry Wentland <[email protected]>Reviewed-by Alex Hung <[email protected]>Reviewed-by Chaitanya Kumar Borah <[email protected]>Signed-off-by Melissa Wen <[email protected]>Only slightly related to this patch itself, so this discussion must not block merging this patch.
I've been looking at revamping the state allocation / reset recently and came across the colorop. It's not clear to me if it's something that should be expected to be reset across a suspend/resume cycle or if it's something that should be maintained across that cycle.
Quoted 8 lines
Quoted 1 line
What is your opinion on that?
I understand colorop should follow the same lifecycle of plane, since colorop
is associated with a plane and represent the color configuration of a given plane state.So, I think it should be preserved and restored in a suspend/resume cycle.
Ack :)
Quoted 2 lines
You mentioned about "revamping state allocation/reset", is there already a public link for this work that I can take a look?
Sure, it's there:
https://lore.kernel.org/r/[email protected]
I should send a v2 soon though. Do you want to be in Cc?
Maxime