* re: drm/amd/display: make PSR static screen entry within 30 ms
@ 2020-01-17 13:17 Colin Ian King
2020-01-24 19:23 ` [PATCH] drm/amd/display: Fix psr static frames calculation Harry Wentland
0 siblings, 1 reply; 3+ messages in thread
From: Colin Ian King @ 2020-01-17 13:17 UTC (permalink / raw)
To: Anthony Koo, Harry Wentland, Alex Deucher, Christian König,
David (ChunMing) Zhou, David Airlie, Daniel Vetter,
Nicholas Kazlauskas, amd-gfx, dri-devel, linux-kernel
Hi,
Static analysis with Coverity has detected a division by zero in the
following commit:
commit 5b5abe9526073ccbf3032d27b5864520829cdd9c
Author: Anthony Koo <Anthony.Koo@amd.com>
Date: Mon Dec 9 17:26:34 2019 -0500
drm/amd/display: make PSR static screen entry within 30 ms
Specifically:
unsigned int vsync_rate_hz = 0;
struct dc_static_screen_params params = {0};
/* Calculate number of static frames before generating interrupt to
* enter PSR.
*/
unsigned int frame_time_microsec = 1000000 / vsync_rate_hz;
vsync_rate_hz is zero, and frame_time_microsec is being assigned a value
that is being divided by zero. I'm not sure why this is coded this way
and not sure what the fix is, hence I'm reporting the issue.
Colin
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] drm/amd/display: Fix psr static frames calculation
2020-01-17 13:17 drm/amd/display: make PSR static screen entry within 30 ms Colin Ian King
@ 2020-01-24 19:23 ` Harry Wentland
2020-01-27 19:58 ` Alex Deucher
0 siblings, 1 reply; 3+ messages in thread
From: Harry Wentland @ 2020-01-24 19:23 UTC (permalink / raw)
To: amd-gfx; +Cc: Colin Ian King, Zhan Liu, Roman Li, stable
From: Roman Li <Roman.Li@amd.com>
[Why]
Driver crash with psr feature enabled due to divide-by-zero error.
This is a regression after rework to calculate static screen frame
number entry time.
[How]
Correct order of operations to avoid divide-by-zero.
Cc: Colin Ian King <colin.king@canonical.com>
Fixes: 5b5abe952607 drm/amd/display: make PSR static screen entry within 30 ms
Cc: stable@vger.kernel.org
Signed-off-by: Roman Li <roman.li@amd.com>
Reviewed-by: Zhan Liu <Zhan.Liu@amd.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index eed3ed7180fd..61c36c1520c2 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -8491,7 +8491,6 @@ bool amdgpu_dm_psr_enable(struct dc_stream_state *stream)
/* Calculate number of static frames before generating interrupt to
* enter PSR.
*/
- unsigned int frame_time_microsec = 1000000 / vsync_rate_hz;
// Init fail safe of 2 frames static
unsigned int num_frames_static = 2;
@@ -8506,8 +8505,10 @@ bool amdgpu_dm_psr_enable(struct dc_stream_state *stream)
* Calculate number of frames such that at least 30 ms of time has
* passed.
*/
- if (vsync_rate_hz != 0)
+ if (vsync_rate_hz != 0) {
+ unsigned int frame_time_microsec = 1000000 / vsync_rate_hz;
num_frames_static = (30000 / frame_time_microsec) + 1;
+ }
params.triggers.cursor_update = true;
params.triggers.overlay_update = true;
--
2.25.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/amd/display: Fix psr static frames calculation
2020-01-24 19:23 ` [PATCH] drm/amd/display: Fix psr static frames calculation Harry Wentland
@ 2020-01-27 19:58 ` Alex Deucher
0 siblings, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2020-01-27 19:58 UTC (permalink / raw)
To: Harry Wentland; +Cc: Colin Ian King, for 3.8, Zhan Liu, Roman Li, amd-gfx list
On Fri, Jan 24, 2020 at 2:23 PM Harry Wentland <harry.wentland@amd.com> wrote:
>
> From: Roman Li <Roman.Li@amd.com>
>
> [Why]
> Driver crash with psr feature enabled due to divide-by-zero error.
> This is a regression after rework to calculate static screen frame
> number entry time.
>
> [How]
> Correct order of operations to avoid divide-by-zero.
>
> Cc: Colin Ian King <colin.king@canonical.com>
> Fixes: 5b5abe952607 drm/amd/display: make PSR static screen entry within 30 ms
> Cc: stable@vger.kernel.org
> Signed-off-by: Roman Li <roman.li@amd.com>
> Reviewed-by: Zhan Liu <Zhan.Liu@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index eed3ed7180fd..61c36c1520c2 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -8491,7 +8491,6 @@ bool amdgpu_dm_psr_enable(struct dc_stream_state *stream)
> /* Calculate number of static frames before generating interrupt to
> * enter PSR.
> */
> - unsigned int frame_time_microsec = 1000000 / vsync_rate_hz;
> // Init fail safe of 2 frames static
> unsigned int num_frames_static = 2;
>
> @@ -8506,8 +8505,10 @@ bool amdgpu_dm_psr_enable(struct dc_stream_state *stream)
> * Calculate number of frames such that at least 30 ms of time has
> * passed.
> */
> - if (vsync_rate_hz != 0)
> + if (vsync_rate_hz != 0) {
> + unsigned int frame_time_microsec = 1000000 / vsync_rate_hz;
> num_frames_static = (30000 / frame_time_microsec) + 1;
> + }
>
> params.triggers.cursor_update = true;
> params.triggers.overlay_update = true;
> --
> 2.25.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-01-27 19:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-17 13:17 drm/amd/display: make PSR static screen entry within 30 ms Colin Ian King
2020-01-24 19:23 ` [PATCH] drm/amd/display: Fix psr static frames calculation Harry Wentland
2020-01-27 19:58 ` Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).