mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Aurabindo Pillai <aurabindo.pillai@amd.com>
To: Hamza Mahfooz <hamza.mahfooz@amd.com>, amd-gfx@lists.freedesktop.org
Cc: stable@vger.kernel.org, "Harry Wentland" <harry.wentland@amd.com>,
	"Leo Li" <sunpeng.li@amd.com>,
	"Rodrigo Siqueira" <Rodrigo.Siqueira@amd.com>,
	"Alex Deucher" <alexander.deucher@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>, "Tom Rix" <trix@redhat.com>,
	"Qingqing Zhuo" <qingqing.zhuo@amd.com>,
	"Aric Cyr" <aric.cyr@amd.com>,
	"Austin Zheng" <austin.zheng@amd.com>,
	"Mike Hsieh" <Mike.Hsieh@amd.com>,
	"Leo (Hanghong) Ma" <hanghong.ma@amd.com>,
	"Dillon Varone" <Dillon.Varone@amd.com>,
	"Bayan Zabihiyan" <bayan.zabihiyan@amd.com>,
	"Amanda Liu" <amanda.liu@amd.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/amd/display: prevent potential division by zero errors
Date: Tue, 5 Sep 2023 15:28:00 -0400	[thread overview]
Message-ID: <e523a175-9f83-492e-996c-4a1fc0622149@amd.com> (raw)
In-Reply-To: <20230905185329.26934-1-hamza.mahfooz@amd.com>



On 2023-09-05 14:53, Hamza Mahfooz wrote:
> There are two places in apply_below_the_range() where it's possible for
> a divide by zero error to occur. So, to fix this make sure the divisor
> is non-zero before attempting the computation in both cases.
> 
> Cc: stable@vger.kernel.org
> Link: https://gitlab.freedesktop.org/drm/amd/-/issues/2637
> Fixes: a463b263032f ("drm/amd/display: Fix frames_to_insert math")
> Fixes: ded6119e825a ("drm/amd/display: Reinstate LFC optimization")
> Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
> ---
>   drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
> index dbd60811f95d..ef3a67409021 100644
> --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
> +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c
> @@ -338,7 +338,9 @@ static void apply_below_the_range(struct core_freesync *core_freesync,
>   		 *  - Delta for CEIL: delta_from_mid_point_in_us_1
>   		 *  - Delta for FLOOR: delta_from_mid_point_in_us_2
>   		 */
> -		if ((last_render_time_in_us / mid_point_frames_ceil) < in_out_vrr->min_duration_in_us) {
> +		if (mid_point_frames_ceil &&
> +		    (last_render_time_in_us / mid_point_frames_ceil) <
> +		    in_out_vrr->min_duration_in_us) {
>   			/* Check for out of range.
>   			 * If using CEIL produces a value that is out of range,
>   			 * then we are forced to use FLOOR.
> @@ -385,8 +387,9 @@ static void apply_below_the_range(struct core_freesync *core_freesync,
>   		/* Either we've calculated the number of frames to insert,
>   		 * or we need to insert min duration frames
>   		 */
> -		if (last_render_time_in_us / frames_to_insert <
> -				in_out_vrr->min_duration_in_us){
> +		if (frames_to_insert &&
> +		    (last_render_time_in_us / frames_to_insert) <
> +		    in_out_vrr->min_duration_in_us){
>   			frames_to_insert -= (frames_to_insert > 1) ?
>   					1 : 0;
>   		}


Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>

--

Thanks & Regards,
Jay

      reply	other threads:[~2023-09-05 19:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 18:53 Hamza Mahfooz
2023-09-05 19:28 ` Aurabindo Pillai [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e523a175-9f83-492e-996c-4a1fc0622149@amd.com \
    --to=aurabindo.pillai@amd.com \
    --cc=Dillon.Varone@amd.com \
    --cc=Mike.Hsieh@amd.com \
    --cc=Rodrigo.Siqueira@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amanda.liu@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aric.cyr@amd.com \
    --cc=austin.zheng@amd.com \
    --cc=bayan.zabihiyan@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hamza.mahfooz@amd.com \
    --cc=hanghong.ma@amd.com \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qingqing.zhuo@amd.com \
    --cc=stable@vger.kernel.org \
    --cc=sunpeng.li@amd.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®