Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754848AbcKJBRd (ORCPT ); Wed, 9 Nov 2016 20:17:33 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:54986 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751644AbcKJBRa (ORCPT ); Wed, 9 Nov 2016 20:17:30 -0500 DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org BD327613F8 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=sboyd@codeaurora.org Date: Wed, 9 Nov 2016 17:17:28 -0800 From: Stephen Boyd To: Viresh Kumar Cc: Rafael Wysocki , nm@ti.com, Viresh Kumar , 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 Subject: Re: [PATCH V3 9/9] PM / OPP: Don't assume platform doesn't have regulators Message-ID: <20161110011728.GV16026@codeaurora.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1413 Lines: 45 On 10/26, Viresh Kumar wrote: > 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 s/had/have/ > for supply voltages as well. > > 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; > + } > + Don't we need an rcu_read_unlock() here as well? > return _generic_set_opp_clk_only(dev, clk, old_freq, freq); > } > -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project