drm/amd/display: fix 64 bit divide in freesync code
Subsystems (3)
Alex Deucher
maintainerPATCH 1/1 drm/amd/display: fix 64 bit divide in freesync code
Use do_div() rather than a a 64 bit divide.
Fixes 3fe5739db48843 ("drm/amd/display: Add flip interval workaround")
Reported-by kernel test robot <[email protected]>
Signed-off-by Alex Deucher <[email protected]>
Cc Angus Wang <[email protected]>
Cc Anthony Koo <[email protected]>
Cc Aric Cyr <[email protected]>
--- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +4 -1
@@ -1230,6 +1230,7 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, {struct core_freesync *core_freesync =NULL ;unsigned int cur_timestamp_in_us; +unsigned long long tmp;if ((mod_freesync ==NULL ) || (stream ==NULL ) || (in_out_vrr ==NULL ))return ;
@@ -1239,7 +1240,9 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,if (in_out_vrr->supported == false)return ; - cur_timestamp_in_us =dm_get_timestamp (core_freesync->dc->ctx)/10 ; + tmp =dm_get_timestamp (core_freesync->dc->ctx); +do_div (tmp,10 ); + cur_timestamp_in_us = tmp; in_out_vrr->flip_interval.vsyncs_between_flip++; in_out_vrr->flip_interval.v_update_timestamp_in_us = cur_timestamp_in_us;
Signature · 1 line
2.35.1
Quoted 25 lines · Alex Deucher
Use
do_div()rather than a a 64 bit divide.Fixes 3fe5739db48843 ("drm/amd/display: Add flip interval workaround")Reported-by kernel test robot <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc Angus Wang <[email protected]>Cc Anthony Koo <[email protected]>Cc Aric Cyr <[email protected]>--- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/modules/freesync/freesync.c +1
-0@@ -1230,6 +1230,7 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, {struct core_freesync *core_freesync =NULL ;unsigned int cur_timestamp_in_us; +unsigned long long tmp;if ((mod_freesync ==NULL ) || (stream ==NULL ) || (in_out_vrr ==NULL ))return ;
drivers/gpu/drm/amd/display/modules/freesync/freesync.c void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, · line 1245
Quoted 7 lines
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +3
-1@@ -1239,7 +1240,9 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,if (in_out_vrr->supported == false)return ; - cur_timestamp_in_us =dm_get_timestamp (core_freesync->dc->ctx)/10 ; + tmp =dm_get_timestamp (core_freesync->dc->ctx); +do_div (tmp,10 ); + cur_timestamp_in_us = tmp;
Any reason not to use
cur_timestamp_in_us = div_u64(dm_get_timestamp(core_freesync->dc->ctx), 10)
and save a variable?
Quoted 6 lines
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +0
-0in_out_vrr->flip_interval.vsyncs_between_flip++; in_out_vrr->flip_interval.v_update_timestamp_in_us = cur_timestamp_in_us;Signature · 1 line
2.35.1
Quoted 37 lines · Nathan Chancellor
Quoted 25 lines · Alex Deucher
Use
do_div()rather than a a 64 bit divide.Fixes 3fe5739db48843 ("drm/amd/display: Add flip interval workaround")Reported-by kernel test robot <[email protected]>Signed-off-by Alex Deucher <[email protected]>Cc Angus Wang <[email protected]>Cc Anthony Koo <[email protected]>Cc Aric Cyr <[email protected]>--- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/gpu/drm/amd/display/modules/freesync/freesync.c +1
-0@@ -1230,6 +1230,7 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, {struct core_freesync *core_freesync =NULL ;unsigned int cur_timestamp_in_us; +unsigned long long tmp;if ((mod_freesync ==NULL ) || (stream ==NULL ) || (in_out_vrr ==NULL ))return ;drivers/gpu/drm/amd/display/modules/freesync/freesync.c void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync, · line 1245
Quoted 7 lines
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +3
-1@@ -1239,7 +1240,9 @@ void mod_freesync_handle_v_update(struct mod_freesync *mod_freesync,if (in_out_vrr->supported == false)return ; - cur_timestamp_in_us =dm_get_timestamp (core_freesync->dc->ctx)/10 ; + tmp =dm_get_timestamp (core_freesync->dc->ctx); +do_div (tmp,10 ); + cur_timestamp_in_us = tmp;Any reason not to use
Quoted 3 lines
cur_timestamp_in_us=div_u64(dm_get_timestamp(core_freesync->dc->ctx), 10)and save a variable?
I can do that.
Alex
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/display/modules/freesync/freesync.c +0
-1in_out_vrr->flip_interval.vsyncs_between_flip++; in_out_vrr->flip_interval.v_update_timestamp_in_us = cur_timestamp_in_us; --2.35.1