From patchwork Mon Apr 9 11:43:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 10331153 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 591706037F for ; Mon, 9 Apr 2018 11:44:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D081285F9 for ; Mon, 9 Apr 2018 11:44:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41AE028B13; Mon, 9 Apr 2018 11:44:44 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 D23B5285F9 for ; Mon, 9 Apr 2018 11:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752262AbeDILol (ORCPT ); Mon, 9 Apr 2018 07:44:41 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35518 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752240AbeDILoj (ORCPT ); Mon, 9 Apr 2018 07:44:39 -0400 Received: by mail-pl0-f67.google.com with SMTP id 61-v6so4959542plb.2 for ; Mon, 09 Apr 2018 04:44:39 -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=9wDc+0pse7OWTpuIPhm3Ig06uxmHSKdgmTinQq1SoDI=; b=DfpsJRN7Fnt3CZ01FZs5EcbZmk0ZXaq6OwsVlvg+JQyVhBwVAHyAuF3ReKf0py33bz TYEbijTwvMl81OJNq4Nk272PE3cKeP7TWFcuRHk7IZa61/y7TTVdFqzWgbNrRB0QnrfR dpwBZEIy2i2qI0jiLQbEU1N7VR6QGoeVGNPb0= 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=9wDc+0pse7OWTpuIPhm3Ig06uxmHSKdgmTinQq1SoDI=; b=JcZxXyGxqSNUVs7h9WRa8AlYJWQ6rn6QUXhN/zKLog6TssGloU6UZXHaizPjPwL9BM 4f2EvJF3Km9mYkTWHLvADnfzJkX5kORkcMcbJypzEQ3f+1AecB3HHGCD3vKJ5LwT6lRH XawbbLhfV/XaJda7TOvPkUZOL209s0UMQv5PEDho2E6S1pRv1GgTsdQeCMqYpn7oQKlP /AT+FCmTcL18N1K949rULsNjUOgeTuGQC1XE4ob+7OOAoBGjlipYjLHb3v16zQeM8C6g uCXP9LHog5MUMKAtndbbobxbVBobuVQW+lW1D/OiLU9MPuzsik6yiakU7EZgOztevp/X C6xA== X-Gm-Message-State: AElRT7FyBAbHXrSMxkw4PDjH3sawOwZZ4XymNr0T57vbUKG7AcGMUGdK npBgQT7AtMPqLFWSiYpCxDatnYARoDg= X-Google-Smtp-Source: AIpwx49hJPR3Qs03Hl6XX42RBichtolLLSLzV6gapvBMEt0eT3xkDez23udZl2Y+EAzH/7i/rzho/w== X-Received: by 2002:a17:902:3084:: with SMTP id v4-v6mr39008494plb.262.1523274279175; Mon, 09 Apr 2018 04:44:39 -0700 (PDT) Received: from localhost ([122.171.228.188]) by smtp.gmail.com with ESMTPSA id j10sm894544pfj.1.2018.04.09.04.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 04:44:38 -0700 (PDT) From: Viresh Kumar To: Ulf Hansson , Stephen Boyd , Viresh Kumar , Nishanth Menon Cc: Viresh Kumar , Rajendra Nayak , Vincent Guittot , linux-pm@vger.kernel.org Subject: [PATCH V2 10/11] PM / OPP: Get performance state using genpd helper Date: Mon, 9 Apr 2018 17:13:50 +0530 Message-Id: X-Mailer: git-send-email 2.15.0.194.g9af6a3dea062 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 genpd core provides an API now to retrieve the performance state from DT, use that instead of the ->get_pstate() callback. Signed-off-by: Viresh Kumar Reviewed-by: Ulf Hansson --- drivers/opp/core.c | 3 --- drivers/opp/of.c | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 416f54ba7a26..e4ec30ee1493 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1056,9 +1056,6 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, } } - if (opp_table->get_pstate) - new_opp->pstate = opp_table->get_pstate(dev, new_opp->rate); - list_add(&new_opp->node, head); mutex_unlock(&opp_table->lock); diff --git a/drivers/opp/of.c b/drivers/opp/of.c index de41e68b780f..5de9ec47c6bd 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -329,6 +330,8 @@ static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev, if (!of_property_read_u32(np, "clock-latency-ns", &val)) new_opp->clock_latency_ns = val; + new_opp->pstate = of_dev_pm_genpd_opp_to_performance_state(dev, np); + ret = opp_parse_supplies(new_opp, dev, opp_table); if (ret) goto free_opp; @@ -379,7 +382,8 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) { struct device_node *np; struct opp_table *opp_table; - int ret = 0, count = 0; + int ret = 0, count = 0, pstate_count = 0; + struct dev_pm_opp *opp; opp_table = _managed_opp(opp_np); if (opp_table) { @@ -413,6 +417,20 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) goto put_opp_table; } + list_for_each_entry(opp, &opp_table->opp_list, node) + pstate_count += !!opp->pstate; + + /* Either all or none of the nodes shall have performance state set */ + if (pstate_count && pstate_count != count) { + dev_err(dev, "Not all nodes have performance state set (%d: %d)\n", + count, pstate_count); + ret = -ENOENT; + goto put_opp_table; + } + + if (pstate_count) + opp_table->genpd_performance_state = true; + opp_table->np = opp_np; if (of_property_read_bool(opp_np, "opp-shared")) opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED;