amdgpu/dc: Use DRM new-style object iterators.
Subsystems (3)
PATCH 1/1 amdgpu/dc: Use DRM new-style object iterators.
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: use for_each_new
- Old from_state_var flag was always choosing the new state
amdgpu_dm_display_resume: use for_each_new
- drm_atomic_helper_duplicate_state is called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: use for_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: use for_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: use for_each_old
- Called after the state was swapped
dm_update_crtcs_state: use for_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: use for_each_new
- Called before the state is swapped
Also fix some typos.
crct -> crtc
undersacn -> underscan
---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leo
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +14 -24
@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector ( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) +struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; -for_each_new_connector_in_state ( - state, - connector, - conn_state, - i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);
@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;
@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;
@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state =to_dm_crtc_state (new_crtcs[i]->base.state); new_stream = new_acrtc_state->stream; - aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",
@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ -for_each_new_connector_in_state (state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ +for_each_old_connector_in_state (state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);
@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);if (new_acrtc_state->stream)
@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)
@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {
@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; -/* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2 -3
@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector); -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector ( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var); +struct drm_crtc *crtc);struct amdgpu_framebuffer ;
Signature · 6 lines
2.7.4 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 1507731880-5843-1-git-send-email-sunpeng.li-5C7GfCeVMHo@public.gmane.org
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 70 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscanSigned-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector ( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) +struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; - for_each_new_connector_in_state(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-8- state, - connector, - conn_state, - i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;
Please assign crtc_from_state here with drm_atomic_get_(new/old)_crtc_state.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3888
Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;
Use for_each_oldnew_*_in_state
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4021
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;
Same.
Quoted 16 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state =to_dm_crtc_state (new_crtcs[i]->base.state); new_stream = new_acrtc_state->stream; - aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4147
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ -for_each_new_connector_in_state (state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ +for_each_old_connector_in_state (state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);
Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4199
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);
Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4214
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)
Same. You're dereferencing crtc->state
Quoted 25 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; -/* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-0@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector);
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version dm_ip_block; · line 234
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-3-struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector ( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var); +struct drm_crtc *crtc);struct amdgpu_framebuffer ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 7dbcabe8-d3de-7cfa-1e4d-b61be746f0cd-VuQAYsv1563Yd54FQh9/[email protected]
Quoted 8 lines
-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Maarten Lankhorst
Sent: Wednesday, October 11, 2017 10:30 AM
To: Li, Sun peng (Leo); [email protected]; [email protected]
Cc: Wentland, Harry; [email protected]
Subject: Re: [PATCH] amdgpu/dc: Use DRM new-style object iterators.
Quoted 34 lines
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 33 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscan
Please split these out as separate changes. I already sent a patch to fix the first one:
https://patchwork.freedesktop.org/patch/181808/
Alex
Quoted 173 lines
Quoted 6 lines
Signed-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
Quoted 7 lines
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38+++++++++--------------
Review
Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)(quoted diff) +0
-0
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.cdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 571
Quoted 8 lines
index 9bfe1f9..9394558 100644
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-1@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 571
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector(
Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-3struct drm_atomic_state *state, - struct drm_crtc *crtc, - bool from_state_var) + struct drm_crtc *crtc) { uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; - for_each_new_connector_in_state(drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-8- state, - connector, - conn_state, - i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;Please assign
crtc_from_statehere with
drm_atomic_get_(new/old)_crtc_state.drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct
Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct
drm_atomic_state*state,drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3888
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;Use for_each_oldnew_*_in_state
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4021
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4118
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state =to_dm_crtc_state (new_crtcs[i]- base.state); new_stream = new_acrtc_state->stream; - aconnector = -amdgpu_dm_find_first_crct_matching_connector(drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4109
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ aconnector =amdgpu_dm_find_first_crtc_matching_connector(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail(
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-2state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit:Failed to find connector for acrtc id:%d "
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4154
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-2"skipping freesync init\n",@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ - for_each_new_connector_in_state(state, connector,
old_conn_state, i) {drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4144
Quoted 2 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0+/* Handle scaling and underscan changes*/ + for_each_old_connector_in_state(state, connector, old_conn_state,i) {
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4145
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0struct amdgpu_dm_connector *aconnector =
to_amdgpu_dm_connector(connector);Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0struct dm_connector_state *con_new_state = to_dm_connector_state(aconnector-base.state);
Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4199
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4214
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)Same. You're dereferencing
crtc->statedrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_update_crtcs_state( · line 4405
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-1@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =
amdgpu_dm_find_first_crct_matching_connector(state, crtc, true);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_update_crtcs_state( · line 4395
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-0+ aconnector =
amdgpu_dm_find_first_crtc_matching_connector(state, crtc);drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c int amdgpu_dm_atomic_check(struct
Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct
drm_device*dev,drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c int amdgpu_dm_atomic_check(struct drm_device *dev,
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (ret) goto fail; -/* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit
Review
Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0* new stream into context w\o causing full reset. Need to * decide how to handle. (quoted diff) +0
-0
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.hdrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version
Quoted 4 lines
index 630e6cd..c1b77bd 100644
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-0@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version
dm_ip_block;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version dm_ip_block;
Quoted 4 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-1void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector); -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version · line 229
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +1
-0+struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector(
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +1
-2struct drm_atomic_state *state, - struct drm_crtc *crtc, - bool from_state_var); + struct drm_crtc *crtc);
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version dm_ip_block; · line 234
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-0struct amdgpu_framebuffer ;_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Leo
maintainerQuoted 70 lines · Maarten Lankhorst
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 69 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscanSigned-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-3@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector ( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) +struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state;
Quoted 12 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-9-for_each_new_connector_in_state ( - state, - connector, - conn_state, - i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;Please assign
crtc_from_statehere with drm_atomic_get_(new/old)_crtc_state.
We're trying to fetch a drm_crtc from a drm_connector_state, I don't think the state getters are applicable here.
Also, the function should really be named 'find_first_connector_matching_crtc'. I'll fix that.
Quoted 17 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3888
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;Use for_each_oldnew_*_in_state
Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4021
Quoted 5 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;Same.
Good points, it seems like there's quite a few places where drm interfaces can be used. Thanks for pointing this out.
Leo
Quoted 83 lines
Quoted 16 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state =to_dm_crtc_state (new_crtcs[i]->base.state); new_stream = new_acrtc_state->stream; - aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4147
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ -for_each_new_connector_in_state (state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ +for_each_old_connector_in_state (state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4199
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4214
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)Same. You're dereferencing
crtc->stateQuoted 34 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; -/* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-3@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector); -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector ( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var); +struct drm_crtc *crtc);
Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version dm_ip_block; · line 234
Quoted 1 line
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-0struct amdgpu_framebuffer ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Op 11-10-17 om 20:55 schreef Leo:
Quoted 84 lines · Maarten Lankhorst
Quoted 72 lines
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 71 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscanSigned-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-5@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) + struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; - for_each_new_connector_in_state( - state, - connector, - conn_state,Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-5- i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;Please assign
crtc_from_statehere with drm_atomic_get_(new/old)_crtc_state.
Quoted 3 lines
We're trying to fetch a
drm_crtcfrom adrm_connector_state, I don't think the state getters are applicable here.Also, the function should really be named '
find_first_connector_matching_crtc'. I'll fix that.
Oh I misunderstood. But in general derefencing $obj->state should be frowned upon. If you ever want to support atomic flip depth > 1, all those references should be gone from your driver, and replaced with get_old/new_state..
Quoted 22 lines
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3887
Quoted 12 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;Use for_each_oldnew_*_in_state
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4020
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;Same.
Quoted 79 lines
Good points, it seems like there's quite a few places where drm interfaces can be used. Thanks for pointing this out.
Leo
Quoted 75 lines
Quoted 14 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state = to_dm_crtc_state(new_crtcs[i]->base.state);new_stream = new_acrtc_state->stream;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4- aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4147
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-1@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ - for_each_new_connector_in_state(state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ + for_each_old_connector_in_state(state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4198
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4213
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)Same. You're dereferencing
crtc->stateQuoted 29 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; - /* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-2@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector); -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var); + struct drm_crtc *crtc);struct amdgpu_framebuffer ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
A message that is not in the archive (sent off-list or not yet received): 2b80ac05-111f-02c7-067a-50b73c5cf3c1-VuQAYsv1563Yd54FQh9/[email protected]
Quoted 85 lines · Maarten Lankhorst
Op 11-10-17 om 20:55 schreef Leo:
Quoted 84 lines · Maarten Lankhorst
Quoted 80 lines
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 68 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscanSigned-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-2@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) + struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; - for_each_new_connector_in_state(drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-8- state, - connector, - conn_state, - i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;Please assign
crtc_from_statehere with drm_atomic_get_(new/old)_crtc_state.
Quoted 5 lines
Quoted 3 lines
We're trying to fetch a
drm_crtcfrom adrm_connector_state, I don't think the state getters are applicable here.Also, the function should really be named '
find_first_connector_matching_crtc'. I'll fix that.Oh I misunderstood. But in general derefencing $obj->state should be frowned upon. If you ever want to support atomic flip depth > 1, all those references should be gone from your driver, and replaced with get_old/new_state..
If I understand correctly this is the forward-looking way of how we get the state now? I still see plenty of $obj->state in i915 and other drivers.
Any objections to doing this as a follow-up patch?
What's atomic flip depth > 1?
Harry
Quoted 93 lines
Quoted 93 lines
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3887
Quoted 12 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;Use for_each_oldnew_*_in_state
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4020
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;Same.
Good points, it seems like there's quite a few places where drm interfaces can be used. Thanks for pointing this out.
Leo
Quoted 67 lines
Quoted 14 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state = to_dm_crtc_state(new_crtcs[i]->base.state);new_stream = new_acrtc_state->stream;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4- aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4147
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-1@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ - for_each_new_connector_in_state(state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ + for_each_old_connector_in_state(state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4198
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4213
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)Same. You're dereferencing
crtc->stateQuoted 23 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; - /* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-0@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector); -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector(
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version dm_ip_block; · line 234
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-2+struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, - struct drm_crtc *crtc, - bool from_state_var); +struct drm_crtc *crtc);struct amdgpu_framebuffer ;
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Op 11-10-17 om 22:40 schreef Harry Wentland:
Quoted 87 lines · Maarten Lankhorst
Quoted 86 lines
Op 11-10-17 om 20:55 schreef Leo:
Quoted 85 lines · Maarten Lankhorst
Quoted 72 lines
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 71 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscanSigned-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-5@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) + struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; - for_each_new_connector_in_state( - state, - connector, - conn_state,Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-5- i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;Please assign
crtc_from_statehere with drm_atomic_get_(new/old)_crtc_state.We're trying to fetch a
drm_crtcfrom adrm_connector_state, I don't think the state getters are applicable here.Also, the function should really be named '
find_first_connector_matching_crtc'. I'll fix that.
Quoted 8 lines
Quoted 2 lines
Oh I misunderstood. But in general derefencing $obj->state should be frowned upon. If you ever want to support atomic flip depth > 1, all those references should be gone from your driver, and replaced with get_old/new_state..
If I understand correctly this is the forward-looking way of how we get the state now? I still see plenty of $obj->state in i915 and other drivers.
Any objections to doing this as a follow-up patch?
What's atomic flip depth > 1?
That we allow multiple uncompleted nonblocking atomic commits to the same crtc, which requires that during commit, $obj->state is not the same as new_$obj_state any more. It can be set to an even newer state, but the current commit has to set the state that is in state->$obj[i].new_state. This can be obtained with either the iterators, or drm_atomic_get_new_$obj_state.
This is why we we got rid of the old iterators, get_existing_state and $obj->state were no longer sufficient for this.
Using drm_atomic_get_old/new_obj_state should be a separate patch, but can be fixed opportunistically.
But something like
for_each_old_crtc_in_state(...) {
new_crtc_state = crtc->state
....
}should definitely be fixed in this patch. It's what the iterators are for. :)
I know i915 is still dereferencing $obj->state, but we're trying to slowly fix these when we come across them. This usually involves passing the correct state object up the callchain, which can be quite deep.
Cheers,
Maarten
Quoted 97 lines
Harry
Quoted 95 lines
Quoted 95 lines
Quoted 12 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3887
Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;Use for_each_oldnew_*_in_state
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4020
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;Same.
Good points, it seems like there's quite a few places where drm interfaces can be used. Thanks for pointing this out.
Leo
Quoted 71 lines
Quoted 14 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state = to_dm_crtc_state(new_crtcs[i]->base.state);new_stream = new_acrtc_state->stream;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4- aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4147
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-1@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ - for_each_new_connector_in_state(state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ + for_each_old_connector_in_state(state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4198
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4213
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)Same. You're dereferencing
crtc->stateQuoted 29 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; - /* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-2@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector); -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var); + struct drm_crtc *crtc);struct amdgpu_framebuffer ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Leo
maintainerQuoted 117 lines · Maarten Lankhorst
Op 11-10-17 om 22:40 schreef Harry Wentland:
Quoted 87 lines · Maarten Lankhorst
Quoted 86 lines
Op 11-10-17 om 20:55 schreef Leo:
Quoted 85 lines · Maarten Lankhorst
Quoted 72 lines
Op 11-10-17 om 16:24 schreef [email protected]:
Quoted 71 lines
From: "Leo (Sunpeng) Li" <[email protected]>
Use the correct for_each_new/old_* iterators instead of for_each_*
List of affected functions:
amdgpu_dm_find_first_crtc_matching_connector: usefor_each_new
- Oldfrom_state_varflag was always choosing the new state
amdgpu_dm_display_resume: usefor_each_new
-drm_atomic_helper_duplicate_stateis called during suspend to cache the state
- It sets 'state' within the state triplet to 'new_state'
amdgpu_dm_commit_planes: usefor_each_old
- Called after the state was swapped (via atomic commit tail)
amdgpu_dm_atomic_commit: usefor_each_new
- Called before the state is swapped
amdgpu_dm_atomic_commit_tail: usefor_each_old
- Called after the state was swapped
dm_update_crtcs_state: usefor_each_new
- Called before the state is swapped (via atomic check)
amdgpu_dm_atomic_check: usefor_each_new
- Called before the state is swappedAlso fix some typos.
crct -> crtc
undersacn -> underscanSigned-off-by Leo (Sunpeng) Li <[email protected]>---
Hi Dave,
This patch goes on top of your fixup for new api's patch. Please feel free to squash them.
Thanks,
Leodrivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 38 +++++++++-------------- drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 5 ++- 2 files changed, 16 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-5@@ -568,25 +568,17 @@ static int dm_suspend(void *handle)return ret; } -struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var) + struct drm_crtc *crtc) {uint32_t i;struct drm_connector_state *conn_state;struct drm_connector *connector;struct drm_crtc *crtc_from_state; - for_each_new_connector_in_state( - state, - connector, - conn_state,Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static int dm_suspend(void *handle) · line 581
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-5- i) { - crtc_from_state = - from_state_var ? - conn_state->crtc : - connector->state->crtc; +for_each_new_connector_in_state (state, connector, conn_state, i) { + crtc_from_state = conn_state->crtc;Please assign
crtc_from_statehere with drm_atomic_get_(new/old)_crtc_state.We're trying to fetch a
drm_crtcfrom adrm_connector_state, I don't think the state getters are applicable here.Also, the function should really be named '
find_first_connector_matching_crtc'. I'll fix that.Quoted 8 lines
Quoted 2 lines
Oh I misunderstood. But in general derefencing $obj->state should be frowned upon. If you ever want to support atomic flip depth > 1, all those references should be gone from your driver, and replaced with get_old/new_state..
If I understand correctly this is the forward-looking way of how we get the state now? I still see plenty of $obj->state in i915 and other drivers.
Any objections to doing this as a follow-up patch?
What's atomic flip depth > 1?
That we allow multiple uncompleted nonblocking atomic commits to the same crtc, which requires that during commit, $obj->state is not the same as new_$obj_state any more. It can be set to an even newer state, but the current commit has to set the state that is in state->$obj[i].new_state. This can be obtained with either the iterators, or drm_atomic_get_new_$obj_state.
This is why we we got rid of the old iterators,
get_existing_stateand $obj->state were no longer sufficient for this.Using drm_atomic_get_old/new_obj_state should be a separate patch, but can be fixed opportunistically.
But something like
for_each_old_crtc_in_state(...) { new_crtc_state = crtc->state .... }
Quoted 8 lines
should definitely be fixed in this patch. It's what the iterators are for. :)
I know i915 is still dereferencing $obj->state, but we're trying to slowly fix these when we come across them. This usually involves passing the correct state object up the callchain, which can be quite deep.
Cheers,
Maarten
Thanks for the clarification.
We're in a similar situation with some of the deeply nested functions, most of which don't take in the state object. That said, there are a few functions lower in the call stack that are eating the correct atomic state (like the ones you've pointed out). We can target those for now, and target more when the opportunity comes.
Leo
Quoted 90 lines
Quoted 90 lines
Harry
Quoted 87 lines
Quoted 87 lines
Quoted 12 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c static void amdgpu_dm_commit_planes(struct drm_atomic_state *state, · line 3887
Quoted 11 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (crtc_from_state == crtc)return to_amdgpu_dm_connector (connector);@@ -3890,7 +3882,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,unsigned long flags;/* update planes when needed */ -for_each_new_plane_in_state (state, plane, old_plane_state, i) { +for_each_old_plane_in_state (state, plane, old_plane_state, i) {struct drm_plane_state *plane_state = plane->state;struct drm_crtc *crtc = plane_state->crtc;struct drm_framebuffer *fb = plane_state->fb;Use for_each_oldnew_*_in_state
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4020
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4024,7 +4016,7 @@ void amdgpu_dm_atomic_commit_tail( dm_state =to_dm_atomic_state (state);/* update changed items */ -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);struct drm_crtc_state *new_state = crtc->state;Same.
Good points, it seems like there's quite a few places where drm interfaces can be used. Thanks for pointing this out.
Leo
Quoted 63 lines
Quoted 14 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0
-0@@ -4113,11 +4105,9 @@ void amdgpu_dm_atomic_commit_tail( new_acrtc_state = to_dm_crtc_state(new_crtcs[i]->base.state);new_stream = new_acrtc_state->stream;drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-4- aconnector = -amdgpu_dm_find_first_crct_matching_connector ( + aconnector =amdgpu_dm_find_first_crtc_matching_connector ( state, - &new_crtcs[i]->base, - false); + &new_crtcs[i]->base);if (!aconnector) { DRM_DEBUG_DRIVER("Atomic commit: Failed to find connector for acrtc id:%d " "skipping freesync init\n",drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4147
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-1@@ -4150,8 +4140,8 @@ void amdgpu_dm_atomic_commit_tail( } } -/* Handle scaling and undersacn changes*/ - for_each_new_connector_in_state(state, connector, old_conn_state, i) { +/* Handle scaling and underscan changes*/ + for_each_old_connector_in_state(state, connector, old_conn_state, i) {struct amdgpu_dm_connector *aconnector =to_amdgpu_dm_connector (connector);struct dm_connector_state *con_new_state =to_dm_connector_state (aconnector->base.state);Same here..
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4198
Quoted 6 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1@@ -4205,7 +4195,7 @@ void amdgpu_dm_atomic_commit_tail( }/* update planes when needed per crtc*/ -for_each_new_crtc_in_state (state, pcrtc, old_crtc_state, j) { +for_each_old_crtc_in_state (state, pcrtc, old_crtc_state, j) { new_acrtc_state =to_dm_crtc_state (pcrtc->state);Same.
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c void amdgpu_dm_atomic_commit_tail( · line 4213
Quoted 9 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1
-1if (new_acrtc_state->stream)@@ -4218,7 +4208,7 @@ void amdgpu_dm_atomic_commit_tail(* mark consumed event for drm_atomic_helper_commit_hw_done */ spin_lock_irqsave (&adev->ddev->event_lock, flags); -for_each_new_crtc_in_state (state, crtc, old_crtc_state, i) { +for_each_old_crtc_in_state (state, crtc, old_crtc_state, i) {struct amdgpu_crtc *acrtc =to_amdgpu_crtc (crtc);if (acrtc->base.state->event)Same. You're dereferencing
crtc->stateQuoted 22 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +2
-0@@ -4402,7 +4392,7 @@ static int dm_update_crtcs_state( new_acrtc_state =to_dm_crtc_state (crtc_state); acrtc =to_amdgpu_crtc (crtc); - aconnector =amdgpu_dm_find_first_crct_matching_connector (state, crtc, true); + aconnector =amdgpu_dm_find_first_crtc_matching_connector (state, crtc);/* TODO This hack should go away */ if (aconnector) {@@ -4715,7 +4705,7 @@ int amdgpu_dm_atomic_check(struct drm_device *dev,if (ret) goto fail; - /* Check scaling and undersacn changes*/ +/* Check scaling and underscan changes*/ /*TODO Removed scaling changes validation due to inability to commit * new stream into context w\o causing full reset. Need to * decide how to handle. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +0
-0@@ -226,10 +226,9 @@ extern const struct amdgpu_ip_block_version dm_ip_block;void amdgpu_dm_update_connector_after_detect (struct amdgpu_dm_connector *aconnector);
Quoted 9 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h extern const struct amdgpu_ip_block_version dm_ip_block; · line 232
Quoted 7 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2
-2-struct amdgpu_dm_connector *amdgpu_dm_find_first_crct_matching_connector( +struct amdgpu_dm_connector *amdgpu_dm_find_first_crtc_matching_connector (struct drm_atomic_state *state, -struct drm_crtc *crtc, -bool from_state_var); + struct drm_crtc *crtc);struct amdgpu_framebuffer ;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel