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: 9395967 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B69F7600BA for ; Wed, 26 Oct 2016 06:34:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 855F42985F for ; Wed, 26 Oct 2016 06:34:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79D6729865; Wed, 26 Oct 2016 06:34:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F7AB2985F for ; Wed, 26 Oct 2016 06:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753089AbcJZGdt (ORCPT ); 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 X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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; }