From patchwork Mon Sep 25 13:17:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 726286 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 9AEFDCE7A94 for ; Mon, 25 Sep 2023 13:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231645AbjIYNSE (ORCPT ); Mon, 25 Sep 2023 09:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231191AbjIYNSD (ORCPT ); Mon, 25 Sep 2023 09:18:03 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EFA510C for ; Mon, 25 Sep 2023 06:17:57 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50306b2920dso7864589e87.0 for ; Mon, 25 Sep 2023 06:17:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647875; x=1696252675; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8U5TCt8PhKvPqkMPolS3qJOc5aJpgLowONzlvaY1uCA=; b=tuTQwHZ3oOn7V7MGJ5JUH4g8KpgW0WWW0vedNhA8gBr9qhL+69mUbIxuFHDZk8Bz/C Pgs0kwULmf15uV8diwpywTMAco385WfGQTM0c3bzlEIc2aitgPU7/EY+fCooUZx9y2bW 5T1h15ufuDjgJsjY9ipnn/g7Ts0uE8Y+YvsKyOLyBvLenRoAWaPmZjBQd8NzglL0R5H8 GOL5x6kHAtijhCU+LwQXJkDH5l86JGE8y8N2aLyLpaqBqHbvKuaL3Po+Yk3u8l9ugeN2 XkRkvMLYlXy2spqhmvR+x6j4Frb7CGdLwL+DXNTtdVJxthnOLwgkjYdOKCLrCDj4lYtl 25Bg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647875; x=1696252675; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8U5TCt8PhKvPqkMPolS3qJOc5aJpgLowONzlvaY1uCA=; b=W6wtfxsRYcQfnCc3KI7mn/TcTOUpmv6YU2EhLp4husNg87PvYzk8c5nfhdYJjnkwQ8 iXN9N+tpBtbI9H2eSCU4tDqS7g2gz2y4fSaWh5qxMOMf8xA/TP+rndcb9+dTLHly+bfj tcHg1gpZV5BjUYbi5zDtp3weXWGc5rA53I33jAELJC1UQNiT2CNs+aERVqmZH0/nk/BX 4Yvst/CdQMwgXVwyVewip2vFnb6IbsJcf7I67nGfp99Fc60J5W2/aFooh5GLOZMkx6iv Vn0mhJnTjFl1Ke2bgpyUSDz3cv4l6aDzPkzMSSiWzHgfroxHtn9mkuiRRb/RcZ1XQrjs 1Wkg== X-Gm-Message-State: AOJu0YymkIlIljCvm2zyv8StB2Cneb/XtxnUHheD2lTkg1uPz4vRvFY9 45eslO9Nle6iH2q2l975wDDJOQ== X-Google-Smtp-Source: AGHT+IHKbJtqXxLpoL/3TxVjGxZPgSGBoxzRkGP+PUJOzo30gCEuhg29mQ3rnnoMG3KuUNvxb6UVyg== X-Received: by 2002:a05:6512:acd:b0:4f9:dac6:2f3d with SMTP id n13-20020a0565120acd00b004f9dac62f3dmr3152406lfu.13.1695647875663; Mon, 25 Sep 2023 06:17:55 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:17:55 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] PM: domains: Introduce dev_pm_domain_set_performance_state() Date: Mon, 25 Sep 2023 15:17:07 +0200 Message-Id: <20230925131715.138411-2-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The generic PM domain is currently the only PM domain variant that supports performance scaling. To allow performance scaling to be supported through a common interface, let's add an optional callback ->set_performance_state(), in the struct dev_pm_domain. Moreover, let's add a function, dev_pm_domain_set_performance_state(), that may be called by consumers to request a new performance state for a device through its PM domain. Note that, in most cases it's preferred that a consumer use the OPP library to request a new performance state for its device. Although, this requires some additional changes to be supported, which are being implemented from subsequent changes. Signed-off-by: Ulf Hansson --- drivers/base/power/common.c | 21 +++++++++++++++++++++ include/linux/pm.h | 2 ++ include/linux/pm_domain.h | 6 ++++++ 3 files changed, 29 insertions(+) diff --git a/drivers/base/power/common.c b/drivers/base/power/common.c index 72115917e0bd..44ec20918a4d 100644 --- a/drivers/base/power/common.c +++ b/drivers/base/power/common.c @@ -228,3 +228,24 @@ void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) device_pm_check_callbacks(dev); } EXPORT_SYMBOL_GPL(dev_pm_domain_set); + +/** + * dev_pm_domain_set_performance_state - Request a new performance state. + * @dev: The device to make the request for. + * @state: Target performance state for the device. + * + * This function should be called when a new performance state needs to be + * requested for a device that is attached to a PM domain. Note that, the + * support for performance scaling for PM domains is optional. + * + * Returns 0 on success and when performance scaling isn't supported, negative + * error code on failure. + */ +int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state) +{ + if (dev->pm_domain && dev->pm_domain->set_performance_state) + return dev->pm_domain->set_performance_state(dev, state); + + return 0; +} +EXPORT_SYMBOL_GPL(dev_pm_domain_set_performance_state); diff --git a/include/linux/pm.h b/include/linux/pm.h index 1400c37b29c7..4c9f571609c8 100644 --- a/include/linux/pm.h +++ b/include/linux/pm.h @@ -719,6 +719,7 @@ extern void dev_pm_put_subsys_data(struct device *dev); * @activate: Called before executing probe routines for bus types and drivers. * @sync: Called after successful driver probe. * @dismiss: Called after unsuccessful driver probe and after driver removal. + * @set_performance_state: Called to request a new performance state. * * Power domains provide callbacks that are executed during system suspend, * hibernation, system resume and during runtime PM transitions instead of @@ -731,6 +732,7 @@ struct dev_pm_domain { int (*activate)(struct device *dev); void (*sync)(struct device *dev); void (*dismiss)(struct device *dev); + int (*set_performance_state)(struct device *dev, unsigned int state); }; /* diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h index 05ad8cefdff1..34663d0d5c55 100644 --- a/include/linux/pm_domain.h +++ b/include/linux/pm_domain.h @@ -435,6 +435,7 @@ struct device *dev_pm_domain_attach_by_name(struct device *dev, void dev_pm_domain_detach(struct device *dev, bool power_off); int dev_pm_domain_start(struct device *dev); void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd); +int dev_pm_domain_set_performance_state(struct device *dev, unsigned int state); #else static inline int dev_pm_domain_attach(struct device *dev, bool power_on) { @@ -457,6 +458,11 @@ static inline int dev_pm_domain_start(struct device *dev) } static inline void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd) {} +static inline int dev_pm_domain_set_performance_state(struct device *dev, + unsigned int state) +{ + return 0; +} #endif #endif /* _LINUX_PM_DOMAIN_H */ From patchwork Mon Sep 25 13:17:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 726285 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 C09EECE7A94 for ; Mon, 25 Sep 2023 13:18:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbjIYNSL (ORCPT ); Mon, 25 Sep 2023 09:18:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231730AbjIYNSH (ORCPT ); Mon, 25 Sep 2023 09:18:07 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07A6C10D for ; Mon, 25 Sep 2023 06:18:00 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2c008042211so107365131fa.2 for ; Mon, 25 Sep 2023 06:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647878; x=1696252678; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AhqA1MINgd8wyumHzpkMN5QpwMn1VgvFU5R0O3ONAJM=; b=WJZ1+v4dJpEF0/JCo1gXHeok7+x23CgH7EbvEhJDP6uGQnY1nGzvLiAkqrwyOS3FK7 CLB4/TGALr4AbLXmqZ+gTqp3OqLj9NMti4DTfbCN/txNBwHi+Qv64WUjMekKK5JUe8Gt 810uMZs4frSaJw1srOAaVLtrEewI2d0Ne3ePowg0nYXvzDYSl8oXKq55dmj7s80N9ll+ OlS4UZ9/vRFFw7G1lt6vrutHy0RxBRzdNmIBw8anv3HGDWh7/jbqBRE+pdERL9oWb+ZX wsHBy4DXxdWOuqhlY0DIQCLLE+ktTe89kV4/BvOZEb+M0Z8J0T6hLI5jQIn3XiZn2JfN kDpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647878; x=1696252678; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AhqA1MINgd8wyumHzpkMN5QpwMn1VgvFU5R0O3ONAJM=; b=u8NYmI9Nf9I4fc2U8XUUN/8za6QQaNon7GpCcasLTkhQ41ETB3b/vda94AP/sLA8Zz T7+nu59OH2T18UXdpilDxnfZnD4sgTxNIoI4RgidtOvdYfOInTb6C7DsfI4ppd/0BSij Mca2Hso5QOY0lYuLTROdo4t9ksFnPPH4JUvrrVSYOLlj/Mzlvd2QG1nvI9ZcnDK8dD3/ bmgVzjmva8eN7RXZNh9I7QtwVJlyYJvbxiw/sfDwAHtXocdnyWciIYbhKejk1oYF5QD+ rKpqTFRRKvixjeCDuQ/7TH6jbfxdmSQhObAc/AzKrba9inwPmwK2+0hiJhzhco2H0g4X Ndqg== X-Gm-Message-State: AOJu0YzkK/yE9hUbAPgPXqCNOD+bhOsmT2gIUpr+N2Dk8qLyoBuGPnOP vJLiEG3Il1rOCSqrq/Jhfk0ZTA== X-Google-Smtp-Source: AGHT+IEx0/FnswSLreQOTAQvzgEeo+ZXQR2hUTbg7rc24PHFcZe2gDmlgALwkrWzUFAiCn1WtP5WzQ== X-Received: by 2002:a05:6512:3082:b0:4fa:ad2d:6c58 with SMTP id z2-20020a056512308200b004faad2d6c58mr6251416lfd.61.1695647878222; Mon, 25 Sep 2023 06:17:58 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.17.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:17:57 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] OPP: Add dev_pm_opp_add_dynamic() to allow more flexibility Date: Mon, 25 Sep 2023 15:17:09 +0200 Message-Id: <20230925131715.138411-4-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org The dev_pm_opp_add() API is limited to add dynamic OPPs with a frequency and a voltage level. To enable more flexibility, let's add a new API, dev_pm_opp_add_dynamic() that's takes a struct dev_pm_opp_data* instead of a list of in-parameters. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 22 ++++++++++------------ drivers/opp/of.c | 10 ++++++---- drivers/opp/opp.h | 2 +- include/linux/pm_opp.h | 29 +++++++++++++++++++++++++---- 4 files changed, 42 insertions(+), 21 deletions(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index 919cc53bc02e..54b6138e1189 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -2002,8 +2002,7 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, * _opp_add_v1() - Allocate a OPP based on v1 bindings. * @opp_table: OPP table * @dev: device for which we do this operation - * @freq: Frequency in Hz for this OPP - * @u_volt: Voltage in uVolts for this OPP + * @data: The OPP data for the OPP to add * @dynamic: Dynamically added OPPs. * * This function adds an opp definition to the opp table and returns status. @@ -2021,10 +2020,10 @@ int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, * -ENOMEM Memory allocation failure */ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, - unsigned long freq, long u_volt, bool dynamic) + struct dev_pm_opp_data *data, bool dynamic) { struct dev_pm_opp *new_opp; - unsigned long tol; + unsigned long tol, u_volt = data->u_volt; int ret; if (!assert_single_clk(opp_table)) @@ -2035,7 +2034,7 @@ int _opp_add_v1(struct opp_table *opp_table, struct device *dev, return -ENOMEM; /* populate the opp table */ - new_opp->rates[0] = freq; + new_opp->rates[0] = data->freq; tol = u_volt * opp_table->voltage_tolerance_v1 / 100; new_opp->supplies[0].u_volt = u_volt; new_opp->supplies[0].u_volt_min = u_volt - tol; @@ -2825,10 +2824,9 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, } /** - * dev_pm_opp_add() - Add an OPP table from a table definitions - * @dev: device for which we do this operation - * @freq: Frequency in Hz for this OPP - * @u_volt: Voltage in uVolts for this OPP + * dev_pm_opp_add_dynamic() - Add an OPP table from a table definitions + * @dev: The device for which we do this operation + * @data: The OPP data for the OPP to add * * This function adds an opp definition to the opp table and returns status. * The opp is made available by default and it can be controlled using @@ -2841,7 +2839,7 @@ int dev_pm_opp_xlate_performance_state(struct opp_table *src_table, * Duplicate OPPs (both freq and volt are same) and !opp->available * -ENOMEM Memory allocation failure */ -int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) +int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *data) { struct opp_table *opp_table; int ret; @@ -2853,13 +2851,13 @@ int dev_pm_opp_add(struct device *dev, unsigned long freq, unsigned long u_volt) /* Fix regulator count for dynamic OPPs */ opp_table->regulator_count = 1; - ret = _opp_add_v1(opp_table, dev, freq, u_volt, true); + ret = _opp_add_v1(opp_table, dev, data, true); if (ret) dev_pm_opp_put_opp_table(opp_table); return ret; } -EXPORT_SYMBOL_GPL(dev_pm_opp_add); +EXPORT_SYMBOL_GPL(dev_pm_opp_add_dynamic); /** * _opp_set_availability() - helper to set the availability of an opp diff --git a/drivers/opp/of.c b/drivers/opp/of.c index ada4963c7cfa..ade6d42cae46 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -1077,13 +1077,15 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table) val = prop->value; while (nr) { - unsigned long freq = be32_to_cpup(val++) * 1000; - unsigned long volt = be32_to_cpup(val++); + struct dev_pm_opp_data data = { + .freq = be32_to_cpup(val++) * 1000, + .u_volt = be32_to_cpup(val++), + }; - ret = _opp_add_v1(opp_table, dev, freq, volt, false); + ret = _opp_add_v1(opp_table, dev, &data, false); if (ret) { dev_err(dev, "%s: Failed to add OPP %ld (%d)\n", - __func__, freq, ret); + __func__, data.freq, ret); goto remove_static_opp; } nr -= 2; diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h index 8a5ea38f3a3d..fefdf9845692 100644 --- a/drivers/opp/opp.h +++ b/drivers/opp/opp.h @@ -251,7 +251,7 @@ struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table); void _opp_free(struct dev_pm_opp *opp); 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_table *opp_table); -int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic); +int _opp_add_v1(struct opp_table *opp_table, struct device *dev, struct dev_pm_opp_data *data, bool dynamic); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, int last_cpu); struct opp_table *_add_opp_table_indexed(struct device *dev, int index, bool getclk); void _put_opp_list_kref(struct opp_table *opp_table); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 91f87d7e807c..a8ee93ba41d8 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -92,6 +92,16 @@ struct dev_pm_opp_config { struct device ***virt_devs; }; +/** + * struct dev_pm_opp_data - The data to use to initialize an OPP. + * @freq: The clock rate in Hz for the OPP. + * @u_volt: The voltage in uV for the OPP. + */ +struct dev_pm_opp_data { + unsigned long freq; + unsigned long u_volt; +}; + #if defined(CONFIG_PM_OPP) struct opp_table *dev_pm_opp_get_opp_table(struct device *dev); @@ -152,8 +162,8 @@ struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, void dev_pm_opp_put(struct dev_pm_opp *opp); -int dev_pm_opp_add(struct device *dev, unsigned long freq, - unsigned long u_volt); +int dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp); + void dev_pm_opp_remove(struct device *dev, unsigned long freq); void dev_pm_opp_remove_all_dynamic(struct device *dev); @@ -322,8 +332,8 @@ static inline struct dev_pm_opp *dev_pm_opp_find_bw_floor(struct device *dev, static inline void dev_pm_opp_put(struct dev_pm_opp *opp) {} -static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, - unsigned long u_volt) +static inline int +dev_pm_opp_add_dynamic(struct device *dev, struct dev_pm_opp_data *opp) { return -EOPNOTSUPP; } @@ -519,6 +529,17 @@ static inline int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_ta /* OPP Configuration helpers */ +static inline int dev_pm_opp_add(struct device *dev, unsigned long freq, + unsigned long u_volt) +{ + struct dev_pm_opp_data data = { + .freq = freq, + .u_volt = u_volt, + }; + + return dev_pm_opp_add_dynamic(dev, &data); +} + /* Regulators helpers */ static inline int dev_pm_opp_set_regulators(struct device *dev, const char * const names[]) From patchwork Mon Sep 25 13:17:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 726284 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 13824CE7A81 for ; Mon, 25 Sep 2023 13:18:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231714AbjIYNSO (ORCPT ); Mon, 25 Sep 2023 09:18:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231788AbjIYNSK (ORCPT ); Mon, 25 Sep 2023 09:18:10 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 604D4115 for ; Mon, 25 Sep 2023 06:18:02 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id 2adb3069b0e04-50435a9f800so8835589e87.2 for ; Mon, 25 Sep 2023 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647880; x=1696252680; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UGGR9pvLY+wooKnYGsA2i71wi2fLynKA1WIbB9823oI=; b=JG37IadUaP/C+jwSLs6b4/k1z5rj7KkktkTY6hcQW2pYJ/Ol5dZeIP0PL7ddIXnY8f Z1sqsaOeoB76QoCvBl9tJ3zzDW8KPphTbuDyjr2OP1o72CYrs39KIC4wpT6o8ylCxOcP icOgHzVtnV4I6oDMnHj5RDnU99Kq0ia066dZKh6m+bBdeUyiNmF+BacxltTXfqzgI1PE KOJaXWwSSqQjNKapEw4irqKtPkfUqfNLFDmwtQDJoZL7WaMf36vq7sfnVGzo5avntecu mxaGanoE/tEoD4WEx+EhouJlZTo4yvfs+OErgxM7OoNLsWhSTVw+jy3B01PhE9rNmCNT Q2Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647880; x=1696252680; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UGGR9pvLY+wooKnYGsA2i71wi2fLynKA1WIbB9823oI=; b=nFUffAd2Cn6jdlpIjEhro6Snm3oFREyH7dEDTT+0vmnUMnlfUJ3/EzxOeEpj6SKlGV ak0r8Iedlj22TXS2yfkhBP+5M56A5KP8jGZBpBCy7rYk8pIsCIidGUGnoqqCoYwBrrI1 C/KF4Qgmu1S5ndaYDCwacPbKVOnwPXX+7uzgAwn1ddzDAlbQ0BSV2zYBntWqcZUgr+Qk lvkqzRlvCwd+koMFyZnbGCqpp5cxlKLjNL9RnRp2KX2ei21wKe7ROk+SQeYr4DNU6+yB ysL8sxHmgieODyrW01zGRfcRgSkaVA7TgDbvNxkCL5mJ9ZJguRvCW3stZ9mEaQgJHKja Gcpg== X-Gm-Message-State: AOJu0YzgkzKV+6h2RTVBGgC9LY9KYc1KpkBpgkkrxXtqnMnnzBwblCNs 9B7rsmYNQdIdZhBiKrUtNWCQkA== X-Google-Smtp-Source: AGHT+IFDV/U1+CFvuV0RG+EvBmu3G460XkDr1UWPQuqt8PiHplj52nhcvo2MurwCK5yDWM7XnDcTyQ== X-Received: by 2002:a19:7711:0:b0:500:78ee:4cd7 with SMTP id s17-20020a197711000000b0050078ee4cd7mr5383774lfc.23.1695647880623; Mon, 25 Sep 2023 06:18:00 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:18:00 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] OPP: Switch to use dev_pm_domain_set_performance_state() Date: Mon, 25 Sep 2023 15:17:11 +0200 Message-Id: <20230925131715.138411-6-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org To support performance scaling for any kinds of PM domains, let's move away from using the genpd specific API, dev_pm_genpd_set_performance_state(), to the common dev_pm_domain_set_performance_state(). No intended functional impact at this point. Signed-off-by: Ulf Hansson --- drivers/opp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/opp/core.c b/drivers/opp/core.c index ca8d1304b508..60dca60ac4af 100644 --- a/drivers/opp/core.c +++ b/drivers/opp/core.c @@ -1030,7 +1030,7 @@ static int _set_performance_state(struct device *dev, struct device *pd_dev, if (!pd_dev) return 0; - ret = dev_pm_genpd_set_performance_state(pd_dev, pstate); + ret = dev_pm_domain_set_performance_state(pd_dev, pstate); if (ret) { dev_err(dev, "Failed to set performance state of %s: %d (%d)\n", dev_name(pd_dev), pstate, ret); From patchwork Mon Sep 25 13:17:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 726282 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 66EEFCE7A98 for ; Mon, 25 Sep 2023 13:18:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231792AbjIYNSU (ORCPT ); Mon, 25 Sep 2023 09:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231806AbjIYNSN (ORCPT ); Mon, 25 Sep 2023 09:18:13 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FFFE107 for ; Mon, 25 Sep 2023 06:18:05 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-50337b43ee6so10566868e87.3 for ; Mon, 25 Sep 2023 06:18:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647883; x=1696252683; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=wxw1p33YOE1Wx3IdS6/yDe9IgDNF8zci3+vg+kboqRc=; b=xwOH8+NWikrFsbTxiNt18SPwgZRiyXp+O/c1EVyL4+dR7QzPvPN8XKSDt553DK/UF6 dcVsYvU9QzpkwdXf7keozroHEuhtrcz86fFXn/kkr+qK3bAJe7hdk6uicJkawfY3CxPn jfeA/QvFJAD+xNXYo7PbKLpw0kFG6/3uVBScxXzZEPD2s5CniwEOvyHtxVHlMnMrl8BR mPQRd3sitKKrEstHg4k21+wHzRdNWS0c8PZPMYeo8I2QaaS+0Um1ACRbpuIQr3FvNlIA NQjRdMXiUYhhOPbNcaQtER8dnkZryqWl1CWyFyQMc4n8xNkCcbvCiRb15hcRC+JzdrD4 xpsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647883; x=1696252683; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wxw1p33YOE1Wx3IdS6/yDe9IgDNF8zci3+vg+kboqRc=; b=Cp6uIkY+iskFje2FkgHxGkdewUt1J2oUxCtygdF52k12+CZjZCLjMD35m4shjOaX56 3t87edbs7btYdizsnA80m+DQ+JGGWDea9vXbKdqWM0P3FsmpSYjPGt8aA8KB6kgAzYkl W8vZHi7QICaYOkYjYvllQq2o6l+hwpwFrRSqjqfFXGTCApbqPUXu+Ik+nWMnJ37CQ68a bw3eQm+1j8RmLjDFWeTYkQxlq4IwkOtJwWfCMZUGvKXgTri16XOpcUxbtOxugo1ZotG7 RAQAIM/GsI2vRwjvgWtvEnMed5BWkz4GtUQUTvt1p8AjNK0ftL4VbTUwmvp0BVc9a317 fAoQ== X-Gm-Message-State: AOJu0YyJIwEnnobqlPdB9NYUDM4HOeZAqGSCnvzTXMel74JU/COZi+F9 Dy1dxhNuOvp5Ii9faQsPotWMVw== X-Google-Smtp-Source: AGHT+IFNueuLCXRNbVrLA4eVjJu12iokEykiWxOyhkw7rPrvIF7kGqhFmBrd80yDDQXxWRiDucIYXA== X-Received: by 2002:a05:6512:308c:b0:500:79f7:1738 with SMTP id z12-20020a056512308c00b0050079f71738mr5892894lfd.17.1695647883494; Mon, 25 Sep 2023 06:18:03 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:18:02 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/9] firmware: arm_scmi: Simplify error path in scmi_dvfs_device_opps_add() Date: Mon, 25 Sep 2023 15:17:13 +0200 Message-Id: <20230925131715.138411-8-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Let's simplify the code in scmi_dvfs_device_opps_add() by using dev_pm_opp_remove_all_dynamic() in the error path. Signed-off-by: Ulf Hansson --- drivers/firmware/arm_scmi/perf.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 9eb58df9124d..733c5ebeb555 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -787,30 +787,22 @@ static int scmi_dvfs_device_opps_add(const struct scmi_protocol_handle *ph, { int idx, ret; unsigned long freq; - struct scmi_opp *opp; struct perf_dom_info *dom; dom = scmi_perf_domain_lookup(ph, domain); if (IS_ERR(dom)) return PTR_ERR(dom); - for (opp = dom->opp, idx = 0; idx < dom->opp_count; idx++, opp++) { + for (idx = 0; idx < dom->opp_count; idx++) { if (!dom->level_indexing_mode) - freq = opp->perf * dom->mult_factor; + freq = dom->opp[idx].perf * dom->mult_factor; else - freq = opp->indicative_freq * 1000; + freq = dom->opp[idx].indicative_freq * 1000; ret = dev_pm_opp_add(dev, freq, 0); if (ret) { dev_warn(dev, "failed to add opp %luHz\n", freq); - - while (idx-- > 0) { - if (!dom->level_indexing_mode) - freq = (--opp)->perf * dom->mult_factor; - else - freq = (--opp)->indicative_freq * 1000; - dev_pm_opp_remove(dev, freq); - } + dev_pm_opp_remove_all_dynamic(dev); return ret; } From patchwork Mon Sep 25 13:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 726283 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 BFED2CE7A96 for ; Mon, 25 Sep 2023 13:18:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231706AbjIYNST (ORCPT ); Mon, 25 Sep 2023 09:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231831AbjIYNSO (ORCPT ); Mon, 25 Sep 2023 09:18:14 -0400 Received: from mail-lj1-x232.google.com (mail-lj1-x232.google.com [IPv6:2a00:1450:4864:20::232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A33B6A2 for ; Mon, 25 Sep 2023 06:18:07 -0700 (PDT) Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2c01d22f332so91290501fa.0 for ; Mon, 25 Sep 2023 06:18:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695647886; x=1696252686; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fsWOr9mWvmZX2dTzJ+FE4Q2Az+t23E8t0uKEFGAoZOI=; b=U+lFD7sQe5sx6HhehOqSxkdj/OGzQTs4Dbqn7qRYWEWfrhW83gX2ZKRMQ+w9tKJzfR 9/NzaYUqQgVNtB0JX1JBZsie8+5jpsnjzh22dFDGf4L5u51F/8ijM7XhlV6Gg9npz2Jf 7iKIWHcysRbDb6B8c4FRdYsZMV2gMIOopWSshEmWl6mockpkPVTRMhoUwAv3EgDQsUkT zu62iSCjhU4zuQjyN6EeYuNbIBlOMuf6flDKWqRR+HhdY1QjnhlkOoQxfofse393fwA7 JXUX/Jd90HAB2eb8ebuNRvdLEyq93/2cp0jGt+ueJHR/GhHrLSxo9ahGY3pxMNCfRsN8 L26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695647886; x=1696252686; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fsWOr9mWvmZX2dTzJ+FE4Q2Az+t23E8t0uKEFGAoZOI=; b=tGemxmXcfPEBG4EaykBWQmZCuA0hr7Fg3a+y//Rkq0xAlgbpeQwYCwrp+6hYtpzdrN xdErVweC/KoCfZcvMAbofPkzrQ435VglTrYJh2sIBfDD+lsHQNF1Qet4tvNVAT0rg1ul jrps33lXDJH/CicWna4aYMvu/7it8INNoDrXNBdEVqrXSfxkvZcuxMUa6aHa+iPdLBQ7 02/5CauZ5YF7sTPvAP+FvcJgP4wFdZUKo4TaOAyQ5HCcYJfjIn+gP9KoWfYg5CBQWnf1 PDCuFMk3FHGkIuXSKvKbImLNaTP6lECTFHFYoiV74Ge5qOFNMEJ94DukarRe7GLNf2Fu b5dA== X-Gm-Message-State: AOJu0YzoAUHGBByRaNhhaB3ifNYuOHscG+GhblIX+Uhxufd4DVkc4Qh6 Fe01PXciqY0vfMWPPUmglXgeUQ== X-Google-Smtp-Source: AGHT+IHKfCzTsoS2MbdaJLaciuQf01sFJ3IqvH48z4MJ8ZgPdLdgU+/B/Iawd1QmPe8D7Z1RTRnMSw== X-Received: by 2002:ac2:5110:0:b0:502:a964:84b1 with SMTP id q16-20020ac25110000000b00502a96484b1mr2196692lfb.25.1695647886003; Mon, 25 Sep 2023 06:18:06 -0700 (PDT) Received: from uffe-tuxpro14.. (h-94-254-63-18.NA.cust.bahnhof.se. [94.254.63.18]) by smtp.gmail.com with ESMTPSA id m29-20020a056512015d00b004fe10276bbfsm1823583lfo.296.2023.09.25.06.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 06:18:05 -0700 (PDT) From: Ulf Hansson To: Sudeep Holla , Cristian Marussi , Viresh Kumar , "Rafael J . Wysocki" Cc: Nishanth Menon , Stephen Boyd , Nikunj Kela , Prasad Sodagudi , Alexandre Torgue , Ulf Hansson , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 9/9] firmware: arm_scmi: Add generic OPP support to the SCMI performance domain Date: Mon, 25 Sep 2023 15:17:15 +0200 Message-Id: <20230925131715.138411-10-ulf.hansson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230925131715.138411-1-ulf.hansson@linaro.org> References: <20230925131715.138411-1-ulf.hansson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org To allow a consumer driver to use the OPP library to scale the performance for its device, let's dynamically add the OPP table when the device gets attached to its SCMI performance domain. Signed-off-by: Ulf Hansson --- drivers/pmdomain/arm/scmi_perf_domain.c | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/pmdomain/arm/scmi_perf_domain.c b/drivers/pmdomain/arm/scmi_perf_domain.c index aa100270500f..bc3f78abb6da 100644 --- a/drivers/pmdomain/arm/scmi_perf_domain.c +++ b/drivers/pmdomain/arm/scmi_perf_domain.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -42,6 +43,37 @@ scmi_pd_set_perf_state(struct generic_pm_domain *genpd, unsigned int state) return ret; } +static int +scmi_pd_attach_dev(struct generic_pm_domain *genpd, struct device *dev) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + int ret; + + /* + * Allow the device to be attached, but don't add the OPP table unless + * the performance level can be changed. + */ + if (!pd->info->set_perf) + return 0; + + ret = pd->perf_ops->device_opps_add(pd->ph, dev, pd->domain_id); + if (ret) + dev_warn(dev, "failed to add OPPs for the device\n"); + + return ret; +} + +static void +scmi_pd_detach_dev(struct generic_pm_domain *genpd, struct device *dev) +{ + struct scmi_perf_domain *pd = to_scmi_pd(genpd); + + if (!pd->info->set_perf) + return; + + dev_pm_opp_remove_all_dynamic(dev); +} + static int scmi_perf_domain_probe(struct scmi_device *sdev) { struct device *dev = &sdev->dev; @@ -95,6 +127,8 @@ static int scmi_perf_domain_probe(struct scmi_device *sdev) scmi_pd->genpd.flags = GENPD_FLAG_ALWAYS_ON | GENPD_FLAG_OPP_TABLE_FW; scmi_pd->genpd.set_performance_state = scmi_pd_set_perf_state; + scmi_pd->genpd.attach_dev = scmi_pd_attach_dev; + scmi_pd->genpd.detach_dev = scmi_pd_detach_dev; ret = pm_genpd_init(&scmi_pd->genpd, NULL, false); if (ret)