Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp651676pxv; Thu, 15 Jul 2021 12:30:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9XaHjCUD9nrLG9+aVYD1U9NZSeMDp0Pg1JuCwtiX2WWYTcY1M3AKKkB53xXVMVQncAD5A X-Received: by 2002:a17:906:f11:: with SMTP id z17mr7353330eji.385.1626377440091; Thu, 15 Jul 2021 12:30:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626377440; cv=none; d=google.com; s=arc-20160816; b=XG89ze05eEr8nseRiTuBd8IKM8TkmIiM4C/uf7WAjNEMwUZhkozEn0AUwwwQoS6L8b NfgrNEUYh7wU91qiKS5Y9Fv+QImt8xewC+LstsMrT6PVF+M6+fX0QAkElISPGvPUawlR g2r6QIlh7oHRvb2SfMGf2xtTNoLGLllbfrKa2NHfBQNYFFmcCtKEaxr6ZUXVnIInWo52 nvOXzxARses0O7M1mr7algvn//XJWxFlzcRpwT1VzZqhGHB7gvIfALmyuvfFyFDDcodv e5MNi4LzmH2EJv9opzyuMk09ne3FfvBE+CrjQ9HIxzIL2C6hX7OE9jM4JVNzVUtrxB/0 mEWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HzjxoqIkhP0fUPSRnmZi3UfF8C7gU4YlwtUUoHctf7Y=; b=AY3WGZTRFBBMTrPe9SkLxPaUda3b4WaCBDQVPZs/+iACWx5sPmJefLYwlePCCPCeBB p/Xmwc/qxXWiPuyl6qvZ5gQWquEBAWAUj42sV5tF9OVLRAQBt3gCd2QOVsYlF532x4Vn PNzpxIoCYs6sSM42CUppHvqFhq2QcCSjFD227sjSRuj5Omng58DVESJXx148tpV6iGRR v3bYeG6X15nXEZdq/P+cF7csCkoue5JQhlxYgX/WHqKl+zIjBe6aHZljgQZjQP6ijcg8 inhCUOaZkSVmSHyoiCeVnGhAkpFYtLfOp+Tg6mTyxtqaKHK7VwaOVfLnjEUPGZ/fbhki sRRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KR805Wtz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a15si8476976eds.375.2021.07.15.12.30.17; Thu, 15 Jul 2021 12:30:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KR805Wtz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243153AbhGOT2n (ORCPT + 99 others); Thu, 15 Jul 2021 15:28:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:45860 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243807AbhGOTKH (ORCPT ); Thu, 15 Jul 2021 15:10:07 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B07A7613DD; Thu, 15 Jul 2021 19:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626375996; bh=Nje1VY87Mw8n/VyptInx2sozSQq7QStzqy3xJAt1djg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KR805WtzL4pqg7oGO00e7++nVlwIHDPMBQcyQamYISCMw9zbceKep3qX63k60uW34 LnfWPv8kDUvscnoQSC8/NAujzH/1T2TMBFRFRSAeEomFogpMrEFx0evkj9OICcFaO3 Jb4cb7CNNqRjHKal05C4vC2jIJJ39dJfJjTEHwOs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Bakoulin , Sung Lee , Stylon Wang , Daniel Wheeler , Alex Deucher , Sasha Levin Subject: [PATCH 5.13 083/266] drm/amd/display: Revert "Fix clock table filling logic" Date: Thu, 15 Jul 2021 20:37:18 +0200 Message-Id: <20210715182628.888176227@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210715182613.933608881@linuxfoundation.org> References: <20210715182613.933608881@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Bakoulin [ Upstream commit ae88357c7966ec2a52cb1e70fd42f74a40c9dfcb ] [Why] This change was found to break some high-refresh modes. Reverting to unblock mainline. Signed-off-by: Ilya Bakoulin Reviewed-by: Sung Lee Acked-by: Stylon Wang Tested-by: Daniel Wheeler Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 78 +++++++------------ .../drm/amd/display/dc/dcn21/dcn21_resource.c | 33 +++----- 2 files changed, 39 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c index 1f56ceab5922..75ba86f951f8 100644 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c @@ -835,66 +835,47 @@ static struct wm_table lpddr4_wm_table_rn = { } }; -static unsigned int find_max_fclk_for_voltage(struct dpm_clocks *clock_table, - unsigned int voltage) +static unsigned int find_socclk_for_voltage(struct dpm_clocks *clock_table, unsigned int voltage) { int i; - uint32_t max_clk = 0; - for (i = 0; i < PP_SMU_NUM_FCLK_DPM_LEVELS; i++) { - if (clock_table->FClocks[i].Vol <= voltage) { - max_clk = clock_table->FClocks[i].Freq > max_clk ? - clock_table->FClocks[i].Freq : max_clk; - } - } - - return max_clk; -} - -static unsigned int find_max_memclk_for_voltage(struct dpm_clocks *clock_table, - unsigned int voltage) -{ - int i; - uint32_t max_clk = 0; - - for (i = 0; i < PP_SMU_NUM_MEMCLK_DPM_LEVELS; i++) { - if (clock_table->MemClocks[i].Vol <= voltage) { - max_clk = clock_table->MemClocks[i].Freq > max_clk ? - clock_table->MemClocks[i].Freq : max_clk; - } + for (i = 0; i < PP_SMU_NUM_SOCCLK_DPM_LEVELS; i++) { + if (clock_table->SocClocks[i].Vol == voltage) + return clock_table->SocClocks[i].Freq; } - return max_clk; + ASSERT(0); + return 0; } -static unsigned int find_max_socclk_for_voltage(struct dpm_clocks *clock_table, - unsigned int voltage) +static unsigned int find_dcfclk_for_voltage(struct dpm_clocks *clock_table, unsigned int voltage) { int i; - uint32_t max_clk = 0; - for (i = 0; i < PP_SMU_NUM_SOCCLK_DPM_LEVELS; i++) { - if (clock_table->SocClocks[i].Vol <= voltage) { - max_clk = clock_table->SocClocks[i].Freq > max_clk ? - clock_table->SocClocks[i].Freq : max_clk; - } + for (i = 0; i < PP_SMU_NUM_DCFCLK_DPM_LEVELS; i++) { + if (clock_table->DcfClocks[i].Vol == voltage) + return clock_table->DcfClocks[i].Freq; } - return max_clk; + ASSERT(0); + return 0; } static void rn_clk_mgr_helper_populate_bw_params(struct clk_bw_params *bw_params, struct dpm_clocks *clock_table, struct integrated_info *bios_info) { int i, j = 0; - unsigned int volt; j = -1; - /* Find max DPM */ - for (i = 0; i < PP_SMU_NUM_DCFCLK_DPM_LEVELS; ++i) { - if (clock_table->DcfClocks[i].Freq != 0 && - clock_table->DcfClocks[i].Vol != 0) + ASSERT(PP_SMU_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL); + + /* Find lowest DPM, FCLK is filled in reverse order*/ + + for (i = PP_SMU_NUM_FCLK_DPM_LEVELS - 1; i >= 0; i--) { + if (clock_table->FClocks[i].Freq != 0 && clock_table->FClocks[i].Vol != 0) { j = i; + break; + } } if (j == -1) { @@ -905,18 +886,13 @@ static void rn_clk_mgr_helper_populate_bw_params(struct clk_bw_params *bw_params bw_params->clk_table.num_entries = j + 1; - for (i = 0; i < bw_params->clk_table.num_entries; i++) { - volt = clock_table->DcfClocks[i].Vol; - - bw_params->clk_table.entries[i].voltage = volt; - bw_params->clk_table.entries[i].dcfclk_mhz = - clock_table->DcfClocks[i].Freq; - bw_params->clk_table.entries[i].fclk_mhz = - find_max_fclk_for_voltage(clock_table, volt); - bw_params->clk_table.entries[i].memclk_mhz = - find_max_memclk_for_voltage(clock_table, volt); - bw_params->clk_table.entries[i].socclk_mhz = - find_max_socclk_for_voltage(clock_table, volt); + for (i = 0; i < bw_params->clk_table.num_entries; i++, j--) { + bw_params->clk_table.entries[i].fclk_mhz = clock_table->FClocks[j].Freq; + bw_params->clk_table.entries[i].memclk_mhz = clock_table->MemClocks[j].Freq; + bw_params->clk_table.entries[i].voltage = clock_table->FClocks[j].Vol; + bw_params->clk_table.entries[i].dcfclk_mhz = find_dcfclk_for_voltage(clock_table, clock_table->FClocks[j].Vol); + bw_params->clk_table.entries[i].socclk_mhz = find_socclk_for_voltage(clock_table, + bw_params->clk_table.entries[i].voltage); } bw_params->vram_type = bios_info->memory_type; diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c index 38a2aa87f5f5..8e3f1d0b4cc3 100644 --- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c +++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c @@ -1575,12 +1575,10 @@ static struct _vcs_dpi_voltage_scaling_st construct_low_pstate_lvl(struct clk_li low_pstate_lvl.phyclk_d18_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_d18_mhz; low_pstate_lvl.phyclk_mhz = dcn2_1_soc.clock_limits[high_voltage_lvl].phyclk_mhz; - if (clk_table->num_entries < MAX_NUM_DPM_LVL) { - for (i = clk_table->num_entries; i > 1; i--) - clk_table->entries[i] = clk_table->entries[i-1]; - clk_table->entries[1] = clk_table->entries[0]; - clk_table->num_entries++; - } + for (i = clk_table->num_entries; i > 1; i--) + clk_table->entries[i] = clk_table->entries[i-1]; + clk_table->entries[1] = clk_table->entries[0]; + clk_table->num_entries++; return low_pstate_lvl; } @@ -1612,6 +1610,10 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param } } + /* clk_table[1] is reserved for min DF PState. skip here to fill in later. */ + if (i == 1) + k++; + clock_limits[k].state = k; clock_limits[k].dcfclk_mhz = clk_table->entries[i].dcfclk_mhz; clock_limits[k].fabricclk_mhz = clk_table->entries[i].fclk_mhz; @@ -1628,25 +1630,14 @@ static void update_bw_bounding_box(struct dc *dc, struct clk_bw_params *bw_param k++; } - - if (clk_table->num_entries >= MAX_NUM_DPM_LVL) { - for (i = 0; i < clk_table->num_entries + 1; i++) - dcn2_1_soc.clock_limits[i] = clock_limits[i]; - } else { - dcn2_1_soc.clock_limits[0] = clock_limits[0]; - for (i = 2; i < clk_table->num_entries + 1; i++) { - dcn2_1_soc.clock_limits[i] = clock_limits[i - 1]; - dcn2_1_soc.clock_limits[i].state = i; - } - } - + for (i = 0; i < clk_table->num_entries + 1; i++) + dcn2_1_soc.clock_limits[i] = clock_limits[i]; if (clk_table->num_entries) { + dcn2_1_soc.num_states = clk_table->num_entries + 1; /* fill in min DF PState */ dcn2_1_soc.clock_limits[1] = construct_low_pstate_lvl(clk_table, closest_clk_lvl); - dcn2_1_soc.num_states = clk_table->num_entries; /* duplicate last level */ - dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = - dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1]; + dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1]; dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states; } -- 2.30.2