From patchwork Tue Nov 29 06:36:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 84510 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp2108097obn; Mon, 28 Nov 2016 22:37:55 -0800 (PST) X-Received: by 10.98.159.67 with SMTP id g64mr25777306pfe.93.1480401475435; Mon, 28 Nov 2016 22:37:55 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c41si30057355plj.134.2016.11.28.22.37.55; Mon, 28 Nov 2016 22:37:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752603AbcK2Ght (ORCPT + 7 others); Tue, 29 Nov 2016 01:37:49 -0500 Received: from mail-pg0-f53.google.com ([74.125.83.53]:36077 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755921AbcK2Ghl (ORCPT ); Tue, 29 Nov 2016 01:37:41 -0500 Received: by mail-pg0-f53.google.com with SMTP id f188so65801072pgc.3 for ; Mon, 28 Nov 2016 22:37:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=xooW5jvpc0bd7BE4Y8GHcp6wRo1d2p5vl413Y63VHPc=; b=WqMiwOvOk8YFFSwmpO3chS05GnmHfnx0HUt6dGLFMgryh4S5zPjMu2jOOSU6Whs/q2 w36s2FxD4VDWzaPEFkMRBFIM0amqD55yl41/+y1fz402EFj5rXLaW3vHxfVVVKImDJDK Tkbl19L4nX3WkO69mz3iooj4U6MAlxK56yCGw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=xooW5jvpc0bd7BE4Y8GHcp6wRo1d2p5vl413Y63VHPc=; b=RjyiqNpKjrDoulv4y6SjfH9Og30BlTqPnEtyy1713d8VJeUX7adU2jBcvteu2DDBFe j51tRMHIXI0vf+Suef+YUrGoT2MO5Tnm5n0gL80zzHLcRKMkqC9N2gW1rp7rDbAVMDpZ 3TCggRlWrCz7le51cIbPP8C0XWXp1z5Jxs8HRErP/D3xAjtq3RqjsU57fRY8HIiWAmWb TG/yxA4LuGzRK2NR3hX6FIJTJgGyFecUuz0UdyVvA9/rJNcJzGJmQzqDX61DElp1oT61 wJfBEuvHXCbJdye1SBox+CoEEIAQyD9PGdnZ9K5YiYscUD1JmMyQ2sZLo148blQHhRvv p4pQ== X-Gm-Message-State: AKaTC01DSB7ALxCEuEVIdZd/msUO5F+l8XrmAcylqgmnB8j3A9a1XgWB0P11JXRyBJJQ02BH X-Received: by 10.98.159.136 with SMTP id v8mr26030044pfk.82.1480401455088; Mon, 28 Nov 2016 22:37:35 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id u23sm91754106pfg.86.2016.11.28.22.37.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 22:37:34 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , nm@ti.com, sboyd@codeaurora.org, Viresh Kumar Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , robh@kernel.org, d-gerlach@ti.com, broonie@kernel.org, devicetree@vger.kernel.org, Viresh Kumar Subject: [PATCH V5 10/10] PM / OPP: Don't assume platform doesn't have regulators Date: Tue, 29 Nov 2016 12:06:57 +0530 Message-Id: <1b5cac826c60d6fe06146acf8f9377de8729fb1d.1480401041.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org If the regulators aren't set explicitly by the platform, the OPP core assumes that the platform doesn't have any regulator and uses the clk-only callback. If the platform failed to register a regulator with the core, then this can turn out to be a dangerous assumption as the OPP core will try to change clk without changing regulators. Handle that properly by making sure that the DT didn't have any entries for supply voltages as well. Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) -- 2.7.1.410.g6faf27b -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 3c9f223709ab..f7a5fb4dbf11 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -748,7 +748,20 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) /* Only frequency scaling */ if (!regulators) { + unsigned long u_volt = opp->supplies[0].u_volt; + rcu_read_unlock(); + + /* + * DT contained supply ratings? Consider platform failed to set + * regulators. + */ + if (unlikely(u_volt)) { + dev_err(dev, "%s: Regulator not registered with OPP core\n", + __func__); + return -EINVAL; + } + return _generic_set_opp_clk_only(dev, clk, old_freq, freq); }