From patchwork Mon Jul 8 13:52:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 11035153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7664A14C0 for ; Mon, 8 Jul 2019 13:52:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6643C20602 for ; Mon, 8 Jul 2019 13:52:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5744428329; Mon, 8 Jul 2019 13:52:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F25BD20602 for ; Mon, 8 Jul 2019 13:52:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F3D489CD9; Mon, 8 Jul 2019 13:52:50 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.kundenserver.de (mout.kundenserver.de [217.72.192.75]) by gabe.freedesktop.org (Postfix) with ESMTPS id 663E289C33; Mon, 8 Jul 2019 13:52:48 +0000 (UTC) Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.145]) with ESMTPA (Nemesis) id 1MTAJl-1hvicR406R-00UWYx; Mon, 08 Jul 2019 15:52:41 +0200 From: Arnd Bergmann To: Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" , David Airlie , Daniel Vetter Subject: [PATCH] drm/amd/display: avoid 64-bit division Date: Mon, 8 Jul 2019 15:52:08 +0200 Message-Id: <20190708135238.651483-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:52AGef0Lq+dkr8kwjZNMwANHvgY3NRXyfVsWmIJgsnAVhNNRfc6 +DvJqiMs58ht8342jZhhnhohh35rAb8AknH5DtGDOAN2AdFoXCfAFhd66huKJ7KP7xjFEOl 1kTxt89yac00Xl8XVX6DHMdODQQoJ3QXl2KnJ+nrhTWnmYS5yWJD5d1DKT84ZJmlLvczuip 7ZBsA0mrNEjAw8ono+ZwA== X-UI-Out-Filterresults: notjunk:1;V03:K0:LM2YkTiy6w0=:Urgvr2KhXrQJHmnNUZ3Aay HFfPj1p4DzZqha1rGAJgrxsvl9i8srVeglCgb73+oum6M1wTdy8DYfYrTpaFTlP7cev+MOAos kyeL6Eq13c7PwtKIpYMvsJYlLZYlh8gu2FUWblDQa3Ng1tNbBh0jSZZQGnBdzegEvULxEcq7u c0la0Zph5YDkQMp/0h0NCc+2rN7rBiMFvYCcw5WwcIb3KegNA3Upn0RYUxCJ/zwbcWup7PHxE xIOB3orusnst6VaI+JFBAsA3Ks7kljv0AXSpRWYyJ6JUKE9jMXIyr/o5QCDN7MDLN3KQkwSQa 6EF2OKILbWXOGfxMgiYdbQefheqOutolj0llTvM7r6pqMHHmOI7DTKvdSRcuoE8CR04K7knZP XdfDWv8uuYM0ZAmAR4kg5jOez0yZ00rwbL7QEeMyVQBnQAZpfOMlzgXKNSWusQO4/QpKcvEmn 5dRCBC4s+r3HluLBSBrvRCR4Hbp9JAX68dim4X+6XlwZTPv95qtUe7yRhl5wLi32pyKwQroQX QoJDTBHHe/XBKcv7z7pajYSK2k9b6VwYvRV9efBlEPZDVmik3ZInGRj5IA1M1JRxVyANblVZU whrhtyHeR68dVy7SfImFQF4WsLWiahcsOCCbt3jlXsAkb+qbKb72HBUalG8TZNiVbHJjKGvC0 kyZ2JWup0wlDDaCg6Gtg0BkHw3LAxzl05Bx0JK3pj2GEz4sSPk4X3jqV1gl9EhI8RUie7/7ak LSU+6aP8VHZ+Up6UUb4n9RG4490JV7q7/gvsVw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Charlene Liu , Chris Park , Arnd Bergmann , Tony Cheng , David Francis , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Nikola Cornij , Dmytro Laktyushkin , dri-devel@lists.freedesktop.org, Jun Lei , Bhawanpreet Lakha , Anthony Koo Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP On 32-bit architectures, dividing a 64-bit integer in the kernel leads to a link error: ERROR: "__udivdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! ERROR: "__divdi3" [drivers/gpu/drm/amd/amdgpu/amdgpu.ko] undefined! Change the two recently introduced instances to a multiply+shift operation that is also much cheaper on 32-bit architectures. We can do that here, since both of them are really 32-bit numbers that change a few percent. Fixes: bedbbe6af4be ("drm/amd/display: Move link functions from dc to dc_link") Fixes: f18bc4e53ad6 ("drm/amd/display: update calculated bounding box logic for NV") Signed-off-by: Arnd Bergmann Acked-by: Slava Abramov Tested-by: Slava Abramov --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 4 ++-- drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 2 +- 2 files changed, 3 insertions(+), 3 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 c17db5c144aa..8dbf759eba45 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -3072,8 +3072,8 @@ uint32_t dc_link_bandwidth_kbps( * but the difference is minimal and is in a safe direction, * which all works well around potential ambiguity of DP 1.4a spec. */ - long long fec_link_bw_kbps = link_bw_kbps * 970LL; - link_bw_kbps = (uint32_t)(fec_link_bw_kbps / 1000LL); + link_bw_kbps = mul_u64_u32_shr(BIT_ULL(32) * 970LL / 1000, + link_bw_kbps, 32); } #endif diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c index b35327bafbc5..70ac8a95d2db 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c @@ -2657,7 +2657,7 @@ static void update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_ calculated_states[i].dram_speed_mts = uclk_states[i] * 16 / 1000; // FCLK:UCLK ratio is 1.08 - min_fclk_required_by_uclk = ((unsigned long long)uclk_states[i]) * 1080 / 1000000; + min_fclk_required_by_uclk = mul_u64_u32_shr(BIT_ULL(32) * 1080 / 1000000, uclk_states[i], 32); calculated_states[i].fabricclk_mhz = (min_fclk_required_by_uclk < min_dcfclk) ? min_dcfclk : min_fclk_required_by_uclk;