gpu/drm: make crtc check before new_connector circle
Subsystems (2)
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
@@ -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
Quoted 4 lines · Bernard Zhao
In function
prepare_signaling, crtc check (c==0) is not related with the nextnew_connectorcircle, maybe we can put the crtc check just after the crtc circle and beforenew_connectorcircle. 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
Signed-off-by Bernard Zhao <[email protected]>--- drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_atomic_uapi.c +6
-7@@ -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
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 nextnew_connectorcircle, maybe we can put the crtc check just after the crtc circle and beforenew_connectorcircle. 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
Signed-off-by Bernard Zhao <[email protected]>--- drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_atomic_uapi.c +6
-7@@ -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.0Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
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 nextnew_connectorcircle, maybe we can put the crtc check just after the crtc circle and beforenew_connectorcircle. 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
Signed-off-by Bernard Zhao <[email protected]>--- drivers/gpu/drm/drm_atomic_uapi.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)drivers/gpu/drm/drm_atomic_uapi.c +6
-7@@ -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.0Signature · 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