Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4724026pxj; Wed, 12 May 2021 11:45:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzncuOmtx1+DfyYLMXJlFZlxAuPIAcJgrWQTgAtq+mTIQInTQ0GfEItZjTzYt6lFd3IKnpl X-Received: by 2002:a17:907:7b9f:: with SMTP id ne31mr39151515ejc.139.1620845149981; Wed, 12 May 2021 11:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620845149; cv=none; d=google.com; s=arc-20160816; b=lXc0p5oIVBuabbtaCl40R99TXIMKzwI8HH6mohjY7useYlrk9iHDxLdqUSRI9jwPvR BeVSjUuNv27tNB+yXCwl6p2ZbdW3E4qg+Tan9vY05BkEWbe5ufGdj58r9kS0YGGOOj0J OA0dY7kPyfQzKWQppzPV/OcypWzPL7dmB1eitg79dsLPYJ4CS72qfGulDCMQOb/emqQO 2U3GIae9z0HzRRrhwBxmXFnrOR1lQmGZq+QP6FhHDo0MM/aomSYPI5sJDXtBJCBsiHCj Slahatky2D78IP9mkMlVVjXoOZnMDC7P3UBUudCGjXXdEVXrt4qsinMgnYzqPuuCFg4I DRIQ== 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=RA/pbHAAU63FrgMpmFbKEnNeJLnYs1lX5PGimFFd6U9bA19jjIdxcHiPiSqpbNkd/J RBCC3aH6c/fY2JWTVm1QX02ck9mlc4WQgpCa/GTVybMhMezdLJXWWTsq+sHByjmttQn0 RF7c3G13fjB/AL4hIhVE+dOY/Wb5I0r7AhkH5nVQe3Hv7Oqh5rAWiMKzTc2kHYsNlvVi QvkrYCVjl5YAoNUhXWS25dr+KuEXSf8xmDcHPgFRclbs5nDEBP+Xf8hDC7lKV0tXONWL USZi2ffW/v2R1ZQMpasIUqQWpjcFMec7eDFTTfM0pW5dwZ3Me+pyM3v0ugtMLWP2Ndbm aaGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fVVQjnxf; 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 t23si673637ejj.290.2021.05.12.11.45.25; Wed, 12 May 2021 11:45:49 -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=fVVQjnxf; 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 S1356950AbhELShi (ORCPT + 99 others); Wed, 12 May 2021 14:37:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:57028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243265AbhELQhB (ORCPT ); Wed, 12 May 2021 12:37:01 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DC5326008E; Wed, 12 May 2021 16:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620835304; bh=u45Q+0Tt09UKWwDU7j/FvWSs3/YE4eCd7NRCiS/ALlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fVVQjnxf4ql680QjB2msvcCCOHeCm7E1IiOYNt7WfoS8DdM79/Y0m6v0KMVJVSw64 v65YmFpUuyzQujs1m/R6fV7z2Cif+OXj6LtV2/9P0lUvf1yPWVIIcUcQC6ZHiZ6oGl klu6Btzlkd9fKtbmIfyydDjTrOS2ZV+UwpgP8DZE= 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.12 289/677] clk: mvebu: armada-37xx-periph: Fix switching CPU freq from 250 Mhz to 1 GHz Date: Wed, 12 May 2021 16:45:35 +0200 Message-Id: <20210512144846.815995390@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144837.204217980@linuxfoundation.org> References: <20210512144837.204217980@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