From patchwork Tue Nov 29 06:36:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 84507 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp2108012obn; Mon, 28 Nov 2016 22:37:37 -0800 (PST) X-Received: by 10.99.253.85 with SMTP id m21mr47776963pgj.38.1480401457596; Mon, 28 Nov 2016 22:37:37 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 43si30048455pla.193.2016.11.28.22.37.37; Mon, 28 Nov 2016 22:37:37 -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 S1755852AbcK2Gh0 (ORCPT + 7 others); Tue, 29 Nov 2016 01:37:26 -0500 Received: from mail-pg0-f51.google.com ([74.125.83.51]:35607 "EHLO mail-pg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755663AbcK2GhR (ORCPT ); Tue, 29 Nov 2016 01:37:17 -0500 Received: by mail-pg0-f51.google.com with SMTP id p66so66100105pga.2 for ; Mon, 28 Nov 2016 22:37:16 -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=3JCmbMx7s51ZWFcl4aGuNXu6/WknCCKGH6vpcYkzaoU=; b=BGgt7Gr285/olOSIQqOjodXZFBb6uLT2iFgEPfILQ4fw2FM2fciTFWi80rCwdO8/+R 96zwd5XRMEy8ZjAcPfpzKxZz0LrxQcqAcddnWlIfxDO2Wj4Ob6yW4oMfZ2N67oq22YDv 94eI6xvxnypG+EBnxi/8mj2W+w4yFDXoTaLLI= 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=3JCmbMx7s51ZWFcl4aGuNXu6/WknCCKGH6vpcYkzaoU=; b=VG3ZschdPSFj2tr0QX7B9eI515MvfN9hxpLJbWgoIbpr1qMD+2/OIISMBp4xG9FN66 b9kidL5S2V2xAVhQen8HFw1gqAi1bhqHONOsKBrPr0f6U2qU0mYbobWffLGNfXfJrfLw aYz+2B6C1GRAHSMJ+Hy9NZZwqsVMfPFXb/bDyaFGy9x0zcY3AiYbEzI3o5u1RbrO5Ai2 YXm+HdiLS0C6D1rrwCx45kZZwKKyia8GUL9Vx5AsYos76z7L9AasgmnI/8P+O5S9nOIp 7nlnyMJUHC8dP9r8Us6KZh9OuzJ5ZRUM8tNLtxe3IRH8eZrZST6YKRwbLq+W6Fe/AYoB MyHA== X-Gm-Message-State: AKaTC00DEJDmfMYDYcgxUTwNkbTG/5rP2599qKDn/GM+YqOXQfHgmih+A3POnjy07lnqNYUG X-Received: by 10.99.246.83 with SMTP id u19mr47346816pgj.165.1480401431418; Mon, 28 Nov 2016 22:37:11 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id c71sm73940319pga.22.2016.11.28.22.37.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 22:37:10 -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 , "# v4 . 6+" Subject: [PATCH V5 03/10] PM / OPP: Don't use OPP structure outside of rcu protected section Date: Tue, 29 Nov 2016 12:06:50 +0530 Message-Id: <89ceffa4d881492bb6f79b4260468e3fb5c794d6.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: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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. Cc: # v4.6+ Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd Tested-by: Dave Gerlach --- drivers/base/power/opp/core.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) -- 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 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; }