Skip to contentSkip to conversation

drm/amdgpu/dc: Simplify drm_crtc_state::active checks

PATCH Applied Michel Dänzer 4 participants 8 messages Jul 22, 2020 – Aug 19, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu/dc: Simplify drm_crtc_state::active checks

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -13
index 312c543b258f..dabef307a74f 100644
@@ -3415,21 +3415,12 @@ static bool modeset_required(struct drm_crtc_state *crtc_state,
 			     struct dc_stream_state *new_stream,
 			     struct dc_stream_state *old_stream)
 {
-	if (!drm_atomic_crtc_needs_modeset(crtc_state))
-		return false;
-
-	if (!crtc_state->enable)
-		return false;
-
-	return crtc_state->active;
+	return crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state);
 }
 
 static bool modereset_required(struct drm_crtc_state *crtc_state)
 {
-	if (!drm_atomic_crtc_needs_modeset(crtc_state))
-		return false;
-
-	return !crtc_state->enable || !crtc_state->active;
+	return !crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state);
 }
 
 static void amdgpu_dm_encoder_destroy(struct drm_encoder *encoder)
@@ -8108,8 +8099,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
 	 * We want to do dc stream updates that do not require a
 	 * full modeset below.
 	 */
-	if (!(enable && aconnector && new_crtc_state->enable &&
-	      new_crtc_state->active))
+	if (!(enable && aconnector && new_crtc_state->active))
 		return 0;
 	/*
 	 * Given above conditions, the dc state cannot be NULL because:
Signature · 6 lines
2.28.0.rc0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Patch itself is good, above just an idea for another patch on top.

Quoted 49 lines
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -14
index 312c543b258f..dabef307a74f 100644
@@ -3415,21 +3415,12 @@ static bool modeset_required(struct drm_crtc_state *crtc_state,
                             struct dc_stream_state *new_stream,
                             struct dc_stream_state *old_stream)
 {
-       if (!drm_atomic_crtc_needs_modeset(crtc_state))
-               return false;
-
-       if (!crtc_state->enable)
-               return false;
-
-       return crtc_state->active;
+       return crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state);
 }
 
 static bool modereset_required(struct drm_crtc_state *crtc_state)
 {
-       if (!drm_atomic_crtc_needs_modeset(crtc_state))
-               return false;
-
-       return !crtc_state->enable || !crtc_state->active;
+       return !crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state);
 }
 
 static void amdgpu_dm_encoder_destroy(struct drm_encoder *encoder)
@@ -8108,8 +8099,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
         * We want to do dc stream updates that do not require a
         * full modeset below.
         */
-       if (!(enable && aconnector && new_crtc_state->enable &&
-             new_crtc_state->active))
+       if (!(enable && aconnector && new_crtc_state->active))
                return 0;
        /*
         * Given above conditions, the dc state cannot be NULL because:
--

2.28.0.rc0

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#2 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

Looks fine to me. The check is sufficiently old enough that I don't mind relying on the core for this either.

Quoted 9 lines

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Quoted 3 lines

Patch itself is good, above just an idea for another patch on top.

That sounds like a reasonable idea to me. These are used more as a stream_changed / stream_removed flag, but I don't think these helpers really need to exist at all.

That could come as a follow up patch.

Regards,
Nicholas Kazlauskas

Quoted 45 lines
Quoted 45 lines
---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c    | 16 +++-------------
  1 file changed, 3 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -14
index 312c543b258f..dabef307a74f 100644
@@ -3415,21 +3415,12 @@ static bool modeset_required(struct drm_crtc_state *crtc_state,
                              struct dc_stream_state *new_stream,
                              struct dc_stream_state *old_stream)
  {
-       if (!drm_atomic_crtc_needs_modeset(crtc_state))
-               return false;
-
-       if (!crtc_state->enable)
-               return false;
-
-       return crtc_state->active;
+       return crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state);
  }
 
  static bool modereset_required(struct drm_crtc_state *crtc_state)
  {
-       if (!drm_atomic_crtc_needs_modeset(crtc_state))
-               return false;
-
-       return !crtc_state->enable || !crtc_state->active;
+       return !crtc_state->active && drm_atomic_crtc_needs_modeset(crtc_state);
  }
 
  static void amdgpu_dm_encoder_destroy(struct drm_encoder *encoder)
@@ -8108,8 +8099,7 @@ static int dm_update_crtc_state(struct amdgpu_display_manager *dm,
          * We want to do dc stream updates that do not require a
          * full modeset below.
          */
-       if (!(enable && aconnector && new_crtc_state->enable &&
-             new_crtc_state->active))
+       if (!(enable && aconnector && new_crtc_state->active))
                 return 0;
         /*
          * Given above conditions, the dc state cannot be NULL because:
--

2.28.0.rc0

Quoted 7 lines
Quoted 4 lines

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
Quoted 8 lines · Nicholas
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

Quoted 19 lines
Quoted 1 line
Quoted 1 line

Looks fine to me. The check is sufficiently old enough that I don't mind relying on the core for this either.

Quoted 12 lines

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Patch itself is good, above just an idea for another patch on top.

Thanks for the reviews! I assume this will get picked up by a DC developer or Alex/Christian.

Quoted 5 lines

That sounds like a reasonable idea to me. These are used more as a stream_changed / stream_removed flag, but I don't think these helpers really need to exist at all.

That could come as a follow up patch.

Yeah, I'm leaving that to you guys. :)

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#4 lore raw
Quoted 7 lines · Michel Dänzer
Quoted 5 lines · Nicholas
Quoted 4 lines · Daniel Vetter
Quoted 3 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

Looks fine to me. The check is sufficiently old enough that I don't mind relying on the core for this either.

"active implies enabled" has been a hard assumption of atomic from day
1. So should work anywhere you have atomic.
-Daniel

Quoted 31 lines
Quoted 14 lines
Quoted 12 lines

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Patch itself is good, above just an idea for another patch on top.

Thanks for the reviews! I assume this will get picked up by a DC developer or Alex/Christian.

Quoted 5 lines

That sounds like a reasonable idea to me. These are used more as a stream_changed / stream_removed flag, but I don't think these helpers really need to exist at all.

That could come as a follow up patch.

Yeah, I'm leaving that to you guys. :)

--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and X developer

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Applied
#5 lore raw
In reply to Michel Dänzer
Quoted 26 lines · Michel Dänzer
Quoted 24 lines · Nicholas
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

Looks fine to me. The check is sufficiently old enough that I don't mind relying on the core for this either.

Quoted 9 lines

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

Patch itself is good, above just an idea for another patch on top.

Thanks for the reviews! I assume this will get picked up by a DC developer or Alex/Christian.

Applied. Thanks!

Alex

Quoted 11 lines
Quoted 7 lines

That sounds like a reasonable idea to me. These are used more as a stream_changed / stream_removed flag, but I don't think these helpers really need to exist at all.

That could come as a follow up patch.

Yeah, I'm leaving that to you guys. :)

Quoted 7 lines

--
Earthling Michel Dänzer | https://redhat.com
Libre software enthusiast | Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 26 lines · Alex Deucher
Quoted 25 lines · Michel Dänzer
Quoted 24 lines · Nicholas
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

Looks fine to me. The check is sufficiently old enough that I don't mind relying on the core for this either.

Quoted 9 lines

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

Patch itself is good, above just an idea for another patch on top.

Thanks for the reviews! I assume this will get picked up by a DC developer or Alex/Christian.

Applied. Thanks!

Thank you. Can't see it in the DRM changes for 5.9 though.

Signature · 6 lines
Earthling Michel Dänzer               |               https://redhat.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#7 lore raw
Quoted 30 lines · Michel Dänzer
Quoted 28 lines · Alex Deucher
Quoted 27 lines · Michel Dänzer
Quoted 26 lines · Nicholas
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Michel Dänzer

From: Michel Dänzer <[email protected]>

drm_atomic_crtc_check enforces that ::active can only be true if ::enable is as well.

Looks fine to me. The check is sufficiently old enough that I don't mind relying on the core for this either.

Quoted 11 lines

modeset vs modereset is a bit an inglorious name choice ... since this seems to be glue code and not part of core dc, maybe rename to enable_required/disable_required to keep it consistent with the wording atomic helpers use? DC also seems to use reset for a lot of other things already (state reset, like atomic, or gpu reset like drm/scheduler's td_r_), so I think this would also help clarity from a DC perspective.

Patch itself is good, above just an idea for another patch on top.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Quoted 1 line

Thanks for the reviews! I assume this will get picked up by a DC developer or Alex/Christian.

Applied. Thanks!

Thank you. Can't see it in the DRM changes for 5.9 though.

Will show up for 5.10 as it didn't seem critical for 5.9.

Alex
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx