From patchwork Thu Feb 25 14:33:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 387217 Delivered-To: patch@linaro.org Received: by 2002:a02:290e:0:0:0:0:0 with SMTP id p14csp360134jap; Thu, 25 Feb 2021 06:33:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJx/c+efW56Jusn4gftRezGUhT4CcpqdQzN8HwphQq2QStgK76rGvs9Sp/NSD92XbfUNQyPD X-Received: by 2002:a17:90a:b383:: with SMTP id e3mr3635458pjr.53.1614263633292; Thu, 25 Feb 2021 06:33:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614263633; cv=none; d=google.com; s=arc-20160816; b=hQh6VBykOJ3C89l4cmn7eRyJTYOpm8fnUf+sE0sS4bxrZHtc2vwFZF79M8W22ORu+t WoKmzlC98p08se7/6HXDs/osFWmN079jSSDFSC1+LAJnfK9gkZ7DpAwt98WgE8Ahn1pE lPw57vzpfakuj21Tfil+GgHVB/kioSEWyfqR/uXlMPp7MPs1t62MXC6V+5WKjtCbDpPH onYP5jet9y9AwJdNX0V4GENmfAeOylhwBryeSsMfT1/ON+Iv5o686ZCMe8kCzUMHs/7i IMSadOeOl2Wz0qBeyJvaxSnkrUMVEpVox1jJBovAW1co6qHvsx6xq7QjAfnUvHFIYrGg mjyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:message-id:date:subject:to:from :dkim-signature:delivered-to; bh=S2ZnSbs2NavbOQAMtxn6FSTWVxQqVWBvdFMUcub3pCc=; b=JLJViyjXWV+h7vz2oKbLoo4vhBR52xqjpGBOojAGB9rA1VEpq6mb8Ays7sG59ITen7 GnqUGnjDO6u9C9S8XGzLCLAh+Umt5Y9jKc6AFDa7Y7Q9XH5BswzUszRPBjZcUTdQ60Sl WJXYZ9reM6TFHtVfi8DeX0FEOuhX0TdwbEkpWhwpK8Ec8c6UqwTMcDTcFcC/Zza23LTu jTWYciqheIOQK2MnSQOMIAcawKmURwJIqOLNjfg/10gGvHo7MnDs7NGQmLLUjpNKG4PG KDN8/Ewf5NUjHYqy2/Eck+/ycuUYVZktJvS2V/GYpmjHUlOgzKhFv9SoC/15lxGc7ujF /yEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="t3TA/rm0"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id g24si5708267pgb.225.2021.02.25.06.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 06:33:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@kernel.org header.s=k20201202 header.b="t3TA/rm0"; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68F736E0C2; Thu, 25 Feb 2021 14:33:49 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 103C06E0C2; Thu, 25 Feb 2021 14:33:48 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 01B5A64F06; Thu, 25 Feb 2021 14:33:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614263626; bh=Z2omBoic64a0PUjdoMoaR0OyACh47HBLzcZeuDlhik8=; h=From:To:Cc:Subject:Date:From; b=t3TA/rm0jyHEsX+ESwjyhby/pDRYG3VklwLyJpX0uy51tUHf2D1aAk3gFhefN5AmN bP40IIn9Xx242Od2pE3asN7aDZUH4QNpY29v9tmXGvJhaFUkGDNdRngzXXoJwZn/d/ wyjYp/IuzPKbI/AZ4ejInh1oPSKcKx4zpreV6UFKgW5JIV2NyA5eXwlxpj1d5ye6gv QeI/8E9ClzOrLxqMWAVWpLTdisDpKvehJ8gIdeyLWxnyPVCFGsiHX10MqE2zJ1Wagv DAHTSLBQGsYkfnNyggAxWFNuO67gIgl/17ZV/jewll5cdSmd05VjUsJWomko8ZeBWt FPOY8rKDhWuVQ== From: Arnd Bergmann To: Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6?= =?utf-8?q?nig?= , David Airlie , Daniel Vetter , Bindu Ramamurthy , Vladimir Stempen Subject: [PATCH] drm/amd/display: fix 64-bit integer division Date: Thu, 25 Feb 2021 15:33:10 +0100 Message-Id: <20210225143339.3693838-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Rodrigo Siqueira , linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Aurabindo Pillai , Dmytro Laktyushkin , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Arnd Bergmann The new display synchronization code caused a regression on all 32-bit architectures: ld.lld: error: undefined symbol: __aeabi_uldivmod >>> referenced by dce_clock_source.c >>> gpu/drm/amd/display/dc/dce/dce_clock_source.o:(get_pixel_clk_frequency_100hz) in archive drivers/built-in.a ld.lld: error: undefined symbol: __aeabi_ldivmod >>> referenced by dc_resource.c >>> gpu/drm/amd/display/dc/core/dc_resource.o:(resource_are_vblanks_synchronizable) in archive drivers/built-in.a >>> referenced by dc_resource.c >>> gpu/drm/amd/display/dc/core/dc_resource.o:(resource_are_vblanks_synchronizable) in archive drivers/built-in.a >>> referenced by dc_resource.c >>> gpu/drm/amd/display/dc/core/dc_resource.o:(resource_are_vblanks_synchronizable) in archive drivers/built-in.a This is not a fast path, so the use of an explicit div_u64/div_s64 seems appropriate. Fixes: 77a2b7265f20 ("drm/amd/display: Synchronize displays with different timings") Signed-off-by: Arnd Bergmann --- drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 12 ++++++------ .../gpu/drm/amd/display/dc/dce/dce_clock_source.c | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) -- 2.29.2 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index 0241c9d96d7a..49214c59c836 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -441,15 +441,15 @@ bool resource_are_vblanks_synchronizable( if (stream2->timing.pix_clk_100hz*100/stream2->timing.h_total/ stream2->timing.v_total > 60) return false; - frame_time_diff = (int64_t)10000 * + frame_time_diff = div_s64(10000ll * stream1->timing.h_total * stream1->timing.v_total * - stream2->timing.pix_clk_100hz / - stream1->timing.pix_clk_100hz / - stream2->timing.h_total / - stream2->timing.v_total; + stream2->timing.pix_clk_100hz, + stream1->timing.pix_clk_100hz * + stream2->timing.h_total * + stream2->timing.v_total); for (i = 0; i < rr_count; i++) { - int64_t diff = (frame_time_diff * base60_refresh_rates[i]) / 10 - 10000; + int64_t diff = div_s64(frame_time_diff * base60_refresh_rates[i], 10) - 10000; if (diff < 0) diff = -diff; diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index 6f47f9bab5ee..85ed6f2c9647 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c @@ -1013,9 +1013,9 @@ static bool get_pixel_clk_frequency_100hz( * not be programmed equal to DPREFCLK */ modulo_hz = REG_READ(MODULO[inst]); - *pixel_clk_khz = ((uint64_t)clock_hz* - clock_source->ctx->dc->clk_mgr->dprefclk_khz*10)/ - modulo_hz; + *pixel_clk_khz = div_u64((uint64_t)clock_hz * 10 * + clock_source->ctx->dc->clk_mgr->dprefclk_khz, + modulo_hz); } else { /* NOTE: There is agreement with VBIOS here that MODULO is * programmed equal to DPREFCLK, in which case PHASE will be