From patchwork Mon Jul 2 08:49:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 140722 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp3743626ljj; Mon, 2 Jul 2018 01:50:08 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLqSukSIExzVyXQhvwrTkuhyc31ld2l3ya1rGb54m69F6WHmuK8tj/UVwBpcILaodEIOwZh X-Received: by 2002:a17:902:1023:: with SMTP id b32-v6mr25467187pla.145.1530521408170; Mon, 02 Jul 2018 01:50:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530521408; cv=none; d=google.com; s=arc-20160816; b=ZNRfRsanWfCnPZV6UXSrTViFocehyQ2FrOMU7h5y2LYR2Po1oawrC8g5zqyrIHN3gS sGUNy0oIGki3L2lly2BsErkv3jSSgbLgibrk+F3R7aFyDCWASuZIq0imxWDyu071SMLH otHv9TNNqIbRuEnPaUtx1mj2kPy0zq82Bnc0B6p81qBxuvKq66f7T2fuB6qrHGFG5xLV Vs+rPjIym8ItHTt6ZWHHd7FV4WFUFX4C8TKB7/LgE0tQDHIqMrDR1GroyIuUMicoxnye CJftpQsRiHaia3FPmSLXKVnXmXmDL5VidvDckwodIcPTKsmoYtU10c3S9Q6W+Oe01zW6 AB4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=KKaFUVhtuRqtVBV3i0eeLybqPWvydvRsjt797gmNCFU=; b=SmqA2QTBJ7uDvjY0BVxdXOqeUNvAZHxaoaO4X7BYXPJPxBZqGlP2+gBS3WS6oM/qiJ 06DFEL4IJCmUHZYwLPm7pEfLMEOMj5DXcdvAUHlFuJAXoAzSDVBaoMTbAIHCsYE5Qc04 JLLLyBPXR3M64ISDRKTzBAFIP+5xYPs+LswAdNSTzY1q17nax2ATDWW5SPeIN+lMkRjq Ub5kkmYGPCYoKdoqVTQaJxnihobLZfT6cxseFK14glOZHVpeK5/QKw9wJ7Acg67ejiCz QCi0Fu7BGsn5dTvbBbZ3ZMW795EmMytfTdYF5U7h/nmVO/NwbCy1fz4kesxs/4I09vAb xIkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d62rCpti; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c13-v6si16394432plo.97.2018.07.02.01.50.07; Mon, 02 Jul 2018 01:50:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=d62rCpti; spf=pass (google.com: best guess record for domain of linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932105AbeGBIuG (ORCPT + 10 others); Mon, 2 Jul 2018 04:50:06 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:41652 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753144AbeGBIuB (ORCPT ); Mon, 2 Jul 2018 04:50:01 -0400 Received: by mail-pg0-f67.google.com with SMTP id l65-v6so6832000pgl.8 for ; Mon, 02 Jul 2018 01:50:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=KKaFUVhtuRqtVBV3i0eeLybqPWvydvRsjt797gmNCFU=; b=d62rCptixIqXQHkYV9WyI97h3un2L1W/c291kBG+rb/3xpqY56wr/BATX2nZpQLgP7 oqsWjqJ3pPnro2dvCyPWOBmjzY9yASaAnv8bfkyDYY5GDij4b/4n49f3ZMtUSAlthMYZ d+otlrqNlc6eRE26iFlUCAYAvtWCGQK07GHGk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=KKaFUVhtuRqtVBV3i0eeLybqPWvydvRsjt797gmNCFU=; b=NGdLT736KLR6EU0yBzX4cc8MiF22jGk3ov1dHk30s1V19Vma7klfbDsveOs11lU5bZ sq4qq4Wl7bPLz6Zv5XZwM/OAWm5bFff3MjsrAqlcemmwWRih4CPBrD75wDwnWn2ikY7t ygHK5/2bhGKjxSZ09Jm/svd3l14Te1xKQWiasnImmE6mBEERMuN7VignI+nI4xd6TrwN 5ievgUd1g4Q+P7nLnbMZaQaQ+qVaN5mJSuQVLgLXMUfgk22728XjoS5yfJfoPUzBn5pB B3YVFqu0lFPTGiqsUKvxXiWsQlpFb4yOt1bCQ5AzNgHg3IW8t0XtcrBr/VBFDFGR3Opo z7MQ== X-Gm-Message-State: APt69E1T1LHXhYsEuAPGePvo22sNbZl1wK3fYGfhLYZLZCh1xhaV2oza lqBYXDOYmj9Z/Rr+VGf4OYZwBsJqdsY= X-Received: by 2002:a65:4d85:: with SMTP id p5-v6mr21103058pgq.249.1530521400577; Mon, 02 Jul 2018 01:50:00 -0700 (PDT) Received: from localhost ([122.172.117.17]) by smtp.gmail.com with ESMTPSA id p76-v6sm29441810pfk.147.2018.07.02.01.49.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jul 2018 01:49:59 -0700 (PDT) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Waldemar Rymarkiewicz , "4 . 6+" , linux-kernel@vger.kernel.org Subject: [PATCH v4.9] PM / OPP: Update voltage in case freq == old_freq Date: Mon, 2 Jul 2018 14:19:47 +0530 Message-Id: <3717ee50c1f1f48cffcb1a2e41c04e28881776d1.1530521347.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.18.0.rc1.242.g61856ae69a2c Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org From: Waldemar Rymarkiewicz Original commit c5c2a97b3ac7 ("PM / OPP: Update voltage in case freq == old_freq"). This commit fixes a rare but possible case when the clk rate is updated without update of the regulator voltage. At boot up, CPUfreq checks if the system is running at the right freq. This is a sanity check in case a bootloader set clk rate that is outside of freq table present with cpufreq core. In such cases system can be unstable so better to change it to a freq that is preset in freq-table. The CPUfreq takes next freq that is >= policy->cur and this is our target_freq that needs to be set now. dev_pm_opp_set_rate(dev, target_freq) checks the target_freq and the old_freq (a current rate). If these are equal it returns early. If not, it searches for OPP (old_opp) that fits best to old_freq (not listed in the table) and updates old_freq (!). Here, we can end up with old_freq = old_opp.rate = target_freq, which is not handled in _generic_set_opp_regulator(). It's supposed to update voltage only when freq > old_freq || freq > old_freq. if (freq > old_freq) { ret = _set_opp_voltage(dev, reg, new_supply); [...] if (freq < old_freq) { ret = _set_opp_voltage(dev, reg, new_supply); if (ret) It results in, no voltage update while clk rate is updated. Example: freq-table = { 1000MHz 1.15V 666MHZ 1.10V 333MHz 1.05V } boot-up-freq = 800MHz # not listed in freq-table freq = target_freq = 1GHz old_freq = 800Mhz old_opp = _find_freq_ceil(opp_table, &old_freq); #(old_freq is modified!) old_freq = 1GHz Fixes: 6a0712f6f199 ("PM / OPP: Add dev_pm_opp_set_rate()") Cc: 4.6+ # v4.6+ Signed-off-by: Waldemar Rymarkiewicz Signed-off-by: Viresh Kumar --- Sending it for stable kernels from 4.6 until 4.9. drivers/base/power/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.18.0.rc1.242.g61856ae69a2c diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 4c7c6da7a989..0580cbe5bd1c 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -642,7 +642,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) rcu_read_unlock(); /* Scaling up? Scale voltage before frequency */ - if (freq > old_freq) { + if (freq >= old_freq) { ret = _set_opp_voltage(dev, reg, u_volt, u_volt_min, u_volt_max); if (ret)