mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: Fix unsigned expression compared with zero
@ 2022-07-06  6:39 Zhongjun Tan
  2022-07-07 18:22 ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Zhongjun Tan @ 2022-07-06  6:39 UTC (permalink / raw)
  To: harry.wentland, sunpeng.li, Rodrigo.Siqueira, alexander.deucher,
	christian.koenig, Xinhui.Pan, airlied, daniel, bas, cai.huoqing
  Cc: amd-gfx, dri-devel, linux-kernel, Zhongjun Tan

From: Zhongjun Tan <tanzhongjun@coolpad.com>

Fix unsigned expression compared with zero

Signed-off-by: Zhongjun Tan <tanzhongjun@coolpad.com>
---
 .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
index 548cdef8a8ad..21e4af38b8c1 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
@@ -244,8 +244,8 @@ static void handle_det_buf_split(struct display_mode_lib *mode_lib,
 	bool req128_c = false;
 	bool surf_linear = (pipe_src_param->sw_mode == dm_sw_linear);
 	bool surf_vert = (pipe_src_param->source_scan == dm_vert);
-	unsigned int log2_swath_height_l = 0;
-	unsigned int log2_swath_height_c = 0;
+	int log2_swath_height_l = 0;
+	int log2_swath_height_c = 0;
 	unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024;
 
 	full_swath_bytes_packed_l = rq_param->misc.rq_l.full_swath_bytes;
-- 
2.29.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amd/display: Fix unsigned expression compared with zero
  2022-07-06  6:39 [PATCH] drm/amd/display: Fix unsigned expression compared with zero Zhongjun Tan
@ 2022-07-07 18:22 ` Alex Deucher
  2022-07-07 20:38   ` Harry Wentland
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Deucher @ 2022-07-07 18:22 UTC (permalink / raw)
  To: Zhongjun Tan, Wentland, Harry
  Cc: Leo (Sunpeng) Li, Siqueira, Rodrigo, Deucher, Alexander,
	Christian Koenig, xinhui pan, Dave Airlie, Daniel Vetter,
	Bas Nieuwenhuizen, cai.huoqing, Zhongjun Tan,
	Maling list - DRI developers, amd-gfx list, LKML

On Wed, Jul 6, 2022 at 3:41 AM Zhongjun Tan <hbut_tan@163.com> wrote:
>
> From: Zhongjun Tan <tanzhongjun@coolpad.com>
>
> Fix unsigned expression compared with zero
>
> Signed-off-by: Zhongjun Tan <tanzhongjun@coolpad.com>
> ---
>  .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
> index 548cdef8a8ad..21e4af38b8c1 100644
> --- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
> +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
> @@ -244,8 +244,8 @@ static void handle_det_buf_split(struct display_mode_lib *mode_lib,
>         bool req128_c = false;
>         bool surf_linear = (pipe_src_param->sw_mode == dm_sw_linear);
>         bool surf_vert = (pipe_src_param->source_scan == dm_vert);
> -       unsigned int log2_swath_height_l = 0;
> -       unsigned int log2_swath_height_c = 0;
> +       int log2_swath_height_l = 0;
> +       int log2_swath_height_c = 0;

@Wentland, Harry Can you comment on the required range needed for
these integers?  Maybe it would be better to just drop the comparisons
with 0.

Alex

>         unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024;
>
>         full_swath_bytes_packed_l = rq_param->misc.rq_l.full_swath_bytes;
> --
> 2.29.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amd/display: Fix unsigned expression compared with zero
  2022-07-07 18:22 ` Alex Deucher
@ 2022-07-07 20:38   ` Harry Wentland
  2022-07-07 20:45     ` Alex Deucher
  0 siblings, 1 reply; 4+ messages in thread
From: Harry Wentland @ 2022-07-07 20:38 UTC (permalink / raw)
  To: Alex Deucher, Zhongjun Tan
  Cc: Leo (Sunpeng) Li, Siqueira, Rodrigo, Deucher, Alexander,
	Christian Koenig, xinhui pan, Dave Airlie, Daniel Vetter,
	Bas Nieuwenhuizen, cai.huoqing, Zhongjun Tan,
	Maling list - DRI developers, amd-gfx list, LKML



On 2022-07-07 14:22, Alex Deucher wrote:
> On Wed, Jul 6, 2022 at 3:41 AM Zhongjun Tan <hbut_tan@163.com> wrote:
>>
>> From: Zhongjun Tan <tanzhongjun@coolpad.com>
>>
>> Fix unsigned expression compared with zero
>>
>> Signed-off-by: Zhongjun Tan <tanzhongjun@coolpad.com>
>> ---
>>  .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
>> index 548cdef8a8ad..21e4af38b8c1 100644
>> --- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
>> +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
>> @@ -244,8 +244,8 @@ static void handle_det_buf_split(struct display_mode_lib *mode_lib,
>>         bool req128_c = false;
>>         bool surf_linear = (pipe_src_param->sw_mode == dm_sw_linear);
>>         bool surf_vert = (pipe_src_param->source_scan == dm_vert);
>> -       unsigned int log2_swath_height_l = 0;
>> -       unsigned int log2_swath_height_c = 0;
>> +       int log2_swath_height_l = 0;
>> +       int log2_swath_height_c = 0;
> 
> @Wentland, Harry Can you comment on the required range needed for
> these integers?  Maybe it would be better to just drop the comparisons
> with 0.
> 

I'm not sure I see the problem we're trying to fix.
An unsigned int can be 0, so a x != 0 or x > 0 check
is still a valid check.

Harry

> Alex
> 
>>         unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024;
>>
>>         full_swath_bytes_packed_l = rq_param->misc.rq_l.full_swath_bytes;
>> --
>> 2.29.0
>>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] drm/amd/display: Fix unsigned expression compared with zero
  2022-07-07 20:38   ` Harry Wentland
@ 2022-07-07 20:45     ` Alex Deucher
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2022-07-07 20:45 UTC (permalink / raw)
  To: Harry Wentland
  Cc: Zhongjun Tan, Leo (Sunpeng) Li, Siqueira, Rodrigo, Deucher,
	Alexander, Christian Koenig, xinhui pan, Dave Airlie,
	Daniel Vetter, Bas Nieuwenhuizen, cai.huoqing, Zhongjun Tan,
	Maling list - DRI developers, amd-gfx list, LKML

On Thu, Jul 7, 2022 at 4:38 PM Harry Wentland <harry.wentland@amd.com> wrote:
>
>
>
> On 2022-07-07 14:22, Alex Deucher wrote:
> > On Wed, Jul 6, 2022 at 3:41 AM Zhongjun Tan <hbut_tan@163.com> wrote:
> >>
> >> From: Zhongjun Tan <tanzhongjun@coolpad.com>
> >>
> >> Fix unsigned expression compared with zero
> >>
> >> Signed-off-by: Zhongjun Tan <tanzhongjun@coolpad.com>
> >> ---
> >>  .../gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c | 4 ++--
> >>  1 file changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
> >> index 548cdef8a8ad..21e4af38b8c1 100644
> >> --- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
> >> +++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_rq_dlg_calc_20.c
> >> @@ -244,8 +244,8 @@ static void handle_det_buf_split(struct display_mode_lib *mode_lib,
> >>         bool req128_c = false;
> >>         bool surf_linear = (pipe_src_param->sw_mode == dm_sw_linear);
> >>         bool surf_vert = (pipe_src_param->source_scan == dm_vert);
> >> -       unsigned int log2_swath_height_l = 0;
> >> -       unsigned int log2_swath_height_c = 0;
> >> +       int log2_swath_height_l = 0;
> >> +       int log2_swath_height_c = 0;
> >
> > @Wentland, Harry Can you comment on the required range needed for
> > these integers?  Maybe it would be better to just drop the comparisons
> > with 0.
> >
>
> I'm not sure I see the problem we're trying to fix.
> An unsigned int can be 0, so a x != 0 or x > 0 check
> is still a valid check.

Hmm, you are right.  I swear I had seen a >= 0 check in that code, but
now I can't find it.  Sorry for the noise.

Alex

>
> Harry
>
> > Alex
> >
> >>         unsigned int detile_buf_size_in_bytes = mode_lib->ip.det_buffer_size_kbytes * 1024;
> >>
> >>         full_swath_bytes_packed_l = rq_param->misc.rq_l.full_swath_bytes;
> >> --
> >> 2.29.0
> >>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-07-07 20:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-06  6:39 [PATCH] drm/amd/display: Fix unsigned expression compared with zero Zhongjun Tan
2022-07-07 18:22 ` Alex Deucher
2022-07-07 20:38   ` Harry Wentland
2022-07-07 20:45     ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®