From patchwork Thu Jan 14 12:40:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 12019433 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-22.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B92EC4332D for ; Thu, 14 Jan 2021 12:42:58 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 34581239FD for ; Thu, 14 Jan 2021 12:42:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 34581239FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=N6IoEH8aB9z3ifEMajeh5e2ArfN4AymWGcrytPzZoSM=; b=d85V0dFRmEswTk0DVD0bHdGhk AnqijXXtz8xfEoM0lQfCLysbnA9WFwxU94lQfxfP0Cu1n/jRFO4i7NczUKF0ecJDbtNdUNS93W10H rAyfli6tFuomgIzXSb415pqZwpwtAuGC7cvZsoQeuXlWK7QbEWf++BwN44GOqsRqqA9oOCkYdNt7A 3oqEiXB+Ve1rZGn3ufKY0EvT3CrHHfz5wWgGjVe7tfH1foEyDnm1y8do3WJ6NPfKJLe3GAf/8xfMp fGMKYdPF6PA2VJG/JREHE4C9q6ujOHiHtuKlAij4fpdLpBh/8Wj+Cdb2coVpyYYMxkwnqNuArMFoC AewRmrjZg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l01wA-0001jh-QB; Thu, 14 Jan 2021 12:41:14 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1l01vs-0001fJ-Lu for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2021 12:41:01 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C688A23A60; Thu, 14 Jan 2021 12:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610628055; bh=4gebIy8dtRAvDVN1y60MtYCqDlAywN6+YARHQq1N+70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=askES8EyD7ymOVr7SLqvxmQSDQgEc3KliAYdbtSZg7WJP9FN3L5AtU4GEMcTHBtgO EwXKvcVxH4Y2AAuSHdMMHEoOnM4lRHWeQKAJOUv3hsAR/8ZfjRtwjBc/hPOuEuRQcF 08ykBNznSjfr79iKUp34Ur3gGdoYvJFgAG+m+KI+/1yQkHisVuoRL6oZuHj2TMV18F j2AaM/2S/D5y2jmZf7/BHasGg6WdxevqY9hXrDGhuM9CCRgt/E4+XCeaBP1ba4p4oq hWjqdbwHUWaV+FTIauGKsYMsqPIgmxAH/BMkUqdWhIQ8efmbclnDOOn9KCeEmBLfLI 9+slAZ/T/xQ4w== Received: by pali.im (Postfix) id D47DA821; Thu, 14 Jan 2021 13:40:53 +0100 (CET) From: =?utf-8?q?Pali_Roh=C3=A1r?= To: Gregory Clement , Andrew Lunn , Michael Turquette , Stephen Boyd , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org Subject: [PATCH mvebu v2 04/10] cpufreq: armada-37xx: Fix the AVS value for loads L0 and L1 Date: Thu, 14 Jan 2021 13:40:26 +0100 Message-Id: <20210114124032.12765-5-pali@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210114124032.12765-1-pali@kernel.org> References: <20210114124032.12765-1-pali@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210114_074056_922993_618DE5CF X-CRM114-Status: GOOD ( 14.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Marek_Beh=C3=BAn?= , Tomasz Maciej Nowak , Luka Perkov , Andre Heider , Vladimir Vid , Russell King , =?utf-8?q?G=C3=A9rald_Kerma?= , Miquel Raynal , Konstantin Porotchkin Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The original CPU voltage value for load L1 is too low for Armada-37xx SoC when base CPU frequency is 1000 or 1200 MHz. It leads to instabilities where CPU gets stuck soon after dynamic voltage scaling from load L1 to L0. Update the CPU voltage value for loads L0 and L1 accordingly when base frequency is 1000 or 1200 MHz. The minimal value is updated from the original 1.05V to 1.108V. This change fixes instability issues on 1 GHz variant of Espressobin and Turris MOX. It is based on previous work from Victor Gu for Espressobin kernel 4.4 [1]. Discussion about this issue is also at armbian forum [2]. [1] - https://github.com/MarvellEmbeddedProcessors/linux-marvell/commit/dc33b62c90696afb6adc7dbcc4ebbd48bedec269 [2] - https://forum.armbian.com/topic/10429-how-to-make-espressobin-v7-stable/ Signed-off-by: Pali Rohár Fixes: 1c3528232f4b ("cpufreq: armada-37xx: Add AVS support") Cc: stable@vger.kernel.org --- drivers/cpufreq/armada-37xx-cpufreq.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/cpufreq/armada-37xx-cpufreq.c b/drivers/cpufreq/armada-37xx-cpufreq.c index b8dc6c849579..92e531f700f4 100644 --- a/drivers/cpufreq/armada-37xx-cpufreq.c +++ b/drivers/cpufreq/armada-37xx-cpufreq.c @@ -73,6 +73,7 @@ #define LOAD_LEVEL_NR 4 #define MIN_VOLT_MV 1000 +#define MIN_VOLT_MV_FOR_L0_L1_1GHZ 1108 /* AVS value for the corresponding voltage (in mV) */ static int avs_map[] = { @@ -208,6 +209,8 @@ static u32 armada_37xx_avs_val_match(int target_vm) * - L2 & L3 voltage should be about 150mv smaller than L0 voltage. * This function calculates L1 & L2 & L3 AVS values dynamically based * on L0 voltage and fill all AVS values to the AVS value table. + * When base CPU frequency is 1000 or 1200 MHz then there is additional + * minimal avs value for load L0 and L1. */ static void __init armada37xx_cpufreq_avs_configure(struct regmap *base, struct armada_37xx_dvfs *dvfs) @@ -239,6 +242,15 @@ static void __init armada37xx_cpufreq_avs_configure(struct regmap *base, for (load_level = 1; load_level < LOAD_LEVEL_NR; load_level++) dvfs->avs[load_level] = avs_min; + /* + * Set the avs value for load L0 and L1 when base CPU frequency is 1000/1200 MHz, + * otherwise the CPU gets stuck when switching from load L1 to load L0 + */ + if (dvfs->cpu_freq_max >= 1000*1000*1000) { + avs_min = armada_37xx_avs_val_match(MIN_VOLT_MV_FOR_L0_L1_1GHZ); + dvfs->avs[0] = dvfs->avs[1] = avs_min; + } + return; } @@ -258,6 +270,20 @@ static void __init armada37xx_cpufreq_avs_configure(struct regmap *base, target_vm = avs_map[l0_vdd_min] - 150; target_vm = target_vm > MIN_VOLT_MV ? target_vm : MIN_VOLT_MV; dvfs->avs[2] = dvfs->avs[3] = armada_37xx_avs_val_match(target_vm); + + /* + * Fix the avs value for load L0 and L1 when base CPU frequency is 1000/1200 MHz, + * otherwise the CPU gets stuck when switching from load L1 to load L0 + */ + if (dvfs->cpu_freq_max >= 1000*1000*1000) { + u32 avs_min = armada_37xx_avs_val_match(MIN_VOLT_MV_FOR_L0_L1_1GHZ); + + if (dvfs->avs[0] < avs_min) + dvfs->avs[0] = avs_min; + + if (dvfs->avs[1] < avs_min) + dvfs->avs[1] = avs_min; + } } static void __init armada37xx_cpufreq_avs_setup(struct regmap *base,