From patchwork Thu Nov 24 11:36:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 83871 Delivered-To: patch@linaro.org Received: by 10.182.1.168 with SMTP id 8csp104323obn; Thu, 24 Nov 2016 03:36:54 -0800 (PST) X-Received: by 10.84.133.129 with SMTP id f1mr4343989plf.64.1479987413892; Thu, 24 Nov 2016 03:36:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d30si10419457plj.185.2016.11.24.03.36.53; Thu, 24 Nov 2016 03:36:53 -0800 (PST) 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 S965536AbcKXLgq (ORCPT + 25 others); Thu, 24 Nov 2016 06:36:46 -0500 Received: from mail-pg0-f49.google.com ([74.125.83.49]:34056 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965512AbcKXLgn (ORCPT ); Thu, 24 Nov 2016 06:36:43 -0500 Received: by mail-pg0-f49.google.com with SMTP id x23so17974156pgx.1 for ; Thu, 24 Nov 2016 03:36:42 -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=bTjvqRW9Z/gizz6CKXDOtl6E82t6bmkX/eemvqk4IQU=; b=kMHXFEzsWuQ4q+qvHTD6NQAKncvUBoW6nLNJS2dpRu/oK8sHjVPiv/PMxwt0uO+YNF GkWcR5ikBzn/ZSiwD8XqwfEQ9F9CnO2iItYIicI1i77QcPeEyMeEUOVBSSt8UacWO0wJ Abefjx8Oa6AUS+T9P47XIriwscHuOC1SuFNXk= 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=bTjvqRW9Z/gizz6CKXDOtl6E82t6bmkX/eemvqk4IQU=; b=cg8yxjTNkV+vhav8PDwB4ziBfX4aucEqpvA3zivLlE2lRV0zI7vk/UON4FsfRrC6qj R8F1+kbA/2l1ed2a1XFMT8Ce77x3YxgaE7b07hhJKLWWsRpoCS4MK15qMiBJBXvGFhmP qo1ret4FBVxMCyN+xqk+xMCkm8qgMX3QPayUPw6OpoZvkCvFtQ7zYMEw00gHWyx2Xt4T gVvmLNjhcJ/t/QAGEs7sHxY0ANXLNcr+kdiz7aOtCh33npOk3wtVWehBv7oQLiQX3H/Q qNxSfMwd9I6UQmRyLvV9teG2GAAoO89fH6cHYQdxVF8n8VuD1BaCcU9CusQAn7RFZRKn Kncg== X-Gm-Message-State: AKaTC03geSfkp7SGShC0LUQfBmbGvmQCNKvi1N7tdovK75vtwYWuq96zgaMo5kLQF7DUY5Ds X-Received: by 10.84.197.1 with SMTP id m1mr4284140pld.75.1479987397228; Thu, 24 Nov 2016 03:36:37 -0800 (PST) Received: from localhost ([122.172.89.192]) by smtp.gmail.com with ESMTPSA id d1sm59823852pfb.76.2016.11.24.03.36.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2016 03:36:36 -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 Subject: [PATCH V4 03/10] PM / OPP: Don't use OPP structure outside of rcu protected section Date: Thu, 24 Nov 2016 17:06:12 +0530 Message-Id: <7817d2d3ccc77680c6e40101e80d201794398693.1479986491.git.viresh.kumar@linaro.org> 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 Tested-by: Dave Gerlach --- 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; }