From patchwork Wed Nov 30 05:14:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 84954 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp87008qgi; Tue, 29 Nov 2016 21:15:02 -0800 (PST) X-Received: by 10.98.214.20 with SMTP id r20mr31725997pfg.59.1480482902806; Tue, 29 Nov 2016 21:15:02 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si62722453pfb.185.2016.11.29.21.15.02; Tue, 29 Nov 2016 21:15:02 -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 S1753594AbcK3FPB (ORCPT + 7 others); Wed, 30 Nov 2016 00:15:01 -0500 Received: from mail-pg0-f47.google.com ([74.125.83.47]:36381 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753023AbcK3FPA (ORCPT ); Wed, 30 Nov 2016 00:15:00 -0500 Received: by mail-pg0-f47.google.com with SMTP id f188so77463935pgc.3 for ; Tue, 29 Nov 2016 21:15:00 -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=6o4pcb4TpWckCJ5XAZJjyMK2rSj633KcrNIsRjAvXyE=; b=htGP7KfWC9yB+1YTvMQFkn+J3435z0h2DroP2GQypBgIkIzstJPDzgWwRqiqC4rItF NIBnygMtaH+5g/m2Ad4Re+eeFMUPOKHi46LVbUOkvT6l803aRG/+MnOb5BqIpWE35lht U7cUIjj19lypzlmbGuhntuA2sW2EZxAMDlU0Q= 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=6o4pcb4TpWckCJ5XAZJjyMK2rSj633KcrNIsRjAvXyE=; b=QNuqe2uBvGrFV637O/Vryra2GVVKR3qptnnq3BtQGD4bqDRQveFHzs9yYdNtG9b1KS m2FKFH7CEOMFufzI2U1HE81fOlcZiQvGCoO4LElC9z1zEOHxcaDMNt2Vd0rvKzMNHfUw woYrmT2z4n4yTv6Ksdj1SLygmE4cDuu16+rCWYe+r4ykvNP0ZsJMzV4BnCZXPdVTtsUz r9y/48vjII3gaN5Ub07w+dVOmffQevrHkAoWZK25/CpGlhuLmzmqe478GJan59G9bYso C3idJGH8ot3gm3VmlXMo9wwzF1GDS28eTWsXX7RkGFYdzpocnBW/RysMs74kiy/j60vI eINA== X-Gm-Message-State: AKaTC0074eaZ+IuhdL9bSmSqrxaLKAh7ek3XZBowugKReSwoJDkgW7K8YWAvvRxRBq1R2rnL X-Received: by 10.98.211.135 with SMTP id z7mr31882258pfk.109.1480482900166; Tue, 29 Nov 2016 21:15:00 -0800 (PST) Received: from localhost ([122.172.143.30]) by smtp.gmail.com with ESMTPSA id p25sm98824292pfk.20.2016.11.29.21.14.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 21:14:59 -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 V6 10/10] PM / OPP: Don't assume platform doesn't have regulators Date: Wed, 30 Nov 2016 10:44:13 +0530 Message-Id: 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 f60d7f943b64..979403448cd6 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); }