From patchwork Thu Nov 24 11:36:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 83877 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp104543obn; Thu, 24 Nov 2016 03:37:24 -0800 (PST) X-Received: by 10.84.212.144 with SMTP id e16mr4429281pli.140.1479987444340; Thu, 24 Nov 2016 03:37:24 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f13si10433207plm.259.2016.11.24.03.37.24; Thu, 24 Nov 2016 03:37:24 -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 S965631AbcKXLhE (ORCPT + 7 others); Thu, 24 Nov 2016 06:37:04 -0500 Received: from mail-pg0-f54.google.com ([74.125.83.54]:35030 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965613AbcKXLhC (ORCPT ); Thu, 24 Nov 2016 06:37:02 -0500 Received: by mail-pg0-f54.google.com with SMTP id p66so17964580pga.2 for ; Thu, 24 Nov 2016 03:37: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=sTZAz9NKKOwO2BzFn6hKB7WaquPTexGv69gA4HIZwRA=; b=WZzNhwnBxyMBPYl8EWfV6S+sg7kiDgfc3QILPUuw/2yYZMulcNl5qSg56Pm6WngNMT zWqQYQOrfBAzpC9ozkGqTRLHeNzZx+9q4l4WbWbedMuRpVeqZHTsgOQUoi/UoBSPnUMq /fkll7hnEHt4eEHnv3llymMF72x8Vr3qF+DQY= 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=sTZAz9NKKOwO2BzFn6hKB7WaquPTexGv69gA4HIZwRA=; b=hq/vxfadvAYhyAUOdkvUWtjYACmzztUiz2S0vwc6qR/nNiaVXjx0J2Ts9gMUi7yzDz 0UN5EaRej5dIFXacYQ0zJ6NUWm/ZZIQRi8bQNd9UQyb/cET/gWWwWg3BLjxtQlA52AA0 BtBoAyKPu4pykZCH2In/zzcCr4CxGcioVjdcq3WbPOeNQSPkExquAa8pPvZhVp0fVchA hzfIhpfOTLKX21XBUxwiu4G4U+bT9gp7KATzS4OfBPhQft/rintSjxpvB+btnitMHfDJ UO/oL83ySA7OXeE5s2evUpi3GaH2IuucXKfP8i8YMKqlHZS0i54s8fRbPGu8OZ8k+x8C +XFA== X-Gm-Message-State: AKaTC01bj1XRctFFJGG1FBApFjO/dWGfXvdqtsZwUwo1ncwsMfdvMIhr3XiwpeyYEQQqp5cx X-Received: by 10.84.178.7 with SMTP id y7mr4393117plb.147.1479987421448; Thu, 24 Nov 2016 03:37:01 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id m19sm59829839pfi.24.2016.11.24.03.37.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2016 03:37:00 -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 V4 10/10] PM / OPP: Don't assume platform doesn't have regulators Date: Thu, 24 Nov 2016 17:06:19 +0530 Message-Id: <82cc855c7abb5d0583abe4cc9132c7e589434814.1479986492.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 --- 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 Reviewed-by: Stephen Boyd diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index d3f4c625b809..337057783e73 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); }