[PATCH 09/28] drm/amd/display: Use DRM new-style object iterators.
Harry Wentland
harry.wentland at amd.com
Thu Oct 19 17:46:28 UTC 2017
From: Dave Airlie <airlied at redhat.com>
Use the correct for_each_new/old_* iterators instead of for_each_*
The following functions were considered:
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
v2: Split out typo fixes to a new patch.
v3: Say "functions considered" instead of "affected functions". The
latter implies that changes are made to each.
[airlied: squashed with my hacks]
Signed-off-by: Leo (Sunpeng) Li <sunpeng.li at amd.com>
Reviewed-by: Sun peng Li <Sunpeng.Li at amd.com>
Acked-by: Harry Wentland <Harry.Wentland at amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 42 +++++++++--------------
1 file changed, 16 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 7f14079e3e69..bf232e131db1 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -605,23 +605,15 @@ static int dm_suspend(void *handle)
static 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_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);
@@ -689,7 +681,7 @@ int amdgpu_dm_display_resume(struct amdgpu_device *adev)
}
/* Force mode set in atomic comit */
- for_each_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i)
+ for_each_new_crtc_in_state(adev->dm.cached_state, crtc, crtc_state, i)
crtc_state->active_changed = true;
cached_state = to_dm_atomic_state(adev->dm.cached_state);
@@ -3933,7 +3925,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_state *state,
unsigned long flags;
/* update planes when needed */
- for_each_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;
@@ -4031,7 +4023,7 @@ static int amdgpu_dm_atomic_commit(struct drm_device *dev,
* it will update crtc->dm_crtc_state->stream pointer which is used in
* the ISRs.
*/
- for_each_crtc_in_state(state, crtc, new_state, i) {
+ for_each_new_crtc_in_state(state, crtc, new_state, i) {
struct dm_crtc_state *old_acrtc_state = to_dm_crtc_state(crtc->state);
struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
@@ -4069,7 +4061,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
dm_state = to_dm_atomic_state(state);
/* update changed items */
- for_each_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;
@@ -4161,8 +4153,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
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",
@@ -4187,8 +4178,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
aconnector =
amdgpu_dm_find_first_crtc_matching_connector(
state,
- crtc,
- false);
+ crtc);
if (aconnector) {
conn_state = to_dm_connector_state(aconnector->base.state);
@@ -4223,7 +4213,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
}
/* Handle scaling and undersacn changes*/
- for_each_connector_in_state(state, connector, old_conn_state, i) {
+ 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);
@@ -4278,7 +4268,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
}
/* update planes when needed per crtc*/
- for_each_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)
@@ -4291,7 +4281,7 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
* mark consumed event for drm_atomic_helper_commit_hw_done
*/
spin_lock_irqsave(&adev->ddev->event_lock, flags);
- for_each_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)
@@ -4462,7 +4452,7 @@ static int dm_update_crtcs_state(struct dc *dc,
/*TODO Move this code into dm_crtc_atomic_check once we get rid of dc_validation_set */
/* update changed items */
- for_each_crtc_in_state(state, crtc, crtc_state, i) {
+ for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
struct amdgpu_crtc *acrtc = NULL;
struct amdgpu_dm_connector *aconnector = NULL;
struct drm_connector_state *conn_state = NULL;
@@ -4474,7 +4464,7 @@ static int dm_update_crtcs_state(struct dc *dc,
new_acrtc_state = to_dm_crtc_state(crtc_state);
acrtc = to_amdgpu_crtc(crtc);
- aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc, true);
+ aconnector = amdgpu_dm_find_first_crtc_matching_connector(state, crtc);
/* TODO This hack should go away */
if (aconnector && enable) {
@@ -4755,7 +4745,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
* we should not add it to list of affected planes.
*/
if (state->legacy_cursor_update) {
- for_each_crtc_in_state(state, crtc, crtc_state, i) {
+ for_each_new_crtc_in_state(state, crtc, crtc_state, i) {
if (crtc_state->color_mgmt_changed) {
ret = drm_atomic_add_affected_planes(state, crtc);
if (ret)
@@ -4815,7 +4805,7 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
* new stream into context w\o causing full reset. Need to
* decide how to handle.
*/
- for_each_connector_in_state(state, connector, conn_state, i) {
+ for_each_new_connector_in_state(state, connector, conn_state, i) {
struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
struct dm_connector_state *con_old_state =
to_dm_connector_state(aconnector->base.state);
--
2.14.1
More information about the amd-gfx
mailing list