From patchwork Fri May 16 08:13:48 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chander Kashyap X-Patchwork-Id: 30310 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6F32920A25 for ; Fri, 16 May 2014 08:14:19 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id rp18sf421956iec.3 for ; Fri, 16 May 2014 01:14:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=wngA2epWjLhr/hx+PuGOAzEvyVEmbH+kLYUqRbDlt3U=; b=eoU8iOHTwa2TxTDPZC3nSXxTiQ1hviu5/CA6nzcF7knYoCTs5AwYbAhpJlrtmfZChu 0ay27iDt44c3JrPIps+Yq/HZYnaE9TNxGMugkVQSto7IZlr9Czro+7K7uKOG8kmGL4xn 28jdg7wyhLwMa0bvj6BVTL3SYf1CCNIFM6BEknp6CLHSVpSIPAsD7IcA8SVvaqNTRMPl xqMnxz9uymsgYnhsWHIQ5vdhY13AnRsAxE/vjZwSlinA02WYh4O+4bULvkRoIjduqs0X 0MRes8rygRpPlwp7KqgwfK2YxFzC+wjfrSvjpfSRysui0dKjJUpacC9NhyTBdYZZf2i6 si5w== X-Gm-Message-State: ALoCoQk6G0WfWGJpSrIXc6CGv8VlIjtVWKtr+2hjQMtoKbpowO5ibbkKi1PMlCUr9gX/cl8Foj5q X-Received: by 10.50.115.104 with SMTP id jn8mr3254557igb.1.1400228058931; Fri, 16 May 2014 01:14:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.164 with SMTP id j33ls574277qgj.73.gmail; Fri, 16 May 2014 01:14:18 -0700 (PDT) X-Received: by 10.52.227.138 with SMTP id sa10mr10801856vdc.25.1400228058827; Fri, 16 May 2014 01:14:18 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id w5si1411921vcl.174.2014.05.16.01.14.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 01:14:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id la4so5771962vcb.41 for ; Fri, 16 May 2014 01:14:18 -0700 (PDT) X-Received: by 10.221.4.66 with SMTP id ob2mr6419247vcb.28.1400228058733; Fri, 16 May 2014 01:14:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp32611vcb; Fri, 16 May 2014 01:14:18 -0700 (PDT) X-Received: by 10.68.181.67 with SMTP id du3mr18938054pbc.96.1400228057642; Fri, 16 May 2014 01:14:17 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bp5si225511pbc.182.2014.05.16.01.14.17; Fri, 16 May 2014 01:14:17 -0700 (PDT) Received-SPF: none (google.com: linux-pm-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756748AbaEPIOP (ORCPT + 12 others); Fri, 16 May 2014 04:14:15 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:60922 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755977AbaEPIOM (ORCPT ); Fri, 16 May 2014 04:14:12 -0400 Received: by mail-pa0-f46.google.com with SMTP id kq14so2232160pab.5 for ; Fri, 16 May 2014 01:14:11 -0700 (PDT) X-Received: by 10.68.219.162 with SMTP id pp2mr19043428pbc.47.1400228051651; Fri, 16 May 2014 01:14:11 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id oa3sm13151981pbb.15.2014.05.16.01.14.07 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 16 May 2014 01:14:10 -0700 (PDT) From: Chander Kashyap To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: nm@ti.com, rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, viresh.kumar@linaro.org, Chander Kashyap , Inderpal Singh Subject: [PATCH v2] PM / OPP: discard duplicate OPP additions Date: Fri, 16 May 2014 13:43:48 +0530 Message-Id: <1400228028-30165-1-git-send-email-chander.kashyap@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: chander.kashyap@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Chander Kashyap It may be possible to unregister and re-register the cpufreq driver. One such example is arm big-little IKS cpufreq driver. While re-registering the driver, same OPPs may get added again. This patch detects the duplicacy and discards them. Signed-off-by: Chander Kashyap Signed-off-by: Inderpal Singh --- Changes in v2: - Reorder check for duplicate opp drivers/base/power/opp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index ca521e1..973da78 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -443,15 +443,24 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) new_opp->u_volt = u_volt; new_opp->available = true; - /* Insert new OPP in order of increasing frequency */ + /* + * Insert new OPP in order of increasing frequency + * and discard if already present + */ head = &dev_opp->opp_list; list_for_each_entry_rcu(opp, &dev_opp->opp_list, node) { - if (new_opp->rate < opp->rate) + if (new_opp->rate <= opp->rate) break; else head = &opp->node; } + if (new_opp->rate == opp->rate) { + mutex_unlock(&dev_opp_list_lock); + kfree(new_opp); + return 0; + } + list_add_rcu(&new_opp->node, head); mutex_unlock(&dev_opp_list_lock);