From patchwork Wed Nov 30 05:14:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 84947 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp86902qgi; Tue, 29 Nov 2016 21:14:40 -0800 (PST) X-Received: by 10.84.208.102 with SMTP id f35mr69114369plh.137.1480482880318; Tue, 29 Nov 2016 21:14:40 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3si62651981pge.291.2016.11.29.21.14.40; Tue, 29 Nov 2016 21:14:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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 stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1752344AbcK3FOj (ORCPT + 3 others); Wed, 30 Nov 2016 00:14:39 -0500 Received: from mail-pg0-f44.google.com ([74.125.83.44]:34564 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750825AbcK3FOi (ORCPT ); Wed, 30 Nov 2016 00:14:38 -0500 Received: by mail-pg0-f44.google.com with SMTP id x23so77790669pgx.1 for ; Tue, 29 Nov 2016 21:14:37 -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=aD9Po29LixlxKd4QZzFx3IfwSN0y7cA4WGhjPD3owWE=; b=TILwn+CMdAwW7CcFyZpKsEwmVS8Y1JxkTMQRup6Lb5gW4KB9i6CI7G8ksP8eO76lIQ 9gzkzKbrUcSzRWCaUjFeBAvL50ALJqk71kKxEfSrKvbTW9rkWYHYxsqkmjoh+4k/s2ac n3GR10ruqzGSvrYYCOqzBBFhMwdfoMx7UNd7k= 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=aD9Po29LixlxKd4QZzFx3IfwSN0y7cA4WGhjPD3owWE=; b=D7uIi9UvwchUJp7wDrrrNl7sDm7ceP3a2odXO1Rb8vgiCcclT/4J4ynhoQO8/484Sb 2PR8L38i1rwfaVCwZ56LkQMWeAc24RL7Sw928ByukLuLigGtcSDMB2vFnwG3xcJLGfot ww7zpUhh6fpBA2BvPw4y1tofDsXC3IeNyAz/9m/BykUGR6qI/VEKL5zxAXlGeOkW2QGi zvdodanLHYPJR/Axp9fYBIlz7cKBWq5keLVyjjkUYR/PTZzXWWE/7umMaNrxRL5e8An5 3HkYnppmS+4K0A4rfEOm2dw8Czg3CWh10bnYxJJ0+HQTTi136mqlzTtAqL9ZGTJ4fG1e L7iQ== X-Gm-Message-State: AKaTC02ps2PQuGCyVIUhmUxsBrK46WHLOTomoJPa4YRGej4RPyikhDHjfZx4EaJQUiy926uf X-Received: by 10.84.197.1 with SMTP id m1mr69987099pld.159.1480482877446; Tue, 29 Nov 2016 21:14:37 -0800 (PST) Received: from localhost ([122.172.143.30]) by smtp.gmail.com with ESMTPSA id s2sm98805589pfi.10.2016.11.29.21.14.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 21:14:36 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@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 V6 03/10] PM / OPP: Don't use OPP structure outside of rcu protected section Date: Wed, 30 Nov 2016 10:44:06 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 stable" 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 60a4210ec6d1..705137da3954 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; }