From patchwork Mon Jan 23 04:41:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 9531751 X-Patchwork-Delegate: rjw@sisk.pl 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 F0D066020B for ; Mon, 23 Jan 2017 04:44:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E148E279E0 for ; Mon, 23 Jan 2017 04:44:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4E1427D5E; Mon, 23 Jan 2017 04:44:30 +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 5B5F8279E0 for ; Mon, 23 Jan 2017 04:44:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750961AbdAWEmW (ORCPT ); Sun, 22 Jan 2017 23:42:22 -0500 Received: from mail-pg0-f53.google.com ([74.125.83.53]:32978 "EHLO mail-pg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750930AbdAWEmT (ORCPT ); Sun, 22 Jan 2017 23:42:19 -0500 Received: by mail-pg0-f53.google.com with SMTP id 204so41435763pge.0 for ; Sun, 22 Jan 2017 20:42:19 -0800 (PST) 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=AWD/biikQU3mOfuRdTGa1XS5V9QuQKzAE0SJ6VBWgNY=; b=DRigarICO7q/mN+QIuZrH6e1hkvV+pNIWKc8oUm/03jPcgti70uiLXtes3C82s/1No pV2WrWDJSrGiWqwWFQ4agip2I1NLqjP6ukDk16mAdggIKcqbJtWGAx2ZsSNNGNo8nm7C /JWWdlcEIE8YTewahtEhL0AqB5PWL5CtlaC3I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=AWD/biikQU3mOfuRdTGa1XS5V9QuQKzAE0SJ6VBWgNY=; b=J6GhVN4UZ5U+qsasl80Sczhsz6udkBC6Q0a46GrzKg0bVcKdgEG8QtsKJ5QUXEz13M yiHLaPE1hKQFb8NQFv9qyqW06nZOImdmnRBQ/vi01I3kuUU6c+tvJTsYHRNBJ83fTXHz AFo2NGwiGLb80y2TZMS6+GW1iG5oyQRxeOpEU3Wl2sbcadA+Zwdg1O7t0glhUVBdrQba R3Pnzdo1/Eewx7myiB3EvE90s6JkJQXDfAVIq+6AB+V7PjBlK1q2h9Q5Hgx0abGoXD2v FW9Rj4DuzamzEd2BatPO9nSliXmIV9a7tb4tc+auxKyHa9dYdHWttKoMVaUsp5ob2Dbe aYkQ== X-Gm-Message-State: AIkVDXIY7VhsoD53+3R3eYhX9GFcgY1B3CturwAAc9oW/nxZkGak47N7L4iXNJNUeJpQOZyR X-Received: by 10.99.153.26 with SMTP id d26mr30859805pge.44.1485146533836; Sun, 22 Jan 2017 20:42:13 -0800 (PST) Received: from localhost ([122.171.65.82]) by smtp.gmail.com with ESMTPSA id w76sm32635311pfd.74.2017.01.22.20.42.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Jan 2017 20:42:13 -0800 (PST) From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Vincent Guittot , Viresh Kumar Subject: [PATCH V2 04/12] PM / OPP: Take reference of the OPP table while adding/removing OPPs Date: Mon, 23 Jan 2017 10:11:44 +0530 Message-Id: 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 Take reference of the OPP table while adding and removing OPPs, that helps us remove special checks in _remove_opp_table(). Signed-off-by: Viresh Kumar Reviewed-by: Stephen Boyd --- drivers/base/power/opp/core.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/base/power/opp/core.c b/drivers/base/power/opp/core.c index 1af349ab630e..1a38b5d8dc54 100644 --- a/drivers/base/power/opp/core.c +++ b/drivers/base/power/opp/core.c @@ -971,9 +971,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_put_opp_table); */ static void _remove_opp_table(struct opp_table *opp_table) { - if (!list_empty(&opp_table->opp_list)) - return; - dev_pm_opp_put_opp_table_unlocked(opp_table); } @@ -1018,8 +1015,7 @@ static void _opp_remove(struct opp_table *opp_table, struct dev_pm_opp *opp) call_srcu(&opp_table->srcu_head.srcu, &opp->rcu_head, _kfree_opp_rcu); mutex_unlock(&opp_table->lock); - - _remove_opp_table(opp_table); + dev_pm_opp_put_opp_table(opp_table); } /** @@ -1170,6 +1166,9 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, new_opp->opp_table = opp_table; + /* Get a reference to the OPP table */ + _get_opp_table_kref(opp_table); + ret = opp_debug_create_one(new_opp, opp_table); if (ret) dev_err(dev, "%s: Failed to register opp to debugfs (%d)\n",