From patchwork Tue May 13 07:41:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chander Kashyap X-Patchwork-Id: 30005 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D065620446 for ; Tue, 13 May 2014 07:41:49 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf48991975pab.3 for ; Tue, 13 May 2014 00:41:49 -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:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=EG8GuDrtzn7sJ/SUcwDS2KZOv56UZs8vc7l6WiH8fIc=; b=ImGKBZ0uvb9Ma6bEtyyln6Ta32gkAdbKF381fYbrPNtBE7+yMr5TfQffYiTART3YtL U7GB06t1STch6oXXO8wlbTPPg7L4UcfFUcfneWWX0XoMBt9YJwnwNHiIeSPopxxpfk8Y aQKUWVW1elcBytqgjJIn0AHpmmyuRfoz72hoq9YnXNxAiZ1aA6HKFL2gwGV5f1yytQr2 KwYcwPbM08kcWDHYH38Og1X8lazqhE/rRk6Cgo16+B9VuPFKKNC5r3rvFqJ0ktANafWK coHHSxL0zZ0sme6eipGXLgIaALfeNwSKp0k17LlSw2xwYvgQyJqbCTTvsImVQFYjQgM8 bHzw== X-Gm-Message-State: ALoCoQl4nRPWosWEBdlN5LbSkKR3uHdIsZwVOPqtwuxVuHZws5rWtaCC5WFhWhmQV85GPmiS7IWd X-Received: by 10.66.251.70 with SMTP id zi6mr13219596pac.37.1399966909316; Tue, 13 May 2014 00:41:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.49.231 with SMTP id q94ls1805383qga.28.gmail; Tue, 13 May 2014 00:41:49 -0700 (PDT) X-Received: by 10.52.175.69 with SMTP id by5mr22992406vdc.16.1399966909175; Tue, 13 May 2014 00:41:49 -0700 (PDT) Received: from mail-vc0-f175.google.com (mail-vc0-f175.google.com [209.85.220.175]) by mx.google.com with ESMTPS id d20si2502063veu.205.2014.05.13.00.41.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 00:41:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.175 as permitted sender) client-ip=209.85.220.175; Received: by mail-vc0-f175.google.com with SMTP id hu19so7129158vcb.20 for ; Tue, 13 May 2014 00:41:49 -0700 (PDT) X-Received: by 10.58.186.207 with SMTP id fm15mr27094191vec.4.1399966909087; Tue, 13 May 2014 00:41:49 -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 ib8csp130144vcb; Tue, 13 May 2014 00:41:48 -0700 (PDT) X-Received: by 10.68.201.226 with SMTP id kd2mr3281603pbc.157.1399966908303; Tue, 13 May 2014 00:41:48 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id hb8si7568151pbc.110.2014.05.13.00.41.47; Tue, 13 May 2014 00:41:47 -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 S1758246AbaEMHlq (ORCPT + 12 others); Tue, 13 May 2014 03:41:46 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:58021 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754563AbaEMHlq (ORCPT ); Tue, 13 May 2014 03:41:46 -0400 Received: by mail-pb0-f45.google.com with SMTP id um1so692212pbc.32 for ; Tue, 13 May 2014 00:41:45 -0700 (PDT) X-Received: by 10.68.213.97 with SMTP id nr1mr3357835pbc.52.1399966905591; Tue, 13 May 2014 00:41:45 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id ss2sm58292342pab.8.2014.05.13.00.41.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 13 May 2014 00:41:45 -0700 (PDT) From: "[Chander Kashyap" To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, viresh.kumar@linaro.org, Chander Kashyap , Inderpal Singh Subject: [PATCH] PM / OPP: discard duplicate OPP additions Date: Tue, 13 May 2014 13:11:30 +0530 Message-Id: <1399966890-22926-1-git-send-email-k.chander@samsung.com> X-Mailer: git-send-email 1.7.9.5 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.175 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 --- drivers/base/power/opp.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index 2553867..2e803a9 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -443,23 +443,33 @@ 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; } - list_add_rcu(&new_opp->node, head); - mutex_unlock(&dev_opp_list_lock); + if (new_opp->rate != opp->rate) { + list_add_rcu(&new_opp->node, head); + mutex_unlock(&dev_opp_list_lock); + + /* + * Notify the changes in the availability of the operable + * frequency/voltage list. + */ + srcu_notifier_call_chain(&dev_opp->head, + OPP_EVENT_ADD, new_opp); + } else { + mutex_unlock(&dev_opp_list_lock); + kfree(new_opp); + } - /* - * Notify the changes in the availability of the operable - * frequency/voltage list. - */ - srcu_notifier_call_chain(&dev_opp->head, OPP_EVENT_ADD, new_opp); return 0; } EXPORT_SYMBOL_GPL(dev_pm_opp_add);