* [PATCH 1/4] drm/amd/display: Use min()/max() macros in dcn_calc_math
2023-01-14 21:18 [PATCH 0/4] drm/amd/display: Use min()/max() helper macros Deepak R Varma
@ 2023-01-14 21:19 ` Deepak R Varma
2023-01-14 21:20 ` Deepak R Varma
2023-01-14 21:20 ` [PATCH 2/4] drm/amd/display: dcn20: Use min()/max() helper macros Deepak R Varma
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Deepak R Varma @ 2023-01-14 21:19 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, dri-devel, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar
Use the standard min() / max() helper macros instead of direct variable
comparison using if/else blocks or ternary operator. Change identified
using minmax.cocci Coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
.../gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
index cac72413a097..81629f3715d3 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
@@ -52,12 +52,12 @@ float dcn_bw_min2(const float arg1, const float arg2)
return arg2;
if (isNaN(arg2))
return arg1;
- return arg1 < arg2 ? arg1 : arg2;
+ return min(arg1, arg2);
}
unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2)
{
- return arg1 > arg2 ? arg1 : arg2;
+ return max(arg1, arg2);
}
float dcn_bw_max2(const float arg1, const float arg2)
{
@@ -65,7 +65,7 @@ float dcn_bw_max2(const float arg1, const float arg2)
return arg2;
if (isNaN(arg2))
return arg1;
- return arg1 > arg2 ? arg1 : arg2;
+ return max(arg1, arg2);
}
float dcn_bw_floor2(const float arg, const float significance)
@@ -93,12 +93,12 @@ float dcn_bw_ceil2(const float arg, const float significance)
float dcn_bw_max3(float v1, float v2, float v3)
{
- return v3 > dcn_bw_max2(v1, v2) ? v3 : dcn_bw_max2(v1, v2);
+ return max(v3, dcn_bw_max2(v1, v2));
}
float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5)
{
- return dcn_bw_max3(v1, v2, v3) > dcn_bw_max2(v4, v5) ? dcn_bw_max3(v1, v2, v3) : dcn_bw_max2(v4, v5);
+ return max(dcn_bw_max3(v1, v2, v3), dcn_bw_max2(v4, v5));
}
float dcn_bw_pow(float a, float exp)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 1/4] drm/amd/display: Use min()/max() macros in dcn_calc_math
2023-01-14 21:19 ` [PATCH 1/4] drm/amd/display: Use min()/max() macros in dcn_calc_math Deepak R Varma
@ 2023-01-14 21:20 ` Deepak R Varma
0 siblings, 0 replies; 7+ messages in thread
From: Deepak R Varma @ 2023-01-14 21:20 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, dri-devel, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar
Use the standard min() / max() helper macros instead of direct variable
comparison using if/else blocks or ternary operator. Change identified
using minmax.cocci Coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
.../gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
index cac72413a097..81629f3715d3 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c
@@ -52,12 +52,12 @@ float dcn_bw_min2(const float arg1, const float arg2)
return arg2;
if (isNaN(arg2))
return arg1;
- return arg1 < arg2 ? arg1 : arg2;
+ return min(arg1, arg2);
}
unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2)
{
- return arg1 > arg2 ? arg1 : arg2;
+ return max(arg1, arg2);
}
float dcn_bw_max2(const float arg1, const float arg2)
{
@@ -65,7 +65,7 @@ float dcn_bw_max2(const float arg1, const float arg2)
return arg2;
if (isNaN(arg2))
return arg1;
- return arg1 > arg2 ? arg1 : arg2;
+ return max(arg1, arg2);
}
float dcn_bw_floor2(const float arg, const float significance)
@@ -93,12 +93,12 @@ float dcn_bw_ceil2(const float arg, const float significance)
float dcn_bw_max3(float v1, float v2, float v3)
{
- return v3 > dcn_bw_max2(v1, v2) ? v3 : dcn_bw_max2(v1, v2);
+ return max(v3, dcn_bw_max2(v1, v2));
}
float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5)
{
- return dcn_bw_max3(v1, v2, v3) > dcn_bw_max2(v4, v5) ? dcn_bw_max3(v1, v2, v3) : dcn_bw_max2(v4, v5);
+ return max(dcn_bw_max3(v1, v2, v3), dcn_bw_max2(v4, v5));
}
float dcn_bw_pow(float a, float exp)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/4] drm/amd/display: dcn20: Use min()/max() helper macros
2023-01-14 21:18 [PATCH 0/4] drm/amd/display: Use min()/max() helper macros Deepak R Varma
2023-01-14 21:19 ` [PATCH 1/4] drm/amd/display: Use min()/max() macros in dcn_calc_math Deepak R Varma
@ 2023-01-14 21:20 ` Deepak R Varma
2023-01-14 21:21 ` [PATCH 3/4] drm/amd/display: dcn21: " Deepak R Varma
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Deepak R Varma @ 2023-01-14 21:20 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, dri-devel, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar
Use the standard min() / max() helper macros instead of direct variable
comparison using if/else blocks or ternary operator. Change identified
using minmax.cocci Coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
.../gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c | 5 +----
.../gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c | 5 +----
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
index d3b5b6fedf04..850bb0f973d4 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
@@ -626,10 +626,7 @@ static bool CalculatePrefetchSchedule(
dst_y_prefetch_oto = Tpre_oto / LineTime;
- if (dst_y_prefetch_oto < dst_y_prefetch_equ)
- *DestinationLinesForPrefetch = dst_y_prefetch_oto;
- else
- *DestinationLinesForPrefetch = dst_y_prefetch_equ;
+ *DestinationLinesForPrefetch = min(dst_y_prefetch_oto, dst_y_prefetch_equ);
*DestinationLinesForPrefetch = dml_floor(4.0 * (*DestinationLinesForPrefetch + 0.125), 1)
/ 4;
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
index edd098c7eb92..6f4903525acc 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
@@ -686,10 +686,7 @@ static bool CalculatePrefetchSchedule(
dst_y_prefetch_oto = Tpre_oto / LineTime;
- if (dst_y_prefetch_oto < dst_y_prefetch_equ)
- *DestinationLinesForPrefetch = dst_y_prefetch_oto;
- else
- *DestinationLinesForPrefetch = dst_y_prefetch_equ;
+ *DestinationLinesForPrefetch = min(dst_y_prefetch_oto, dst_y_prefetch_equ);
*DestinationLinesForPrefetch = dml_floor(4.0 * (*DestinationLinesForPrefetch + 0.125), 1)
/ 4;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/4] drm/amd/display: dcn21: Use min()/max() helper macros
2023-01-14 21:18 [PATCH 0/4] drm/amd/display: Use min()/max() helper macros Deepak R Varma
2023-01-14 21:19 ` [PATCH 1/4] drm/amd/display: Use min()/max() macros in dcn_calc_math Deepak R Varma
2023-01-14 21:20 ` [PATCH 2/4] drm/amd/display: dcn20: Use min()/max() helper macros Deepak R Varma
@ 2023-01-14 21:21 ` Deepak R Varma
2023-01-14 21:21 ` [PATCH 4/4] drm/amd/display: dcn32: " Deepak R Varma
2023-01-22 18:45 ` [PATCH 0/4] drm/amd/display: " Deepak R Varma
4 siblings, 0 replies; 7+ messages in thread
From: Deepak R Varma @ 2023-01-14 21:21 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, dri-devel, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar
Use the standard min() / max() helper macros instead of direct variable
comparison using if/else blocks or ternary operator. Change identified
using minmax.cocci Coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
.../gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
index 1d84ae50311d..41fb5fddd85d 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
@@ -838,10 +838,7 @@ static bool CalculatePrefetchSchedule(
dst_y_prefetch_equ = dml_floor(4.0 * (dst_y_prefetch_equ + 0.125), 1) / 4.0;
- if (dst_y_prefetch_oto < dst_y_prefetch_equ)
- *DestinationLinesForPrefetch = dst_y_prefetch_oto;
- else
- *DestinationLinesForPrefetch = dst_y_prefetch_equ;
+ *DestinationLinesForPrefetch = min(dst_y_prefetch_oto, dst_y_prefetch_equ);
// Limit to prevent overflow in DST_Y_PREFETCH register
*DestinationLinesForPrefetch = dml_min(*DestinationLinesForPrefetch, 63.75);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 4/4] drm/amd/display: dcn32: Use min()/max() helper macros
2023-01-14 21:18 [PATCH 0/4] drm/amd/display: Use min()/max() helper macros Deepak R Varma
` (2 preceding siblings ...)
2023-01-14 21:21 ` [PATCH 3/4] drm/amd/display: dcn21: " Deepak R Varma
@ 2023-01-14 21:21 ` Deepak R Varma
2023-01-22 18:45 ` [PATCH 0/4] drm/amd/display: " Deepak R Varma
4 siblings, 0 replies; 7+ messages in thread
From: Deepak R Varma @ 2023-01-14 21:21 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, dri-devel, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar
Use the standard min() / max() helper macros instead of direct variable
comparison using if/else blocks or ternary operator. Change identified
using minmax.cocci Coccinelle semantic patch.
Signed-off-by: Deepak R Varma <drv@mailo.com>
---
drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
index f94abd124021..80820f012891 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c
@@ -908,7 +908,7 @@ static bool subvp_drr_schedulable(struct dc *dc, struct dc_state *context, struc
stretched_drr_us = drr_frame_us + mall_region_us + SUBVP_DRR_MARGIN_US;
drr_stretched_vblank_us = (drr_timing->v_total - drr_timing->v_addressable) * drr_timing->h_total /
(double)(drr_timing->pix_clk_100hz * 100) * 1000000 + (stretched_drr_us - drr_frame_us);
- max_vblank_mallregion = drr_stretched_vblank_us > mall_region_us ? drr_stretched_vblank_us : mall_region_us;
+ max_vblank_mallregion = max(drr_stretched_vblank_us, mall_region_us);
/* We consider SubVP + DRR schedulable if the stretched frame duration of the DRR display (i.e. the
* highest refresh rate + margin that can support UCLK P-State switch) passes the static analysis
@@ -999,7 +999,7 @@ static bool subvp_vblank_schedulable(struct dc *dc, struct dc_state *context)
(double)(vblank_timing->pix_clk_100hz * 100) * 1000000;
subvp_active_us = main_timing->v_addressable * main_timing->h_total /
(double)(main_timing->pix_clk_100hz * 100) * 1000000;
- max_vblank_mallregion = vblank_blank_us > mall_region_us ? vblank_blank_us : mall_region_us;
+ max_vblank_mallregion = max(vblank_blank_us, mall_region_us);
// Schedulable if VACTIVE region of the SubVP pipe can fit the MALL prefetch, VBLANK frame time,
// and the max of (VBLANK blanking time, MALL region)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH 0/4] drm/amd/display: Use min()/max() helper macros
2023-01-14 21:18 [PATCH 0/4] drm/amd/display: Use min()/max() helper macros Deepak R Varma
` (3 preceding siblings ...)
2023-01-14 21:21 ` [PATCH 4/4] drm/amd/display: dcn32: " Deepak R Varma
@ 2023-01-22 18:45 ` Deepak R Varma
4 siblings, 0 replies; 7+ messages in thread
From: Deepak R Varma @ 2023-01-22 18:45 UTC (permalink / raw)
To: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, Pan, Xinhui, David Airlie, Daniel Vetter,
amd-gfx, dri-devel, linux-kernel
Cc: Saurabh Singh Sengar, Praveen Kumar
On Sun, Jan 15, 2023 at 02:48:45AM +0530, Deepak R Varma wrote:
> This patch series proposes using standard min() / max() helper macros instead of
> direct variable comparison using the ternary operator or if/else evaluations. I
> have tested the change using a dummy module and similar simulations on my x86
> machine.
Hello,
May I request a review feedback and comments on this patch set please?
Thank you,
./drv
>
> Deepak R Varma (4):
> drm/amd/display: Use min()/max() macros in dcn_calc_math
> drm/amd/display: dcn20: Use min()/max() helper macros
> drm/amd/display: dcn21: Use min()/max() helper macros
> drm/amd/display: dcn32: Use min()/max() helper macros
>
> .../gpu/drm/amd/display/dc/dml/calcs/dcn_calc_math.c | 10 +++++-----
> .../drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c | 5 +----
> .../amd/display/dc/dml/dcn20/display_mode_vba_20v2.c | 5 +----
> .../drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c | 5 +----
> drivers/gpu/drm/amd/display/dc/dml/dcn32/dcn32_fpu.c | 4 ++--
> 5 files changed, 10 insertions(+), 19 deletions(-)
>
> --
> 2.34.1
>
>
>
^ permalink raw reply [flat|nested] 7+ messages in thread