From patchwork Thu Nov 5 08:51:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 56027 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp278787lbr; Thu, 5 Nov 2015 00:52:18 -0800 (PST) X-Received: by 10.50.79.129 with SMTP id j1mr1644834igx.52.1446713538321; Thu, 05 Nov 2015 00:52:18 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cq10si3492894igb.96.2015.11.05.00.52.17; Thu, 05 Nov 2015 00:52:18 -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; 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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161226AbbKEIwJ (ORCPT + 28 others); Thu, 5 Nov 2015 03:52:09 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:33932 "EHLO mail-pa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033105AbbKEIwB (ORCPT ); Thu, 5 Nov 2015 03:52:01 -0500 Received: by padhx2 with SMTP id hx2so73541315pad.1 for ; Thu, 05 Nov 2015 00:52:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=PwYzgOg2yVrQJCR6/awl1YbrzxktDf6wNjCiAaZLxYA=; b=cvdlqGVfDNjfn7XL9S293U+W3FIajRad9mAIOSk8eshNJfiUlkcSoIPY9WFov9sNNu N38oRNs5QlzUAISke5NM0iYuYQ8lwAw7cWt6sHCJaQ55KjufUU/4P5lN1u+knP+KlJoj T/d89XvDTtLDyZDHMhMBlNgYbtAHc9rGS/qbsSMFyzhSz35aDfs+sFUeej20PJ92Y2xP +DlMMamk8Njc+t3BOg5yhU3giA82lLCM5+BeCxr9IwY9Eb+kxAhxQkRGDAfZaaqgMh7b /wtuhQChk8AcMfWx7yBl85JsumlYiri3qfMOI1zzQNCL3n+VGUgNSSvEdo6qAwiBVSRG H6qw== 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=PwYzgOg2yVrQJCR6/awl1YbrzxktDf6wNjCiAaZLxYA=; b=dah3VMiWFT1nvzk3BJll2DPdGyJ8WwLFAwMVMSn4/Prw9agnwuNmZTWG9UMQaKp5Vb oSFxro/83RJN0GuGOi5vCzsnFXnQD5A9D8NM38SOCQR48eUQ8kQXsZAptvdiFqqpstAq UTSGCrNIXdWqH92DtZWgTRyi4dMTYv6MRXXN8DWj6O1ACVYfDG24onZq1qNk/iuJGB7s oXIjCDgS6OhtXhR88aPCUtvU9x8sTF9qMfxgsgGr9W8BshZPd87xlKFYlkQImIg8fqGF asYDEApjMKYN9+SRbRnTGORDmuxE9TfiIFTIyhwIbsypR2QC/CkJovln3Xud3KixAXvS pINw== X-Gm-Message-State: ALoCoQm4Y5JyyHIk3kHDHxFisR0RgA/STgZEgpIBNzrQ1FIXK8cD11qG+S473gX0s/ihjTsCJATi X-Received: by 10.68.139.225 with SMTP id rb1mr7912681pbb.33.1446713520571; Thu, 05 Nov 2015 00:52:00 -0800 (PST) Received: from localhost ([122.172.111.169]) by smtp.gmail.com with ESMTPSA id cs7sm6518186pad.35.2015.11.05.00.51.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 05 Nov 2015 00:52:00 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, Viresh Kumar , "4 . 3 # 4 . 3" , Bartlomiej Zolnierkiewicz , Dmitry Torokhov , Greg Kroah-Hartman , Len Brown , linux-kernel@vger.kernel.org (open list), Nishanth Menon , Pavel Machek Subject: [PATCH V2 3/4] PM / OPP: Hold dev_opp_list_lock for writers Date: Thu, 5 Nov 2015 14:21:20 +0530 Message-Id: X-Mailer: git-send-email 2.6.2.198.g614a2ac 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 Writers need to update OPP device and their list with dev_opp_list_lock mutex held, which was missed at few places. Fix it. Cc: 4.3 # 4.3 Signed-off-by: Viresh Kumar --- drivers/base/power/opp/core.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- 2.6.2.198.g614a2ac -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index a93a433c9ac5..7a395f5ba5f9 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -1175,13 +1175,17 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) struct device_opp *dev_opp; int ret = 0, count = 0; + mutex_lock(&dev_opp_list_lock); + dev_opp = _managed_opp(opp_np); if (dev_opp) { /* OPPs are already managed */ if (!_add_list_dev(dev, dev_opp)) ret = -ENOMEM; + mutex_unlock(&dev_opp_list_lock); return ret; } + mutex_unlock(&dev_opp_list_lock); /* We have opp-list node now, iterate over it and add OPPs */ for_each_available_child_of_node(opp_np, np) { @@ -1199,15 +1203,20 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) if (WARN_ON(!count)) return -ENOENT; + mutex_lock(&dev_opp_list_lock); + dev_opp = _find_device_opp(dev); if (WARN_ON(IS_ERR(dev_opp))) { ret = PTR_ERR(dev_opp); + mutex_unlock(&dev_opp_list_lock); goto free_table; } dev_opp->np = opp_np; dev_opp->shared_opp = of_property_read_bool(opp_np, "opp-shared"); + mutex_unlock(&dev_opp_list_lock); + return 0; free_table: