From patchwork Tue Oct 4 11:56:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 77251 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2173462qgf; Tue, 4 Oct 2016 04:57:17 -0700 (PDT) X-Received: by 10.66.21.231 with SMTP id y7mr1278989pae.156.1475582237894; Tue, 04 Oct 2016 04:57:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s5si3281996paw.9.2016.10.04.04.57.17; Tue, 04 Oct 2016 04:57:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753712AbcJDL5M (ORCPT + 27 others); Tue, 4 Oct 2016 07:57:12 -0400 Received: from mail-pa0-f49.google.com ([209.85.220.49]:35162 "EHLO mail-pa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753582AbcJDL5J (ORCPT ); Tue, 4 Oct 2016 07:57:09 -0400 Received: by mail-pa0-f49.google.com with SMTP id ik13so19292491pac.2 for ; Tue, 04 Oct 2016 04:57:09 -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=VOAtT1eHDPWMGVyMT0HbaNl917daYRWifTsjmQFKfGU=; b=TwMnNfeEN1ZwsLFGZ8bwBkbfUKNujR4wvF1t/gyEMI454IBmuVIEakF6hyqF+msU1Y FSewCF2fBIbag+Wzi9TSpiEu86jc6hJ4j6Al8Ru9kfhvucFwpremWOERCY9eGMsJvXqm F3LYoz2BIOfArRmQRQJv4phVx4hJkLMPy0l28= 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=VOAtT1eHDPWMGVyMT0HbaNl917daYRWifTsjmQFKfGU=; b=Y/6vpc/RaYphBFaDcIAZasdKXyNJa+3OfTpUPKTkE1GkSvOjq0NXy45Adxb0oUhhS+ nbK54UJM2RsPbDNNyIEgXC5z7K6znVZ0hBAWYEcBvUlpFptz4BVsIBwQ3AlAilP/DK1t eBPl/1pCqyNsGQ2nG5OpNTpdLC0w41A6mIVZpCzFKorrLjtZCxZ6psaDVeuiSiyXZ6Ik CXRypv7tt+CymsEZMT5/h0PHfcoWK6aaYFn13QSQcRkQ2mygy36gvIA+eGLKOg2GLblx KCdLLJx8xB2QrH2l+ybloINIUnmnZFwo+RmPbRcDO4A+V10gDWy/B6G5m7urooRdzf/V gpeg== X-Gm-Message-State: AA6/9Rn9r3dHIm6MEfO23RJnJxT6akq0g6bDuVqtrG11AwwIOlYqcByb2fxymjTvkhREAajj X-Received: by 10.66.19.161 with SMTP id g1mr4489559pae.11.1475582228999; Tue, 04 Oct 2016 04:57:08 -0700 (PDT) Received: from localhost ([122.171.115.29]) by smtp.gmail.com with ESMTPSA id wa9sm5433289pac.35.2016.10.04.04.57.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Oct 2016 04:57:08 -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 2/8] PM / OPP: Don't use OPP structure outside of rcu protected section Date: Tue, 4 Oct 2016 17:26:44 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The OPP structure must not be used out of the rcu protected section. Cache the values to be used in separate variables instead. Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) -- 2.7.1.410.g6faf27b diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 4c7c6da7a989..056527a3fb4e 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -584,6 +584,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) struct clk *clk; unsigned long freq, old_freq; unsigned long u_volt, u_volt_min, u_volt_max; + unsigned long old_u_volt, old_u_volt_min, old_u_volt_max; int ret; if (unlikely(!target_freq)) { @@ -633,6 +634,14 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) return ret; } + if (IS_ERR(old_opp)) { + old_u_volt = 0; + } else { + old_u_volt = old_opp->u_volt; + old_u_volt_min = old_opp->u_volt_min; + old_u_volt_max = old_opp->u_volt_max; + } + u_volt = opp->u_volt; u_volt_min = opp->u_volt_min; u_volt_max = opp->u_volt_max; @@ -677,9 +686,10 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) __func__, old_freq); restore_voltage: /* This shouldn't harm even if the voltages weren't updated earlier */ - if (!IS_ERR(old_opp)) - _set_opp_voltage(dev, reg, old_opp->u_volt, - old_opp->u_volt_min, old_opp->u_volt_max); + if (old_u_volt) { + _set_opp_voltage(dev, reg, old_u_volt, old_u_volt_min, + old_u_volt_max); + } return ret; }