Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4554822pxj; Wed, 12 May 2021 08:06:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhXZ35AiJ8e1UKyHd5s594jim2ducQpxAW+XEd4fBjiIFJTg4DlYPGaFuHxZarJDylzRq1 X-Received: by 2002:a05:6830:13c4:: with SMTP id e4mr29715250otq.315.1620832002906; Wed, 12 May 2021 08:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620832002; cv=none; d=google.com; s=arc-20160816; b=RDS9236OBAUXjS0T6avnhhjWUznWn0bwXJbjgS4FCJf+Uunvxx/vLNwr6YjIFEN3yw wU3+rtsCg7IghZxiyvMkh2oeCNCSmrihqCZ3O2gwXXZKd/678mLzHbxfCRWpDMTGMcpq A7IQHTuVqLqog4/Wgq8OEXNbyVp+A0OD0yn/DcxJOWe9U698lY6iOZq3USEhCCTsesLW 4ed56s40pTJA9/I2Uj5k9hTsS519r7f/XyfRwuGAYLMd8WadVXE345JE7e6LgZm/YT1f NK46tkY9i33Bl0wvSMH07HV/EEKd6AZ11poIZwUCQ8+kWnwH/3NTMLjX/OS4iEhwlRta 68TQ== 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=tifDYkzKNXCE+fSIJKlsEkpP8aV+/CyjdizkyQmYmHM=; b=vEm3J1tFgR0HFxGGIBjorKoi1vVcz8RqLaaO3In0cOveKhvDZG5yMbn2NP+rWf568d j1+ijD/pX4vr8RXKdT3315YckHUVkYJwkjWOB0VtZNN3AmD4fxE4UhxqymbxCvfDQzNx TNdASee5I4cZPA7gSSgmhkhmsZK4qNYH3uVotRSqFVknB6LWF85qbIeUly8/wKweabr8 oFXreSQo6Sn4pLSWNrXiVoP2VKRDUk/oFJMHD/SNhV5KQZGosM+gWVw9r/DheaOG60rE FVB6vIsy2s9BtdX2XslSahl9Y12MZpniYsVITInzj2IsU5SBOmL76uj2VZdh+VmMPld5 ikmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=YJ1CApH3; 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 r81si204599oib.79.2021.05.12.08.06.22; Wed, 12 May 2021 08:06:42 -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=YJ1CApH3; 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 S231742AbhELPFw (ORCPT + 99 others); Wed, 12 May 2021 11:05:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:58514 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232918AbhELPBw (ORCPT ); Wed, 12 May 2021 11:01:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6E9B861442; Wed, 12 May 2021 14:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620831451; bh=oi9HjzGCp4rC7f8WgixC9KxOxN4ifaRgrUThLDkEcZA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YJ1CApH3Trahc6idBQln6RHggKRY+AbPmSU9m67RCs2DkUW2S4Bw98QydEGurwSj+ XArLwdRYwR/D6492MmShyhAUtl6ChjyGMa427g8W9vDRaXBAXJrj3ILMxX8L9ZLS6g 6aUFLdEk9PFI/PzYvFzWv+VwzdzfZhmDRQZaNMD0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= , Stephen Boyd , Gregory CLEMENT , Tomasz Maciej Nowak , Anders Trier Olesen , Philip Soares , Viresh Kumar , Sasha Levin Subject: [PATCH 5.4 118/244] clk: mvebu: armada-37xx-periph: Fix switching CPU freq from 250 Mhz to 1 GHz Date: Wed, 12 May 2021 16:48:09 +0200 Message-Id: <20210512144746.799312063@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144743.039977287@linuxfoundation.org> References: <20210512144743.039977287@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: Pali Rohár [ Upstream commit 4decb9187589f61fe9fc2bc4d9b01160b0a610c5 ] It was observed that the workaround introduced by commit 61c40f35f5cd ("clk: mvebu: armada-37xx-periph: Fix switching CPU rate from 300Mhz to 1.2GHz") when base CPU frequency is 1.2 GHz is also required when base CPU frequency is 1 GHz. Otherwise switching CPU frequency directly from L2 (250 MHz) to L0 (1 GHz) causes a crash. When base CPU frequency is just 800 MHz no crashed were observed during switch from L2 to L0. Signed-off-by: Pali Rohár Acked-by: Stephen Boyd Acked-by: Gregory CLEMENT Tested-by: Tomasz Maciej Nowak Tested-by: Anders Trier Olesen Tested-by: Philip Soares Fixes: 2089dc33ea0e ("clk: mvebu: armada-37xx-periph: add DVFS support for cpu clocks") Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- drivers/clk/mvebu/armada-37xx-periph.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c index d5226ab8e26f..5193dc817197 100644 --- a/drivers/clk/mvebu/armada-37xx-periph.c +++ b/drivers/clk/mvebu/armada-37xx-periph.c @@ -485,8 +485,10 @@ static long clk_pm_cpu_round_rate(struct clk_hw *hw, unsigned long rate, } /* - * Switching the CPU from the L2 or L3 frequencies (300 and 200 Mhz - * respectively) to L0 frequency (1.2 Ghz) requires a significant + * Workaround when base CPU frequnecy is 1000 or 1200 MHz + * + * Switching the CPU from the L2 or L3 frequencies (250/300 or 200 MHz + * respectively) to L0 frequency (1/1.2 GHz) requires a significant * amount of time to let VDD stabilize to the appropriate * voltage. This amount of time is large enough that it cannot be * covered by the hardware countdown register. Due to this, the CPU @@ -496,15 +498,15 @@ static long clk_pm_cpu_round_rate(struct clk_hw *hw, unsigned long rate, * To work around this problem, we prevent switching directly from the * L2/L3 frequencies to the L0 frequency, and instead switch to the L1 * frequency in-between. The sequence therefore becomes: - * 1. First switch from L2/L3(200/300MHz) to L1(600MHZ) + * 1. First switch from L2/L3 (200/250/300 MHz) to L1 (500/600 MHz) * 2. Sleep 20ms for stabling VDD voltage - * 3. Then switch from L1(600MHZ) to L0(1200Mhz). + * 3. Then switch from L1 (500/600 MHz) to L0 (1000/1200 MHz). */ static void clk_pm_cpu_set_rate_wa(unsigned long rate, struct regmap *base) { unsigned int cur_level; - if (rate != 1200 * 1000 * 1000) + if (rate < 1000 * 1000 * 1000) return; regmap_read(base, ARMADA_37XX_NB_CPU_LOAD, &cur_level); -- 2.30.2