Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1620283ybv; Fri, 21 Feb 2020 00:25:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwOEa7Of6nuqFugRyd5YvzQeEL6C9wIN8l7DXKpPp0X0VTAJ6GSgj7bnwCSglA4dwT69rKN X-Received: by 2002:a9d:760d:: with SMTP id k13mr25975542otl.42.1582273549268; Fri, 21 Feb 2020 00:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582273549; cv=none; d=google.com; s=arc-20160816; b=CKNHjP3HHbVz/zQ47H3ZtNr20w4c3EwbN58QvwTyHvX2V3lADMr3gSMsB8ht5dT/5a FgoXO9tZ+6+yHZVSZfIjGED/+rKLJqO6w5u8bzT6No3H2vveRN4grTimZbhENcEKYtQp x86SU/DMKCCdKYEaX/yBS25ZOzQXeJV3O3rQeUO61ojE3/BkQlXNaae7oN53adasoKAe NQ9y/Mzz5qBHCQhgBKXyJ33imJ4Iee8wwVMuOb5sC8QJECGsuRV7rDlngvemHZM2ou73 hhflgSeaoKVG5rKoBc3lR0msRaPn2OHLQZMKdhHR9GU7f+HPlUX4nViEswnKfzgmSOiS qptQ== 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=vMExGlLMxh7O9KYTRWg40fGe+wpRqLrPEaUOm9R/L2o=; b=TYmM1tG/ahq/9PO+9PzKktscPpNoi6AM0qpnoPvpFO7NHwW8u3SvPtA/J1jtky6du2 +TxVprg5sTmEFuheJJcqgFF/nV8Gk7zBXOEBZvlxpOrxitIhu4AmWS/XgAdiaCz+yqeR 30YyvjfP6f7yxU47r18vJ0fVJ5Quuv8ZVr1q//uU12ZVUIwF6jbRj2fgzNHuht+5PcUo r2JA1MjeGGEv0n0N+KpZopjcm2SvalhlIBaabW3q54Bx0Unv7vhSWfJ76dIv3peExoua FJPNXJl8o5x60CwxkwRU8gpOY42xHfYVIGpqgqYJpvMK0v0m1eyNnflWdTOL2LESGNwA sbnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bIwVKpIg; 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 z21si1115180oti.199.2020.02.21.00.25.36; Fri, 21 Feb 2020 00:25:49 -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=bIwVKpIg; 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 S2388737AbgBUIZA (ORCPT + 99 others); Fri, 21 Feb 2020 03:25:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:37514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733083AbgBUIYx (ORCPT ); Fri, 21 Feb 2020 03:24:53 -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 4EB49246A0; Fri, 21 Feb 2020 08:24:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582273492; bh=BNCWoPz9N9JT1a4CxnyW2istYkmuYz1zj4L7Qm7jjnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bIwVKpIgZKY90T7URTH0AfJo8jxjbsMYi2TbDYbWvjfqLZBBvUkC1RCm47580RguL LOTdeZ2h4QFRzd76qfZp+d1N2RMHnCxvkmPziXyUZ7xtyZd2+eI7qYRiiYKekVBCL7 RUZq4Hvz2jqbtLjoEfaSsRnY3bBB1Nn23Jb2Zj7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicholas Kazlauskas , Alex Deucher , Sasha Levin Subject: [PATCH 4.19 191/191] drm/amdgpu/display: handle multiple numbers of fclks in dcn_calcs.c (v2) Date: Fri, 21 Feb 2020 08:42:44 +0100 Message-Id: <20200221072313.769324535@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072250.732482588@linuxfoundation.org> References: <20200221072250.732482588@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: Alex Deucher [ Upstream commit c37243579d6c881c575dcfb54cf31c9ded88f946 ] We might get different numbers of clocks from powerplay depending on what the OEM has populated. v2: add assert for at least one level Bug: https://gitlab.freedesktop.org/drm/amd/issues/963 Reviewed-by: Nicholas Kazlauskas Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../gpu/drm/amd/display/dc/calcs/dcn_calcs.c | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c index 6342f64993512..b0956c360393e 100644 --- a/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c +++ b/drivers/gpu/drm/amd/display/dc/calcs/dcn_calcs.c @@ -1346,6 +1346,7 @@ void dcn_bw_update_from_pplib(struct dc *dc) struct dc_context *ctx = dc->ctx; struct dm_pp_clock_levels_with_voltage fclks = {0}, dcfclks = {0}; bool res; + unsigned vmin0p65_idx, vmid0p72_idx, vnom0p8_idx, vmax0p9_idx; /* TODO: This is not the proper way to obtain fabric_and_dram_bandwidth, should be min(fclk, memclk) */ res = dm_pp_get_clock_levels_by_type_with_voltage( @@ -1357,17 +1358,28 @@ void dcn_bw_update_from_pplib(struct dc *dc) res = verify_clock_values(&fclks); if (res) { - ASSERT(fclks.num_levels >= 3); - dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 = 32 * (fclks.data[0].clocks_in_khz / 1000.0) / 1000.0; - dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 = dc->dcn_soc->number_of_channels * - (fclks.data[fclks.num_levels - (fclks.num_levels > 2 ? 3 : 2)].clocks_in_khz / 1000.0) - * ddr4_dram_factor_single_Channel / 1000.0; - dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 = dc->dcn_soc->number_of_channels * - (fclks.data[fclks.num_levels - 2].clocks_in_khz / 1000.0) - * ddr4_dram_factor_single_Channel / 1000.0; - dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = dc->dcn_soc->number_of_channels * - (fclks.data[fclks.num_levels - 1].clocks_in_khz / 1000.0) - * ddr4_dram_factor_single_Channel / 1000.0; + ASSERT(fclks.num_levels); + + vmin0p65_idx = 0; + vmid0p72_idx = fclks.num_levels - + (fclks.num_levels > 2 ? 3 : (fclks.num_levels > 1 ? 2 : 1)); + vnom0p8_idx = fclks.num_levels - (fclks.num_levels > 1 ? 2 : 1); + vmax0p9_idx = fclks.num_levels - 1; + + dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 = + 32 * (fclks.data[vmin0p65_idx].clocks_in_khz / 1000.0) / 1000.0; + dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 = + dc->dcn_soc->number_of_channels * + (fclks.data[vmid0p72_idx].clocks_in_khz / 1000.0) + * ddr4_dram_factor_single_Channel / 1000.0; + dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 = + dc->dcn_soc->number_of_channels * + (fclks.data[vnom0p8_idx].clocks_in_khz / 1000.0) + * ddr4_dram_factor_single_Channel / 1000.0; + dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = + dc->dcn_soc->number_of_channels * + (fclks.data[vmax0p9_idx].clocks_in_khz / 1000.0) + * ddr4_dram_factor_single_Channel / 1000.0; } else BREAK_TO_DEBUGGER(); -- 2.20.1