mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow
@ 2023-09-08  0:32 Abhinav Kumar
  2023-09-08  0:35 ` Dmitry Baryshkov
  0 siblings, 1 reply; 4+ messages in thread
From: Abhinav Kumar @ 2023-09-08  0:32 UTC (permalink / raw)
  To: freedreno, Rob Clark, Abhinav Kumar, Dmitry Baryshkov, Sean Paul,
	Marijn Suijten, David Airlie, Daniel Vetter, Kalyan Thota
  Cc: dri-devel, quic_jesszhan, quic_parellan, nespera, Rob Clark,
	linux-arm-msm, linux-kernel

_dpu_plane_calc_bw() uses integer variables to calculate the bandwidth
used during plane bandwidth calculations. However for high resolution
displays this overflows easily and leads to below errors

[dpu error]crtc83 failed performance check -7

Promote the intermediate variables to u64 to avoid overflow.

Fixes: c33b7c0389e1 ("drm/msm/dpu: add support for clk and bw scaling for display")
Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/32
Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
index ae970af1154f..c6193131beec 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
@@ -118,7 +118,7 @@ static u64 _dpu_plane_calc_bw(const struct dpu_mdss_cfg *catalog,
 	const struct drm_display_mode *mode,
 	struct dpu_sw_pipe_cfg *pipe_cfg)
 {
-	int src_width, src_height, dst_height, fps;
+	u64 src_width, src_height, dst_height, fps;
 	u64 plane_prefill_bw;
 	u64 plane_bw;
 	u32 hw_latency_lines;
-- 
2.40.1


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

* Re: [PATCH] drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow
  2023-09-08  0:32 [PATCH] drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow Abhinav Kumar
@ 2023-09-08  0:35 ` Dmitry Baryshkov
  2023-09-08  0:52   ` Abhinav Kumar
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Baryshkov @ 2023-09-08  0:35 UTC (permalink / raw)
  To: Abhinav Kumar, freedreno, Rob Clark, Sean Paul, Marijn Suijten,
	David Airlie, Daniel Vetter, Kalyan Thota
  Cc: dri-devel, quic_jesszhan, quic_parellan, nespera, Rob Clark,
	linux-arm-msm, linux-kernel

On 08/09/2023 03:32, Abhinav Kumar wrote:
> _dpu_plane_calc_bw() uses integer variables to calculate the bandwidth
> used during plane bandwidth calculations. However for high resolution
> displays this overflows easily and leads to below errors

Can we move the u64 conversion closer to the place where we actually 
need it? Having u64 source width looks very strange.

> 
> [dpu error]crtc83 failed performance check -7
> 
> Promote the intermediate variables to u64 to avoid overflow.
> 
> Fixes: c33b7c0389e1 ("drm/msm/dpu: add support for clk and bw scaling for display")
> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/32
> Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> index ae970af1154f..c6193131beec 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
> @@ -118,7 +118,7 @@ static u64 _dpu_plane_calc_bw(const struct dpu_mdss_cfg *catalog,
>   	const struct drm_display_mode *mode,
>   	struct dpu_sw_pipe_cfg *pipe_cfg)
>   {
> -	int src_width, src_height, dst_height, fps;
> +	u64 src_width, src_height, dst_height, fps;
>   	u64 plane_prefill_bw;
>   	u64 plane_bw;
>   	u32 hw_latency_lines;

-- 
With best wishes
Dmitry


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

* Re: [PATCH] drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow
  2023-09-08  0:35 ` Dmitry Baryshkov
@ 2023-09-08  0:52   ` Abhinav Kumar
  2023-09-08  0:54     ` Dmitry Baryshkov
  0 siblings, 1 reply; 4+ messages in thread
From: Abhinav Kumar @ 2023-09-08  0:52 UTC (permalink / raw)
  To: Dmitry Baryshkov, freedreno, Rob Clark, Sean Paul,
	Marijn Suijten, David Airlie, Daniel Vetter, Kalyan Thota
  Cc: dri-devel, quic_jesszhan, quic_parellan, nespera, Rob Clark,
	linux-arm-msm, linux-kernel



On 9/7/2023 5:35 PM, Dmitry Baryshkov wrote:
> On 08/09/2023 03:32, Abhinav Kumar wrote:
>> _dpu_plane_calc_bw() uses integer variables to calculate the bandwidth
>> used during plane bandwidth calculations. However for high resolution
>> displays this overflows easily and leads to below errors
> 
> Can we move the u64 conversion closer to the place where we actually 
> need it? Having u64 source width looks very strange.
> 

Its this math 
https://gitlab.freedesktop.org/drm/msm/-/blob/msm-next/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c#L139 
which overflows.

So its not just one variable but I can even change this to u32 as that 
also fixes the issue. Let me know if u32 works better.

Perhaps I went too far to go from int to u64.

>>
>> [dpu error]crtc83 failed performance check -7
>>
>> Promote the intermediate variables to u64 to avoid overflow.
>>
>> Fixes: c33b7c0389e1 ("drm/msm/dpu: add support for clk and bw scaling 
>> for display")
>> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/32
>> Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
>> ---
>>   drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>> index ae970af1154f..c6193131beec 100644
>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>> @@ -118,7 +118,7 @@ static u64 _dpu_plane_calc_bw(const struct 
>> dpu_mdss_cfg *catalog,
>>       const struct drm_display_mode *mode,
>>       struct dpu_sw_pipe_cfg *pipe_cfg)
>>   {
>> -    int src_width, src_height, dst_height, fps;
>> +    u64 src_width, src_height, dst_height, fps;
>>       u64 plane_prefill_bw;
>>       u64 plane_bw;
>>       u32 hw_latency_lines;
> 

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

* Re: [PATCH] drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow
  2023-09-08  0:52   ` Abhinav Kumar
@ 2023-09-08  0:54     ` Dmitry Baryshkov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Baryshkov @ 2023-09-08  0:54 UTC (permalink / raw)
  To: Abhinav Kumar, freedreno, Rob Clark, Sean Paul, Marijn Suijten,
	David Airlie, Daniel Vetter, Kalyan Thota
  Cc: dri-devel, quic_jesszhan, quic_parellan, nespera, Rob Clark,
	linux-arm-msm, linux-kernel

On 08/09/2023 03:52, Abhinav Kumar wrote:
> 
> 
> On 9/7/2023 5:35 PM, Dmitry Baryshkov wrote:
>> On 08/09/2023 03:32, Abhinav Kumar wrote:
>>> _dpu_plane_calc_bw() uses integer variables to calculate the bandwidth
>>> used during plane bandwidth calculations. However for high resolution
>>> displays this overflows easily and leads to below errors
>>
>> Can we move the u64 conversion closer to the place where we actually 
>> need it? Having u64 source width looks very strange.
>>
> 
> Its this math 
> https://gitlab.freedesktop.org/drm/msm/-/blob/msm-next/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c#L139 which overflows.
> 
> So its not just one variable but I can even change this to u32 as that 
> also fixes the issue. Let me know if u32 works better.
> 
> Perhaps I went too far to go from int to u64.

I'd prefer to have the u64 conversion around the actual calculations - 
so that we emphasise the issue, not the size of the width / etc.

> 
>>>
>>> [dpu error]crtc83 failed performance check -7
>>>
>>> Promote the intermediate variables to u64 to avoid overflow.
>>>
>>> Fixes: c33b7c0389e1 ("drm/msm/dpu: add support for clk and bw scaling 
>>> for display")
>>> Closes: https://gitlab.freedesktop.org/drm/msm/-/issues/32
>>> Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
>>> ---
>>>   drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c 
>>> b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> index ae970af1154f..c6193131beec 100644
>>> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_plane.c
>>> @@ -118,7 +118,7 @@ static u64 _dpu_plane_calc_bw(const struct 
>>> dpu_mdss_cfg *catalog,
>>>       const struct drm_display_mode *mode,
>>>       struct dpu_sw_pipe_cfg *pipe_cfg)
>>>   {
>>> -    int src_width, src_height, dst_height, fps;
>>> +    u64 src_width, src_height, dst_height, fps;
>>>       u64 plane_prefill_bw;
>>>       u64 plane_bw;
>>>       u32 hw_latency_lines;
>>

-- 
With best wishes
Dmitry


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

end of thread, other threads:[~2023-09-08  0:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-08  0:32 [PATCH] drm/msm/dpu: change _dpu_plane_calc_bw() to use u64 to avoid overflow Abhinav Kumar
2023-09-08  0:35 ` Dmitry Baryshkov
2023-09-08  0:52   ` Abhinav Kumar
2023-09-08  0:54     ` Dmitry Baryshkov

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®