From patchwork Thu Dec 1 10:58:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 86017 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp633554qgi; Thu, 1 Dec 2016 02:59:07 -0800 (PST) X-Received: by 10.99.107.4 with SMTP id g4mr68776477pgc.108.1480589947259; Thu, 01 Dec 2016 02:59:07 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h25si68790422pfd.139.2016.12.01.02.59.07; Thu, 01 Dec 2016 02:59:07 -0800 (PST) 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=neutral (body hash did not verify) header.i=@linaro.org; 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=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757311AbcLAK7F (ORCPT + 13 others); Thu, 1 Dec 2016 05:59:05 -0500 Received: from mail-pg0-f52.google.com ([74.125.83.52]:34662 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757355AbcLAK7D (ORCPT ); Thu, 1 Dec 2016 05:59:03 -0500 Received: by mail-pg0-f52.google.com with SMTP id x23so94068069pgx.1 for ; Thu, 01 Dec 2016 02:59:01 -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=3WUW/y2J3zGLteDa03PjLKF/NvDA+gxWBFvurGXeT0U=; b=hySmiqrjzPfmhx6vnm6z5JnyzvBcTDgoNlsDfW6+sZIOizSlA/WYvHzozP0hMi+AYU dpxkeAmWBl3REXHDJseRI23yxLBMNI7UdROm3OCmWHSF+FX626CbvnSEHDqSyiODKmSn HN3pQbihbRySfjkkduhaiQGc0svrfjBa8eo0o= 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=3WUW/y2J3zGLteDa03PjLKF/NvDA+gxWBFvurGXeT0U=; b=QUMM8noc2K5Womx/Gq/LhKEN/xBcQbIMJ2lf3Kce3408D7He76C/J3kL0IFSuFw8J0 Tc/yhghsJoL+IDGqiVopFAHO33Sf3ubMp59xnR6M3Hp5Bsm1jSwC78EUorfMmJyAwu4u 299c/n8DBQBeIrSNucTZOlJAA+xOGboH8tRi4IMC4x8W3Hf6eIOyW+pH39ZiBsWO+lCu k15LLsWJ2BdhI4J+fuSOfxWwzGmW50zmTcmiLIZzubLy28F9Km+soBuXyxnVY0P6/yfx HP0UrYtei48W3NMeTtjY7aQG/olnFleybKpuUVuocCh6zcz/FuVwr1sfXKYty9ekzXFk dKLg== X-Gm-Message-State: AKaTC0007Kb5i2dOSu9l8FwyFLZw1OTSv7f25FM+5BA57lF3MZua2b9D+3xnqx7jVmahfcBV X-Received: by 10.84.213.150 with SMTP id g22mr83062216pli.11.1480589940589; Thu, 01 Dec 2016 02:59:00 -0800 (PST) Received: from localhost ([122.172.143.30]) by smtp.gmail.com with ESMTPSA id q14sm109786990pfa.40.2016.12.01.02.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 02:59:00 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Vincent Guittot , robh@kernel.org, d-gerlach@ti.com, broonie@kernel.org, devicetree@vger.kernel.org, Viresh Kumar Subject: [PATCH V7 10/10] PM / OPP: Don't assume platform doesn't have regulators Date: Thu, 1 Dec 2016 16:28:23 +0530 Message-Id: <6f174b5d2fd2d09332fbc80f074d67c48be63ac7.1480564564.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 linux-pm" 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 35ff06283738..a0e6294baf1d 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); }