Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4611562pxj; Wed, 12 May 2021 09:13:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyep1NTjwAvS6x2yZbdZh0sNXxseXfk0oOTZY+dZkhRX4HGqo8cqtth07O3OpX8+GY19L0R X-Received: by 2002:a17:906:5786:: with SMTP id k6mr2557274ejq.198.1620835991434; Wed, 12 May 2021 09:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620835991; cv=none; d=google.com; s=arc-20160816; b=LFShNuW/zXzv4J2lZWSiRT7726By0+biuJCcY9Q6nyMj0Tg8o1jCyc/tYzzXXrkq+J K95gS9NmS3RtJJr1JbQOk9IngcqsEbcIH4awBJqQio4bN8qup44AA2fThJUB6FPx0O7X KWhRBhECl8Frv8bPkXOOBlNkxVzL8CW281iC3xISm5bqJbcHBjKbZa0CvmmJFj7rwaCJ foCA3TDy9iNJb4gl1GL1f0G3c4ZjoAQd7x4d2D+RjmSQMSr4QL/r4qfrrmO0NVCMwyT/ VPJsci2MKNdibezsvX73TyDulkaeQ4j1jp2/ng2Ck07lffy6FEZUGjAyEiHr+x1rWyE0 g95g== 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=1+RSLK6XiLZPgCP98VPc/Z3C/qBGRFrf4dXO69csRr8=; b=ngnhwlp7K8rdWLVzyHuMvfGK0d96YzC/hnxVWWgIXTb1EyP+kgd+HJBdvj/sgOMRN1 6TiOJ7onlDzAnzNHCelme9sTvEO99mGi81YiPqH/i0dnn6SBcIZchzSvD0NtTw8MfPJu bvNCeUX54N2grXFefmPSzLirZ9DolX7ABTF7l6IOI7VxLZBzjEEBO9Czr06+K3YbP0hO uMnhQLH9X/gDoeBuR0HAT7nomRz3YZmiCjTdd9tTBZ5UYhlAYKFzPiPOkp67Tvpy/ooO TjMORDCq64z3/6+C2ap26vSvdPWLDeCnjAaHgzoJ7YKlW6wz9m8QQwDjExYC6e1H3Hf7 YwNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2vVVypBf; 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 b10si303105ejz.608.2021.05.12.09.12.46; Wed, 12 May 2021 09:13:11 -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=2vVVypBf; 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 S238926AbhELQGt (ORCPT + 99 others); Wed, 12 May 2021 12:06:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:37004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235185AbhELP06 (ORCPT ); Wed, 12 May 2021 11:26:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id CFA4061A14; Wed, 12 May 2021 15:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832322; bh=u45Q+0Tt09UKWwDU7j/FvWSs3/YE4eCd7NRCiS/ALlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2vVVypBfxtoPAAELjQvl0CbrrsbbUXqS6T5Qd0q3ETvMHwbEJpSIHk5lbKbvb57ft loDorYztvChslSR1kZaYhKlmbpfHOUOoYN3JxFyPqXn3bAuTG+xxKDwkofU9mqIShR CwjY8K2h631T/Cu2+sBmMy6qZ7E4Nomv5anmTM50= 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.10 233/530] clk: mvebu: armada-37xx-periph: Fix switching CPU freq from 250 Mhz to 1 GHz Date: Wed, 12 May 2021 16:45:43 +0200 Message-Id: <20210512144827.503556720@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 6507bd2c5f31..b15e177bea7e 100644 --- a/drivers/clk/mvebu/armada-37xx-periph.c +++ b/drivers/clk/mvebu/armada-37xx-periph.c @@ -487,8 +487,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 @@ -498,15 +500,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