From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1257C43334 for ; Tue, 5 Jul 2022 07:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbiGEHAm (ORCPT ); Tue, 5 Jul 2022 03:00:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230240AbiGEHAg (ORCPT ); Tue, 5 Jul 2022 03:00:36 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEA35E0DD for ; Tue, 5 Jul 2022 00:00:34 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id i17so1177450pfk.1 for ; Tue, 05 Jul 2022 00:00:34 -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=WWn76D86a1mEcSjBQhlRWmVzJMrbS7iUkVOv/o7W4cI=; b=HD5eyLpgWrbnOGBRxm4GZac5zNe5J7E05Jtue7+jWWXouDjii9avtOLAG41RTfOMi6 /v2so/GVD0HYNac/R414rhUY9VuQO4edOWSAr+3G4Sds19poXf022IdA7MpiNa04zULw Yheudj+5DhT7eokQgA1lpclOp9ikLjF5+yFxyX3zLsfpHEVV6yQd2cCjo49vu/B5T1qn SuAaNG4DJqhUtPQ1ODR9S8Hh8+unobNg8u5O1J7Hoj83NmTo8vsh0H/hTlI0oyYR78uN pQJMn24PqWyW9lWC1hv532xrirqH5CzZJ4Q5sCn/yN77vOvmnYp3UCJ4WhgOI89q4rvi 1izw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WWn76D86a1mEcSjBQhlRWmVzJMrbS7iUkVOv/o7W4cI=; b=qgAp79fZc5tzniYi31n2JoA+EL9egbPUhsZPLDOqdj1faTw8ONl64wu0HE4EiNbzcj zON5ATfGyiDXIXgsvM5t7S6oTqHKyl/cESsBbIBuDDyieys+AatdFof2RPQndsCfSLoG DJyscQxHgX5NCOGbUUlGhEWbj8N2eKeZZDUDmaoToWkkT/DZRQr2YpmW7tK12wphHCcx KRmieGosOyDxeIMIZZGQD95tPNG8CF/dcA02/IdL61S2eV8wYopmfBwQzEykmUxzEVIa qkr7dP5nBuRVZsY1p6GL8QsqLtOtvTGuOGqbcNEw67aTgp/3N5cMW8kDW/j02NUnJKNs J5+g== X-Gm-Message-State: AJIora9XtpjINOA+OGXG85z5kXMLiN1/v7kqxOff7yOn0DTdW8jHT6Zo 6Uz/AGVavfsbOneCZi+DDNiyzQ== X-Google-Smtp-Source: AGRyM1tsHivUtQGS4VcjxuhnswvvQB+zBPVYrt445EpyGuwJCb6Fxox73MWjKONTZx0o9Mi/spK97Q== X-Received: by 2002:a63:82c3:0:b0:40c:c340:318d with SMTP id w186-20020a6382c3000000b0040cc340318dmr28886915pgd.191.1657004434244; Tue, 05 Jul 2022 00:00:34 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id y6-20020a626406000000b0050dc76281f0sm22093419pfb.202.2022.07.05.00.00.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:33 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 01/13] OPP: Use consistent names for OPP table instances Date: Tue, 5 Jul 2022 12:30:04 +0530 Message-Id: <17bd927869b3a4d34c21aadad3536ccdcdf1078f.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The OPP table is called "opp_table" at most of the places and "table" at few. Make all of them follow the same naming convention, "opp_table". Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 7 ++++--- drivers/opp/cpu.c | 12 ++++++------ drivers/opp/of.c | 12 ++++++------ 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5ad43dbfd87f..e836d3043d22 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1585,15 +1585,16 @@ void dev_pm_opp_remove_all_dynamic(struct device *d= ev) } EXPORT_SYMBOL_GPL(dev_pm_opp_remove_all_dynamic); =20 -struct dev_pm_opp *_opp_allocate(struct opp_table *table) +struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table) { struct dev_pm_opp *opp; int supply_count, supply_size, icc_size; =20 /* Allocate space for at least one supply */ - supply_count =3D table->regulator_count > 0 ? table->regulator_count : 1; + supply_count =3D opp_table->regulator_count > 0 ? + opp_table->regulator_count : 1; supply_size =3D sizeof(*opp->supplies) * supply_count; - icc_size =3D sizeof(*opp->bandwidth) * table->path_count; + icc_size =3D sizeof(*opp->bandwidth) * opp_table->path_count; =20 /* allocate new OPP node and supplies structures */ opp =3D kzalloc(sizeof(*opp) + supply_size + icc_size, GFP_KERNEL); diff --git a/drivers/opp/cpu.c b/drivers/opp/cpu.c index 5004335cf0de..3c3506021501 100644 --- a/drivers/opp/cpu.c +++ b/drivers/opp/cpu.c @@ -41,7 +41,7 @@ * the table if any of the mentioned functions have been invoked in the in= terim. */ int dev_pm_opp_init_cpufreq_table(struct device *dev, - struct cpufreq_frequency_table **table) + struct cpufreq_frequency_table **opp_table) { struct dev_pm_opp *opp; struct cpufreq_frequency_table *freq_table =3D NULL; @@ -76,7 +76,7 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, freq_table[i].driver_data =3D i; freq_table[i].frequency =3D CPUFREQ_TABLE_END; =20 - *table =3D &freq_table[0]; + *opp_table =3D &freq_table[0]; =20 out: if (ret) @@ -94,13 +94,13 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_init_cpufreq_table); * Free up the table allocated by dev_pm_opp_init_cpufreq_table */ void dev_pm_opp_free_cpufreq_table(struct device *dev, - struct cpufreq_frequency_table **table) + struct cpufreq_frequency_table **opp_table) { - if (!table) + if (!opp_table) return; =20 - kfree(*table); - *table =3D NULL; + kfree(*opp_table); + *opp_table =3D NULL; } EXPORT_SYMBOL_GPL(dev_pm_opp_free_cpufreq_table); #endif /* CONFIG_CPU_FREQ */ diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 30394929d700..e07fc31de416 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -767,7 +767,7 @@ void dev_pm_opp_of_remove_table(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); =20 -static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *table, +static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_tabl= e, struct device_node *np, bool peak) { const char *name =3D peak ? "opp-peak-kBps" : "opp-avg-kBps"; @@ -780,9 +780,9 @@ static int _read_bw(struct dev_pm_opp *new_opp, struct = opp_table *table, return -ENODEV; =20 count =3D prop->length / sizeof(u32); - if (table->path_count !=3D count) { + if (opp_table->path_count !=3D count) { pr_err("%s: Mismatch between %s and paths (%d %d)\n", - __func__, name, count, table->path_count); + __func__, name, count, opp_table->path_count); return -EINVAL; } =20 @@ -808,7 +808,7 @@ static int _read_bw(struct dev_pm_opp *new_opp, struct = opp_table *table, return ret; } =20 -static int _read_opp_key(struct dev_pm_opp *new_opp, struct opp_table *tab= le, +static int _read_opp_key(struct dev_pm_opp *new_opp, struct opp_table *opp= _table, struct device_node *np, bool *rate_not_available) { bool found =3D false; @@ -832,10 +832,10 @@ static int _read_opp_key(struct dev_pm_opp *new_opp, = struct opp_table *table, * opp-peak-kBps =3D ; * opp-avg-kBps =3D ; */ - ret =3D _read_bw(new_opp, table, np, true); + ret =3D _read_bw(new_opp, opp_table, np, true); if (!ret) { found =3D true; - ret =3D _read_bw(new_opp, table, np, false); + ret =3D _read_bw(new_opp, opp_table, np, false); } =20 /* The properties were found but we failed to parse them */ --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84AB7CCA47B for ; Tue, 5 Jul 2022 07:00:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230337AbiGEHAr (ORCPT ); Tue, 5 Jul 2022 03:00:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230261AbiGEHAj (ORCPT ); Tue, 5 Jul 2022 03:00:39 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1089DF5AA for ; Tue, 5 Jul 2022 00:00:37 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id w185so6989443pfb.4 for ; Tue, 05 Jul 2022 00:00:37 -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=orAHTGD4Jsa6jh6pgoHDIf1kVufO1X0WbaBUQ/zQ1ZQ=; b=Hkes36yGoFLr0vcDQ8HBOddE0S9RPDMGQ2Th5zNp7upEqgIFBJgkpTk2v2w2uY1n/y wV6TZc4txtUfXwJzfJTHW/sOlyBvyocSmUuJ5URjFGoexnl0SLDiCSdV9Z48UWozHipS 3+AdevpFL3PqdWSB+6EVy3uFf97rz0eNtqzPwnOQSWMnfKCWJ04PzB4W7LyiVf0y0oQL g8bU7ZHOGe9l75lQqiKIUpbEZfxp/R7dVB/dl4eOkw0S2B18gYZ3wd3o/z1qR6ELAoWB dmRkMVZmHo9kTFzT+nMxQCdZrMAITeG3ockpy4QWEMwltdlVQwimaqBU/uZ2XvGpMEoH +R5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=orAHTGD4Jsa6jh6pgoHDIf1kVufO1X0WbaBUQ/zQ1ZQ=; b=3D/aO2vniEwsII1f8fODpVXMJgCZ6dZs5XcdZbzBNMIE6un6qSm5pZOU82p1DzczgJ +XQsY2RI5my1pgEeycSUC2LHiRrbAZRT9Q079l2Yh35VfUtYMJTGMv8gGgZa5QDUnPFF jro41v8O3GpXXIhAcrx9haftOE03j8W3NRRdD8hC3M9dycMUwpF9aASHRn7v0Sy+hJnC mRZ6YioDD8awxleUO9anViu4/gSwHXz/La6eBcJ21L2IHJXdKTRjJkqK7484iyi4RFQA cnJekDFdw1K2fE3NHmloANVdMTWacKpD8ms/R6ce+2KLC4bWUrNhdTltL1RSIEIdE7LM 8sGQ== X-Gm-Message-State: AJIora9QTtIT7wMfr+iwmIEhII2uHvF5ldJ3AxvHqwIyzKYuAcwBMTCt G24lARJaP20C5FUOuuD7RPU+FQ== X-Google-Smtp-Source: AGRyM1sijueN2OOpd1ZrAUwr8JG70NPmQ6onkoe4e2aAtRJim21Uusnh9goNi4F9CYM78bbIauSgqw== X-Received: by 2002:a63:4d26:0:b0:411:83dd:2c3 with SMTP id a38-20020a634d26000000b0041183dd02c3mr26690851pgb.508.1657004437162; Tue, 05 Jul 2022 00:00:37 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id cj15-20020a056a00298f00b0052559bd12aasm22000550pfb.61.2022.07.05.00.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:36 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 02/13] OPP: Remove rate_not_available parameter to _opp_add() Date: Tue, 5 Jul 2022 12:30:05 +0530 Message-Id: <1cc2e6afabbf1a6bdeea1a589f921a58b4d4d056.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" commit 32715be4fe95 ("opp: Fix adding OPP entries in a wrong order if rate is unavailable") removed the only user of this field, get rid of rest of it now. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 4 ++-- drivers/opp/of.c | 10 ++++------ drivers/opp/opp.h | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index e836d3043d22..ae5949656d77 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1713,7 +1713,7 @@ void _required_opps_available(struct dev_pm_opp *opp,= int count) * should be considered an error by the callers of _opp_add(). */ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, - struct opp_table *opp_table, bool rate_not_available) + struct opp_table *opp_table) { struct list_head *head; int ret; @@ -1792,7 +1792,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct d= evice *dev, new_opp->available =3D true; new_opp->dynamic =3D dynamic; =20 - ret =3D _opp_add(dev, new_opp, opp_table, false); + ret =3D _opp_add(dev, new_opp, opp_table); if (ret) { /* Don't return error for duplicate OPPs */ if (ret =3D=3D -EBUSY) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index e07fc31de416..bec9644a7260 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -808,8 +808,8 @@ static int _read_bw(struct dev_pm_opp *new_opp, struct = opp_table *opp_table, return ret; } =20 -static int _read_opp_key(struct dev_pm_opp *new_opp, struct opp_table *opp= _table, - struct device_node *np, bool *rate_not_available) +static int _read_opp_key(struct dev_pm_opp *new_opp, + struct opp_table *opp_table, struct device_node *np) { bool found =3D false; u64 rate; @@ -825,7 +825,6 @@ static int _read_opp_key(struct dev_pm_opp *new_opp, st= ruct opp_table *opp_table new_opp->rate =3D (unsigned long)rate; found =3D true; } - *rate_not_available =3D !!ret; =20 /* * Bandwidth consists of peak and average (optional) values: @@ -881,13 +880,12 @@ static struct dev_pm_opp *_opp_add_static_v2(struct o= pp_table *opp_table, struct dev_pm_opp *new_opp; u32 val; int ret; - bool rate_not_available =3D false; =20 new_opp =3D _opp_allocate(opp_table); if (!new_opp) return ERR_PTR(-ENOMEM); =20 - ret =3D _read_opp_key(new_opp, opp_table, np, &rate_not_available); + ret =3D _read_opp_key(new_opp, opp_table, np); if (ret < 0) { dev_err(dev, "%s: opp key field not found\n", __func__); goto free_opp; @@ -920,7 +918,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp= _table *opp_table, if (opp_table->is_genpd) new_opp->pstate =3D pm_genpd_opp_to_performance_state(dev, new_opp); =20 - ret =3D _opp_add(dev, new_opp, opp_table, rate_not_available); + ret =3D _opp_add(dev, new_opp, opp_table); if (ret) { /* Don't return error for duplicate OPPs */ if (ret =3D=3D -EBUSY) diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 13abe991e811..e449828ffbf4 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -247,7 +247,7 @@ struct opp_device *_add_opp_dev(const struct device *de= v, struct opp_table *opp_ 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); -int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_ta= ble *opp_table, bool rate_not_available); +int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_ta= ble *opp_table); int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned = long freq, long u_volt, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int l= ast_cpu); struct opp_table *_add_opp_table_indexed(struct device *dev, int index, bo= ol getclk); --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0C59CCA47F for ; Tue, 5 Jul 2022 07:01:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230379AbiGEHA7 (ORCPT ); Tue, 5 Jul 2022 03:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbiGEHAn (ORCPT ); Tue, 5 Jul 2022 03:00:43 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6151910FEE for ; Tue, 5 Jul 2022 00:00:40 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id n12so10755419pfq.0 for ; Tue, 05 Jul 2022 00:00:40 -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=KRrnUdGamCbkam2j5LdYTW9gHcI75hKYFbox7BL3/XY=; b=A2orPeJku745omSXs6i631qSAIyedbYWwRJe+I8/EzOxnJxgVNjsj6m1/GAEPXFIUr zJc0wmZ++SjzRezgPQcyPmuqFyReGWC4w4+IgoTLGyf2cyk1txI6qj3+epZaaBdp0WNz 8MJVZHM8L4UoZoD9hJnhD6iiyN3MKVH7/fU+SZmfD5oBSFQinQkSzx83jEFMi/OZQ3My 9rpVe0EzDKTKDrE1CqP7nCUpOCA/Q1nwhrHlvVwFL1faD3MyCNm0NX57aySCzmJ0LhTh KDB/fWStNikhy2rXNZYaT/GFdTJ3uX5WIPtcbrnC7Sd3j8BZTb6i0iXy+Fnk3HI1Vfz0 W0DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KRrnUdGamCbkam2j5LdYTW9gHcI75hKYFbox7BL3/XY=; b=UwXrDsusGrYIkKK13tW0qkIgXO0Ad9urbLydne/pA8Bi27snQ1xDn2eogs32PSTXyG ZTpCLWSWCHJJUUPSSM23oXVacWsB06XybBkPpeUUel1vaQgCww+KLEutNesgiscXTrkF ydrQOHqI3GPN6WtDUrvZrGO4y5p7n1VoLFOrn1zaSUksU8d/g6LukDT8qKynj7590TXQ 2ErYvqp1AKivhR3KuBIu+y4AWjdTdemZaXdLXlMSsv6Sju69geC79K8t2WBWtygoxvK0 fo+RJerPwisYQoWLpg5+Z552+xyaK3/+OppjkFi4xsUHjZA9CZqk3LyTrO7Ky4sns1EB hXUA== X-Gm-Message-State: AJIora8czQa6gt0DsEAN+KMQFBLmDf9IIs360K37rvD8mQE8S2RvtxXQ OLoOCK6Jw9qfuJhPEW/0lW+3uw== X-Google-Smtp-Source: AGRyM1u4GrAbNDy2dSBIvKZmivsrXDdqiCIQz4jE23OQrwxwEJJcdwNLC2vnadE4U7N8y3wBPlViLA== X-Received: by 2002:aa7:989a:0:b0:525:252f:3c51 with SMTP id r26-20020aa7989a000000b00525252f3c51mr40356737pfl.39.1657004439921; Tue, 05 Jul 2022 00:00:39 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id c16-20020a170902b69000b001678dcb4c5asm22566988pls.100.2022.07.05.00.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:39 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 03/13] OPP: Reuse _opp_compare_key() in _opp_add_static_v2() Date: Tue, 5 Jul 2022 12:30:06 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Reuse _opp_compare_key() in _opp_add_static_v2() instead of just comparing frequency while finding suspend frequency. Also add a comment over _opp_compare_key() explaining its return values. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 6 ++++++ drivers/opp/of.c | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index ae5949656d77..00d5911b20f8 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1636,6 +1636,12 @@ static bool _opp_supported_by_regulators(struct dev_= pm_opp *opp, return true; } =20 +/* + * Returns + * 0: opp1 =3D=3D opp2 + * 1: opp1 > opp2 + * -1: opp1 < opp2 + */ int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) { if (opp1->rate !=3D opp2->rate) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index bec9644a7260..bb49057cb1fc 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -929,8 +929,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp= _table *opp_table, /* OPP to select on device suspend */ if (of_property_read_bool(np, "opp-suspend")) { if (opp_table->suspend_opp) { - /* Pick the OPP with higher rate as suspend OPP */ - if (new_opp->rate > opp_table->suspend_opp->rate) { + /* Pick the OPP with higher rate/bw/level as suspend OPP */ + if (_opp_compare_key(new_opp, opp_table->suspend_opp) =3D=3D 1) { opp_table->suspend_opp->suspend =3D false; new_opp->suspend =3D true; opp_table->suspend_opp =3D new_opp; --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 477E1C433EF for ; Tue, 5 Jul 2022 07:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230301AbiGEHBE (ORCPT ); Tue, 5 Jul 2022 03:01:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230321AbiGEHAp (ORCPT ); Tue, 5 Jul 2022 03:00:45 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F62311478 for ; Tue, 5 Jul 2022 00:00:43 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o31-20020a17090a0a2200b001ef7bd037bbso6333135pjo.0 for ; Tue, 05 Jul 2022 00:00: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=miW8Tr7lV7G34W+RMqWJnrYWMkcRAss34hOq+aE2O90=; b=CsHSuaH9QoAcMU51PGaqtXOpeV+UKOMHFJgIkdj032ULga4/6muXaTuj75cplkOM8s ++FurW1vI6T3RCVZcRJ49SSkOvGlXfty/zhpT6ZwRbo9BGFCaNorURdAmhKpa6wk9re6 T3Scdb5hkItEAFco+8wl587AJc/6eYv/HKUFdfowTRYcdtx3nLNBi0GwLWOk2t84dRyP HlqwxoUAGmDcrkg9Uf7ZuQ09/X5Q+kqDkeyDIUjHtEekp5hOINHkMiHZFF2/PK02ByNn Zs5R9smmFbY+O0Pr3jBKWaNnbUJ8qhAyPP1LuNz5PHeHmht9ZgXr2dK3aHQYRhqe+mXB pPLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=miW8Tr7lV7G34W+RMqWJnrYWMkcRAss34hOq+aE2O90=; b=y3AVMg5zvZPiKVCYxHanbigR0oJaUNyGL2gG3UBMViW5LaDqiWK7vQJBjGNC1IWD9x BRMf804/iYjkmsAcwmjN98lymAko1187jM8GEkyRTCov2lK3UBpHQgPRkV/ByadtstaX x6qkgRzcfMG6FntkPr/QN0+BuZw+CSPxmEmwQcTA8st61pHDYuoqbP+Fy6XbOOqjHaBh 9qx955B2/60PJ2HNuDfCywPRvfyKerT5wIXjSNwuYyfxJF/reP+e/sIn4wWfXGYr+lFB jv5hYeUHymP6Z5cF7LBxSY14V37waqUh97yrGbDxPkohl0+ZjoF+CC70XpbAzHcE37iV TNrA== X-Gm-Message-State: AJIora+/fdUI1Mxs0vVvCnWlR+oRChdxOM6YDZrurRI0HifSGyNtBDtc oRb23WemnaHf1/WmI7ecTB6+bg== X-Google-Smtp-Source: AGRyM1sEvzGL5/pHJGu3PkBYNyFPoHxKkiLVS9lcfkbxzdtau15ZF+qrALM42AZPJvNsMP6u7Xw6UA== X-Received: by 2002:a17:90b:3a8d:b0:1ef:7d4:6a5f with SMTP id om13-20020a17090b3a8d00b001ef07d46a5fmr39512462pjb.139.1657004442946; Tue, 05 Jul 2022 00:00:42 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id h23-20020a632117000000b0041245ccb6b1sm3117358pgh.62.2022.07.05.00.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:42 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 04/13] OPP: Make dev_pm_opp_set_opp() independent of frequency Date: Tue, 5 Jul 2022 12:30:07 +0530 Message-Id: <89976ad1c64d0716d69bd834aa8b82d66d83ad85.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" dev_pm_opp_set_opp() can be called for any device, it may or may not have a frequency value associated with it. If a frequency value isn't available, we pass 0 to _set_opp(). Make it optional instead by making _set_opp() accept a pointer instead, as the frequency value is anyway available in the OPP. This makes dev_pm_opp_set_opp() and _set_opp() completely independent of any special key value. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 52 +++++++++++++++++++++++++++++++++------------- drivers/opp/opp.h | 4 ++-- 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 00d5911b20f8..daabc810a1f9 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -784,19 +784,33 @@ static int _set_opp_voltage(struct device *dev, struc= t regulator *reg, return ret; } =20 -static inline int _generic_set_opp_clk_only(struct device *dev, struct clk= *clk, - unsigned long freq) +static inline int _generic_set_opp_clk_only(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data) { + unsigned long *target =3D data; + unsigned long freq; int ret; =20 /* We may reach here for devices which don't change frequency */ - if (IS_ERR(clk)) + if (IS_ERR(opp_table->clk)) return 0; =20 - ret =3D clk_set_rate(clk, freq); + /* One of target and opp must be available */ + if (target) { + freq =3D *target; + } else if (opp) { + freq =3D opp->rate; + } else { + WARN_ON(1); + return -EINVAL; + } + + ret =3D clk_set_rate(opp_table->clk, freq); if (ret) { dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, ret); + } else { + opp_table->rate_clk_single =3D freq; } =20 return ret; @@ -990,7 +1004,7 @@ static int _disable_opp_table(struct device *dev, stru= ct opp_table *opp_table) } =20 static int _set_opp(struct device *dev, struct opp_table *opp_table, - struct dev_pm_opp *opp, unsigned long freq) + struct dev_pm_opp *opp, void *clk_data, bool forced) { struct dev_pm_opp *old_opp; int scaling_down, ret; @@ -1005,15 +1019,14 @@ static int _set_opp(struct device *dev, struct opp_= table *opp_table, old_opp =3D opp_table->current_opp; =20 /* Return early if nothing to do */ - if (old_opp =3D=3D opp && opp_table->current_rate =3D=3D freq && - opp_table->enabled) { + if (!forced && old_opp =3D=3D opp && opp_table->enabled) { dev_dbg(dev, "%s: OPPs are same, nothing to do\n", __func__); return 0; } =20 dev_dbg(dev, "%s: switching OPP: Freq %lu -> %lu Hz, Level %u -> %u, Bw %= u -> %u\n", - __func__, opp_table->current_rate, freq, old_opp->level, - opp->level, old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, + __func__, old_opp->rate, opp->rate, old_opp->level, opp->level, + old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, opp->bandwidth ? opp->bandwidth[0].peak : 0); =20 scaling_down =3D _opp_compare_key(old_opp, opp); @@ -1046,7 +1059,7 @@ static int _set_opp(struct device *dev, struct opp_ta= ble *opp_table, } } =20 - ret =3D _generic_set_opp_clk_only(dev, opp_table->clk, freq); + ret =3D _generic_set_opp_clk_only(dev, opp_table, opp, clk_data); if (ret) return ret; =20 @@ -1082,7 +1095,6 @@ static int _set_opp(struct device *dev, struct opp_ta= ble *opp_table, /* Make sure current_opp doesn't get freed */ dev_pm_opp_get(opp); opp_table->current_opp =3D opp; - opp_table->current_rate =3D freq; =20 return ret; } @@ -1103,6 +1115,7 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned = long target_freq) struct opp_table *opp_table; unsigned long freq =3D 0, temp_freq; struct dev_pm_opp *opp =3D NULL; + bool forced =3D false; int ret; =20 opp_table =3D _find_opp_table(dev); @@ -1120,7 +1133,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned = long target_freq) * equivalent to a clk_set_rate() */ if (!_get_opp_count(opp_table)) { - ret =3D _generic_set_opp_clk_only(dev, opp_table->clk, target_freq); + ret =3D _generic_set_opp_clk_only(dev, opp_table, NULL, + &target_freq); goto put_opp_table; } =20 @@ -1141,12 +1155,22 @@ int dev_pm_opp_set_rate(struct device *dev, unsigne= d long target_freq) __func__, freq, ret); goto put_opp_table; } + + /* + * An OPP entry specifies the highest frequency at which other + * properties of the OPP entry apply. Even if the new OPP is + * same as the old one, we may still reach here for a different + * value of the frequency. In such a case, do not abort but + * configure the hardware to the desired frequency forcefully. + */ + forced =3D opp_table->rate_clk_single !=3D target_freq; } =20 - ret =3D _set_opp(dev, opp_table, opp, freq); + ret =3D _set_opp(dev, opp_table, opp, &target_freq, forced); =20 if (target_freq) dev_pm_opp_put(opp); + put_opp_table: dev_pm_opp_put_opp_table(opp_table); return ret; @@ -1174,7 +1198,7 @@ int dev_pm_opp_set_opp(struct device *dev, struct dev= _pm_opp *opp) return PTR_ERR(opp_table); } =20 - ret =3D _set_opp(dev, opp_table, opp, opp ? opp->rate : 0); + ret =3D _set_opp(dev, opp_table, opp, NULL, false); dev_pm_opp_put_opp_table(opp_table); =20 return ret; diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index e449828ffbf4..e481bdb59499 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -159,7 +159,7 @@ enum opp_table_access { * @clock_latency_ns_max: Max clock latency in nanoseconds. * @parsed_static_opps: Count of devices for which OPPs are initialized fr= om DT. * @shared_opp: OPP is shared between multiple devices. - * @current_rate: Currently configured frequency. + * @rate_clk_single: Currently configured frequency for single clk. * @current_opp: Currently configured OPP for the table. * @suspend_opp: Pointer to OPP to be used during device suspend. * @genpd_virt_dev_lock: Mutex protecting the genpd virtual device pointer= s. @@ -208,7 +208,7 @@ struct opp_table { =20 unsigned int parsed_static_opps; enum opp_table_access shared_opp; - unsigned long current_rate; + unsigned long rate_clk_single; struct dev_pm_opp *current_opp; struct dev_pm_opp *suspend_opp; =20 --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5DEE0C433EF for ; Tue, 5 Jul 2022 07:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230404AbiGEHBF (ORCPT ); Tue, 5 Jul 2022 03:01:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230336AbiGEHAr (ORCPT ); Tue, 5 Jul 2022 03:00:47 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12113101C3 for ; Tue, 5 Jul 2022 00:00:46 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id w24so11300707pjg.5 for ; Tue, 05 Jul 2022 00:00: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=KsUvRKQT2AVjAK3kpk9fo+2UaVrAIK8kVr0Wn3bLJKA=; b=MSmkFr2MbDp5neqjTTRVl9ePxtJmXZpJnGWXYkKRc5mtP/iOAQ5tO0q7/Synoc45Dm OGa+ZL77JdySobbPneyI7oAkKi4SblebELgliQFm+fa7ZXrvKWhhJ1BwQdw9tKgT793E RAhU16nhWeKY/11XlaCIWG35iV+ApkgmZYooSQPaQHGmyHj7z9kq2D4UjgBhCNW4FeAx BRVSz02voZHE7yjzkzURmFxjZFq/nJyyLLFbH8+7Lna1AljiPOraWt7Z4QRqN4kCzI5F INKOBi/OWJ2R26aI0viah49+w0fZWc02BADwVFPX+kvRoILNe6L0DIpdpVPaIaveZXSd FV/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KsUvRKQT2AVjAK3kpk9fo+2UaVrAIK8kVr0Wn3bLJKA=; b=yyZUVMWnmP8pDBCEPCXqBIYe3dDh9N9zMhB2zaM3Fsve/lt4y7myk9+D9M+217zK5j D3XV9phNGh5kEEQuutvIVeLyekJaqsB6ssDS/+r5xLVaM+K8AG6ol77YYCo102hJkhYX Mu7h9voeKp4blQwCB2c6up50vyE+VxHnJuXkAFqGshnVvBORveIJCIm6i5GMEWJsPWjO 3+pqXbfZyovAsl6oXum/txd8eAdGMtBvwDZ1k2T4o5XtVKRTztN+CvZEbg3+xJkpaxOL NFh6bp7s1IXOChF6qxQY66DvhykM32+veQh60RwBiMRTrc3yGNAHtMNkh4Jh+Nvcaoeo uMIA== X-Gm-Message-State: AJIora89UQCwIKnwN9ur46+gz3hsgvE+zWycXqtfjHmynSoyX6ePCnrz s2i7OLCn6LCJ3wXCbDGd2nDgtw== X-Google-Smtp-Source: AGRyM1sXUV1O5TyqgLSs2RioUpR9z6ZqQqQKW3igRtmNrUZJR6/fvyFJNMnCQGtfs/Dy65SZCRm0Kg== X-Received: by 2002:a17:90b:3802:b0:1ed:2434:eb44 with SMTP id mq2-20020a17090b380200b001ed2434eb44mr42223751pjb.85.1657004445571; Tue, 05 Jul 2022 00:00:45 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id s1-20020a170902988100b0016a4a57a25asm22412596plp.152.2022.07.05.00.00.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:45 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Bjorn Andersson , Rob Herring , Manivannan Sadhasivam , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 05/13] dt-bindings: opp: accept array of frequencies Date: Tue, 5 Jul 2022 12:30:08 +0530 Message-Id: <1110ceeb20c2e50573b0e208f52238d280f10845.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Krzysztof Kozlowski Devices might need to control several clocks when scaling the frequency and voltage. Allow passing array of clock frequencies, similarly to the voltages. Signed-off-by: Krzysztof Kozlowski Reviewed-by: Bjorn Andersson Acked-by: Rob Herring Reviewed-by: Manivannan Sadhasivam Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- Documentation/devicetree/bindings/opp/opp-v2-base.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml b/Docum= entation/devicetree/bindings/opp/opp-v2-base.yaml index 76c8acd981b3..66d0ec763f0b 100644 --- a/Documentation/devicetree/bindings/opp/opp-v2-base.yaml +++ b/Documentation/devicetree/bindings/opp/opp-v2-base.yaml @@ -50,6 +50,16 @@ select: false property to uniquely identify the OPP nodes exists. Devices like= power domains must have another (implementation dependent) property. =20 + Entries for multiple clocks shall be provided in the same field,= as + array of frequencies. The OPP binding doesn't provide any provi= sions + to relate the values to their clocks or the order in which the c= locks + need to be configured and that is left for the implementation + specific binding. + minItems: 1 + maxItems: 16 + items: + maxItems: 1 + opp-microvolt: description: | Voltage for the OPP --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1ECC2C433EF for ; Tue, 5 Jul 2022 07:01:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230427AbiGEHBI (ORCPT ); Tue, 5 Jul 2022 03:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230346AbiGEHAz (ORCPT ); Tue, 5 Jul 2022 03:00:55 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C44EDE0DD for ; Tue, 5 Jul 2022 00:00:49 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id o18so9439505pgu.9 for ; Tue, 05 Jul 2022 00:00: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=G6+JJZXhhPuFkMBdsLtq/Gd28qJ1KvFHHo+xW7UL/pE=; b=fJWtP+Gb0KAwGZ8QJi3fBlrZdMsHtTb7U/NLDNMK8276nYtvNnspd4m/4ygjyv0AI5 o/SBcilZ4WAVwhFKYW6n7wdOKHiTYcg3n+O2z86GdntXFo5rOEn+db+NHnv2hX8v6tNX GbU7nQqWetPskxKbzG+JCa4x5wEu0MLgBWGNinA8g0uqKu/UKRwgWZjUOX+2Tt/vkVnb v5Ee8jubU8pZTeqNPGt/SP7Z04+wMZ+BqNUmf/6mqbWVJOkZJPt7jw1kSJ1Xsgy9Agp2 ugR4pm99xkNitu6vWQmez6GdBWfukfstDrzc62Nzijx2BNp+pP6g/GjIImVkHuGKrevo WgoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G6+JJZXhhPuFkMBdsLtq/Gd28qJ1KvFHHo+xW7UL/pE=; b=kZE3A2D5qZH5c5mb2Bp+syUQooj2ccLNR8vWlBQVBTQqELUCRO4t6GwT1IVAr66Kfl zpcdLfX6a9BJkJD/+84Ec2Hsec+QEmrAPRe06yRBTfJn/z2e1wSUkv9JMBy4g8EE0Iks zdy0fzYP2CUAGJez1PEYBitQNEbpwpp3sBdz3RH523qpe55I4G8wpw1ZdG4CtaprPRpS f8W08444NLMd9TnD/xF0nAA40ZhLcuRFGaMAUc+EY0YUoEewdi2uUxeGmL9RJgKsO8b8 mYkjaEn9d/rQ/D+7OeowWfRFPcqFr75t+ZuR8RvUX3G4ZjFDryyH4F2YFF4ul+5wcB98 piIQ== X-Gm-Message-State: AJIora/2pAOGg87dDQBYUgaAcNtzqGt1g8GYSjCDsW13Y1WGxJFeA7G8 yzi3ADEezQaDtSM+IbPm1LR91w== X-Google-Smtp-Source: AGRyM1vmNyHgdPC1CpHsANhXfrNQHxiQlP08/kjyI7FuwiSjUC30Emh3+mTxWv3m8+K+7BjzI2VyKQ== X-Received: by 2002:a63:7d58:0:b0:40c:995f:2b3d with SMTP id m24-20020a637d58000000b0040c995f2b3dmr27753939pgn.601.1657004449100; Tue, 05 Jul 2022 00:00:49 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id 84-20020a621757000000b00524e8e48156sm22776472pfx.142.2022.07.05.00.00.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:48 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , Jon Hunter , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 06/13] OPP: Allow multiple clocks for a device Date: Tue, 5 Jul 2022 12:30:09 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds support to allow multiple clocks for a device. The design is pretty much similar to how this is done for regulators, and platforms can supply their own version of the config_clks() callback if they have multiple clocks for their device. The core manages the calls via opp_table->config_clks() eventually. We have kept both "clk" and "clks" fields in the OPP table structure and the reason is provided as a comment in _opp_set_clknames(). The same isn't done for "rates" though and we use rates[0] at most of the places now. Co-developed-by: Krzysztof Kozlowski Signed-off-by: Krzysztof Kozlowski Tested-by: Jon Hunter Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 199 +++++++++++++++++++++++++++++------------ drivers/opp/debugfs.c | 27 +++++- drivers/opp/of.c | 69 +++++++++++--- drivers/opp/opp.h | 16 ++-- include/linux/pm_opp.h | 7 +- 5 files changed, 235 insertions(+), 83 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index daabc810a1f9..003cd48123d7 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -181,7 +181,7 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *op= p) return 0; } =20 - return opp->rate; + return opp->rates[0]; } EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); =20 @@ -430,7 +430,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count); /* Helpers to read keys */ static unsigned long _read_freq(struct dev_pm_opp *opp, int index) { - return opp->rate; + return opp->rates[0]; } =20 static unsigned long _read_level(struct dev_pm_opp *opp, int index) @@ -784,22 +784,19 @@ static int _set_opp_voltage(struct device *dev, struc= t regulator *reg, return ret; } =20 -static inline int _generic_set_opp_clk_only(struct device *dev, - struct opp_table *opp_table, struct dev_pm_opp *opp, void *data) +static int +_opp_config_clk_single(struct device *dev, struct opp_table *opp_table, + struct dev_pm_opp *opp, void *data, bool scaling_down) { unsigned long *target =3D data; unsigned long freq; int ret; =20 - /* We may reach here for devices which don't change frequency */ - if (IS_ERR(opp_table->clk)) - return 0; - /* One of target and opp must be available */ if (target) { freq =3D *target; } else if (opp) { - freq =3D opp->rate; + freq =3D opp->rates[0]; } else { WARN_ON(1); return -EINVAL; @@ -1025,11 +1022,11 @@ static int _set_opp(struct device *dev, struct opp_= table *opp_table, } =20 dev_dbg(dev, "%s: switching OPP: Freq %lu -> %lu Hz, Level %u -> %u, Bw %= u -> %u\n", - __func__, old_opp->rate, opp->rate, old_opp->level, opp->level, - old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, + __func__, old_opp->rates[0], opp->rates[0], old_opp->level, + opp->level, old_opp->bandwidth ? old_opp->bandwidth[0].peak : 0, opp->bandwidth ? opp->bandwidth[0].peak : 0); =20 - scaling_down =3D _opp_compare_key(old_opp, opp); + scaling_down =3D _opp_compare_key(opp_table, old_opp, opp); if (scaling_down =3D=3D -1) scaling_down =3D 0; =20 @@ -1059,9 +1056,11 @@ static int _set_opp(struct device *dev, struct opp_t= able *opp_table, } } =20 - ret =3D _generic_set_opp_clk_only(dev, opp_table, opp, clk_data); - if (ret) - return ret; + if (opp_table->config_clks) { + ret =3D opp_table->config_clks(dev, opp_table, opp, clk_data, scaling_do= wn); + if (ret) + return ret; + } =20 /* Scaling down? Configure required OPPs after frequency */ if (scaling_down) { @@ -1133,8 +1132,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned = long target_freq) * equivalent to a clk_set_rate() */ if (!_get_opp_count(opp_table)) { - ret =3D _generic_set_opp_clk_only(dev, opp_table, NULL, - &target_freq); + ret =3D opp_table->config_clks(dev, opp_table, NULL, + &target_freq, false); goto put_opp_table; } =20 @@ -1255,6 +1254,8 @@ static struct opp_table *_allocate_opp_table(struct d= evice *dev, int index) INIT_LIST_HEAD(&opp_table->dev_list); INIT_LIST_HEAD(&opp_table->lazy); =20 + opp_table->clk =3D ERR_PTR(-ENODEV); + /* Mark regulator count uninitialized */ opp_table->regulator_count =3D -1; =20 @@ -1301,18 +1302,22 @@ static struct opp_table *_update_opp_table_clk(stru= ct device *dev, int ret; =20 /* - * Return early if we don't need to get clk or we have already tried it + * Return early if we don't need to get clk or we have already done it * earlier. */ - if (!getclk || IS_ERR(opp_table) || opp_table->clk) + if (!getclk || IS_ERR(opp_table) || !IS_ERR(opp_table->clk) || + opp_table->clks) return opp_table; =20 /* Find clk for the device */ opp_table->clk =3D clk_get(dev, NULL); =20 ret =3D PTR_ERR_OR_ZERO(opp_table->clk); - if (!ret) + if (!ret) { + opp_table->config_clks =3D _opp_config_clk_single; + opp_table->clk_count =3D 1; return opp_table; + } =20 if (ret =3D=3D -ENOENT) { dev_dbg(dev, "%s: Couldn't find clock: %d\n", __func__, ret); @@ -1417,7 +1422,7 @@ static void _opp_table_kref_release(struct kref *kref) =20 _of_clear_opp_table(opp_table); =20 - /* Release clk */ + /* Release automatically acquired single clk */ if (!IS_ERR(opp_table->clk)) clk_put(opp_table->clk); =20 @@ -1505,7 +1510,7 @@ void dev_pm_opp_remove(struct device *dev, unsigned l= ong freq) mutex_lock(&opp_table->lock); =20 list_for_each_entry(iter, &opp_table->opp_list, node) { - if (iter->rate =3D=3D freq) { + if (iter->rates[0] =3D=3D freq) { opp =3D iter; break; } @@ -1612,24 +1617,28 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_remove_all_dynamic); struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table) { struct dev_pm_opp *opp; - int supply_count, supply_size, icc_size; + int supply_count, supply_size, icc_size, clk_size; =20 /* Allocate space for at least one supply */ supply_count =3D opp_table->regulator_count > 0 ? opp_table->regulator_count : 1; supply_size =3D sizeof(*opp->supplies) * supply_count; + clk_size =3D sizeof(*opp->rates) * opp_table->clk_count; icc_size =3D sizeof(*opp->bandwidth) * opp_table->path_count; =20 /* allocate new OPP node and supplies structures */ - opp =3D kzalloc(sizeof(*opp) + supply_size + icc_size, GFP_KERNEL); - + opp =3D kzalloc(sizeof(*opp) + supply_size + clk_size + icc_size, GFP_KER= NEL); if (!opp) return NULL; =20 - /* Put the supplies at the end of the OPP structure as an empty array */ + /* Put the supplies, bw and clock at the end of the OPP structure */ opp->supplies =3D (struct dev_pm_opp_supply *)(opp + 1); + + opp->rates =3D (unsigned long *)(opp->supplies + supply_count); + if (icc_size) - opp->bandwidth =3D (struct dev_pm_opp_icc_bw *)(opp->supplies + supply_c= ount); + opp->bandwidth =3D (struct dev_pm_opp_icc_bw *)(opp->rates + opp_table->= clk_count); + INIT_LIST_HEAD(&opp->node); =20 return opp; @@ -1660,21 +1669,43 @@ static bool _opp_supported_by_regulators(struct dev= _pm_opp *opp, return true; } =20 +static int _opp_compare_rate(struct opp_table *opp_table, + struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) +{ + int i; + + for (i =3D 0; i < opp_table->clk_count; i++) { + if (opp1->rates[i] !=3D opp2->rates[i]) + return opp1->rates[i] < opp2->rates[i] ? -1 : 1; + } + + /* Same rates for both OPPs */ + return 0; +} + /* * Returns * 0: opp1 =3D=3D opp2 * 1: opp1 > opp2 * -1: opp1 < opp2 */ -int _opp_compare_key(struct dev_pm_opp *opp1, struct dev_pm_opp *opp2) +int _opp_compare_key(struct opp_table *opp_table, struct dev_pm_opp *opp1, + struct dev_pm_opp *opp2) { - if (opp1->rate !=3D opp2->rate) - return opp1->rate < opp2->rate ? -1 : 1; + int ret; + + ret =3D _opp_compare_rate(opp_table, opp1, opp2); + if (ret) + return ret; + if (opp1->bandwidth && opp2->bandwidth && opp1->bandwidth[0].peak !=3D opp2->bandwidth[0].peak) return opp1->bandwidth[0].peak < opp2->bandwidth[0].peak ? -1 : 1; + if (opp1->level !=3D opp2->level) return opp1->level < opp2->level ? -1 : 1; + + /* Duplicate OPPs */ return 0; } =20 @@ -1694,7 +1725,7 @@ static int _opp_is_duplicate(struct device *dev, stru= ct dev_pm_opp *new_opp, * loop. */ list_for_each_entry(opp, &opp_table->opp_list, node) { - opp_cmp =3D _opp_compare_key(new_opp, opp); + opp_cmp =3D _opp_compare_key(opp_table, new_opp, opp); if (opp_cmp > 0) { *head =3D &opp->node; continue; @@ -1705,8 +1736,8 @@ static int _opp_is_duplicate(struct device *dev, stru= ct dev_pm_opp *new_opp, =20 /* Duplicate OPPs */ dev_warn(dev, "%s: duplicate OPPs detected. Existing: freq: %lu, volt: %= lu, enabled: %d. New: freq: %lu, volt: %lu, enabled: %d\n", - __func__, opp->rate, opp->supplies[0].u_volt, - opp->available, new_opp->rate, + __func__, opp->rates[0], opp->supplies[0].u_volt, + opp->available, new_opp->rates[0], new_opp->supplies[0].u_volt, new_opp->available); =20 /* Should we compare voltages for all regulators here ? */ @@ -1727,7 +1758,7 @@ void _required_opps_available(struct dev_pm_opp *opp,= int count) =20 opp->available =3D false; pr_warn("%s: OPP not supported by required OPP %pOF (%lu)\n", - __func__, opp->required_opps[i]->np, opp->rate); + __func__, opp->required_opps[i]->np, opp->rates[0]); return; } } @@ -1768,7 +1799,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *n= ew_opp, if (!_opp_supported_by_regulators(new_opp, opp_table)) { new_opp->available =3D false; dev_warn(dev, "%s: OPP not supported by regulators (%lu)\n", - __func__, new_opp->rate); + __func__, new_opp->rates[0]); } =20 /* required-opps not fully initialized yet */ @@ -1814,7 +1845,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct d= evice *dev, return -ENOMEM; =20 /* populate the opp table */ - new_opp->rate =3D freq; + new_opp->rates[0] =3D freq; tol =3D u_volt * opp_table->voltage_tolerance_v1 / 100; new_opp->supplies[0].u_volt =3D u_volt; new_opp->supplies[0].u_volt_min =3D u_volt - tol; @@ -2017,6 +2048,17 @@ static void _opp_put_regulators(struct opp_table *op= p_table) opp_table->regulator_count =3D -1; } =20 +static void _put_clks(struct opp_table *opp_table, int count) +{ + int i; + + for (i =3D count - 1; i >=3D 0; i--) + clk_put(opp_table->clks[i]); + + kfree(opp_table->clks); + opp_table->clks =3D NULL; +} + /** * _opp_set_clknames() - Set clk names for the device * @dev: Device for which clk names is being set. @@ -2031,10 +2073,12 @@ static void _opp_put_regulators(struct opp_table *o= pp_table) * This must be called before any OPPs are initialized for the device. */ static int _opp_set_clknames(struct opp_table *opp_table, struct device *d= ev, - const char * const names[]) + const char * const names[], + config_clks_t config_clks) { const char * const *temp =3D names; - int count =3D 0; + int count =3D 0, ret, i; + struct clk *clk; =20 /* Count number of clks */ while (*temp++) @@ -2047,28 +2091,60 @@ static int _opp_set_clknames(struct opp_table *opp_= table, struct device *dev, if (!count && !names[1]) count =3D 1; =20 - /* We support only one clock name for now */ - if (count !=3D 1) + /* Fail early for invalid configurations */ + if (!count || (config_clks && count =3D=3D 1) || (!config_clks && count >= 1)) return -EINVAL; =20 /* Another CPU that shares the OPP table has set the clkname ? */ - if (opp_table->clk_configured) + if (opp_table->clks) return 0; =20 - /* clk shouldn't be initialized at this point */ - if (WARN_ON(opp_table->clk)) - return -EBUSY; + opp_table->clks =3D kmalloc_array(count, sizeof(*opp_table->clks), + GFP_KERNEL); + if (!opp_table->clks) + return -ENOMEM; =20 - /* Find clk for the device */ - opp_table->clk =3D clk_get(dev, names[0]); - if (IS_ERR(opp_table->clk)) { - return dev_err_probe(dev, PTR_ERR(opp_table->clk), - "%s: Couldn't find clock\n", __func__); + /* Find clks for the device */ + for (i =3D 0; i < count; i++) { + clk =3D clk_get(dev, names[i]); + if (IS_ERR(clk)) { + ret =3D dev_err_probe(dev, PTR_ERR(clk), + "%s: Couldn't find clock with name: %s\n", + __func__, names[i]); + goto free_clks; + } + + opp_table->clks[i] =3D clk; } =20 - opp_table->clk_configured =3D true; + opp_table->clk_count =3D count; + + /* Set generic single clk set here */ + if (count =3D=3D 1) { + opp_table->config_clks =3D _opp_config_clk_single; + + /* + * We could have just dropped the "clk" field and used "clks" + * everywhere. Instead we kept the "clk" field around for + * following reasons: + * + * - avoiding clks[0] everywhere else. + * - not running single clk helpers for multiple clk usecase by + * mistake. + * + * Since this is single-clk case, just update the clk pointer + * too. + */ + opp_table->clk =3D opp_table->clks[0]; + } else { + opp_table->config_clks =3D config_clks; + } =20 return 0; + +free_clks: + _put_clks(opp_table, i); + return ret; } =20 /** @@ -2077,11 +2153,13 @@ static int _opp_set_clknames(struct opp_table *opp_= table, struct device *dev, */ static void _opp_put_clknames(struct opp_table *opp_table) { - if (opp_table->clk_configured) { - clk_put(opp_table->clk); - opp_table->clk =3D ERR_PTR(-EINVAL); - opp_table->clk_configured =3D false; - } + if (!opp_table->clks) + return; + + opp_table->config_clks =3D NULL; + opp_table->clk =3D ERR_PTR(-ENODEV); + + _put_clks(opp_table, opp_table->clk_count); } =20 /** @@ -2298,11 +2376,16 @@ int dev_pm_opp_set_config(struct device *dev, struc= t dev_pm_opp_config *config) =20 /* Configure clocks */ if (config->clk_names) { - ret =3D _opp_set_clknames(opp_table, dev, config->clk_names); + ret =3D _opp_set_clknames(opp_table, dev, config->clk_names, + config->config_clks); if (ret) goto err; =20 data->flags |=3D OPP_CONFIG_CLK; + } else if (config->config_clks) { + /* Don't allow config callback without clocks */ + ret =3D -EINVAL; + goto err; } =20 /* Configure property names */ @@ -2614,7 +2697,7 @@ static int _opp_set_availability(struct device *dev, = unsigned long freq, =20 /* Do we have the frequency? */ list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { - if (tmp_opp->rate =3D=3D freq) { + if (tmp_opp->rates[0] =3D=3D freq) { opp =3D tmp_opp; break; } @@ -2685,7 +2768,7 @@ int dev_pm_opp_adjust_voltage(struct device *dev, uns= igned long freq, =20 /* Do we have the frequency? */ list_for_each_entry(tmp_opp, &opp_table->opp_list, node) { - if (tmp_opp->rate =3D=3D freq) { + if (tmp_opp->rates[0] =3D=3D freq) { opp =3D tmp_opp; break; } diff --git a/drivers/opp/debugfs.c b/drivers/opp/debugfs.c index 1b6e5c55c3ed..402c507edac7 100644 --- a/drivers/opp/debugfs.c +++ b/drivers/opp/debugfs.c @@ -74,6 +74,24 @@ static void opp_debug_create_bw(struct dev_pm_opp *opp, } } =20 +static void opp_debug_create_clks(struct dev_pm_opp *opp, + struct opp_table *opp_table, + struct dentry *pdentry) +{ + char name[12]; + int i; + + if (opp_table->clk_count =3D=3D 1) { + debugfs_create_ulong("rate_hz", S_IRUGO, pdentry, &opp->rates[0]); + return; + } + + for (i =3D 0; i < opp_table->clk_count; i++) { + snprintf(name, sizeof(name), "rate_hz_%d", i); + debugfs_create_ulong(name, S_IRUGO, pdentry, &opp->rates[i]); + } +} + static void opp_debug_create_supplies(struct dev_pm_opp *opp, struct opp_table *opp_table, struct dentry *pdentry) @@ -117,10 +135,11 @@ void opp_debug_create_one(struct dev_pm_opp *opp, str= uct opp_table *opp_table) * Get directory name for OPP. * * - Normally rate is unique to each OPP, use it to get unique opp-name. - * - For some devices rate isn't available, use index instead. + * - For some devices rate isn't available or there are multiple, use + * index instead for them. */ - if (likely(opp->rate)) - id =3D opp->rate; + if (likely(opp_table->clk_count =3D=3D 1)) + id =3D opp->rates[0]; else id =3D _get_opp_count(opp_table); =20 @@ -134,7 +153,6 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struc= t opp_table *opp_table) debugfs_create_bool("turbo", S_IRUGO, d, &opp->turbo); debugfs_create_bool("suspend", S_IRUGO, d, &opp->suspend); debugfs_create_u32("performance_state", S_IRUGO, d, &opp->pstate); - debugfs_create_ulong("rate_hz", S_IRUGO, d, &opp->rate); debugfs_create_u32("level", S_IRUGO, d, &opp->level); debugfs_create_ulong("clock_latency_ns", S_IRUGO, d, &opp->clock_latency_ns); @@ -142,6 +160,7 @@ void opp_debug_create_one(struct dev_pm_opp *opp, struc= t opp_table *opp_table) opp->of_name =3D of_node_full_name(opp->np); debugfs_create_str("of_name", S_IRUGO, d, (char **)&opp->of_name); =20 + opp_debug_create_clks(opp, opp_table, d); opp_debug_create_supplies(opp, opp_table, d); opp_debug_create_bw(opp, opp_table, d); =20 diff --git a/drivers/opp/of.c b/drivers/opp/of.c index bb49057cb1fc..080481a05223 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -767,6 +767,53 @@ void dev_pm_opp_of_remove_table(struct device *dev) } EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); =20 +static int _read_rate(struct dev_pm_opp *new_opp, struct opp_table *opp_ta= ble, + struct device_node *np) +{ + struct property *prop; + int i, count, ret; + u64 *rates; + + if (!opp_table->clk_count) + return -ENODEV; + + prop =3D of_find_property(np, "opp-hz", NULL); + if (!prop) + return -ENODEV; + + count =3D prop->length / sizeof(u64); + if (opp_table->clk_count !=3D count) { + pr_err("%s: Count mismatch between opp-hz and clk_count (%d %d)\n", + __func__, count, opp_table->clk_count); + return -EINVAL; + } + + rates =3D kmalloc_array(count, sizeof(*rates), GFP_KERNEL); + if (!rates) + return -ENOMEM; + + ret =3D of_property_read_u64_array(np, "opp-hz", rates, count); + if (ret) { + pr_err("%s: Error parsing opp-hz: %d\n", __func__, ret); + } else { + /* + * Rate is defined as an unsigned long in clk API, and so + * casting explicitly to its type. Must be fixed once rate is 64 + * bit guaranteed in clk API. + */ + for (i =3D 0; i < count; i++) { + new_opp->rates[i] =3D (unsigned long)rates[i]; + + /* This will happen for frequencies > 4.29 GHz */ + WARN_ON(new_opp->rates[i] !=3D rates[i]); + } + } + + kfree(rates); + + return ret; +} + static int _read_bw(struct dev_pm_opp *new_opp, struct opp_table *opp_tabl= e, struct device_node *np, bool peak) { @@ -812,19 +859,13 @@ static int _read_opp_key(struct dev_pm_opp *new_opp, struct opp_table *opp_table, struct device_node *np) { bool found =3D false; - u64 rate; int ret; =20 - ret =3D of_property_read_u64(np, "opp-hz", &rate); - if (!ret) { - /* - * Rate is defined as an unsigned long in clk API, and so - * casting explicitly to its type. Must be fixed once rate is 64 - * bit guaranteed in clk API. - */ - new_opp->rate =3D (unsigned long)rate; + ret =3D _read_rate(new_opp, opp_table, np); + if (!ret) found =3D true; - } + else if (ret !=3D -ENODEV) + return ret; =20 /* * Bandwidth consists of peak and average (optional) values: @@ -893,8 +934,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp= _table *opp_table, =20 /* Check if the OPP supports hardware's hierarchy of versions or not */ if (!_opp_is_supported(dev, opp_table, np)) { - dev_dbg(dev, "OPP not supported by hardware: %lu\n", - new_opp->rate); + dev_dbg(dev, "OPP not supported by hardware: %s\n", + of_node_full_name(np)); goto free_opp; } =20 @@ -930,7 +971,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp= _table *opp_table, if (of_property_read_bool(np, "opp-suspend")) { if (opp_table->suspend_opp) { /* Pick the OPP with higher rate/bw/level as suspend OPP */ - if (_opp_compare_key(new_opp, opp_table->suspend_opp) =3D=3D 1) { + if (_opp_compare_key(opp_table, new_opp, opp_table->suspend_opp) =3D=3D= 1) { opp_table->suspend_opp->suspend =3D false; new_opp->suspend =3D true; opp_table->suspend_opp =3D new_opp; @@ -945,7 +986,7 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp= _table *opp_table, opp_table->clock_latency_ns_max =3D new_opp->clock_latency_ns; =20 pr_debug("%s: turbo:%d rate:%lu uv:%lu uvmin:%lu uvmax:%lu latency:%lu le= vel:%u\n", - __func__, new_opp->turbo, new_opp->rate, + __func__, new_opp->turbo, new_opp->rates[0], new_opp->supplies[0].u_volt, new_opp->supplies[0].u_volt_min, new_opp->supplies[0].u_volt_max, new_opp->clock_latency_ns, new_opp->level); diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index e481bdb59499..816009eaafee 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -79,7 +79,7 @@ struct opp_config_data { * @suspend: true if suspend OPP * @removed: flag indicating that OPP's reference is dropped by OPP core. * @pstate: Device's power domain's performance state. - * @rate: Frequency in hertz + * @rates: Frequencies in hertz * @level: Performance level * @supplies: Power supplies voltage/current values * @bandwidth: Interconnect bandwidth values @@ -102,7 +102,7 @@ struct dev_pm_opp { bool suspend; bool removed; unsigned int pstate; - unsigned long rate; + unsigned long *rates; unsigned int level; =20 struct dev_pm_opp_supply *supplies; @@ -170,8 +170,10 @@ enum opp_table_access { * @supported_hw: Array of version number to support. * @supported_hw_count: Number of elements in supported_hw array. * @prop_name: A name to postfix to many DT properties, while parsing them. - * @clk_configured: Clock name is configured by the platform. - * @clk: Device's clock handle + * @config_clks: Platform specific config_clks() callback. + * @clks: Device's clock handles, for multiple clocks. + * @clk: Device's clock handle, for single clock. + * @clk_count: Number of clocks. * @config_regulators: Platform specific config_regulators() callback. * @regulators: Supply regulators * @regulator_count: Number of power supply regulators. Its value can be -1 @@ -220,8 +222,10 @@ struct opp_table { unsigned int *supported_hw; unsigned int supported_hw_count; const char *prop_name; - bool clk_configured; + config_clks_t config_clks; + struct clk **clks; struct clk *clk; + int clk_count; config_regulators_t config_regulators; struct regulator **regulators; int regulator_count; @@ -246,7 +250,7 @@ struct opp_table *_find_opp_table(struct device *dev); struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table= *opp_table); 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); +int _opp_compare_key(struct opp_table *opp_table, struct dev_pm_opp *opp1,= struct dev_pm_opp *opp2); int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_ta= ble *opp_table); int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned = long freq, long u_volt, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int l= ast_cpu); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 50cbc75bef71..104151dfe46c 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -61,9 +61,13 @@ typedef int (*config_regulators_t)(struct device *dev, struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, struct regulator **regulators, unsigned int count); =20 +typedef int (*config_clks_t)(struct device *dev, struct opp_table *opp_tab= le, + struct dev_pm_opp *opp, void *data, bool scaling_down); + /** * struct dev_pm_opp_config - Device OPP configuration values - * @clk_names: Clk names, NULL terminated array, max 1 clock for now. + * @clk_names: Clk names, NULL terminated array. + * @config_clks: Custom set clk helper. * @prop_name: Name to postfix to properties. * @config_regulators: Custom set regulator helper. * @supported_hw: Array of hierarchy of versions to match. @@ -78,6 +82,7 @@ typedef int (*config_regulators_t)(struct device *dev, struct dev_pm_opp_config { /* NULL terminated */ const char * const *clk_names; + config_clks_t config_clks; const char *prop_name; config_regulators_t config_regulators; const unsigned int *supported_hw; --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81182C43334 for ; Tue, 5 Jul 2022 07:01:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230444AbiGEHBN (ORCPT ); Tue, 5 Jul 2022 03:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbiGEHA4 (ORCPT ); Tue, 5 Jul 2022 03:00:56 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FA531181E for ; Tue, 5 Jul 2022 00:00:52 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id e132so10624437pgc.5 for ; Tue, 05 Jul 2022 00:00:52 -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=hsy8RgpVRpOJDolyph05nBpVAaILT2BYyd7LLXQK8tY=; b=tWLIhvIMi3bqQ1WIU1mnGOdt9m5zPw3uFewvM95H9pkuxcUMFi9im2HymV9Fe/cfL6 oRp8cnD6MSosK/ZVue8RFaKk5x6Pb68e0oVxf1YXUk41etd+7w6x5sXwvJcqFgVN7xjX mI5743zHcb9t5iGMOMfKFbHCZemw+02HpiqGt6FPtxLzkKurDK5jub1/BclltguVyBpK 1GNF9pjO1jjUDKjDmwNdGNTpV8UOS6oep3Ih1BDdnyWfacdKsPG7BHRkn1VdWT+H1tqK m5MWPGv8Vp7zV710mEa8SX8y1UznzMYdiXuaOBhJVfLetd9mr5Zjc6cxhkS2ah/XgVwS +wWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hsy8RgpVRpOJDolyph05nBpVAaILT2BYyd7LLXQK8tY=; b=6bn6MFKHy+flT6bn+bw5c6sVp/SWALNsjGvJB6aeTLSGFN+n/Ceu5UbUt3tDm23X+v xw4gZSoQYYTI11Xw9DLM7KTTOek5t4oWTteEcqI+AsCUDCE62wZsgG3wapyoo3lfyki5 ewfWagm6AFszND+7KeRjVU+WNuEmWghaohD7HDcaFI8mqelGoHW8lSK6XNSf2yqYOOyI hUF9ejLTq4J6Xw2LeF5AR7TtUHbqXt2qY96w3tLAF8fWMO1Z0YfZqxQOiM83QTthAbuE FoaCYEzZe9JJdERyaf3XR4+BjVejA0nC3tqbSmrxyziy5VzorCaVsd7J1Ppni5yqqv1m wcCA== X-Gm-Message-State: AJIora9gvP1uyQHCa62AVg0QuF9YT8PQwGMPlUkSnJH90S1OYoMtnfqQ +2H/4iSfeWHLzJUi/l2XotyhqA== X-Google-Smtp-Source: AGRyM1vn717VOM81aTHiUjQo6ju+/4RDSOtae3Ze+4pYF3x3lXmyfcGmGRPPtyy9DaQowEDB7AD83w== X-Received: by 2002:a63:185b:0:b0:411:75ee:c87a with SMTP id 27-20020a63185b000000b0041175eec87amr27710197pgy.607.1657004451865; Tue, 05 Jul 2022 00:00:51 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id f20-20020a170902ab9400b0016a109c7606sm22609436plr.259.2022.07.05.00.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:51 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH V2 07/13] OPP: Compare bandwidths for all paths in _opp_compare_key() Date: Tue, 5 Jul 2022 12:30:10 +0530 Message-Id: <1bbfdbf08c010bf6687b906a6865981d0a075acd.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Replicate the same behavior as "rates" here and compare all values instead of relying on the first entry alone. Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 003cd48123d7..261f5e1abfe1 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1683,6 +1683,20 @@ static int _opp_compare_rate(struct opp_table *opp_t= able, return 0; } =20 +static int _opp_compare_bw(struct opp_table *opp_table, struct dev_pm_opp = *opp1, + struct dev_pm_opp *opp2) +{ + int i; + + for (i =3D 0; i < opp_table->path_count; i++) { + if (opp1->bandwidth[i].peak !=3D opp2->bandwidth[i].peak) + return opp1->bandwidth[i].peak < opp2->bandwidth[i].peak ? -1 : 1; + } + + /* Same bw for both OPPs */ + return 0; +} + /* * Returns * 0: opp1 =3D=3D opp2 @@ -1698,9 +1712,9 @@ int _opp_compare_key(struct opp_table *opp_table, str= uct dev_pm_opp *opp1, if (ret) return ret; =20 - if (opp1->bandwidth && opp2->bandwidth && - opp1->bandwidth[0].peak !=3D opp2->bandwidth[0].peak) - return opp1->bandwidth[0].peak < opp2->bandwidth[0].peak ? -1 : 1; + ret =3D _opp_compare_bw(opp_table, opp1, opp2); + if (ret) + return ret; =20 if (opp1->level !=3D opp2->level) return opp1->level < opp2->level ? -1 : 1; --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3984C43334 for ; Tue, 5 Jul 2022 07:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230462AbiGEHBS (ORCPT ); Tue, 5 Jul 2022 03:01:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbiGEHA4 (ORCPT ); Tue, 5 Jul 2022 03:00:56 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DAE811C07 for ; Tue, 5 Jul 2022 00:00:55 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id i8-20020a17090a4b8800b001ef8a65bfbdso4101835pjh.1 for ; Tue, 05 Jul 2022 00:00:55 -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=yne49kj4HQHNC6O00jzXvoEbyLaflHJsRm88BUWfTRA=; b=MVk6ugHg/PsAUBgTbj5ES8HglG1EVcnPkitNAK3zaiR4Vmr9/p1WzQ8DajGvAG0Smx SaE7JeE3gyz/lsQUd0jvG3zOMeDbA+NgoImSRfMn3oIa5qUtoE2a2X/utbeCfsp9IDG6 Qpjm/6DnRtLIxO24wPS93MxGXo2sRA6MFmYjIscJ3YtoK4+alR3s6qBle2VCbMu8yf8m NO6B9BMIPJpMhmeHdpx+xBwXX8hXnPE78dlZf0+0Bl8cddT0to95XAFKbhrWGPCNZOEi F47n112KYmLdtqm8jD81BfpE4298b24o919ZHQLr8NutTChyMDeFvFI2GlDIuuA9On7g 9G1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yne49kj4HQHNC6O00jzXvoEbyLaflHJsRm88BUWfTRA=; b=I6lXxJyEOuuWsQh70JsR+tNNRdWCt6S6JdISikIBeB3JkwZHm0W2ZTv5/Ecj8cmbzw yoxBlkLWMnnKLk8cZC8EZ/nydHqR9UB1eWM8ebrsMRUI8lkwc+mGcrSY9YVtuxDmZAHk Oeo0rSNpMwQPZMFee6HpFywLRFRrN3/8veHnyZ0nMhMwlORicWyxj+t9nc73l9A1Xu/K XSK4PGBaouzvEQzV/+uqBMSNfsqXzTJS8TokyZQOxWyVJ7ACtYP/u2pElDGdkz4rrqvz xWgejEqtLOzM6XHsJznW96ngu6g07qPn3T4XXKhcUFtGX9xCvf/6LriKJsqRxOY/GOBj cG7w== X-Gm-Message-State: AJIora/HWIv6BbBdJtfCQ0hPJ0NlMzFL5Up5jbwR5A0fsW1gKAnwoloy Env/7S9g/ncz3qZlKcoPCQPofg== X-Google-Smtp-Source: AGRyM1tpszP8t3guUioLy0gqcXoXDweT4feRKVPX/H1jc/zN/5TI9ZdMvol1LMS3SbaG/KoBGayG/A== X-Received: by 2002:a17:902:6b41:b0:16a:55f6:95ee with SMTP id g1-20020a1709026b4100b0016a55f695eemr40987923plt.156.1657004454759; Tue, 05 Jul 2022 00:00:54 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id l22-20020a17090a3f1600b001ecfa85c8f0sm11564120pjc.26.2022.07.05.00.00.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:54 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 08/13] OPP: Add key specific assert() method to key finding helpers Date: Tue, 5 Jul 2022 12:30:11 +0530 Message-Id: <1428eae4e3d3454eed6fccf1c53435402c102f4c.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The helpers for the clock key, at least, would need to assert that the helpers are called only for single clock case. Prepare for that by adding an argument to the key finding helpers. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 52 +++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 261f5e1abfe1..e1696cf63409 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -481,10 +481,15 @@ static struct dev_pm_opp *_opp_table_find_key(struct = opp_table *opp_table, unsigned long *key, int index, bool available, unsigned long (*read)(struct dev_pm_opp *opp, int index), bool (*compare)(struct dev_pm_opp **opp, struct dev_pm_opp *temp_opp, - unsigned long opp_key, unsigned long key)) + unsigned long opp_key, unsigned long key), + bool (*assert)(struct opp_table *opp_table)) { struct dev_pm_opp *temp_opp, *opp =3D ERR_PTR(-ERANGE); =20 + /* Assert that the requirement is met */ + if (assert && !assert(opp_table)) + return ERR_PTR(-EINVAL); + mutex_lock(&opp_table->lock); =20 list_for_each_entry(temp_opp, &opp_table->opp_list, node) { @@ -509,7 +514,8 @@ static struct dev_pm_opp * _find_key(struct device *dev, unsigned long *key, int index, bool availabl= e, unsigned long (*read)(struct dev_pm_opp *opp, int index), bool (*compare)(struct dev_pm_opp **opp, struct dev_pm_opp *temp_opp, - unsigned long opp_key, unsigned long key)) + unsigned long opp_key, unsigned long key), + bool (*assert)(struct opp_table *opp_table)) { struct opp_table *opp_table; struct dev_pm_opp *opp; @@ -522,7 +528,7 @@ _find_key(struct device *dev, unsigned long *key, int i= ndex, bool available, } =20 opp =3D _opp_table_find_key(opp_table, key, index, available, read, - compare); + compare, assert); =20 dev_pm_opp_put_opp_table(opp_table); =20 @@ -531,35 +537,42 @@ _find_key(struct device *dev, unsigned long *key, int= index, bool available, =20 static struct dev_pm_opp *_find_key_exact(struct device *dev, unsigned long key, int index, bool available, - unsigned long (*read)(struct dev_pm_opp *opp, int index)) + unsigned long (*read)(struct dev_pm_opp *opp, int index), + bool (*assert)(struct opp_table *opp_table)) { /* * The value of key will be updated here, but will be ignored as the * caller doesn't need it. */ - return _find_key(dev, &key, index, available, read, _compare_exact); + return _find_key(dev, &key, index, available, read, _compare_exact, + assert); } =20 static struct dev_pm_opp *_opp_table_find_key_ceil(struct opp_table *opp_t= able, unsigned long *key, int index, bool available, - unsigned long (*read)(struct dev_pm_opp *opp, int index)) + unsigned long (*read)(struct dev_pm_opp *opp, int index), + bool (*assert)(struct opp_table *opp_table)) { return _opp_table_find_key(opp_table, key, index, available, read, - _compare_ceil); + _compare_ceil, assert); } =20 static struct dev_pm_opp *_find_key_ceil(struct device *dev, unsigned long= *key, int index, bool available, - unsigned long (*read)(struct dev_pm_opp *opp, int index)) + unsigned long (*read)(struct dev_pm_opp *opp, int index), + bool (*assert)(struct opp_table *opp_table)) { - return _find_key(dev, key, index, available, read, _compare_ceil); + return _find_key(dev, key, index, available, read, _compare_ceil, + assert); } =20 static struct dev_pm_opp *_find_key_floor(struct device *dev, unsigned long *key, int index, bool available, - unsigned long (*read)(struct dev_pm_opp *opp, int index)) + unsigned long (*read)(struct dev_pm_opp *opp, int index), + bool (*assert)(struct opp_table *opp_table)) { - return _find_key(dev, key, index, available, read, _compare_floor); + return _find_key(dev, key, index, available, read, _compare_floor, + assert); } =20 /** @@ -588,14 +601,15 @@ static struct dev_pm_opp *_find_key_floor(struct devi= ce *dev, struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available) { - return _find_key_exact(dev, freq, 0, available, _read_freq); + return _find_key_exact(dev, freq, 0, available, _read_freq, NULL); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); =20 static noinline struct dev_pm_opp *_find_freq_ceil(struct opp_table *opp_t= able, unsigned long *freq) { - return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq); + return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq, + NULL); } =20 /** @@ -619,7 +633,7 @@ static noinline struct dev_pm_opp *_find_freq_ceil(stru= ct opp_table *opp_table, struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, unsigned long *freq) { - return _find_key_ceil(dev, freq, 0, true, _read_freq); + return _find_key_ceil(dev, freq, 0, true, _read_freq, NULL); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); =20 @@ -644,7 +658,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq) { - return _find_key_floor(dev, freq, 0, true, _read_freq); + return _find_key_floor(dev, freq, 0, true, _read_freq, NULL); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); =20 @@ -666,7 +680,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); struct dev_pm_opp *dev_pm_opp_find_level_exact(struct device *dev, unsigned int level) { - return _find_key_exact(dev, level, 0, true, _read_level); + return _find_key_exact(dev, level, 0, true, _read_level, NULL); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_level_exact); =20 @@ -691,7 +705,7 @@ struct dev_pm_opp *dev_pm_opp_find_level_ceil(struct de= vice *dev, unsigned long temp =3D *level; struct dev_pm_opp *opp; =20 - opp =3D _find_key_ceil(dev, &temp, 0, true, _read_level); + opp =3D _find_key_ceil(dev, &temp, 0, true, _read_level, NULL); *level =3D temp; return opp; } @@ -722,7 +736,7 @@ struct dev_pm_opp *dev_pm_opp_find_bw_ceil(struct devic= e *dev, unsigned int *bw, unsigned long temp =3D *bw; struct dev_pm_opp *opp; =20 - opp =3D _find_key_ceil(dev, &temp, index, true, _read_bw); + opp =3D _find_key_ceil(dev, &temp, index, true, _read_bw, NULL); *bw =3D temp; return opp; } @@ -753,7 +767,7 @@ struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct devi= ce *dev, unsigned long temp =3D *bw; struct dev_pm_opp *opp; =20 - opp =3D _find_key_floor(dev, &temp, index, true, _read_bw); + opp =3D _find_key_floor(dev, &temp, index, true, _read_bw, NULL); *bw =3D temp; return opp; } --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 769CDC433EF for ; Tue, 5 Jul 2022 07:01:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230470AbiGEHBV (ORCPT ); Tue, 5 Jul 2022 03:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230374AbiGEHA7 (ORCPT ); Tue, 5 Jul 2022 03:00:59 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3297101C3 for ; Tue, 5 Jul 2022 00:00:57 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id v4-20020a17090abb8400b001ef966652a3so1399054pjr.4 for ; Tue, 05 Jul 2022 00:00:57 -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=bTnSd1R3c2h/MITa9c+P658EkVFvGV+MYxMCfkJEHnA=; b=NYf8GTmlfn19nNUsHKtjZ+dPbmWcd1QNJHok5icKPNNqrMl53t0rWdVRobyER1sfIY gjXVj7Hv9kTL9tr0llnm+3p3a0vc9SAJshBZ60vot93+dApC7kcluFPnu6kmssMYYVrO X2KW/EjOJEeZ72Wh42nbchY+J2YJqvA3zI5KoBuLQeS7yPFABcYlKpITZWlrdBbznRB6 T4Y8ctu7OSO2XzAb08NqJmP2WFgSCXA4Yix05+y+V0Lf3VbNMimP+pQ+8Z3xTroq9l7z +IN4xwb+NnVJAqDLTE0hXtKWt+Qqffx1h8DZWu7Ow17eRySDJz+NCcuz7gOADgGJ6IGh MwTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bTnSd1R3c2h/MITa9c+P658EkVFvGV+MYxMCfkJEHnA=; b=6B1BJGO4kyQj3uarILYNOIOLwpDfsSBFiOQeEHZXi/ksoyoTwM5OY5Zob99LaBZlu5 zZNvQwckzuEw6K5xWG8+VpsJ5gb3w7rpxieoVP9eFsXq4hmV5RJQLrYIldBkvC5h2JE3 qfjhb2eD7xUoAPdey4rcwKZkU4q2EohnrXWprMPb8Cn8VqE41AqU12hFKxa4rAvVAaW/ qwlMxQXvO1YZVmdPMFLxOkH/1OYX5pngEimXMykNxadPZxKvyk2DKoRVA0964FnCtjqh i6KuzMcpTT2Q6wH59E7WCipzWfqYihI+mSMmzCzt0UgGInFcxRLK4cuKjXyqGRBHwQjs 0oig== X-Gm-Message-State: AJIora+OFJtXs932BXGtBZlzEqcfaPJlpqKjrJQf4LSb2Me99v9JeDPl MvaV/6BD8pLn5Eot/AYdLxzX+w== X-Google-Smtp-Source: AGRyM1s9x5apNo/JV/bi7399PxHr880FTjl5pyveN2IyqLdLo+GXLyH5ayAyZXd+FV5nyOW6iRZu3w== X-Received: by 2002:a17:902:cccf:b0:168:c4c3:e8ca with SMTP id z15-20020a170902cccf00b00168c4c3e8camr41917841ple.40.1657004457506; Tue, 05 Jul 2022 00:00:57 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id md4-20020a17090b23c400b001ecb5602944sm11499949pjb.28.2022.07.05.00.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:00:57 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 09/13] OPP: Assert clk_count == 1 for single clk helpers Date: Tue, 5 Jul 2022 12:30:12 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Many helpers can be safely called only for devices that have a single clk associated with them. Assert the same for those routines. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index e1696cf63409..5b3542557f72 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -97,6 +97,18 @@ struct opp_table *_find_opp_table(struct device *dev) return opp_table; } =20 +/* + * Returns true if multiple clocks aren't there, else returns false with W= ARN. + * + * We don't force clk_count =3D=3D 1 here as there are users who don't hav= e a clock + * representation in the OPP table and manage the clock configuration them= selves + * in an platform specific way. + */ +static bool assert_single_clk(struct opp_table *opp_table) +{ + return !WARN_ON(opp_table->clk_count > 1); +} + /** * dev_pm_opp_get_voltage() - Gets the voltage corresponding to an opp * @opp: opp for which voltage has to be returned for @@ -181,6 +193,9 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *op= p) return 0; } =20 + if (!assert_single_clk(opp->opp_table)) + return 0; + return opp->rates[0]; } EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); @@ -601,7 +616,8 @@ static struct dev_pm_opp *_find_key_floor(struct device= *dev, struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available) { - return _find_key_exact(dev, freq, 0, available, _read_freq, NULL); + return _find_key_exact(dev, freq, 0, available, _read_freq, + assert_single_clk); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_exact); =20 @@ -609,7 +625,7 @@ static noinline struct dev_pm_opp *_find_freq_ceil(stru= ct opp_table *opp_table, unsigned long *freq) { return _opp_table_find_key_ceil(opp_table, freq, 0, true, _read_freq, - NULL); + assert_single_clk); } =20 /** @@ -633,7 +649,7 @@ static noinline struct dev_pm_opp *_find_freq_ceil(stru= ct opp_table *opp_table, struct dev_pm_opp *dev_pm_opp_find_freq_ceil(struct device *dev, unsigned long *freq) { - return _find_key_ceil(dev, freq, 0, true, _read_freq, NULL); + return _find_key_ceil(dev, freq, 0, true, _read_freq, assert_single_clk); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); =20 @@ -658,7 +674,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_ceil); struct dev_pm_opp *dev_pm_opp_find_freq_floor(struct device *dev, unsigned long *freq) { - return _find_key_floor(dev, freq, 0, true, _read_freq, NULL); + return _find_key_floor(dev, freq, 0, true, _read_freq, assert_single_clk); } EXPORT_SYMBOL_GPL(dev_pm_opp_find_freq_floor); =20 @@ -1521,6 +1537,9 @@ void dev_pm_opp_remove(struct device *dev, unsigned l= ong freq) if (IS_ERR(opp_table)) return; =20 + if (!assert_single_clk(opp_table)) + goto put_table; + mutex_lock(&opp_table->lock); =20 list_for_each_entry(iter, &opp_table->opp_list, node) { @@ -1542,6 +1561,7 @@ void dev_pm_opp_remove(struct device *dev, unsigned l= ong freq) __func__, freq); } =20 +put_table: /* Drop the reference taken by _find_opp_table() */ dev_pm_opp_put_opp_table(opp_table); } @@ -1868,6 +1888,9 @@ int _opp_add_v1(struct opp_table *opp_table, struct d= evice *dev, unsigned long tol; int ret; =20 + if (!assert_single_clk(opp_table)) + return -EINVAL; + new_opp =3D _opp_allocate(opp_table); if (!new_opp) return -ENOMEM; @@ -2721,6 +2744,11 @@ static int _opp_set_availability(struct device *dev,= unsigned long freq, return r; } =20 + if (!assert_single_clk(opp_table)) { + r =3D -EINVAL; + goto put_table; + } + mutex_lock(&opp_table->lock); =20 /* Do we have the frequency? */ @@ -2792,6 +2820,11 @@ int dev_pm_opp_adjust_voltage(struct device *dev, un= signed long freq, return r; } =20 + if (!assert_single_clk(opp_table)) { + r =3D -EINVAL; + goto put_table; + } + mutex_lock(&opp_table->lock); =20 /* Do we have the frequency? */ @@ -2823,11 +2856,11 @@ int dev_pm_opp_adjust_voltage(struct device *dev, u= nsigned long freq, opp); =20 dev_pm_opp_put(opp); - goto adjust_put_table; + goto put_table; =20 adjust_unlock: mutex_unlock(&opp_table->lock); -adjust_put_table: +put_table: dev_pm_opp_put_opp_table(opp_table); return r; } --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73D4BCCA47C for ; Tue, 5 Jul 2022 07:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230489AbiGEHBZ (ORCPT ); Tue, 5 Jul 2022 03:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230313AbiGEHBC (ORCPT ); Tue, 5 Jul 2022 03:01:02 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 125F1101C6 for ; Tue, 5 Jul 2022 00:01:01 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id o31-20020a17090a0a2200b001ef7bd037bbso6333920pjo.0 for ; Tue, 05 Jul 2022 00:01:01 -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=vLm3xPD9OxbHjcm/3fn6+SA6JSr3RLuVTRqSmxurVMY=; b=gKr6TFO1o5rV/BJddvsaeHxIruLKA4Z2tP5sqRSoBNOYHrukCuOEPGVo7e0FTYEgcl JPs+oG85x6SFfg1vEvtXP/lQAQshrSfhiZOrw0EvjkPoldint3hsdATSOECt1ld+kral 1/fwMfJjCAslWGLERTlFONibnZ2X/aI+FyQheqN49D0SODJRUq9YvPe4bETtuDUx7lhn O+DgQG7qTltlnJSl6LpWP/hbMr85OFfSWtaXD2E472mS/yPchzfIXGR5RE6AgJums6Yp aZePjB4t17iRU707AGz931Cy7UL5f6O6XOmW21x0CWOznju7ZLKjwk5pBiGkT88ykqro SrPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vLm3xPD9OxbHjcm/3fn6+SA6JSr3RLuVTRqSmxurVMY=; b=tgiMdhXOz3pC3SM7QfuYM76ugBputQg80p90HpCKsm0HKv/37+k2jDIIAPAB95sPiT v2sEJNQt5QEc5SX28SXXda16PnIVPJxajRs+aF9hqwclbEsTK0eoCO4AM2eOm77NwZtL PuUEgG4X1mgmkocFVsyrCyERWebKXqzC3dDuCi5sw3da2wJX/RB8sCjQO4y0d3qAEgNb QR87m9N19VEuiXoPqOqDhpMwYj82eBf0rpPm4ZczX1k1yqjRGepKdUyE+M39t9YPnwez ZWyfrdOg/jKxMiJQj/NUxmPTD6IVeBiOFqjKHGA03VpW+MBULu/QicoiTmZHhzpCOOZv ubTA== X-Gm-Message-State: AJIora9CTUm8ieOuz3mAQc/gy3624E/pC4rHbhH2W6qdRM3lMK1X0b4x DTMFO5+BXbNdT6eoK4zMYqWa4Q== X-Google-Smtp-Source: AGRyM1uxCpNI8nwgrEdlh7MZTqT7inkXpk5zwGEbVXLVh4hAaidUoOJ+LwVIrS0wKmYsGRPXdI//wQ== X-Received: by 2002:a17:903:1246:b0:16b:a568:4f74 with SMTP id u6-20020a170903124600b0016ba5684f74mr31761798plh.0.1657004460632; Tue, 05 Jul 2022 00:01:00 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id b8-20020a170902650800b0016bee668a62sm1513972plk.108.2022.07.05.00.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:01:00 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 10/13] OPP: Provide a simple implementation to configure multiple clocks Date: Tue, 5 Jul 2022 12:30:13 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This provides a simple implementation to configure multiple clocks for a device. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 34 ++++++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 10 ++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 5b3542557f72..597f7df3e375 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -843,6 +843,40 @@ _opp_config_clk_single(struct device *dev, struct opp_= table *opp_table, return ret; } =20 +/* + * Simple implementation for configuring multiple clocks. Configure clocks= in + * the order in which they are present in the array while scaling up. + */ +int dev_pm_opp_config_clks_simple(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, + bool scaling_down) +{ + int ret, i; + + if (scaling_down) { + for (i =3D opp_table->clk_count - 1; i >=3D 0; i--) { + ret =3D clk_set_rate(opp_table->clks[i], opp->rates[i]); + if (ret) { + dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, + ret); + return ret; + } + } + } else { + for (i =3D 0; i < opp_table->clk_count; i++) { + ret =3D clk_set_rate(opp_table->clks[i], opp->rates[i]); + if (ret) { + dev_err(dev, "%s: failed to set clock rate: %d\n", __func__, + ret); + return ret; + } + } + } + + return ret; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_config_clks_simple); + static int _opp_config_regulator_single(struct device *dev, struct dev_pm_opp *old_opp, struct dev_pm_opp *new_opp, struct regulator **regulators, unsigned int count) diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 104151dfe46c..683e6baf9618 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -159,6 +159,9 @@ int dev_pm_opp_unregister_notifier(struct device *dev, = struct notifier_block *nb int dev_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *co= nfig); int devm_pm_opp_set_config(struct device *dev, struct dev_pm_opp_config *c= onfig); void dev_pm_opp_clear_config(int token); +int dev_pm_opp_config_clks_simple(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, + bool scaling_down); =20 struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_table *src_tab= le, struct opp_table *dst_table, struct dev_pm_opp *src_opp); int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, struct= opp_table *dst_table, unsigned int pstate); @@ -342,6 +345,13 @@ static inline int devm_pm_opp_set_config(struct device= *dev, struct dev_pm_opp_c =20 static inline void dev_pm_opp_clear_config(int token) {} =20 +static inline int dev_pm_opp_config_clks_simple(struct device *dev, + struct opp_table *opp_table, struct dev_pm_opp *opp, void *data, + bool scaling_down) +{ + return -EOPNOTSUPP; +} + static inline struct dev_pm_opp *dev_pm_opp_xlate_required_opp(struct opp_= table *src_table, struct opp_table *dst_table, struct dev_pm_opp *src_opp) { --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5A6E5CCA47C for ; Tue, 5 Jul 2022 07:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230493AbiGEHB2 (ORCPT ); Tue, 5 Jul 2022 03:01:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230402AbiGEHBF (ORCPT ); Tue, 5 Jul 2022 03:01:05 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A4AEE0FD for ; Tue, 5 Jul 2022 00:01:04 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id m2so10249755plx.3 for ; Tue, 05 Jul 2022 00:01:04 -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=dgzYVIoUF/W7ZZqlkRPUIeh8Y0nkpYJWUmbATvkU2GI=; b=yGoD2hyeQwWrzlSQ45BdlmoPYQvy4nmu81ti6NYReaSEmCgC/ywl/t1yTm1OjXRVsN L73KTn8aJPM84deNLu74ZtZeeAxa+vMWp0j9RjZ6LH1KV/ZUBNkmQVNm0vTzwTn9FhkW SP7U3nwHJa0z7CR5YdhizAtoCDlh2ZIpAJPdm0mxzsLCFPU3kpVzNI9oQIIEdKs6zCT3 Lrp30aShQy23RRH5poC3xbokeBJc3pEn4m5L0BO3LW/jzoBcXQyVPbwq6mtug2DUFqXf cYBp07jOrzq7lxX+/KyC4Lo3gQfBSyvb7kN5c9At9ZcuirNlTlEcCLiv5IPyo89QDnS4 aWbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dgzYVIoUF/W7ZZqlkRPUIeh8Y0nkpYJWUmbATvkU2GI=; b=3xqjlmtbqsafGPb1BVde4Jcbj1QzotA2CkClxvYNVRnI0EFK9kBnkoNmP6dG2vq6oF 1LdpJg1CwJD3thPAIAFPnWK3aTueqBnAJPfq5j4CSB+EPto7dfpzChOUp5g28dFDchjp 5/UpUeGovlbQ1ULfpzeQ5T55dBsrNDpcFwOx7I3KOREDJgzkMgpPsAk3gQhdmIgl3mw6 faLUmnOm7OCndBqkJ2E6UTbp9YlM85ceDhN5njchKPzE+eayi7QF0PetOExJNcuqBEKG geqouTRc2a8kmvlOT/8LhA57UYV+xfjTHS9KpgzdN36gEA4ddeii0MltSAZHQUHp+hpo kFaw== X-Gm-Message-State: AJIora+2sM4BIua22trK8HGdQL/BmU89CAHyPi1/EgtOvvzp2mwyMV4w SFQjuz7wooUx82Z2UQZzsibcZw== X-Google-Smtp-Source: AGRyM1v1J2kF4CQzLQeSp9H28kOL+JQ3ADsbF48SrQi09UZfZq0BKDfJ+V//5K7St0Zqv85y/uGZgg== X-Received: by 2002:a17:90b:3648:b0:1ef:7c45:62cb with SMTP id nh8-20020a17090b364800b001ef7c4562cbmr17443339pjb.132.1657004463621; Tue, 05 Jul 2022 00:01:03 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id q11-20020a63504b000000b004126f1e48f4sm769229pgl.20.2022.07.05.00.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:01:03 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Krzysztof Kozlowski , Dmitry Osipenko , linux-kernel@vger.kernel.org Subject: [PATCH V2 11/13] OPP: Allow config_clks helper for single clk case Date: Tue, 5 Jul 2022 12:30:14 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is a corner case with Tegra30, where we want to skip clk configuration via dev_pm_opp_set_opp(), but still want the OPP core to read the "opp-hz" property so we can find the right OPP via freq finding helpers. This is the easiest of the ways to make it work, without any special hacks in the OPP core. Allow config_clks to be passed for single clk case. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 597f7df3e375..666e1ebf91d1 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2177,7 +2177,7 @@ static int _opp_set_clknames(struct opp_table *opp_ta= ble, struct device *dev, count =3D 1; =20 /* Fail early for invalid configurations */ - if (!count || (config_clks && count =3D=3D 1) || (!config_clks && count >= 1)) + if (!count || (!config_clks && count > 1)) return -EINVAL; =20 /* Another CPU that shares the OPP table has set the clkname ? */ @@ -2203,10 +2203,12 @@ static int _opp_set_clknames(struct opp_table *opp_= table, struct device *dev, } =20 opp_table->clk_count =3D count; + opp_table->config_clks =3D config_clks; =20 /* Set generic single clk set here */ if (count =3D=3D 1) { - opp_table->config_clks =3D _opp_config_clk_single; + if (!opp_table->config_clks) + opp_table->config_clks =3D _opp_config_clk_single; =20 /* * We could have just dropped the "clk" field and used "clks" @@ -2221,8 +2223,6 @@ static int _opp_set_clknames(struct opp_table *opp_ta= ble, struct device *dev, * too. */ opp_table->clk =3D opp_table->clks[0]; - } else { - opp_table->config_clks =3D config_clks; } =20 return 0; --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5973AC433EF for ; Tue, 5 Jul 2022 07:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231179AbiGEHBb (ORCPT ); Tue, 5 Jul 2022 03:01:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230424AbiGEHBH (ORCPT ); Tue, 5 Jul 2022 03:01:07 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D70B811143 for ; Tue, 5 Jul 2022 00:01:06 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id fz10so5182045pjb.2 for ; Tue, 05 Jul 2022 00:01:06 -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=cnPaxH1mDSIZ2e0GPjWftFKnYfExNBe634PCeF5701I=; b=u0/ja3+gzAShKN6od06YgRN0+EGIwLFWHCcHMqrhK1OuLT/q7/z0A7GTO8fHEsmENa RPhjD9ICXz65xj+j2vi03p3qYBuXe8mK09mrt3WOedwsDu+5PHtNznf/cK3FXR4wuhjz Vo3Gnibs1I8n6zHJi0MNeET2Qq95OKZxHrTMblvQ0FOHlh+uFp3tg9aFEFFGcrK9K8A7 K5Euw9lBjy+qM5MpKyT0VDZWOqpumVqX4oshKpighn4dnJ2X+sSJHGbJUTf5lNB8DIZe wU5s9kqAgKJSlwHMgSvw5CGCANGz1g7pf2pWNy42iHSifmHGMuHPLVGwt8ajeDGMcbQf ZgGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cnPaxH1mDSIZ2e0GPjWftFKnYfExNBe634PCeF5701I=; b=tAp5bvp3B+dPQXp/tAqRYmGPHClZaJYff7CQwNg7ohbS5Qc+MchdCKcwUWhGSJ+2iJ 5Lp4h+NcWioZBnha160wp3WuvIqtqY8jqRKMXamaZZ5jI1t9VUw6Z00Xb3ErIX1d72xT ZbbkVSvybg6xrKFycX0c0QNQ+tH6He83yNYhwudThLzeRvArNTqTdVJPPGY6hDmSGTuN 0cXJ4grEkID8X7OsuVZ84zlTjrUHAMxD4aaLUUD5O0c33cP5QkPSBzEw/DJ57RoljSS6 BS2qhaxK8zEkb7mviU/MIA+IW7VGDXSTdLp4wMxnizVmr+M0m2e1dBGjmy3f0fLMqG0H KYxw== X-Gm-Message-State: AJIora+qpmv32LTfJRWfm7W0x0AiO5psSMOdr6hqjzfVth/VxBUOEwzJ 1xThbjEOtYgLm8GJZVe4lSCTOw== X-Google-Smtp-Source: AGRyM1tjcbGETqs70V1A+ZZhLgbBZCVq5Tv/ZsONxxt2m7iSUGbCm4TgP9CVwz8uwJRRcRfg8CCLVg== X-Received: by 2002:a17:90a:408f:b0:1d1:d1ba:2abb with SMTP id l15-20020a17090a408f00b001d1d1ba2abbmr43123411pjg.152.1657004466394; Tue, 05 Jul 2022 00:01:06 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id w194-20020a627bcb000000b005286308ee62sm3641624pfc.121.2022.07.05.00.01.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:01:06 -0700 (PDT) From: Viresh Kumar To: Dmitry Osipenko , MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Thierry Reding , Jonathan Hunter Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , "Rafael J. Wysocki" , Stephen Boyd , Nishanth Menon , Krzysztof Kozlowski , Dmitry Osipenko , linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH V2 12/13] PM / devfreq: tegra30: Register config_clks helper Date: Tue, 5 Jul 2022 12:30:15 +0530 Message-Id: <17e26d352a8de3e003d2f6b578d1d037737682a2.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" There is a corner case with Tegra30, where we want to skip clk configuration that happens via dev_pm_opp_set_opp(), but still want the OPP core to read the "opp-hz" property so we can find the right OPP via freq finding helpers. The OPP core provides support for the platforms to provide config_clks helpers now, lets use that instead of devm_pm_opp_of_add_table_noclk() to achieve the same result, as the OPP core won't parse the DT's "opp-hz" property anymore if the clock isn't provided. Tested-by: Dmitry Osipenko Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/devfreq/tegra30-devfreq.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/devfreq/tegra30-devfreq.c b/drivers/devfreq/tegra30-de= vfreq.c index 65ecf17a36f4..0e0a4058f45c 100644 --- a/drivers/devfreq/tegra30-devfreq.c +++ b/drivers/devfreq/tegra30-devfreq.c @@ -821,6 +821,15 @@ static int devm_tegra_devfreq_init_hw(struct device *d= ev, return err; } =20 +static int tegra_devfreq_config_clks_nop(struct device *dev, + struct opp_table *opp_table, + struct dev_pm_opp *opp, void *data, + bool scaling_down) +{ + /* We want to skip clk configuration via dev_pm_opp_set_opp() */ + return 0; +} + static int tegra_devfreq_probe(struct platform_device *pdev) { u32 hw_version =3D BIT(tegra_sku_info.soc_speedo_id); @@ -830,6 +839,13 @@ static int tegra_devfreq_probe(struct platform_device = *pdev) unsigned int i; long rate; int err; + const char *clk_names[] =3D { "actmon", NULL }; + struct dev_pm_opp_config config =3D { + .supported_hw =3D &hw_version, + .supported_hw_count =3D 1, + .clk_names =3D clk_names, + .config_clks =3D tegra_devfreq_config_clks_nop, + }; =20 tegra =3D devm_kzalloc(&pdev->dev, sizeof(*tegra), GFP_KERNEL); if (!tegra) @@ -874,13 +890,13 @@ static int tegra_devfreq_probe(struct platform_device= *pdev) return err; } =20 - err =3D devm_pm_opp_set_supported_hw(&pdev->dev, &hw_version, 1); + err =3D devm_pm_opp_set_config(&pdev->dev, &config); if (err) { - dev_err(&pdev->dev, "Failed to set supported HW: %d\n", err); + dev_err(&pdev->dev, "Failed to set OPP config: %d\n", err); return err; } =20 - err =3D devm_pm_opp_of_add_table_noclk(&pdev->dev, 0); + err =3D devm_pm_opp_of_add_table_indexed(&pdev->dev, 0); if (err) { dev_err(&pdev->dev, "Failed to add OPP table: %d\n", err); return err; --=20 2.31.1.272.g89b43f80a514 From nobody Sun Apr 19 07:16:06 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A651CC433EF for ; Tue, 5 Jul 2022 07:01:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230504AbiGEHBe (ORCPT ); Tue, 5 Jul 2022 03:01:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230492AbiGEHBW (ORCPT ); Tue, 5 Jul 2022 03:01:22 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 065801180D for ; Tue, 5 Jul 2022 00:01:10 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d5so10204960plo.12 for ; Tue, 05 Jul 2022 00:01:10 -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=UdH5G4Th4X2DMlPi52KYT3YEURw2bBNX0NOy7kuLMhY=; b=BplPUaz2WEKeGGwt/6Z+X3PMdVT80ZtLj7KK/CmEKgshjOHlZXpmzz5l/xAvLB/GeA jW8PXw7eXfK/0hNvmWemwOj5hTyYsxJyi0IGxk4vt/Bih3femV2cAwdx8MYaZ1Cs2Lxu PrM8ojwX5nUpbTjw2oZ6LIzGS1bPhWwMY2GD2DmXCTZethyfwyXsfKbZFsHqxWaswsM1 /n9Xjbu+X7PQsqoteDTQvAff/VxWKdPE9n2A1t2GczSJ6lcWKZe3SNG6byONmjMKsoLr 1uof0B8QTtvTcFOdOJANAyJcMXwfRWMoBfhaIgV55yTMUyrMD8xsI1LyjH7CpygbipbS B7Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UdH5G4Th4X2DMlPi52KYT3YEURw2bBNX0NOy7kuLMhY=; b=iJUqxOQ4uaT9HdgVbvKnq7FrYrYiQtYSYio+XpFTiwykRdLbI0SBMWX+IUpomDUV7+ HS5hG5IBSBpUZQTKq7+RHpZBYZqcnbtoMASi82WsFWOUj7yKafKzvfuyfKg0JpwVGL1z ScSsc8PkZNyuHg/9YwodsWUC41YKQsZXxaLbnGvXkp9QSjGZOY3F/Armkfbtsx/zu01Z 9GtsQDEJQ+viiFTCXVV/6NOj9PDAKIy2s1IrYBqE6CzLe4azhZyPYrxMaz/RDcHuIZ8a xT157AFcWEI1S4diwXCdelhc9a8pKmmbNI1Gi8JzydrNfKnIpJOFUuW/sKpaGr27CoNZ ElwA== X-Gm-Message-State: AJIora/b1M707bNZKfftujurFMTB4yN9EmKujTTt3ZRtvuCqHNGt2SyB 11f/rU7HRpSSPAQAOzlIruQwUg== X-Google-Smtp-Source: AGRyM1uANnFSFJWuoa9R9F/MRzwQAyXBS+zhGAv+0KR1ZYDjnYmpjdSC9nCLv6eJ0Zer7VCaSAXp+g== X-Received: by 2002:a17:90b:314c:b0:1ed:442c:117e with SMTP id ip12-20020a17090b314c00b001ed442c117emr40647091pjb.160.1657004469470; Tue, 05 Jul 2022 00:01:09 -0700 (PDT) Received: from localhost ([122.171.18.80]) by smtp.gmail.com with ESMTPSA id 70-20020a621849000000b0051bb79437f7sm22134187pfy.37.2022.07.05.00.01.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Jul 2022 00:01:09 -0700 (PDT) From: Viresh Kumar To: Viresh Kumar , Nishanth Menon , Stephen Boyd , "Rafael J. Wysocki" Cc: Viresh Kumar , linux-pm@vger.kernel.org, Vincent Guittot , Krzysztof Kozlowski , linux-kernel@vger.kernel.org Subject: [PATCH V2 13/13] OPP: Remove dev{m}_pm_opp_of_add_table_noclk() Date: Tue, 5 Jul 2022 12:30:16 +0530 Message-Id: <8e639af4cd22b6980cb3146d7656980b8697e647.1657003420.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Remove the now unused variants and the extra "getclk" parameter from few routines, which is always "true" now. Signed-off-by: Viresh Kumar Tested-by: Manivannan Sadhasivam --- drivers/opp/core.c | 19 +++++++---------- drivers/opp/of.c | 48 +++++++----------------------------------- drivers/opp/opp.h | 2 +- include/linux/pm_opp.h | 12 ----------- 4 files changed, 17 insertions(+), 64 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 666e1ebf91d1..0205b83e1c02 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1360,8 +1360,7 @@ void _get_opp_table_kref(struct opp_table *opp_table) } =20 static struct opp_table *_update_opp_table_clk(struct device *dev, - struct opp_table *opp_table, - bool getclk) + struct opp_table *opp_table) { int ret; =20 @@ -1369,8 +1368,7 @@ static struct opp_table *_update_opp_table_clk(struct= device *dev, * Return early if we don't need to get clk or we have already done it * earlier. */ - if (!getclk || IS_ERR(opp_table) || !IS_ERR(opp_table->clk) || - opp_table->clks) + if (IS_ERR(opp_table) || !IS_ERR(opp_table->clk) || opp_table->clks) return opp_table; =20 /* Find clk for the device */ @@ -1409,8 +1407,7 @@ static struct opp_table *_update_opp_table_clk(struct= device *dev, * uses the opp_tables_busy flag to indicate if another creator is in the = middle * of adding an OPP table and others should wait for it to finish. */ -struct opp_table *_add_opp_table_indexed(struct device *dev, int index, - bool getclk) +struct opp_table *_add_opp_table_indexed(struct device *dev, int index) { struct opp_table *opp_table; =20 @@ -1457,12 +1454,12 @@ struct opp_table *_add_opp_table_indexed(struct dev= ice *dev, int index, unlock: mutex_unlock(&opp_table_lock); =20 - return _update_opp_table_clk(dev, opp_table, getclk); + return _update_opp_table_clk(dev, opp_table); } =20 -static struct opp_table *_add_opp_table(struct device *dev, bool getclk) +static struct opp_table *_add_opp_table(struct device *dev) { - return _add_opp_table_indexed(dev, 0, getclk); + return _add_opp_table_indexed(dev, 0); } =20 struct opp_table *dev_pm_opp_get_opp_table(struct device *dev) @@ -2444,7 +2441,7 @@ int dev_pm_opp_set_config(struct device *dev, struct = dev_pm_opp_config *config) if (!data) return -ENOMEM; =20 - opp_table =3D _add_opp_table(dev, false); + opp_table =3D _add_opp_table(dev); if (IS_ERR(opp_table)) { kfree(data); return PTR_ERR(opp_table); @@ -2735,7 +2732,7 @@ int dev_pm_opp_add(struct device *dev, unsigned long = freq, unsigned long u_volt) struct opp_table *opp_table; int ret; =20 - opp_table =3D _add_opp_table(dev, true); + opp_table =3D _add_opp_table(dev); if (IS_ERR(opp_table)) return PTR_ERR(opp_table); =20 diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 080481a05223..6b19764a3897 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -1123,7 +1123,7 @@ static int _of_add_opp_table_v1(struct device *dev, s= truct opp_table *opp_table) return ret; } =20 -static int _of_add_table_indexed(struct device *dev, int index, bool getcl= k) +static int _of_add_table_indexed(struct device *dev, int index) { struct opp_table *opp_table; int ret, count; @@ -1139,7 +1139,7 @@ static int _of_add_table_indexed(struct device *dev, = int index, bool getclk) index =3D 0; } =20 - opp_table =3D _add_opp_table_indexed(dev, index, getclk); + opp_table =3D _add_opp_table_indexed(dev, index); if (IS_ERR(opp_table)) return PTR_ERR(opp_table); =20 @@ -1163,11 +1163,11 @@ static void devm_pm_opp_of_table_release(void *data) dev_pm_opp_of_remove_table(data); } =20 -static int _devm_of_add_table_indexed(struct device *dev, int index, bool = getclk) +static int _devm_of_add_table_indexed(struct device *dev, int index) { int ret; =20 - ret =3D _of_add_table_indexed(dev, index, getclk); + ret =3D _of_add_table_indexed(dev, index); if (ret) return ret; =20 @@ -1195,7 +1195,7 @@ static int _devm_of_add_table_indexed(struct device *= dev, int index, bool getclk */ int devm_pm_opp_of_add_table(struct device *dev) { - return _devm_of_add_table_indexed(dev, 0, true); + return _devm_of_add_table_indexed(dev, 0); } EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table); =20 @@ -1218,7 +1218,7 @@ EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table); */ int dev_pm_opp_of_add_table(struct device *dev) { - return _of_add_table_indexed(dev, 0, true); + return _of_add_table_indexed(dev, 0); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); =20 @@ -1234,7 +1234,7 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); */ int dev_pm_opp_of_add_table_indexed(struct device *dev, int index) { - return _of_add_table_indexed(dev, index, true); + return _of_add_table_indexed(dev, index); } EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed); =20 @@ -1247,42 +1247,10 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed); */ int devm_pm_opp_of_add_table_indexed(struct device *dev, int index) { - return _devm_of_add_table_indexed(dev, index, true); + return _devm_of_add_table_indexed(dev, index); } EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table_indexed); =20 -/** - * dev_pm_opp_of_add_table_noclk() - Initialize indexed opp table from dev= ice - * tree without getting clk for device. - * @dev: device pointer used to lookup OPP table. - * @index: Index number. - * - * Register the initial OPP table with the OPP library for given device on= ly - * using the "operating-points-v2" property. Do not try to get the clk for= the - * device. - * - * Return: Refer to dev_pm_opp_of_add_table() for return values. - */ -int dev_pm_opp_of_add_table_noclk(struct device *dev, int index) -{ - return _of_add_table_indexed(dev, index, false); -} -EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_noclk); - -/** - * devm_pm_opp_of_add_table_noclk() - Initialize indexed opp table from de= vice - * tree without getting clk for device. - * @dev: device pointer used to lookup OPP table. - * @index: Index number. - * - * This is a resource-managed variant of dev_pm_opp_of_add_table_noclk(). - */ -int devm_pm_opp_of_add_table_noclk(struct device *dev, int index) -{ - return _devm_of_add_table_indexed(dev, index, false); -} -EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table_noclk); - /* CPU device specific helpers */ =20 /** diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 816009eaafee..5e089651c91f 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -254,7 +254,7 @@ int _opp_compare_key(struct opp_table *opp_table, struc= t dev_pm_opp *opp1, struc int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_ta= ble *opp_table); int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned = long freq, long u_volt, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int l= ast_cpu); -struct opp_table *_add_opp_table_indexed(struct device *dev, int index, bo= ol getclk); +struct opp_table *_add_opp_table_indexed(struct device *dev, int index); void _put_opp_list_kref(struct opp_table *opp_table); void _required_opps_available(struct dev_pm_opp *opp, int count); =20 diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 683e6baf9618..dc1fb5890792 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -402,8 +402,6 @@ static inline int dev_pm_opp_sync_regulators(struct dev= ice *dev) int dev_pm_opp_of_add_table(struct device *dev); int dev_pm_opp_of_add_table_indexed(struct device *dev, int index); int devm_pm_opp_of_add_table_indexed(struct device *dev, int index); -int dev_pm_opp_of_add_table_noclk(struct device *dev, int index); -int devm_pm_opp_of_add_table_noclk(struct device *dev, int index); void dev_pm_opp_of_remove_table(struct device *dev); int devm_pm_opp_of_add_table(struct device *dev); int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask); @@ -434,16 +432,6 @@ static inline int devm_pm_opp_of_add_table_indexed(str= uct device *dev, int index return -EOPNOTSUPP; } =20 -static inline int dev_pm_opp_of_add_table_noclk(struct device *dev, int in= dex) -{ - return -EOPNOTSUPP; -} - -static inline int devm_pm_opp_of_add_table_noclk(struct device *dev, int i= ndex) -{ - return -EOPNOTSUPP; -} - static inline void dev_pm_opp_of_remove_table(struct device *dev) { } --=20 2.31.1.272.g89b43f80a514