From patchwork Tue Nov 29 06:36:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9451029 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F06AC60756 for ; Tue, 29 Nov 2016 06:37:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E736D27BFC for ; Tue, 29 Nov 2016 06:37:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBDFD27F89; Tue, 29 Nov 2016 06:37:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F3AC27F46 for ; Tue, 29 Nov 2016 06:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755500AbcK2Ghu (ORCPT ); Tue, 29 Nov 2016 01:37:50 -0500 Received: from mail-pg0-f47.google.com ([74.125.83.47]:34697 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755878AbcK2Ghk (ORCPT ); Tue, 29 Nov 2016 01:37:40 -0500 Received: by mail-pg0-f47.google.com with SMTP id x23so66095773pgx.1 for ; Mon, 28 Nov 2016 22:37:40 -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=xooW5jvpc0bd7BE4Y8GHcp6wRo1d2p5vl413Y63VHPc=; b=WqMiwOvOk8YFFSwmpO3chS05GnmHfnx0HUt6dGLFMgryh4S5zPjMu2jOOSU6Whs/q2 w36s2FxD4VDWzaPEFkMRBFIM0amqD55yl41/+y1fz402EFj5rXLaW3vHxfVVVKImDJDK Tkbl19L4nX3WkO69mz3iooj4U6MAlxK56yCGw= 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=xooW5jvpc0bd7BE4Y8GHcp6wRo1d2p5vl413Y63VHPc=; b=mLfq6GEgQ/JAamr3kDtyU9FOBfyCerr2L1cXy7zsHtYjmFsNGZ2WnxADHgC+9Geu0l tvPJ6wyMUhklLOHktjYXE9xB22+J3CsTv7jV9oCHhA48r6mh0w23x5s+yGHHnCBZiB4x k+eSxdOsO8XitTno6qtpDlOIju6vs4dChXQUu+pg7J7632gr3nf9pTYAx1cvGCdukslr a4BOoIzpdaYX6KfffqvA1vyphS930MK2sJALdWcOoLKjF1GOXjTbCE9JHpvsIFOebrpz uoUX+6gHrxRzpaDsB/oMI/Y+3uQQrsBG7NAUJm0rizDURQ6jeJ2Mn+zZ7VuPGZseq0mh asfQ== X-Gm-Message-State: AKaTC022tlVScF5pLDW0WVtg2fv1E5NgBON4cQ9ib6fO0Tn4g4NL5W0qeKesHBZ46ocwcqrZ X-Received: by 10.98.159.136 with SMTP id v8mr26030044pfk.82.1480401455088; Mon, 28 Nov 2016 22:37:35 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id u23sm91754106pfg.86.2016.11.28.22.37.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 22:37:34 -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 V5 10/10] PM / OPP: Don't assume platform doesn't have regulators Date: Tue, 29 Nov 2016 12:06:57 +0530 Message-Id: <1b5cac826c60d6fe06146acf8f9377de8729fb1d.1480401041.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 X-Virus-Scanned: ClamAV using ClamSMTP 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(+) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 3c9f223709ab..f7a5fb4dbf11 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); }