From patchwork Thu Aug 20 07:56:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248009 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1136061ils; Thu, 20 Aug 2020 00:57:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzgom2dxD/cfaAMSNVHRSwQWzrGbDvJe8BJlMz7YW0LLv8DAykt8U5C6FA2w+a5d6GTu/0v X-Received: by 2002:a17:906:ecf7:: with SMTP id qt23mr2177349ejb.314.1597910231682; Thu, 20 Aug 2020 00:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597910231; cv=none; d=google.com; s=arc-20160816; b=gGr7L5GplDBOfU/v5wT5FPLFD5LSPkZjmigOPZWymvQOr8yEfF6S3PIIqBHXayww1U drDspMWnQr2pE3+skTlRnCrNcuPcSaxBckpuUeofwCdv4nsKBK/Wi0AZo9JY2xgAZDLJ nrWu487aj4Yd96kdoTjf6n3pi9u+SENJYQ2v9PO+rEAB9O23yY/bEpEOLbq5fpDMirfl ckgXr6cRUr8OaiwnN7RKkmt4etoeKKYXgZM1wrXzBsAVRHQdKXtJjKAATfpudgENAPnE W154ag7p0/alR4XWKCrt6JsFft1ek7yUkQx1IrViiq6i71EIx6frNy5/Tyxh8HZremU3 nBrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Xmu7H0E+tFg4FErq7QIubnUbkqLX4YsFmMjBv8snFjM=; b=llBzQ2/LJBesYWnSuNX32GXvFI0tI8IWyQ8xlMz7fvdJaHyS+XxqH1KTbtjQFUAW3g iX/8L0BbYhBfpq2YjFJnvjco4of4hIX8quWz6qDGfmOv4EqQgiJfTU4RMPHVdjC1ZClO YXf3AaMp/EXKq8hfmpLZywD0ArzaeDq9FwEncQbiOLtRDNXWmbtMjhNOdkHHfoK9rGAx Bho++7L1oDsRAE1sZHyUP0IX1cdsyyjVPOLUiujnmlnlBWC7WSNI9h4z+kWcbtLmhIBV U/zohvVgS7+3x+GO3RuJW5R/cEZuMuF3pRgpEp7wznTUGSA7R4R1qiCwyCKI9l4jFJl8 JqTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XeiN7jhz; 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 b20si98079ejq.631.2020.08.20.00.57.11; Thu, 20 Aug 2020 00:57:11 -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=XeiN7jhz; 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 S1726844AbgHTH5J (ORCPT + 10 others); Thu, 20 Aug 2020 03:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726799AbgHTH4o (ORCPT ); Thu, 20 Aug 2020 03:56:44 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E615AC061386 for ; Thu, 20 Aug 2020 00:56:43 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id h2so679057plr.0 for ; Thu, 20 Aug 2020 00:56:43 -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 :mime-version:content-transfer-encoding; bh=Xmu7H0E+tFg4FErq7QIubnUbkqLX4YsFmMjBv8snFjM=; b=XeiN7jhzKtl+qc8zYJeYP04FEkec+TZuADSi0PKem0kyofYbjO4yrpZIEMlrJHIQR7 mj5Esq/GTfN/ZYF9OXmHMeIDIEjaLrFoXuYn7idXzBm3Nquh1dSU9enaxPZAjA/JYcdn C5LMaanseLjriumFoBuVFmsBjF0KyB2MR11rKB9+NZ/dKVQTvxy7KcT3Tw4lOJ4VDQdo oLj39R9AGF900jmwJp49Dodn8o+o5FwO9f7uu6QGtQESBGxtN0RxB5tZC2ZP05Oxhckq Hd5TEsf4yTk7fZ/Y9de8Ka6RiGaXIy0lCItr2P8hHkPOqPCvhV3LH5fZZ8BnLnS/ky2b Ig8w== 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:mime-version:content-transfer-encoding; bh=Xmu7H0E+tFg4FErq7QIubnUbkqLX4YsFmMjBv8snFjM=; b=JF2S3f13XXGxlCWKXIYXdfnCyG+s7vpgMfNAynaB2CYrSFfWcwfvhu0QVQPzpU/aVb nRyV1ZbeIi/C7VQDid93mlmYpYB8oZoJ2ZDibbz2fkVegHr6Cu36kSkpBCcShLqNJwDK PlVKeF96ldLWX1N7ZqH+j/pcCFfWudcajgWRZ3tpQEkzTtbKxOCZCGMuh2h1ZeqhizES YyOiW97+zSxEHoEWBlR+tzfM6cHc56cihIDtMPJsVco85Zi2qfEyVR+yGvwMDH8XB2U0 K/xoxgeOQusEhD2AztMtgojbAysBVcX2m+teT8EngWYBIX+JFoDwgA+AvzWY2UVd5rBB ogug== X-Gm-Message-State: AOAM533bPl2v7slkPZiF2xhlioTJZwGR4T5fJ2Cv8OM+EqxYJGES3saI DwVNJkg2ldiu0K0voHRy+2FfLQ== X-Received: by 2002:a17:902:a585:: with SMTP id az5mr1692694plb.172.1597910203441; Thu, 20 Aug 2020 00:56:43 -0700 (PDT) Received: from localhost ([122.172.43.13]) by smtp.gmail.com with ESMTPSA id f6sm1777666pfa.23.2020.08.20.00.56.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 00:56:42 -0700 (PDT) From: Viresh Kumar To: rnayak@codeaurora.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , sibis@codeaurora.org, sbhanu@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 1/4] opp: Rename regulator_enabled and use it as status of all resources Date: Thu, 20 Aug 2020 13:26:31 +0530 Message-Id: <38740bd2a53a0f4778e9a8719ac2c590423f745a.1597909885.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Expand the scope of the regulator_enabled flag and use it to track status of all the resources. This will be used for other stuff in the next patch. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 19 +++++++++---------- drivers/opp/opp.h | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 9668ea04cc80..6f43ef4945b7 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; @@ -909,12 +907,12 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq) if (ret) goto put_opp_table; - if (opp_table->regulator_enabled) { + if (opp_table->regulators) regulator_disable(opp_table->regulators[0]); - opp_table->regulator_enabled = false; - } ret = _set_required_opps(dev, opp_table, NULL); + + opp_table->enabled = false; goto put_opp_table; } @@ -1001,8 +999,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); @@ -1796,11 +1797,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 e51646ff279e..0c3de3f6db5c 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -147,11 +147,11 @@ 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 * @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 @@ -195,9 +195,9 @@ 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; bool genpd_performance_state; bool is_genpd; From patchwork Thu Aug 20 07:56:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248008 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1136057ils; Thu, 20 Aug 2020 00:57:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxNa/uGzIWmWtwqZJ8xMlWhXRVdl/oMtQ3iomHSCOalkNGC7BtIdGUFAoKFmBhhVDaKXSpx X-Received: by 2002:a17:907:2163:: with SMTP id rl3mr1985940ejb.355.1597910230745; Thu, 20 Aug 2020 00:57:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597910230; cv=none; d=google.com; s=arc-20160816; b=Vge/73UeN8sb+XSCBm6D32aC9MzQp6U3/hcPHYDj3Sf4lyxtFWrUDpvXWzW2LFSDjJ joD461r30waJ0l8BAg/SVnVyrIrOurkRIgQ0AZLwhddYj+NfTDwy2xoZfXlLhnlsPMu3 RQdOZHbSlufJquInTTFXZjwzLd1M5kZzzdq/r4MyyF2RlM2ai/lwqvACTv4G5sy3YdNJ DuSCmmIFcwGMJU6GxfC7aEjgJys/3PORAa7f0DPJ0gd37pEButxdXayG6XUJq/6Sx2qF jFgEc8nys25h3N8keLgcIscZ51a5JuEjxHg2AFfWR6zRHHTQxGps5SKhCyC8910Y7pOm q02Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7cAYVPl8VrNuz/qq2w1qboUHzBiXW9tB7aHazhnx+PM=; b=jPYXKDpcp+9gjlrNZutMGtY5c25gVmPg9O0nhTGKAdkeixbS5Gzi52rVZrv6QEXRRQ LbxMARjx/TGdbS0oDeJHFee33W9Abc19zMNj1BxgThqfawCiS/eHZVAyr5akLq0gZQRk GMoAJUFjHbTcN9+A9gnnpAdpmNQdvS9H22UN1j9yCv+A7vyG10LDvnpomV38/aUC7h1L 2baWzymGSEQcWwsJM3Yz7XMXqoGmXQ3riGTZ4G7zS1Jq6Q3Gyh5k8UZSHnYf6/LKWc1r bULdXOSyZYzXvKEQMCrucpRrqjhJcTP3d6EVyoiywyR8xP3LgyMeuqnys3R8otrlbB7r phxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djA1hgKE; 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 b20si98079ejq.631.2020.08.20.00.57.10; Thu, 20 Aug 2020 00:57:10 -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=djA1hgKE; 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 S1726867AbgHTH5J (ORCPT + 10 others); Thu, 20 Aug 2020 03:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726844AbgHTH4r (ORCPT ); Thu, 20 Aug 2020 03:56:47 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 075B2C061344 for ; Thu, 20 Aug 2020 00:56:46 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id 2so611993pjx.5 for ; Thu, 20 Aug 2020 00:56:46 -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 :mime-version:content-transfer-encoding; bh=7cAYVPl8VrNuz/qq2w1qboUHzBiXW9tB7aHazhnx+PM=; b=djA1hgKEGskSmARq3FIBrHUsYkkRYcjjVOCAopzAHSM3DdER8yOHcbaeLUYu5OrdvX 29WLW6jF8w82pw3sGSWKV4gumuYQhCXS4+Uo4wB648aMj1oTtl9KY8tJIO2c6MlCAz4H XIkYwISLFxGmNwkmqb+OiuqROpFTHyyt33+A1MmQy3ItCODZx5ppQSlVAieEW8ahhIlX OhsoT3yiRmkfL2VoIorrNcAF64tNwrUkhFBh3gtPNX6a1XkdAB50b0NjhU/iZryBEP+p QYSe8XvJkTtiE6bt5CsFiWpW3o6QXx3WpQl+Yma5Qmee4izygCJael6hkfcplCxDECYN moKA== 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:mime-version:content-transfer-encoding; bh=7cAYVPl8VrNuz/qq2w1qboUHzBiXW9tB7aHazhnx+PM=; b=uK9rgO6Sr4YGGD1VBcsRZ4cgciVn+zMZzPiZ/0G68Yi6Jo5LuB/LY0tphyjKoGOg0U BaSP6Hje2GNXe9x6hwLa/+v7nhoMH840o8/Uk+Uz+C8R9V2yv7g6Naw7cO3lzgThtoLH Re7mnb0ba2EUDF+8gbUZ1tHXsCgivffDPxizGmg7QBudwbk0BNoXYJW593iZ9mvGMspc RKqSauLD0SrZEKWYra+m3Xplxqf4C+JE5s8wZ48J12Mhl583ycu+fM0nOTaTjYCdAp2O WUBrS6LnBZe3yz6mtdbNaN324KrykMfSOLGQj61DlTxKfT5JQe83W7JmNJwzXAupsiZA aCWg== X-Gm-Message-State: AOAM530foII9JuUp+svcsnkyM3s7C/1pjBc1JZRV0kWq/YDXOTaKVrmJ htHM8GhD54aab330976f2qyLnw== X-Received: by 2002:a17:902:be0f:: with SMTP id r15mr156256pls.84.1597910206510; Thu, 20 Aug 2020 00:56:46 -0700 (PDT) Received: from localhost ([122.172.43.13]) by smtp.gmail.com with ESMTPSA id v10sm21351892pjy.3.2020.08.20.00.56.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 00:56:45 -0700 (PDT) From: Viresh Kumar To: rnayak@codeaurora.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , sibis@codeaurora.org, sbhanu@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 2/4] opp: Reuse the enabled flag in !target_freq path Date: Thu, 20 Aug 2020 13:26:32 +0530 Message-Id: <9cefccfbf124c49f32c905549aad9ab284957065.1597909885.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 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/configured or not, as it disables the resources when target_freq is set to 0. Handle that with the new enabled flag and remove otherwise complex conditional statements. Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 6f43ef4945b7..0b437d483b75 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -886,22 +886,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) @@ -931,14 +927,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; } /* From patchwork Thu Aug 20 07:56:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248006 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1135961ils; Thu, 20 Aug 2020 00:56:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUkPXJU3NpayitzTGqWAjq58uHeVHHKkVCgDxqkQbvqLtsCsPYXy1dJTUWM5EJXGLyWXkv X-Received: by 2002:a05:6402:1758:: with SMTP id v24mr1749728edx.274.1597910216563; Thu, 20 Aug 2020 00:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597910216; cv=none; d=google.com; s=arc-20160816; b=ivo77eM3dsCGnq2+j4MavXrbpPVMmNBDAKSHiHzjXOhceLSZqQTy3/p+WppvZzTnoS IHxFXJfO4M2Pazav9ZK2xOjVrElW0g3M0TAHzecTNUZ2kHtITQVvEBRrZkAIaU+AfSJu N3pGibiyTy/BlXCkXlYlh+dsqc7gJRbCx5YDezuTM8uKJUspTCWgngCpZOR0uJgTK3Lp e8/UuqGNeT/lWiqNAQUPzy7JMHadSa9JrqAJIVEhDKEuum28tfBU9ZL+28l9wVT5Ts3W 6qOIus6w/azW1I/O5ZrL/soJOLMkU766tbUE14+D1ctTxQttNMJVPKtKMkX/3FxpPRls 6q9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iqN+JRqBcM9sNS/bUUY7pxB30ldKatY72VtpGF2V5es=; b=bGjrH8Pb/1McO9Pb0tii7OJelpCPN7ZapZGU81PuZAUwA/IIP61wxgF9FD7BAqCEp1 dXGfVsuXBv4vFFYkt/knk6Gkqxx8ihKKgjSFgzwpMR+jfQVW9J9QjpxsJNb9GoAjUzpI ydUIlIbY450+h7R5JZXcTZjmA0YpBw519aXDZex5Iictgf8o6vdI/1Fnl4BLJ7kKRShA Qymt45qMh7cgSAae05FDLyPSXCc6eyuOT6h8j3iJD0wQ6dpJhA5MDRzgaZ/EDr0cc9jL lMM4y7YGVkxnu3JEBToP6UWXk/spkV0HVhkKTJKPcLMS7uDXXrYFbEooNG6bP8PCkpFa D8xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mf3rBwfB; 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 cq3si924375edb.474.2020.08.20.00.56.56; Thu, 20 Aug 2020 00:56:56 -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=mf3rBwfB; 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 S1726973AbgHTH4w (ORCPT + 10 others); Thu, 20 Aug 2020 03:56:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726965AbgHTH4u (ORCPT ); Thu, 20 Aug 2020 03:56:50 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D12B9C061383 for ; Thu, 20 Aug 2020 00:56:49 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id 74so609089pfx.13 for ; Thu, 20 Aug 2020 00:56:49 -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 :mime-version:content-transfer-encoding; bh=iqN+JRqBcM9sNS/bUUY7pxB30ldKatY72VtpGF2V5es=; b=mf3rBwfBi0yKumSxP8KE3wv22MrRq2xvrN50piShKy6hP8xLXV3o5c16JSMPtHIuy9 +HGYFuxUtPOQIAee5skPIxdRSp80RPp98Qx6YwSDRviMIhgkE82sV9+XsVzIUBMIGU2e lkZcKh7JmQg9xjbLnH9GRK+c0hnXZDbtIKuTMOZ3W57PY29jgpHVO/nMynDjGZGJIrHE K+YfMWeOJij4utbSUAv5OX9S+m1BpIwcShog7ZvylOCusbSalofndd2qgQ4SeOiXiyMG OuXv/60JgKFcucPFV41z8wupsn3Qp0MuPSHYvbPdYjVV6ld3eHhT9ofkMZeqrFjVqJ5z J7tg== 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:mime-version:content-transfer-encoding; bh=iqN+JRqBcM9sNS/bUUY7pxB30ldKatY72VtpGF2V5es=; b=TwT9afCWubtUZrvMEeyOVXi4M4bWuS9YMJLz7yyUdrrEZzqiWrzokInIyJabW1Hk48 TnAU2DJvobnQm8zM7MY8VYCVWWJX0N4HZ5IAYkyzMjFlh8QnJhn5B1rqzIxElCMkvVnp jgKN5yJIpuXh6crJeq1dmsaTNTmicCIoMzezVEK/WEHCRgXNVmxGdSbrPsQpEbdQ31D+ 6FUjKGKvtyqF6+mqoeh1MZU3ab3flxQnDDu/h+iUauS368z8xFIWpJ8ss4yKrRePNTew 3vUhIyJ3rLlm+TjxLCIEfY3kOBUXyW5F6e3aR/PQO+6nopJ6f/zzFM9yPucO5678u6vo scsQ== X-Gm-Message-State: AOAM531WCNIXLRDc/qIT4P2+lESArRwyJ2xRz4VfDZax8q3McBGUeWby UAOgSj5NHTxjty3QYITpJLd6yq0sQ0ut4A== X-Received: by 2002:a63:4b61:: with SMTP id k33mr1583047pgl.195.1597910209384; Thu, 20 Aug 2020 00:56:49 -0700 (PDT) Received: from localhost ([122.172.43.13]) by smtp.gmail.com with ESMTPSA id n17sm1570767pgg.6.2020.08.20.00.56.48 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 00:56:48 -0700 (PDT) From: Viresh Kumar To: rnayak@codeaurora.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , sibis@codeaurora.org, sbhanu@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 3/4] opp: Split out _opp_set_rate_zero() Date: Thu, 20 Aug 2020 13:26:33 +0530 Message-Id: <5a0183fa0b61cf70839fa90aa70f79e33ab4f60a.1597909885.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 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.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 0b437d483b75..4edd2c3d6d91 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; + + if (opp_table->regulators) + regulator_disable(opp_table->regulators[0]); + + ret = _set_required_opps(dev, opp_table, NULL); + + 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; - - if (opp_table->regulators) - regulator_disable(opp_table->regulators[0]); - - ret = _set_required_opps(dev, opp_table, NULL); - - opp_table->enabled = false; + ret = _opp_set_rate_zero(dev, opp_table); goto put_opp_table; } From patchwork Thu Aug 20 07:56:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 248007 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp1135993ils; Thu, 20 Aug 2020 00:57:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPYbhTySFxC2IbZjL7/O+WFm9jxPckKxcEJ3wDvw0tb+zlxnP2UpV9I8jTwZqSLoPmfWPB X-Received: by 2002:a17:906:1392:: with SMTP id f18mr1979975ejc.521.1597910220859; Thu, 20 Aug 2020 00:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597910220; cv=none; d=google.com; s=arc-20160816; b=vDXojOm6O4WfPnOQ5jV1blRmAFmEgz2JnAsOcskakP3ClYqyTSnx3Wtw3AaUU9WAUs A3ZVXVcelbOUbHW70i9mhBluW6UiBiUjwOWk41EEuFlP+LYPbE9V7pEGDzMwAEi+AR2I Ia2RSKBLsQxABETtaBleaCBg36cJllEDxYW1yTiC368wmQbIj2x3Fhj0jnnp1lz0owe/ Bcys9lLYozKahbVjrfJiwE3RpQ5oEDSYg//MtAehHaPc3c9L5N6ImkhU7jXjAkFGKMbE s6Wqc8welqDtrdUyGn3ab1o7BxA7lJRU4wQBWgbHcUQbDMcd382Lz6qg7PJHtYAVMA0+ MDKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MKa/l++NJX3mb6HDqlPH9HCmk5UKEoj8jJyL9pAVlUc=; b=JimmgkKv5j1i7zd8ulr9V8bHjqbt+9eZAgHBth3AcSP1yBv5MBSPwLDy6sFnvyOd/S jStVMau1rtBGYeqWzphFE3M0waRi0sSaIE+rye5YOoT1h8SIaZ/9b5usbSmp4uK5NvEb YB4vfllFl/J8xrEAhXWbnRXJ3gMLQSbbk17hIcBtuud/x7pSAtJ49rnC/bOfWi+KjiHB XXP76KCKJTWj5WS9Sy2SLCR/BBtn//+vbJJHlu7f8DfJrhgbO64VLaA/Kqk+fBr+A34n 2dPmmY3HndmdVTuTx323GVK7JhljjisTGnIMJIbmB/eVSnqaYIFKHD/S0ZimnnpTC1FX lutw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JOhKqnxX; 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 n20si880649eda.329.2020.08.20.00.57.00; Thu, 20 Aug 2020 00:57:00 -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=JOhKqnxX; 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 S1726968AbgHTH46 (ORCPT + 10 others); Thu, 20 Aug 2020 03:56:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726951AbgHTH4y (ORCPT ); Thu, 20 Aug 2020 03:56:54 -0400 Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C5D7C061383 for ; Thu, 20 Aug 2020 00:56:53 -0700 (PDT) Received: by mail-pl1-x643.google.com with SMTP id y10so549287plr.11 for ; Thu, 20 Aug 2020 00:56:53 -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 :mime-version:content-transfer-encoding; bh=MKa/l++NJX3mb6HDqlPH9HCmk5UKEoj8jJyL9pAVlUc=; b=JOhKqnxXyMfppUBIxlmvtEQlY5wB7zlwWW93yYoleBojKtOVakJwUIYj1ZKu4hzmZb EKEtrRsslpuOJ6lZJaqD+bqa4AbhVNuOyzF8abrRSlnfiLB1UstLmeV0AgLrLqMr7frF jZ7/sXrCNYPogK/+ohFMy/NlW0bTZ6dNRT/FIFnee66X/ZhU1eWzEPe7CqQ21fxnvvIo lJWQ5fdhyFNVMMVIGukrmECNfz/6JlWWOepDnc0ODoCBVC7C7ZnSP3D81+RgzZM3r2Fa NCf25h2gHBexgANYvR4Vsdbt3TNddA4eotdZtqvTC+OO+NpvXmNWzvPp8l2vAs0WNGWd Uqsg== 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:mime-version:content-transfer-encoding; bh=MKa/l++NJX3mb6HDqlPH9HCmk5UKEoj8jJyL9pAVlUc=; b=Bm8aotCCSV+7QoOur+ubTP9wPTJvTfzk/IQbydz/l63KR72PzNAlDjQT3nL2llSevZ didgwIT12XDw3KwKqhGPXymtBDKPmpEBdmuDjebo/mLxYX4sP01umfGx2GnEz2EL+BX7 c0541aNGGAOOlauVmUWlG631mD4NOr7OTIxHs5RcoATCceS5QhPVC343z7sx7jyO1Su3 5Li3CnL8LDF8cImQRggmEt7+0rawsOo+XX5D/DApQObskF+p0KfYbRwRMaCbsi3/wM/D 6NgxGz+0nZ3y+xt5AkUaXXx9cUl872k0omF1rdwIy8Ci2bVKtVnkbAF92eRnGgvpS/XZ iNMw== X-Gm-Message-State: AOAM532SB4eMJbn8XpiKwPs+HHVzIUYQDU10VYr8+PwJUGRRQCgAh4yM S+5EIYksqWhonQIZ9b0PUMH81g== X-Received: by 2002:a17:902:868b:: with SMTP id g11mr1739808plo.9.1597910212779; Thu, 20 Aug 2020 00:56:52 -0700 (PDT) Received: from localhost ([122.172.43.13]) by smtp.gmail.com with ESMTPSA id m19sm1596343pgd.21.2020.08.20.00.56.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Aug 2020 00:56:52 -0700 (PDT) From: Viresh Kumar To: rnayak@codeaurora.org, Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Rafael Wysocki , sibis@codeaurora.org, sbhanu@codeaurora.org, linux-kernel@vger.kernel.org Subject: [PATCH V3 4/4] opp: Remove _dev_pm_opp_find_and_remove_table() wrapper Date: Thu, 20 Aug 2020 13:26:34 +0530 Message-Id: X-Mailer: git-send-email 2.25.0.rc1.19.g042ed3e048af In-Reply-To: References: MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Remove the unnecessary wrapper and merge _dev_pm_opp_find_and_remove_table() with dev_pm_opp_remove_table(). Signed-off-by: Viresh Kumar --- drivers/opp/core.c | 21 ++++++++------------- drivers/opp/cpu.c | 2 +- drivers/opp/of.c | 2 +- drivers/opp/opp.h | 1 - 4 files changed, 10 insertions(+), 16 deletions(-) -- 2.25.0.rc1.19.g042ed3e048af diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 4edd2c3d6d91..6978b9218c6e 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2395,7 +2395,14 @@ int dev_pm_opp_unregister_notifier(struct device *dev, } EXPORT_SYMBOL(dev_pm_opp_unregister_notifier); -void _dev_pm_opp_find_and_remove_table(struct device *dev) +/** + * dev_pm_opp_remove_table() - Free all OPPs associated with the device + * @dev: device pointer used to lookup OPP table. + * + * Free both OPPs created using static entries present in DT and the + * dynamically added entries. + */ +void dev_pm_opp_remove_table(struct device *dev) { struct opp_table *opp_table; @@ -2420,16 +2427,4 @@ void _dev_pm_opp_find_and_remove_table(struct device *dev) /* Drop reference taken while the OPP table was added */ dev_pm_opp_put_opp_table(opp_table); } - -/** - * dev_pm_opp_remove_table() - Free all OPPs associated with the device - * @dev: device pointer used to lookup OPP table. - * - * Free both OPPs created using static entries present in DT and the - * dynamically added entries. - */ -void dev_pm_opp_remove_table(struct device *dev) -{ - _dev_pm_opp_find_and_remove_table(dev); -} EXPORT_SYMBOL_GPL(dev_pm_opp_remove_table); diff --git a/drivers/opp/cpu.c b/drivers/opp/cpu.c index b5055cc886ef..5004335cf0de 100644 --- a/drivers/opp/cpu.c +++ b/drivers/opp/cpu.c @@ -124,7 +124,7 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, continue; } - _dev_pm_opp_find_and_remove_table(cpu_dev); + dev_pm_opp_remove_table(cpu_dev); } } diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 0430290670ab..7d9d4455a59e 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -616,7 +616,7 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, */ void dev_pm_opp_of_remove_table(struct device *dev) { - _dev_pm_opp_find_and_remove_table(dev); + dev_pm_opp_remove_table(dev); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 0c3de3f6db5c..78e876ec803e 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -217,7 +217,6 @@ void _get_opp_table_kref(struct opp_table *opp_table); int _get_opp_count(struct opp_table *opp_table); struct opp_table *_find_opp_table(struct device *dev); struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table); -void _dev_pm_opp_find_and_remove_table(struct device *dev); struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table); void _opp_free(struct dev_pm_opp *opp); int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2);