From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 141A82C866 for ; Fri, 24 Nov 2023 14:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IX+vC1sB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C6EBC433AB; Fri, 24 Nov 2023 14:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700835267; bh=gCYp3fozMtWTPwDjLoiWBd29P3vVKaTTmPCxRLhHlGY=; h=Subject:To:Cc:From:Date:From; b=IX+vC1sBEGVIuS//15QZRtTn4RMfJA7SPgal2TNWDHsP/rdFmnh4EGr5nrmYqUJuN Tq1MoVzKVrUnv6RNzP2NTLP22QFWj9KB09YTlXngtGBsXqNuI8TLQNMcIkkYi78JTk feDyPeyCqCldFk8DIJ97weZPVkPN/3Z2AzCK8RWI= Subject: FAILED: patch "[PATCH] drm/amd/display: prevent potential division by zero errors" failed to apply to 5.10-stable tree To: hamza.mahfooz@amd.com,alexander.deucher@amd.com,aurabindo.pillai@amd.com Cc: From: Date: Fri, 24 Nov 2023 14:14:17 +0000 Message-ID: <2023112417-strobe-facial-2d94@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.10-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y git checkout FETCH_HEAD git cherry-pick -x 084f658ece139645d203fa09c77c7f96cb849bb7 # git commit -s git send-email --to '' --in-reply-to '2023112417-strobe-facial-2d94@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^.. Possible dependencies: 084f658ece13 ("drm/amd/display: prevent potential division by zero errors") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 084f658ece139645d203fa09c77c7f96cb849bb7 Mon Sep 17 00:00:00 2001 From: Hamza Mahfooz Date: Tue, 5 Sep 2023 13:27:22 -0400 Subject: [PATCH] drm/amd/display: prevent potential division by zero errors 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") Reviewed-by: Aurabindo Pillai Signed-off-by: Hamza Mahfooz Signed-off-by: Alex Deucher 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; }