From patchwork Mon Aug 10 07:06:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajendra Nayak X-Patchwork-Id: 11707005 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E826513A4 for ; Mon, 10 Aug 2020 07:08:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C99092076C for ; Mon, 10 Aug 2020 07:08:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="eN6FIskG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726115AbgHJHIb (ORCPT ); Mon, 10 Aug 2020 03:08:31 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:42243 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726010AbgHJHI3 (ORCPT ); Mon, 10 Aug 2020 03:08:29 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597043308; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=DWno83mBRJaK7NOCf0kx0lg1MeEy1FowAQbEwyuoYr4=; b=eN6FIskGg7sU0DjXA5lxtZ0jb2akfaiUgEJtIeItOVWI6NFb2SdDBaJMQ4sY1AHL6Z8zHxgr OHeZpSZNA5SOihl5O9H4S0l0TOVJeoD0nccs8suO3Yl9V+ogmAXQTUorvG3if5g8t4vcfql9 S5xxUCmjq371XKHwFUJSGARpkaw= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI5ZDFmMiIsICJsaW51eC1wbUB2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n06.prod.us-west-2.postgun.com with SMTP id 5f30f20d1e4d3989d4ed2b27 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 10 Aug 2020 07:06:53 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 64E17C433CB; Mon, 10 Aug 2020 07:06:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from blr-ubuntu-173.qualcomm.com (blr-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: rnayak) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7C2E4C433C6; Mon, 10 Aug 2020 07:06:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7C2E4C433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=rnayak@codeaurora.org From: Rajendra Nayak To: vireshk@kernel.org, nm@ti.com, sboyd@kernel.org, viresh.kumar@linaro.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Rajendra Nayak Subject: [PATCH] opp: Fix dev_pm_opp_set_rate() to not return early Date: Mon, 10 Aug 2020 12:36:19 +0530 Message-Id: <1597043179-17903-1-git-send-email-rnayak@codeaurora.org> X-Mailer: git-send-email 2.7.4 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org dev_pm_opp_set_rate() can now be called with freq = 0 inorder to either drop performance or bandwidth votes or to disable regulators on platforms which support them. In such cases, a subsequent call to dev_pm_opp_set_rate() with the same frequency ends up returning early because 'old_freq == freq' Instead make it fall through and put back the dropped performance and bandwidth votes and/or enable back the regulators. Fixes: cd7ea582 ("opp: Make dev_pm_opp_set_rate() handle freq = 0 to drop performance votes") Reported-by: Sajida Bhanu Signed-off-by: Rajendra Nayak Reviewed-by: Sibi Sankar Tested-by: Matthias Kaehlcke --- drivers/opp/core.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0c8c74a..a994f30 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -901,6 +901,9 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) /* Return early if nothing to do */ if (old_freq == freq) { + if (opp_table->required_opp_tables || opp_table->regulators || + opp_table->paths) + goto skip_clk_only; dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n", __func__, freq); ret = 0; @@ -919,6 +922,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) goto put_opp_table; } +skip_clk_only: temp_freq = old_freq; old_opp = _find_freq_ceil(opp_table, &temp_freq); if (IS_ERR(old_opp)) { @@ -954,8 +958,10 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) IS_ERR(old_opp) ? NULL : old_opp->supplies, opp->supplies); } else { + ret = 0; /* Only frequency scaling */ - ret = _generic_set_opp_clk_only(dev, clk, freq); + if (freq != old_freq) + ret = _generic_set_opp_clk_only(dev, clk, freq); } /* Scaling down? Configure required OPPs after frequency */ From patchwork Thu Aug 13 04:28:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 11711659 X-Patchwork-Delegate: viresh.linux@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27CB3913 for ; Thu, 13 Aug 2020 04:29:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FFA6207DA for ; Thu, 13 Aug 2020 04:29:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iPOv0PAO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgHME3R (ORCPT ); Thu, 13 Aug 2020 00:29:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbgHME3R (ORCPT ); Thu, 13 Aug 2020 00:29:17 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9093C061383 for ; Wed, 12 Aug 2020 21:29:16 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id h12so2180233pgm.7 for ; Wed, 12 Aug 2020 21:29:16 -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=EmYcMBFXduhCjGSSeOrt+gv2BnfjO/m6pxI+pucShxg=; b=iPOv0PAOwGrizFxzdFf9t/4kn5i+QSHq+MB1/7/E3KmAWZydvSEm9crZyK1GDeKqn7 /INLfrfZNWy6yZvtzwawmgA8kajj/4viTNR9HS8kR9wKHePKh97qIZqVJAFTyK9GQp7+ jDg5Fvzwb3NMb41ZAcoMd7zN3BOffp3hN0qPbQ1SjX9H0x/HAWeYpbA+O84xCJ9spPIF tlt+8cVEnDJ0DDpskXmrRjAOGmUp5669+QmD7fLAr0Xh9R3XwRmVOc2TrPjoiufiSiqv BZnFfrjRDHm/c6Lo0dl4RdIEYzFHizFjUOBxvEjDvvn2jG5oW/NB6XtnhVx+K/HOZR1e roKA== 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=EmYcMBFXduhCjGSSeOrt+gv2BnfjO/m6pxI+pucShxg=; b=P0AOk+XdywBL4WZ6E+LrO0IhOCzSsexuadxZljxzegEvnx+pS7xKf4XY6AElQo+yd4 C13C+pQkqiwqVS5dmy0T8aI7/g7W5FFxZNq3I++N8AHrFldru3PRx2HpfBWF4sNT1ocB he1akWNWT4IAvuI5KRH/VMSmNHyLgqqRD5y33sRkdI4n/XahGNAzZthbmuGpoRn9NobW LUU2zZmHYtH52ysTwGZ8Tk4A3Yz5crs7hfDoq7DCZfYWU0AJNui6f+UBducLfxVnsRy+ MCLZAv2e3Udyt7/cD9rIB5crWe25tUbGaQrJ5te4Xo/VgkJfSQs/WdJWmZTYK7hU3Fug gpgg== X-Gm-Message-State: AOAM530yubTNJrBaSq5YWjO8LV3hUUGDUOu0UYOw7AOjr2dcdAYK6GV4 mJdH8XDrI58inDdyBv0dQ/EJFw== X-Google-Smtp-Source: ABdhPJzODPFHAqWtboOMEMett8hu9BBsAIi3bVplg9YbNaau3YXbRuJT8Xz5EMlvOj5mGIEVF2KpBQ== X-Received: by 2002:aa7:9468:: with SMTP id t8mr2530895pfq.182.1597292955865; Wed, 12 Aug 2020 21:29:15 -0700 (PDT) Received: from localhost ([171.79.32.211]) by smtp.gmail.com with ESMTPSA id f195sm3837538pfa.96.2020.08.12.21.29.14 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 21:29:15 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , mka@chromium.org, sibis@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] opp: Track device's resources configuration status Date: Thu, 13 Aug 2020 09:58:59 +0530 Message-Id: <453b3897507838e95359d891ef967165bd167a4e.1597292833.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: <1597043179-17903-1-git-send-email-rnayak@codeaurora.org> In-Reply-To: References: Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The OPP core needs to track if the resources of devices are enabled or configured or not, as it disables the resources when target_freq is set to 0. Handle that with a separate variable to make it easy to maintain. Also note that we will unconditionally call clk_set_rate() in the case where the resources are getting enabled again. This shouldn't have any side effects anyway. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 37 ++++++++++++++++++------------------- drivers/opp/opp.h | 2 ++ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9668ea04cc80..e8882e7fd8a5 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -888,22 +888,18 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } if (unlikely(!target_freq)) { + ret = 0; + + if (!opp_table->enabled) + goto put_opp_table; + /* * Some drivers need to support cases where some platforms may * have OPP table for the device, while others don't and * opp_set_rate() just needs to behave like clk_set_rate(). */ - if (!_get_opp_count(opp_table)) { - ret = 0; - goto put_opp_table; - } - - if (!opp_table->required_opp_tables && !opp_table->regulators && - !opp_table->paths) { - dev_err(dev, "target frequency can't be 0\n"); - ret = -EINVAL; + if (!_get_opp_count(opp_table)) goto put_opp_table; - } ret = _set_opp_bw(opp_table, NULL, dev, true); if (ret) @@ -915,6 +911,9 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) } ret = _set_required_opps(dev, opp_table, NULL); + if (!ret) + opp_table->enabled = false; + goto put_opp_table; } @@ -933,14 +932,11 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) old_freq = clk_get_rate(clk); /* Return early if nothing to do */ - if (old_freq == freq) { - if (!opp_table->required_opp_tables && !opp_table->regulators && - !opp_table->paths) { - dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n", - __func__, freq); - ret = 0; - goto put_opp_table; - } + if (opp_table->enabled && old_freq == freq) { + dev_dbg(dev, "%s: old/new frequencies (%lu Hz) are same, nothing to do\n", + __func__, freq); + ret = 0; + goto put_opp_table; } /* @@ -1001,8 +997,11 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) dev_err(dev, "Failed to set required opps: %d\n", ret); } - if (!ret) + if (!ret) { ret = _set_opp_bw(opp_table, opp, dev, false); + if (!ret) + opp_table->enabled = true; + } put_opp: dev_pm_opp_put(opp); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index e51646ff279e..bd35802acc6e 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -152,6 +152,7 @@ enum opp_table_access { * property). * @paths: Interconnect path handles * @path_count: Number of interconnect paths + * @enabled: Set to true if the device's resources are enabled/configured. * @genpd_performance_state: Device's power domain support performance state. * @is_genpd: Marks if the OPP table belongs to a genpd. * @set_opp: Platform specific set_opp callback @@ -198,6 +199,7 @@ struct opp_table { bool regulator_enabled; struct icc_path **paths; unsigned int path_count; + bool enabled; bool genpd_performance_state; bool is_genpd;