Skip to contentSkip to conversation

gpu/drm: make crtc check before new_connector circle

PATCH In review Bernard Zhao 2 participants 4 messages Nov 2, 2020

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

PATCH 1/1 gpu/drm: make crtc check before new_connector circle

In function prepare_signaling, crtc check (c==0) is not related with the next new_connector circle, maybe we can put the crtc check just after the crtc circle and before new_connector circle. This change is to make the code to run a bit first.

---
 drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +6 -7
index 25c269bc4681..566110996474 100644
@@ -1182,6 +1182,12 @@ static int prepare_signaling(struct drm_device *dev,
 
 		c++;
 	}
+	/*
+	 * Having this flag means user mode pends on event which will never
+	 * reach due to lack of at least one CRTC for signaling
+	 */
+	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+		return -EINVAL;
 
 	for_each_new_connector_in_state(state, conn, conn_state, i) {
 		struct drm_writeback_connector *wb_conn;
@@ -1220,13 +1226,6 @@ static int prepare_signaling(struct drm_device *dev,
 		conn_state->writeback_job->out_fence = fence;
 	}
 
-	/*
-	 * Having this flag means user mode pends on event which will never
-	 * reach due to lack of at least one CRTC for signaling
-	 */
-	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
-		return -EINVAL;
-
 	return 0;
 }
 
Signature · 1 line
2.29.0
#1 lore raw
Quoted 4 lines · Bernard Zhao

In function prepare_signaling, crtc check (c==0) is not related with the next new_connector circle, maybe we can put the crtc check just after the crtc circle and before new_connector circle. This change is to make the code to run a bit first.

I'm a bit confused here with your explanation, I'm not understanding why you do this change ... Can you pls elaborate? Maybe give an example or something of the problem this patch solves, that often helps.

Thanks, Daniel

Quoted 40 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +6 -7
index 25c269bc4681..566110996474 100644
@@ -1182,6 +1182,12 @@ static int prepare_signaling(struct drm_device *dev,
 
 		c++;
 	}
+	/*
+	 * Having this flag means user mode pends on event which will never
+	 * reach due to lack of at least one CRTC for signaling
+	 */
+	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+		return -EINVAL;
 
 	for_each_new_connector_in_state(state, conn, conn_state, i) {
 		struct drm_writeback_connector *wb_conn;
@@ -1220,13 +1226,6 @@ static int prepare_signaling(struct drm_device *dev,
 		conn_state->writeback_job->out_fence = fence;
 	}
 
-	/*
-	 * Having this flag means user mode pends on event which will never
-	 * reach due to lack of at least one CRTC for signaling
-	 */
-	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
-		return -EINVAL;
-
 	return 0;
 }
 
Signature · 1 line
2.29.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
author
#2 lore raw

From: Daniel Vetter <[email protected]>
Date: 2020-11-02 18:17:24
To: Bernard Zhao <[email protected]>
Cc: Maarten Lankhorst <[email protected]>,Maxime Ripard <[email protected]>,Thomas Zimmermann <[email protected]>,David Airlie <[email protected]>,Daniel Vetter <[email protected]>,[email protected],[email protected],[email protected]

Quoted 10 lines · Bernard Zhao
Quoted 4 lines

In function prepare_signaling, crtc check (c==0) is not related with the next new_connector circle, maybe we can put the crtc check just after the crtc circle and before new_connector circle. This change is to make the code to run a bit first.

I'm a bit confused here with your explanation, I'm not understanding why you do this change ... Can you pls elaborate? Maybe give an example or something of the problem this patch solves, that often helps.

Thanks, Daniel

Hi:

This change is to make the function return error earlier when run into the error branch:
if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))

    return -EINVAL;

There two main FOR circles in this function, and the second FOR circle never changes the if condition("(c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))") variable`s value, like c & arg->flags. So I think maybe we can check this condition before the second for circle, and return the error earlier when run into this error branch.

BR//Bernard

Quoted 45 lines
Quoted 40 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +6 -7
index 25c269bc4681..566110996474 100644
@@ -1182,6 +1182,12 @@ static int prepare_signaling(struct drm_device *dev,
 
 		c++;
 	}
+	/*
+	 * Having this flag means user mode pends on event which will never
+	 * reach due to lack of at least one CRTC for signaling
+	 */
+	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+		return -EINVAL;
 
 	for_each_new_connector_in_state(state, conn, conn_state, i) {
 		struct drm_writeback_connector *wb_conn;
@@ -1220,13 +1226,6 @@ static int prepare_signaling(struct drm_device *dev,
 		conn_state->writeback_job->out_fence = fence;
 	}
 
-	/*
-	 * Having this flag means user mode pends on event which will never
-	 * reach due to lack of at least one CRTC for signaling
-	 */
-	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
-		return -EINVAL;
-
 	return 0;
 }
 
Signature · 1 line
2.29.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#3 lore raw
Quoted 20 lines · Bernard

From: Daniel Vetter <[email protected]>
Date: 2020-11-02 18:17:24
To: Bernard Zhao <[email protected]>
Cc: Maarten Lankhorst <[email protected]>,Maxime Ripard <[email protected]>,Thomas Zimmermann <[email protected]>,David Airlie <[email protected]>,Daniel Vetter <[email protected]>,[email protected],[email protected],[email protected]

Quoted 10 lines · Bernard Zhao
Quoted 4 lines

In function prepare_signaling, crtc check (c==0) is not related with the next new_connector circle, maybe we can put the crtc check just after the crtc circle and before new_connector circle. This change is to make the code to run a bit first.

I'm a bit confused here with your explanation, I'm not understanding why you do this change ... Can you pls elaborate? Maybe give an example or something of the problem this patch solves, that often helps.

Thanks, Daniel

Hi:

Quoted 8 lines

This change is to make the function return error earlier when run into the error branch:
if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))

    return -EINVAL;

There two main FOR circles in this function, and the second FOR circle never changes the if condition("(c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))") variable`s value, like c & arg->flags. So I think maybe we can check this condition before the second for circle, and return the error earlier when run into this error branch.

Ah ok. Makes sense, but this case is only ever hit for bad userspace that got something wrong, so I'm not sure we should optimize for this. And with this we kinda bury this fairly important check in the middle, so I don't think it improves code readability.
-Daniel

Quoted 50 lines

BR//Bernard

Quoted 45 lines
Quoted 40 lines
---
 drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/gpu/drm/drm_atomic_uapi.c +6 -7
index 25c269bc4681..566110996474 100644
@@ -1182,6 +1182,12 @@ static int prepare_signaling(struct drm_device *dev,
 
 		c++;
 	}
+	/*
+	 * Having this flag means user mode pends on event which will never
+	 * reach due to lack of at least one CRTC for signaling
+	 */
+	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
+		return -EINVAL;
 
 	for_each_new_connector_in_state(state, conn, conn_state, i) {
 		struct drm_writeback_connector *wb_conn;
@@ -1220,13 +1226,6 @@ static int prepare_signaling(struct drm_device *dev,
 		conn_state->writeback_job->out_fence = fence;
 	}
 
-	/*
-	 * Having this flag means user mode pends on event which will never
-	 * reach due to lack of at least one CRTC for signaling
-	 */
-	if (c == 0 && (arg->flags & DRM_MODE_PAGE_FLIP_EVENT))
-		return -EINVAL;
-
 	return 0;
 }
 
Signature · 1 line
2.29.0
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel