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;