From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Chris Park <Chris.Park@amd.com>,
Wenjing Liu <Wenjing.Liu@amd.com>, Eryk Brol <eryk.brol@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Sasha Levin <sashal@kernel.org>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 5.9 08/15] drm/amd/display: Prevent bandwidth overflow
Date: Sat, 19 Dec 2020 22:34:26 -0500 [thread overview]
Message-ID: <20201220033434.2728348-8-sashal@kernel.org> (raw)
In-Reply-To: <20201220033434.2728348-1-sashal@kernel.org>
From: Chris Park <Chris.Park@amd.com>
[ Upstream commit 80089dd8410f356d5104496d5ab71a66a4f4646b ]
[Why]
At very high pixel clock, bandwidth calculation exceeds 32 bit size
and overflow value. This causes the resulting selection of link rate
to be inaccurate.
[How]
Change order of operation and use fixed point to deal with integer
accuracy. Also address bug found when forcing link rate.
Signed-off-by: Chris Park <Chris.Park@amd.com>
Reviewed-by: Wenjing Liu <Wenjing.Liu@amd.com>
Acked-by: Eryk Brol <eryk.brol@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/amd/display/dc/core/dc_link.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index b0f8bfd48d102..462f8b18440b3 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -3394,10 +3394,13 @@ uint32_t dc_bandwidth_in_kbps_from_timing(
{
uint32_t bits_per_channel = 0;
uint32_t kbps;
+ struct fixed31_32 link_bw_kbps;
if (timing->flags.DSC) {
- kbps = (timing->pix_clk_100hz * timing->dsc_cfg.bits_per_pixel);
- kbps = kbps / 160 + ((kbps % 160) ? 1 : 0);
+ link_bw_kbps = dc_fixpt_from_int(timing->pix_clk_100hz);
+ link_bw_kbps = dc_fixpt_div_int(link_bw_kbps, 160);
+ link_bw_kbps = dc_fixpt_mul_int(link_bw_kbps, timing->dsc_cfg.bits_per_pixel);
+ kbps = dc_fixpt_ceil(link_bw_kbps);
return kbps;
}
--
2.27.0
next prev parent reply other threads:[~2020-12-20 3:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-20 3:34 [PATCH AUTOSEL 5.9 01/15] ARM: sunxi: Add machine match for the Allwinner V3 SoC Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 02/15] pNFS/flexfiles: Fix array overflow when flexfiles mirroring is enabled Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 03/15] cfg80211: initialize rekey_data Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 04/15] ethernet: select CONFIG_CRC32 as needed Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 05/15] [SECURITY] fix namespaced fscaps when !CONFIG_SECURITY Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 06/15] lwt: Disable BH too in run_lwt_bpf() Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 07/15] net: stmmac: increase the timeout for dma reset Sasha Levin
2020-12-20 3:34 ` Sasha Levin [this message]
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 09/15] drm/amdkfd: Fix leak in dmabuf import Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 10/15] Input: cros_ec_keyb - send 'scancodes' in addition to key events Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 11/15] selftests/bpf: Fix array access with signed variable test Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 12/15] selftests/bpf: Fix "dubious pointer arithmetic" test Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 13/15] initramfs: fix clang build failure Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 14/15] elfcore: fix building with clang Sasha Levin
2020-12-20 3:34 ` [PATCH AUTOSEL 5.9 15/15] Input: goodix - add upside-down quirk for Teclast X98 Pro tablet Sasha Levin
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=20201220033434.2728348-8-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Chris.Park@amd.com \
--cc=Wenjing.Liu@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=eryk.brol@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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
Powered by JetHome