From patchwork Thu Nov 10 05:16:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 81599 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp553858qge; Wed, 9 Nov 2016 21:16:45 -0800 (PST) X-Received: by 10.99.173.3 with SMTP id g3mr20894034pgf.12.1478755005762; Wed, 09 Nov 2016 21:16:45 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u89si2946116pfg.283.2016.11.09.21.16.45; Wed, 09 Nov 2016 21:16:45 -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 S1751420AbcKJFQn (ORCPT + 13 others); Thu, 10 Nov 2016 00:16:43 -0500 Received: from mail-pf0-f182.google.com ([209.85.192.182]:34478 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbcKJFQm (ORCPT ); Thu, 10 Nov 2016 00:16:42 -0500 Received: by mail-pf0-f182.google.com with SMTP id n85so139647614pfi.1 for ; Wed, 09 Nov 2016 21:16:42 -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; bh=AJHmqnMSQJt76+7t1Nvkk4IE/tZgmMV92FFuUxriX9I=; b=d9LPXBhCpX1FqwTuWNoKI9fhhO7BDcf7VVSBX+bkDFfXrJ2urKfV4mldt39t261t2Q vVgd/5JTxThh+4E0t1phBhhx0Arua32OsYkaeVwJfulemCwZlBZcxkaoxqpC9HRwykEX eOSCixnh15wfxt7shmCcNxY5Vdw990ks4C9cQ= 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; bh=AJHmqnMSQJt76+7t1Nvkk4IE/tZgmMV92FFuUxriX9I=; b=U3LUXYd3kyMkai6EtgQONcsEUDZrYbGNceoJnhTkIKl5hKtLi9KUtFwnCExD4To3pp hWWpCfnixfYySkqAye9AqMsayKMElOu9wpNrVysz+a+0/qfHc/O5NfDb0xjtC8DiFQ0K CQ0Uj6VIG93Ob/wR7u41/XaSAbR8BbHMrbyQ17oBVG1i73RfBqw0MusFCdpM+ukBd9qn GoMdjIUTOpBJZ+YgWim6uoxfFwrQk1X4sf89tvfrrU+Z6O5xILh8EYUX5aeJIpzProqa +ipg4om0ii5qr34ISvgkAVnO/ig0v1dBscYuDuV/OCY08W2dtjZ2e+x3ZzrqKhimwWZa LAXQ== X-Gm-Message-State: ABUngvcovmB0cyd+A/SLNwYugXnH/mdW9WYGNtTsZ5gMQfRwGUlkud9GBfbnUEWgP6ezqDl4 X-Received: by 10.99.114.73 with SMTP id c9mr20978372pgn.44.1478755002077; Wed, 09 Nov 2016 21:16:42 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id xy8sm1006568pac.11.2016.11.09.21.16.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Nov 2016 21:16:41 -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, linux-kernel@vger.kernel.org, broonie@kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH V4 9/9] PM / OPP: Don't assume platform doesn't have regulators Date: Thu, 10 Nov 2016 10:46:28 +0530 Message-Id: <16ac92a9fcc4adbc146d2dff19b3d24b23ad745f.1478752125.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: <20161110011728.GV16026@codeaurora.org> References: <20161110011728.GV16026@codeaurora.org> 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 --- V4: - s/had/have - fix missing rcu_read_unlock() 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 3298fac01bb0..cb33f8b2b56d 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -734,7 +734,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); }