From patchwork Wed Oct 26 06:32:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 79326 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp251904qge; Tue, 25 Oct 2016 23:33:58 -0700 (PDT) X-Received: by 10.98.220.5 with SMTP id t5mr1149573pfg.161.1477463638286; Tue, 25 Oct 2016 23:33:58 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si728915pas.289.2016.10.25.23.33.57; Tue, 25 Oct 2016 23:33:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-pm-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 linux-pm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-pm-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 S1753089AbcJZGdt (ORCPT + 14 others); Wed, 26 Oct 2016 02:33:49 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:34654 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753389AbcJZGds (ORCPT ); Wed, 26 Oct 2016 02:33:48 -0400 Received: by mail-pf0-f174.google.com with SMTP id n85so17475616pfi.1 for ; Tue, 25 Oct 2016 23:33:47 -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=bTjvqRW9Z/gizz6CKXDOtl6E82t6bmkX/eemvqk4IQU=; b=YVEm1taCI+59SEt/H4+4+HWmHI0wyRFriQOCVnc/P7CffRPa0qvPrZxjyv6BptVovq jeuUqQIkvyOMR7TgK4DBiTU0BWcnvgnqni4LlHL2Q3+ubxVMNewu4KF/LkEIh32+5sKc ozWrT/y/2MUSlxoGtnvm2XLfPUs1Lhsu+8ptA= 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=JlVN44DC/7194za/FOFfmitHVZQHP3TSNWxx5sDpROpwwYrZdNp5SJhZzmeLbXUZZ3 V1s02lGWG10LkMBMZKIoam1I0u/T2bPzEa+NPsXDysnSvVjcNZCqDH9sj61y1USroFdx VcgEXBYZLHz2EX28HcrSoMnNNakB9eO8QjfuvCGTTIMvF9Rt4vUNajTRAXxBKJVByDbj v9JJb2BslSxP2SZkmaRUNxeVTYYA6MQwcRJ/9QTog2G+pCnXHKs03Hi9OUgcs1cLMnt4 WVj4FWptb+ONj0Tlh6VbypyoAaB4RCM2++nhz0fMh61drr+8kJukOA9/5c8bhuHAyAkh Inew== X-Gm-Message-State: ABUngvdIBtlU6J4E9+XlXvNgHlbetY+9J7DLBvHdCdGSrHwz31qKg/U9hwY85vBtkLGe+zqJ X-Received: by 10.98.59.153 with SMTP id w25mr1217127pfj.112.1477463627340; Tue, 25 Oct 2016 23:33:47 -0700 (PDT) Received: from localhost ([171.61.116.10]) by smtp.gmail.com with ESMTPSA id a78sm1332644pfj.44.2016.10.25.23.33.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Oct 2016 23:33:46 -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 V3 2/9] PM / OPP: Don't use OPP structure outside of rcu protected section Date: Wed, 26 Oct 2016 12:02:57 +0530 Message-Id: <57dffa3dc126fed6690a79a8ca1f192ef1c2a79e.1477463128.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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@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 -- To unsubscribe from this list: send the line "unsubscribe linux-pm" 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; }