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: 247667 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp955545ilo; Wed, 12 Aug 2020 21:29:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvOPQixzmPqjc7mGyguQv9VWxYGsB/xE4VfTlUgWW6WmF0+mft2SH6Xbw0inPWknyYkFdn X-Received: by 2002:a50:c089:: with SMTP id k9mr2901824edf.110.1597292961063; Wed, 12 Aug 2020 21:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597292961; cv=none; d=google.com; s=arc-20160816; b=UkyHoBi8Fp4PjG2EZBxkwdncJpJmo9e7nJ9rUOvhg2rq7A5QCH3eMYFdaCJd3QC1pX W0id7glnAHRlRFxrjtBF9p8axOLnBMRspxs4xsnPaTiIFJYKN57XE2BTSBU9MnQqO2n6 EZcHobd8uiYf8u0xVd+DUnsro0jvpNDOdrt05VLIc/TR26CFVJ+MglAhIIcSgbcy3x+N xa+IAUO3A+0WHo1FOjsQFe3K/q4I3kIQFpockwXXtE4sVT1/chwF8FW5j25TP2E1f0xD huXZnrSs3DAXL9ybrPLeZPsI1J4+etF/XP9Z71fJQD7a/zjOYcsIDx80ys4wLg9pAMZr ZV5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=EmYcMBFXduhCjGSSeOrt+gv2BnfjO/m6pxI+pucShxg=; b=HiFWPCQrlzgmfde1lCiyn/CaoxAppSDqDIuX1+cVp/YghEl/oMN1yP8Wyd0l9FoOSl 19UuPLlCIkRwH39PPyilPeBn8IU+njwviTOIVQ9i3sTOTql5R0AhLwvLgQlotXIK4JGf B2mmzpVrVi6gEMVelBQiwwFq1hK66HyyaEL5kmVjYydES5jEkfbAlO3Ia05HDZzrz/DN CnZnq4KWT+yCy2AkSAuPUKD7c7mWfHFK1A5QOe35bKEfLwqqkascgmHGhyCLvx70Rd/j wjCkTnT0sa7peTHr25w6v4trG6Eozyj8/hio/kcMAtMHUOWWeAtDbytle1MqNF/PPEUk cWcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iPOv0PAO; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si2485817edx.530.2020.08.12.21.29.20; Wed, 12 Aug 2020 21:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=iPOv0PAO; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726419AbgHME3R (ORCPT + 10 others); 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-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(-) -- 2.14.1 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; From patchwork Thu Aug 13 04:29:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 247668 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp955596ilo; Wed, 12 Aug 2020 21:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzi3hy0c5lYMTbRe8RRGRjkJ7v2i/1Z/RUMfKbWLSz+p+c1oKxQuS6Ctm7lWDEE0VjvqSVR X-Received: by 2002:a05:6402:31a3:: with SMTP id dj3mr3052457edb.73.1597292967993; Wed, 12 Aug 2020 21:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597292967; cv=none; d=google.com; s=arc-20160816; b=CtE69meLxIuxfZUQpg/1kbHeYp4/PAiGxOeQI/O/Yu1EB/TAxbPM+RAgrHyhrJY6ig EmtUVsLgOulEsxQP4G6cjkCEuoTPfaW3eLv18uAbtHrj6s63Kk4Vbf3MCpjDZ/5B/APg 1tXNH1/xCuzxMQDKwfQWWP6WManEXsKFN/tcvPomVkkKQkMU5c1iTCK/G/TOiiOaRHgz 2zobULtfsg5rOwuMAdTZ3koPoQTJjRd09oIb67tFzctxrXEuqpmzh42e4eTdvM6GWlu9 yNB9eIzxkpSB7nGjB0j36rwSorw8lkG1HEg8HhuYF692SoJu3l21KKPN3gwW48hZNNnI MUjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=FnqSmZl+R1cGEwJxsBmPrjhnE5qy7kpLT7a0PkymWnw=; b=Gu+85kn8gJA9gI1xL26XcXj3vn7tKDFplfWeZz4yyVr2i+EAoPrGf5LJ3BsHnZQWrU bBs+rn3QoGE3gby++0IOj+d74QDmtusNcuR4lV0AnMkeyEJH9cjzEu9+RYRyM+PCO2DE jHiS6gx8jeQSWftJy9I3zpIqNTagWrqm5ZLG6xJeortMXBQ1M0yRFGHF666Glf++boP6 0Sb5jSo4Ns6HjoShXZZnnxIduYzseDhQp4teyFgLCsxPPKSq4avYnGt4bYbWn70adCcC XhMucrFXxK0D3U5M+EMcyoTpvpTekzIQesaBIB6Tbwh3NSCcplvbSpbevJOaKyL3ZADd R3ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BPdliqHQ; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si2589474edr.58.2020.08.12.21.29.27; Wed, 12 Aug 2020 21:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BPdliqHQ; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726576AbgHME3W (ORCPT + 10 others); Thu, 13 Aug 2020 00:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbgHME3V (ORCPT ); Thu, 13 Aug 2020 00:29:21 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64BE1C061757 for ; Wed, 12 Aug 2020 21:29:21 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id y206so2150379pfb.10 for ; Wed, 12 Aug 2020 21:29:21 -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=FnqSmZl+R1cGEwJxsBmPrjhnE5qy7kpLT7a0PkymWnw=; b=BPdliqHQ2ac8a7pDlzzKWFbfJ7zncwNDnULEgX3wbaKLhjzg2QdF/0gtOmzTTYuAp3 8mTDmClt4jyQJN0kSTsNE7PoI6Re7qQWNqKIQtkHXtaFLeGx+g8KoXteYTQyONnYSWom fQXfY+X5oBNxy7r/JFqmEgje4ndjG0/J12iQVbhdgCJVPM7FX1EE64/dOhY/N6qmg686 YFf6Pu7Mj2gpfvmbQOM635n01REzkt/liLaHUJYO9EdoInCA+6RazqqkyRi95QI5ScF4 ehUCXXEaLTlyJT/7TzPmqiTfEfHuEzM87KvtXDSNKdBVO0b85ikaDYwKNXCBvJhCBp2o /FOw== 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=FnqSmZl+R1cGEwJxsBmPrjhnE5qy7kpLT7a0PkymWnw=; b=l92nVmqEGSOx/SwIZTNhvt12j7r55KYOk3KXJNTQwblPPsFO/LJH3tjeGR1fv2dQF+ ZSXqpp455QZbp6vU1jo1mfUXZvWOctFX2lyqw892KXuQqLRa0sjxD2dTKexMrUjtpjW+ t54LswfcRsR8dPjfrJkJQr6rUkMx5NI8eTEnVRUrS6xJK6vRpidOi995ZIyD/b9lvk/m P5TPkw2qQpDTl2RaSFwFiuVQ+t/xNl8+vL77BDfswNWqf2/VGDe1q5UuPYMyw7Nk0oPx xSl9eD9P8Fb/pZozjhsSJ+1hBkRd0ZIWgiY+WMbt51+4AnZOyDAL8kcXSbkkZC9E0mNf UMgg== X-Gm-Message-State: AOAM532NMuICCuevkTs0sfAiXC0MPam3/VEpUivkyqLHuRvziH6FaCSe VTZSNenFCjPCur+VErPdhz+7OQ== X-Received: by 2002:a62:18c9:: with SMTP id 192mr2490337pfy.23.1597292960896; Wed, 12 Aug 2020 21:29:20 -0700 (PDT) Received: from localhost ([171.79.32.211]) by smtp.gmail.com with ESMTPSA id a17sm3792120pgi.26.2020.08.12.21.29.19 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 21:29:20 -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 3/4] opp: Reused enabled flag and remove regulator_enabled Date: Thu, 13 Aug 2020 09:59:00 +0530 Message-Id: <359b588928b7e58b009f786b17ddc088c6a7d18b.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 common "enabled" flag can be used here instead of "regulator_enabled" now. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 13 +++---------- drivers/opp/opp.h | 2 -- 2 files changed, 3 insertions(+), 12 deletions(-) -- 2.14.1 diff --git a/drivers/opp/core.c b/drivers/opp/core.c index e8882e7fd8a5..5f5da257f58a 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -703,12 +703,10 @@ static int _generic_set_opp_regulator(struct opp_table *opp_table, * Enable the regulator after setting its voltages, otherwise it breaks * some boot-enabled regulators. */ - if (unlikely(!opp_table->regulator_enabled)) { + if (unlikely(!opp_table->enabled)) { ret = regulator_enable(reg); if (ret < 0) dev_warn(dev, "Failed to enable regulator: %d", ret); - else - opp_table->regulator_enabled = true; } return 0; @@ -905,10 +903,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if (ret) goto put_opp_table; - if (opp_table->regulator_enabled) { - regulator_disable(opp_table->regulators[0]); - opp_table->regulator_enabled = false; - } + regulator_disable(opp_table->regulators[0]); ret = _set_required_opps(dev, opp_table, NULL); if (!ret) @@ -1795,11 +1790,9 @@ void dev_pm_opp_put_regulators(struct opp_table *opp_table) /* Make sure there are no concurrent readers while updating opp_table */ WARN_ON(!list_empty(&opp_table->opp_list)); - if (opp_table->regulator_enabled) { + if (opp_table->enabled) { for (i = opp_table->regulator_count - 1; i >= 0; i--) regulator_disable(opp_table->regulators[i]); - - opp_table->regulator_enabled = false; } for (i = opp_table->regulator_count - 1; i >= 0; i--) diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index bd35802acc6e..0c3de3f6db5c 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -147,7 +147,6 @@ enum opp_table_access { * @clk: Device's clock handle * @regulators: Supply regulators * @regulator_count: Number of power supply regulators. Its value can be -1 - * @regulator_enabled: Set to true if regulators were previously enabled. * (uninitialized), 0 (no opp-microvolt property) or > 0 (has opp-microvolt * property). * @paths: Interconnect path handles @@ -196,7 +195,6 @@ struct opp_table { struct clk *clk; struct regulator **regulators; int regulator_count; - bool regulator_enabled; struct icc_path **paths; unsigned int path_count; bool enabled; From patchwork Thu Aug 13 04:29:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 247669 Delivered-To: patch@linaro.org Received: by 2002:a92:cc90:0:0:0:0:0 with SMTP id x16csp955601ilo; Wed, 12 Aug 2020 21:29:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGi6nLMxSMkUlw/PxHTumPn4s3rLWES+ZnNmW4Bl6I6JDYjqzoBGzbKz1lmKnH45xSheGC X-Received: by 2002:a05:6402:206d:: with SMTP id bd13mr3041899edb.57.1597292968321; Wed, 12 Aug 2020 21:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597292968; cv=none; d=google.com; s=arc-20160816; b=qiQbXilIxavqBRF5K+K/uCkrq0+AHylvQLNcewbAO7FLRukCCIIvdfYpQ3MzxOQUri pe4dg5i+iPs/9gkT7gOX3CDE0qF2fm79TQRneoL1zILmdKirCIQBF/TFd+egNUauECi1 aukagIxXyCDKbGC4AHacjpFxa5NKupvJ6delQv7KS/kH1VIM1pOjP6t8Qvap7E1HtrOa 2i9gUU1+aYP+uTZQjY0VzXClSckhaqBO59qh6juurep32YAQSdUm6g8NslTxTGkRx9mA aZ2T4RcMSeyzug0nyr0wEaglfM+foWAuQs5cOsG+kRpvOV9boyJk9clqpfxiwMW588mB vrGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=R39mZXnsq0qTraesNliee1MsAVA33s9QnxlmS7GVZbI=; b=XjzbR4Iy3y77bSVQwYPEatQj/b9GQypd9OeY+uxKCgdiLj3L+ojD70LCAQ9zlOmRb3 9y3DAZ06uB2GxuHOkuvPesxtWo0gIVseDOyRexlVv251AqRqKDpM445Va3AhekQPlVMw B4BDMTAxfI5rERzO70EqBM68vvZAsrs4wmBFvfeJtrP8rzxZNNveIZeNxNjhdaCiTAyY OEr5RMeCW7grnztHncZljPAn+QQo0FXYQuvm3jjD3pcSP/w73grqL3VK4F75bdf0Chfp ovlsRbnXlUoFOgafz3WYIq+EGsiVYQNyXXq6A7tRxjfazmYNrnVtd6gDgLBhWmCHjhhO Luew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1n9tH4E; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si2589474edr.58.2020.08.12.21.29.28; Wed, 12 Aug 2020 21:29:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=H1n9tH4E; spf=pass (google.com: domain of linux-pm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-pm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726596AbgHME30 (ORCPT + 10 others); Thu, 13 Aug 2020 00:29:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbgHME30 (ORCPT ); Thu, 13 Aug 2020 00:29:26 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A6FC061383 for ; Wed, 12 Aug 2020 21:29:26 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id y6so2078651plt.3 for ; Wed, 12 Aug 2020 21:29:26 -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=R39mZXnsq0qTraesNliee1MsAVA33s9QnxlmS7GVZbI=; b=H1n9tH4E5LR0hLMncTHZa2OqXcJNGM/3MvpETAWc3xKJJ9siDUlT2ZUQURgpPlKa+J HmNGgAwmwoRAWO6F/0Qlx0qr2uy8Ou0s3fXMQKoOkwTYAHCuC+KQPUQzw6216SHg0e77 RMghBXdyNvyQ9Rnz+XnB5xM1BBL9L9cYbN+AUFMbmwsLkgjbtB3IPnG6JYQyWTh63eOj GDW6niGkwGcCDGMtHG6O98TsJtdMXPvxOFABUPHKrQm8YqX4InK55oS29bDncwbabq43 10SCYCle0cQ9QfVH4RGsUb6sIJKd7PiVwJhdnY2zhfZxfPlFLhaQRp7Wqc/s9LGz1IbS G1zg== 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=R39mZXnsq0qTraesNliee1MsAVA33s9QnxlmS7GVZbI=; b=goFS8HSRddZL/6qqTPzzZ8dJqgeVODtkmX6saB63zNeaI3T/n4HXZc18UqcKs/Mty8 VZ1kr4Y3JsFawjz6/PMK7c0AxhECcH+MELJz0bcXeXNItRCx1RSuXlB/1+knDgnhPkHr Fa/kRrBwib3/Py97KmizHvCGqtSVVnO33Lpz/L6Gc3aG+RUYNY7s5cbhFOgHK1Oi79gx 0zkT3fyFO21ww2bxqB6Y/sQi0gcBK2m1TwjK2FcAmyLhgpfhOvUoaooWK2nFu+jCc7BC Zssga2p7dipga2Sl6aJbHf04PhQpbqUNauvymMUWnBM5bswJxL9eWDf9LY6iyiaPkgu/ jqtw== X-Gm-Message-State: AOAM531cxabgQOYR6DPKPplnLsdLDjmipX21FhLbcTBvT7W7qudGv8dl DClnntLSffMLyljt1rkqecXYDw== X-Received: by 2002:a17:902:b788:: with SMTP id e8mr2354217pls.117.1597292965549; Wed, 12 Aug 2020 21:29:25 -0700 (PDT) Received: from localhost ([171.79.32.211]) by smtp.gmail.com with ESMTPSA id e26sm4100031pfj.197.2020.08.12.21.29.24 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Aug 2020 21:29:25 -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 4/4] opp: Split out _opp_set_rate_zero() Date: Thu, 13 Aug 2020 09:59:01 +0530 Message-Id: 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 Create separate routine _opp_set_rate_zero() to handle !target_freq case. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) -- 2.14.1 diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5f5da257f58a..e198b57efcf8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -860,6 +860,34 @@ int dev_pm_opp_set_bw(struct device *dev, struct dev_pm_opp *opp) } EXPORT_SYMBOL_GPL(dev_pm_opp_set_bw); +static int _opp_set_rate_zero(struct device *dev, struct opp_table *opp_table) +{ + int ret; + + if (!opp_table->enabled) + return 0; + + /* + * 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)) + return 0; + + ret = _set_opp_bw(opp_table, NULL, dev, true); + if (ret) + return ret; + + regulator_disable(opp_table->regulators[0]); + + ret = _set_required_opps(dev, opp_table, NULL); + if (!ret) + opp_table->enabled = false; + + return ret; +} + /** * dev_pm_opp_set_rate() - Configure new OPP based on frequency * @dev: device for which we do this operation @@ -886,29 +914,7 @@ 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)) - goto put_opp_table; - - ret = _set_opp_bw(opp_table, NULL, dev, true); - if (ret) - goto put_opp_table; - - regulator_disable(opp_table->regulators[0]); - - ret = _set_required_opps(dev, opp_table, NULL); - if (!ret) - opp_table->enabled = false; - + ret = _opp_set_rate_zero(dev, opp_table); goto put_opp_table; }