From patchwork Sat Feb 4 21:04:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 9555765 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E9A6B602B5 for ; Sat, 4 Feb 2017 21:06:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBF112582C for ; Sat, 4 Feb 2017 21:06:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0EA126E51; Sat, 4 Feb 2017 21:06:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,T_DKIM_INVALID autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8F41C2582C for ; Sat, 4 Feb 2017 21:06:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1ca7Xb-00047q-9d; Sat, 04 Feb 2017 21:06:39 +0000 Received: from mail-wm0-f65.google.com ([74.125.82.65]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1ca7XQ-0003vs-Qg; Sat, 04 Feb 2017 21:06:31 +0000 Received: by mail-wm0-f65.google.com with SMTP id u63so13048078wmu.2; Sat, 04 Feb 2017 13:06:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:references:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=ZSr+upSQHBEW4nB8yluSwvTF/jC/tgZ3mslBlNfCL88=; b=oGMVMN4y47h9/rn7EsiKYwiUkQTwuR9o2H0TXQ23XWBOijm7aiNK2mnfB+Ifq2QiED mzJ1X9EHy9E/05v872HDr9mwzIU1Cpbtun65NXnidSbWlJXINQIeh3H28fF/NyeDL1Ec Ay7sDKxCKmNHC0t1Mcamko9VaSrilgWD1m1J4UJDfFHKGAWqr800OutMDE+CqK7+lT1D usm/1K5HDzuVA0uAQdzA6gby7RLRmNj4OQdUp0wQMawIaRpB5aP+TR3bcs2yC+uJinmi ePF3cj5/55W74p8YhJNnFT6EatIcqv1kRMgQxBgxtwsFoB058WFNQSELrynnMblNy/7J AKzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=ZSr+upSQHBEW4nB8yluSwvTF/jC/tgZ3mslBlNfCL88=; b=eHuvExRVNNlM1cWtyuUKNCLCIjLNwPBknqytGAJNNvmsQtQkV5ezjnnBKu/awqkVDv P1HDi5xf2LEghbA3L9kyuCgjk4g027udSSCZwWn1sp7TTqmlQfkkhqqkbgIvnXE7bN3+ MpTW3fTPVb1ROrVIY0d/rXhFAHUtZybzHhMf4UE9kDy2f0Zbd48yo3TZJ3QhTV6xYqV+ +eMaK1Y3ucRf26gyidrkITwSbV3u4kwK1Aa3aERIFU5G6xL8s3tEledhdAhjM8OfsYWl bPZ23PJaq8Y+LiY9lc2dXkZT0+epQvzbM4JYqbjC9CffccVxgBAdZMPAmMOXyZBxdKai pLug== X-Gm-Message-State: AIkVDXK91Z129ziEtlhb8ajoK/RoBowTcH0zP1Mvs8ihMS9nl6PlFVsYYkYPx1HnIoShxQ== X-Received: by 10.223.170.70 with SMTP id q6mr3045797wrd.103.1486242306998; Sat, 04 Feb 2017 13:05:06 -0800 (PST) Received: from ?IPv6:2003:c6:ebce:1e00:2171:4d5:b787:b5ce? (p200300C6EBCE1E00217104D5B787B5CE.dip0.t-ipconnect.de. [2003:c6:ebce:1e00:2171:4d5:b787:b5ce]) by smtp.googlemail.com with ESMTPSA id s26sm51519934wra.26.2017.02.04.13.05.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 Feb 2017 13:05:06 -0800 (PST) From: Heiner Kallweit Subject: [PATCH 2/2] cpufreq: scpi: RfC - Allow to ignore invalid SCPI DVFS clock rates To: Sudeep Holla References: <3b60654a-88b6-6262-396e-a058ade1c586@gmail.com> Message-ID: <9a4d7b23-3d5b-b8be-142e-76ded75a5ea4@gmail.com> Date: Sat, 4 Feb 2017 22:04:48 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <3b60654a-88b6-6262-396e-a058ade1c586@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170204_130629_041490_22E66967 X-CRM114-Status: UNSURE ( 9.61 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-amlogic@lists.infradead.org, "linux-arm-kernel@lists.infradead.org" , Kevin Hilman Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Get the highest allowed SCPI DVFS clock rate and ignore all OPP's exceeding this clock rate threshold. Based on DT settings the highest allowed clock rate may be lower than the firmware-offered highest clock rate. This is useful on systems where the firmware offers too optimistic clock rates causing instabilities and crashes. Signed-off-by: Heiner Kallweit --- drivers/cpufreq/scpi-cpufreq.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/cpufreq/scpi-cpufreq.c b/drivers/cpufreq/scpi-cpufreq.c index ea7a4e1b..b5148f3b 100644 --- a/drivers/cpufreq/scpi-cpufreq.c +++ b/drivers/cpufreq/scpi-cpufreq.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include "arm_big_little.h" @@ -54,6 +56,20 @@ static int scpi_init_opp_table(const struct cpumask *cpumask) struct scpi_opp *opp; struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask)); struct scpi_dvfs_info *info = scpi_get_dvfs_info(cpu_dev); + u32 max_freq = UINT_MAX; + + if (cpu_dev->of_node) { + struct clk *clk = of_clk_get(cpu_dev->of_node, 0); + + if (!IS_ERR(clk)) { + /* find highest supported rate */ + long tmp = clk_round_rate(clk, UINT_MAX); + + if (tmp > 0) + max_freq = tmp; + clk_put(clk); + } + } if (IS_ERR(info)) return PTR_ERR(info); @@ -62,6 +78,12 @@ static int scpi_init_opp_table(const struct cpumask *cpumask) return -EIO; for (opp = info->opps, idx = 0; idx < info->count; idx++, opp++) { + /* quirk: skip too optimistic firmware-provided rates */ + if (opp->freq > max_freq) { + pr_notice("skip frequency %u\n", opp->freq); + continue; + } + ret = dev_pm_opp_add(cpu_dev, opp->freq, opp->m_volt * 1000); if (ret) { dev_warn(cpu_dev, "failed to add opp %uHz %umV\n",