Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13473623ybl; Sun, 29 Dec 2019 12:45:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzk2jblGEEP00U1BL19Lc4psGpgOs7NwKutRjYbA9STf+Wo1x5yTFnl5q2X5vwFd1SsOnw4 X-Received: by 2002:a9d:1c95:: with SMTP id l21mr60754787ota.271.1577652353450; Sun, 29 Dec 2019 12:45:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652353; cv=none; d=google.com; s=arc-20160816; b=xZ2IxihY+K8uFa2sjuUeoWHdpOBVUsLBwgztWOvt21+f7jDEN/o8XRaeQYhMEpW0/O qaTaIFukyWWNLOFrrqxzgwIHgI4mBQNkFSh1mVehNrU3PPO33aLHR+cRTKMP39jirqkz wIA/fXH7uOc1/PfTQMcIeInrztTwgtWNglYEZ/W8ckV/Wd5GaazvNnLF7bgK2B1Ug4my VXjIdpnIaUV8Rg6QchZ12abDrO0TnkvDH2a5wMlLhqU3V2jTJ7Bxx/jPE2pQnRXVnPIR APPChu31ZlXtq1R3/KU0Q4a6rDPPq2+hLWIhMS49RH4kQ5A9vjuOa/nxIAVUrmuLwA8O P+YA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+PM+hWa2jUcSA0L2QOqSryJ30dpTh24FxsqFIdq1Foc=; b=uadsF1S+B7MzSmm3iEV22umPOyW72tkEFyev/4fhS7D/wvoAWHCd1T7FJHdKBGwx+X JVjeaJpjv+ph4/5svHe9P68CLCKntO+BpORLWl32q5x06Tr60RRQXwQoWgAFr5QNXG+P /2s4VcHhutv4/+V2sr5xMs7qAYytixTTYUhiNkFc9TacF3OSlbeebmPLbdqAX6om43gt uRcqFRk0tSY0y9IdZC1HIg3By9z27rdPxmUUxSpaxHa9rDySEOj0S6t/SUkzPOM0K39a 1rODytwGhMjDoVkzumNd0hNUwb/VGRSpFCGNHRDDZKEJV03fSC8noRgsHIqK0O+BmQxe /1Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mvBuMiHf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si20552788oih.206.2019.12.29.12.45.42; Sun, 29 Dec 2019 12:45:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mvBuMiHf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731163AbfL2Rq4 (ORCPT + 99 others); Sun, 29 Dec 2019 12:46:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:56720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731121AbfL2Rqn (ORCPT ); Sun, 29 Dec 2019 12:46:43 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7C64206A4; Sun, 29 Dec 2019 17:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641603; bh=VAktnDucK6425Kb0ZzoykzYzXO+ljRxDcVp+y1r1LN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvBuMiHfaNct3wMozxlebFWnxLzwVX4w7caeT5rCBzSBN6pGpJ9zJ9MRw8lzBF4u7 4pHqOO0FSb91uMwkffgjOnhc86XReQwsY7ZNukyBQXkzYKBnR+TAYYN78eFUam3x93 /BeyzEKNTfBm+ZHZeU6KfUEf5V98l1jU0FtzCxI0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aric Cyr , Anthony Koo , Bhawanpreet Lakha , Alex Deucher , Sasha Levin Subject: [PATCH 5.4 133/434] drm/amd/display: Properly round nominal frequency for SPD Date: Sun, 29 Dec 2019 18:23:06 +0100 Message-Id: <20191229172710.541820093@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aric Cyr [ Upstream commit c59802313e84bede954235b3a5dd0dd5325f49c5 ] [Why] Some displays rely on the SPD verticle frequency maximum value. Must round the calculated refresh rate to the nearest integer. [How] Round the nominal calculated refresh rate to the nearest whole integer. Signed-off-by: Aric Cyr Reviewed-by: Anthony Koo Acked-by: Bhawanpreet Lakha Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/modules/freesync/freesync.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index ec70c9b12e1a..0978c698f0f8 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -743,6 +743,10 @@ void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, nominal_field_rate_in_uhz = mod_freesync_calc_nominal_field_rate(stream); + /* Rounded to the nearest Hz */ + nominal_field_rate_in_uhz = 1000000ULL * + div_u64(nominal_field_rate_in_uhz + 500000, 1000000); + min_refresh_in_uhz = in_config->min_refresh_in_uhz; max_refresh_in_uhz = in_config->max_refresh_in_uhz; @@ -996,14 +1000,13 @@ unsigned long long mod_freesync_calc_nominal_field_rate( const struct dc_stream_state *stream) { unsigned long long nominal_field_rate_in_uhz = 0; + unsigned int total = stream->timing.h_total * stream->timing.v_total; - /* Calculate nominal field rate for stream */ + /* Calculate nominal field rate for stream, rounded up to nearest integer */ nominal_field_rate_in_uhz = stream->timing.pix_clk_100hz / 10; nominal_field_rate_in_uhz *= 1000ULL * 1000ULL * 1000ULL; - nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, - stream->timing.h_total); - nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, - stream->timing.v_total); + + nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, total); return nominal_field_rate_in_uhz; } -- 2.20.1