From patchwork Thu Dec 1 10:58:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 86010 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp633406qgi; Thu, 1 Dec 2016 02:58:39 -0800 (PST) X-Received: by 10.84.197.165 with SMTP id n34mr84506514pld.34.1480589919070; Thu, 01 Dec 2016 02:58:39 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u3si40233703plb.141.2016.12.01.02.58.38; Thu, 01 Dec 2016 02:58:39 -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 S1757267AbcLAK6h (ORCPT + 3 others); Thu, 1 Dec 2016 05:58:37 -0500 Received: from mail-pg0-f52.google.com ([74.125.83.52]:35267 "EHLO mail-pg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757104AbcLAK6h (ORCPT ); Thu, 1 Dec 2016 05:58:37 -0500 Received: by mail-pg0-f52.google.com with SMTP id p66so94045385pga.2 for ; Thu, 01 Dec 2016 02:58:36 -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=v6GIgujhdgtZAwySNGizjjzU55ZZxvf1NcIWr7cVi+o=; b=DrE0gLnDr9kz+QPJ+3AENV/jpDB7lcRsBzGp79BSUsGvU7/p+2zazdpbFbltxQElNv f+YkyW702wCaDjmipD4dUJO4g0GxUX8jWR/6D6R/njWeQBPGAk/aMb1Ht5QrEqm8N0xu KnNoZrgK+80+dR7sNOlnLI3WTEv/WiplefFWU= 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=v6GIgujhdgtZAwySNGizjjzU55ZZxvf1NcIWr7cVi+o=; b=aqWpeHlg5B8Yh3/0irp4RUOuz0rt3GX9TIUuxJU0Z/WiYazmmzgbBV0NAMR2Ir4G9d 9xE6CAj4EDsEKQwepAANQXxBFIfSYuw//y888UtxtSTO2jt663HMSuySoU9m5qlRM1aw 0SWVmRO7r9HGf5h99xrMnRurozhy2e1/dJoz8/HCEtagdA/LQsBKk+UT63z6eFefbV5X 25evklQKL0nkrhn318KPePFr+xOka+n/Xqeta1EZwHsCHVmqxbWD0WlDhxFsk6PLBjCc Q3sTDzuiYz8F8Z3d3EYOaAQ4IMW35iPzEPZgOjL9OdYShCGMKOuJFtJVTQiLidO/knIk /e2w== X-Gm-Message-State: AKaTC034iH/nomuccewFFG2bg9h+/Qnx1gQmMX82QMXIgMgRFeO87wg6Ksj4g2adlfpQYYTT X-Received: by 10.98.155.146 with SMTP id e18mr38458141pfk.45.1480589916477; Thu, 01 Dec 2016 02:58:36 -0800 (PST) Received: from localhost ([122.172.143.30]) by smtp.gmail.com with ESMTPSA id r1sm109756181pfg.56.2016.12.01.02.58.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2016 02:58:35 -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 V7 03/10] PM / OPP: Don't use OPP structure outside of rcu protected section Date: Thu, 1 Dec 2016 16:28:16 +0530 Message-Id: <8c81920230d36d7be918296aadc06d6aec1113d0.1480564564.git.viresh.kumar@linaro.org> 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 2824d3a5e9f0..6441dfda489f 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; }