From patchwork Wed Oct 26 06:33:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 79332 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp252074qge; Tue, 25 Oct 2016 23:34:31 -0700 (PDT) X-Received: by 10.99.122.87 with SMTP id j23mr1022921pgn.134.1477463671309; Tue, 25 Oct 2016 23:34:31 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ff2si749895pad.208.2016.10.25.23.34.30; Tue, 25 Oct 2016 23:34:31 -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=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 S1754242AbcJZGeX (ORCPT + 14 others); Wed, 26 Oct 2016 02:34:23 -0400 Received: from mail-pf0-f179.google.com ([209.85.192.179]:34800 "EHLO mail-pf0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754161AbcJZGeM (ORCPT ); Wed, 26 Oct 2016 02:34:12 -0400 Received: by mail-pf0-f179.google.com with SMTP id n85so17482976pfi.1 for ; Tue, 25 Oct 2016 23:34:12 -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:in-reply-to:references :in-reply-to:references; bh=DMIGZSPzDTm8uJauZBqpWEGGznAGXCt2QZsQ+Nb52tQ=; b=jCGHs/TBFp7GZaNAjkVekJ5LW+feULfW+P7KyTsdsMtv/4ZEm7or1jRuuXn7mYcOn5 AjDQM9gi4hC3iH+lip0QTcG28pzBACfyWUpTZrEEs2DHHjBycM9os3+WpWV0CCV4TyjY rhQp81/O16xNpKkrUcvhNlHCPSxuRqzbXhFNI= 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=DMIGZSPzDTm8uJauZBqpWEGGznAGXCt2QZsQ+Nb52tQ=; b=HZzOpQZNQ5W6yXRd2iqCX1rxkinwAu9G09tQyIk9Bg1hKitSqHXtrj+BWYOSVsf/vX YWENhgb4ersIMyAPxF7R1clh5JmrFHOGYUssThBfwCp0Nn6VXHzdKzi1y8p+uWwhCOav zLW4DxnXb6WF7AT667KucH5Z7OL8Sm5nZAHYM8dSaETsXyFIs7GFThjJwhUe6ikpv7K/ 2BLmLue1fVPJUtYB9dKIjdKAsKHKZ+vaekUp2j2X/33La42n4UDyrlLosbD6m6c9Fler FET1kZjQ40LnMrQw94f7mtpNyPt/sWNoUzIyV6mYWMWWQAIBTegnL8IYiP5ZOPDb4Mto gF/g== X-Gm-Message-State: ABUngveXzk+tyKzs9HH9krahvLa48W3FhC4by1xjs2uJ5vOCeKlNk0kKP3FBR5/Agyy977YJ X-Received: by 10.99.232.17 with SMTP id s17mr963336pgh.127.1477463652040; Tue, 25 Oct 2016 23:34:12 -0700 (PDT) Received: from localhost ([171.61.116.10]) by smtp.gmail.com with ESMTPSA id ht5sm1346174pad.16.2016.10.25.23.34.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2016 23:34:11 -0700 (PDT) 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, Viresh Kumar Subject: [PATCH V3 9/9] PM / OPP: Don't assume platform doesn't have regulators Date: Wed, 26 Oct 2016 12:03:04 +0530 Message-Id: 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 had any entries for supply voltages as well. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 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 3298fac01bb0..34cd48dfe89e 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -734,7 +734,17 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) /* Only frequency scaling */ if (!regulators) { - rcu_read_unlock(); + /* + * DT contained supply ratings? Consider platform failed to set + * regulators. + */ + if (unlikely(opp->supplies[0].u_volt)) { + rcu_read_unlock(); + 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); }