drm/amd/display: Simplify same effect if/else blocks
Subsystems (3)
PATCH 1/1 drm/amd/display: Simplify same effect if/else blocks
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using cond_no_effect.cocci Coccinelle semantic patch script.
---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.
drivers/gpu/drm/amd/display/dc/core/dc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +3 -8
@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } - +if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Signature · 1 line
2.34.1
Quoted 11 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.
Preface: I do not know the code.
Perhaps Rodrigo Siqueira made a copy/paste error submitting the code for commit 9114b55fabae ("drm/amd/display: Fix SubVP control flow in the MPO context") as the code prior to this change is identical.
Perhaps one of the false uses should be true or dependent on the interdependent_update_lock state.
drivers/gpu/drm/amd/display/dc/core/dc.c
Quoted 1 line
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-0
[]
drivers/gpu/drm/amd/display/dc/core/dc.c static void commit_planes_for_stream(struct dc *dc, · line 3480
Quoted 12 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } -
Perhaps something like:
if (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock(dc, context, should_lock_all_pipes && dc->hwss.interdependent_update_lock, should_lock_all_pipes, NULL, subvp_prev_use);
Quoted 6 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +3
-0+if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Quoted 13 lines · Joe Perches
Quoted 11 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.
Quoted 8 lines
Preface: I do not know the code.
Perhaps Rodrigo Siqueira made a copy/paste error submitting the code for commit
9114b55fabae("drm/amd/display: Fix SubVP control flow in the MPO context") as the code prior to this change is identical.Perhaps one of the false uses should be true or dependent on the
interdependent_update_lockstate.
Thank you Joe for the recommendation.
Hi Rodrigo,
Can you review and comment on if and what is wrong with your commit?
Thank you,
./drv
Quoted 31 lines
drivers/gpu/drm/amd/display/dc/core/dc.c
Quoted 2 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-0[]
drivers/gpu/drm/amd/display/dc/core/dc.c static void commit_planes_for_stream(struct dc *dc, · line 3480
Quoted 12 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } -Perhaps something like:
if (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock(dc, context, should_lock_all_pipes && dc->hwss.interdependent_update_lock, should_lock_all_pipes, NULL, subvp_prev_use);Quoted 6 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +3
-0+if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Quoted 20 lines · Deepak R Varma
Quoted 19 lines · Joe Perches
Quoted 11 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.Preface: I do not know the code.
Perhaps Rodrigo Siqueira made a copy/paste error submitting the code for commit
9114b55fabae("drm/amd/display: Fix SubVP control flow in the MPO context") as the code prior to this change is identical.
Quoted 7 lines
Quoted 2 lines
Perhaps one of the false uses should be true or dependent on the
interdependent_update_lockstate.Thank you Joe for the recommendation.
Hi Rodrigo,
Can you review and comment on if and what is wrong with your commit?
Hello Rodrigo, Alex,
Could you please suggest what would be the necessary fix for this typo error?
Thank you,
Deepak.
Quoted 37 lines
Thank you,
./drvQuoted 31 lines
drivers/gpu/drm/amd/display/dc/core/dc.c
Quoted 2 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-0[]
drivers/gpu/drm/amd/display/dc/core/dc.c static void commit_planes_for_stream(struct dc *dc, · line 3480
Quoted 12 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } -Perhaps something like:
if (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock(dc, context, should_lock_all_pipes && dc->hwss.interdependent_update_lock, should_lock_all_pipes, NULL, subvp_prev_use);Quoted 6 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +3
-0+if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Harry Wentland
maintainerQuoted 24 lines · Deepak R Varma
Quoted 23 lines · Deepak R Varma
Quoted 21 lines · Joe Perches
Quoted 11 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.Preface: I do not know the code.
Perhaps Rodrigo Siqueira made a copy/paste error submitting the code for commit
9114b55fabae("drm/amd/display: Fix SubVP control flow in the MPO context") as the code prior to this change is identical.Perhaps one of the false uses should be true or dependent on the
interdependent_update_lockstate.
Quoted 8 lines
Quoted 4 lines
Thank you Joe for the recommendation.
Hi Rodrigo,
Can you review and comment on if and what is wrong with your commit?Hello Rodrigo, Alex,
Could you please suggest what would be the necessary fix for this typo error?
It's not quite a "typo" error. When I look at this code in our internal repo I see a couple missing lock calls here that differ between the two cases. I don't know why this was never ported over and am surprised it doesn't lead to issues.
I would prefer we keep the code as-is for now until this gets sorted.
Harry
Quoted 42 lines
Thank you,
Deepak.Quoted 37 lines
Thank you,
./drvQuoted 31 lines
drivers/gpu/drm/amd/display/dc/core/dc.c
Quoted 2 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-0[]
drivers/gpu/drm/amd/display/dc/core/dc.c static void commit_planes_for_stream(struct dc *dc, · line 3480
Quoted 12 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } -Perhaps something like:
if (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock(dc, context, should_lock_all_pipes && dc->hwss.interdependent_update_lock, should_lock_all_pipes, NULL, subvp_prev_use);Quoted 6 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +3
-0+if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Quoted 36 lines · Harry Wentland
Quoted 24 lines · Deepak R Varma
Quoted 23 lines · Deepak R Varma
Quoted 21 lines · Joe Perches
Quoted 11 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.Preface: I do not know the code.
Perhaps Rodrigo Siqueira made a copy/paste error submitting the code for commit
9114b55fabae("drm/amd/display: Fix SubVP control flow in the MPO context") as the code prior to this change is identical.Perhaps one of the false uses should be true or dependent on the
interdependent_update_lockstate.Quoted 8 lines
Quoted 4 lines
Thank you Joe for the recommendation.
Hi Rodrigo,
Can you review and comment on if and what is wrong with your commit?Hello Rodrigo, Alex,
Could you please suggest what would be the necessary fix for this typo error?
Quoted 5 lines
It's not quite a "typo" error. When I look at this code in our internal repo I see a couple missing lock calls here that differ between the two cases. I don't know why this was never ported over and am surprised it doesn't lead to issues.
I would prefer we keep the code as-is for now until this gets sorted.
Sounds good. Do let me know if I can be of any help.
Deepak.
Quoted 46 lines
Harry
Quoted 42 lines
Thank you,
Deepak.Quoted 37 lines
Thank you,
./drvQuoted 31 lines
drivers/gpu/drm/amd/display/dc/core/dc.c
Quoted 2 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-0[]
drivers/gpu/drm/amd/display/dc/core/dc.c static void commit_planes_for_stream(struct dc *dc, · line 3480
Quoted 12 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } -Perhaps something like:
if (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock(dc, context, should_lock_all_pipes && dc->hwss.interdependent_update_lock, should_lock_all_pipes, NULL, subvp_prev_use);Quoted 6 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +3
-0+if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Quoted 36 lines · Harry Wentland
Quoted 24 lines · Deepak R Varma
Quoted 23 lines · Deepak R Varma
Quoted 21 lines · Joe Perches
Quoted 11 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.Preface: I do not know the code.
Perhaps Rodrigo Siqueira made a copy/paste error submitting the code for commit
9114b55fabae("drm/amd/display: Fix SubVP control flow in the MPO context") as the code prior to this change is identical.Perhaps one of the false uses should be true or dependent on the
interdependent_update_lockstate.Quoted 8 lines
Quoted 4 lines
Thank you Joe for the recommendation.
Hi Rodrigo,
Can you review and comment on if and what is wrong with your commit?Hello Rodrigo, Alex,
Could you please suggest what would be the necessary fix for this typo error?
Quoted 6 lines
It's not quite a "typo" error. When I look at this code in our internal repo I see a couple missing lock calls here that differ between the two cases. I don't know why this was never ported over and am surprised it doesn't lead to issues.
I would prefer we keep the code as-is for now until this gets sorted.
Actually I was wrong. Too many similar-looking snippets in this function made me look at the wrong thing. This change is fine and
Harry
Quoted 45 lines
Harry
Quoted 42 lines
Thank you,
Deepak.Quoted 37 lines
Thank you,
./drvQuoted 31 lines
drivers/gpu/drm/amd/display/dc/core/dc.c
Quoted 2 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-0[]
drivers/gpu/drm/amd/display/dc/core/dc.c static void commit_planes_for_stream(struct dc *dc, · line 3480
Quoted 12 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +0
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } -Perhaps something like:
if (dc->hwss.subvp_pipe_control_lock) dc->hwss.subvp_pipe_control_lock(dc, context, should_lock_all_pipes && dc->hwss.interdependent_update_lock, should_lock_all_pipes, NULL, subvp_prev_use);Quoted 6 lines
drivers/gpu/drm/amd/display/dc/core/dc.c +3
-0+if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Quoted 3 lines · Harry Wentland
Actually I was wrong. Too many similar-looking snippets in this function made me look at the wrong thing. This change is fine and
Reviewed-by Harry Wentland <[email protected].
So why was the change made in the first place?
Please explain commit 9114b55fabae.
Hamza Mahfooz
AppliedQuoted 7 lines · Deepak R Varma
The if / else block code has same effect irrespective of the logical evaluation. Hence, simply the implementation by removing the unnecessary conditional evaluation. While at it, also fix the long line checkpatch complaint. Issue identified using
cond_no_effect.cocciCoccinelle semantic patch script.Signed-off-by Deepak R Varma <[email protected]>
Applied, thanks!
Quoted 30 lines
---
Please note: The proposed change is compile tested only. If there are any inbuilt test cases that I should run for further verification, I will appreciate guidance about it. Thank you.drivers/gpu/drm/amd/display/dc/core/dc.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/gpu/drm/amd/display/dc/core/dc.c +3
-8@@ -3470,14 +3470,9 @@ static void commit_planes_for_stream(struct dc *dc,/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup */ -if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - }else { -if (dc->hwss.subvp_pipe_control_lock) - dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes,NULL , subvp_prev_use); - } - +if (dc->hwss.subvp_pipe_control_lock) + dc->hwss.subvp_pipe_control_lock (dc, context, false, should_lock_all_pipes, +NULL , subvp_prev_use);return ; }
Signature · 1 line
Hamza