Linux Power Management development
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Linux PM <linux-pm@vger.kernel.org>
Cc: Lukasz Luba <lukasz.luba@arm.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
Subject: [PATCH v1 2/3] PM: EM: Make three functions static
Date: Wed, 05 Mar 2025 22:11:21 +0100	[thread overview]
Message-ID: <1929404.tdWV9SEqCh@rjwysocki.net> (raw)
In-Reply-To: <5880743.DvuYhMxLoT@rjwysocki.net>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Three functions in the Energy Model code, em_dev_update_perf_domain(),
em_table_alloc() and em_table_free(), have no users outside that code and
so make them static, remove their headers from the Energy Model header
file and remove a piece of documentation associated with them.

This also helps to clean up RCU handling in the Energy Model code that
will be done subsequently.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---

This essentially follow the rules that all functions without users in the
files where they are defined should be static (with all due respect to any
out-of-the-tree users of them).

This change can be reversed when any new users of these functions appear,
but it will have to take changes made by the subsequent patch into account.

---
 Documentation/power/energy-model.rst |   39 +----------------------------------
 include/linux/energy_model.h         |   16 --------------
 kernel/power/energy_model.c          |    9 +++-----
 3 files changed, 6 insertions(+), 58 deletions(-)

--- a/Documentation/power/energy-model.rst
+++ b/Documentation/power/energy-model.rst
@@ -203,43 +203,8 @@
 or in Section 2.5
 
 
-2.4 Runtime modifications
-^^^^^^^^^^^^^^^^^^^^^^^^^
-
-Drivers willing to update the EM at runtime should use the following dedicated
-function to allocate a new instance of the modified EM. The API is listed
-below::
-
-  struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd);
-
-This allows to allocate a structure which contains the new EM table with
-also RCU and kref needed by the EM framework. The 'struct em_perf_table'
-contains array 'struct em_perf_state state[]' which is a list of performance
-states in ascending order. That list must be populated by the device driver
-which wants to update the EM. The list of frequencies can be taken from
-existing EM (created during boot). The content in the 'struct em_perf_state'
-must be populated by the driver as well.
-
-This is the API which does the EM update, using RCU pointers swap::
-
-  int em_dev_update_perf_domain(struct device *dev,
-			struct em_perf_table __rcu *new_table);
-
-Drivers must provide a pointer to the allocated and initialized new EM
-'struct em_perf_table'. That new EM will be safely used inside the EM framework
-and will be visible to other sub-systems in the kernel (thermal, powercap).
-The main design goal for this API is to be fast and avoid extra calculations
-or memory allocations at runtime. When pre-computed EMs are available in the
-device driver, than it should be possible to simply re-use them with low
-performance overhead.
-
-In order to free the EM, provided earlier by the driver (e.g. when the module
-is unloaded), there is a need to call the API::
-
-  void em_table_free(struct em_perf_table __rcu *table);
-
-It will allow the EM framework to safely remove the memory, when there is
-no other sub-system using it, e.g. EAS.
+2.4 Accessing power values and computing costs
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 To use the power values in other sub-systems (like thermal, powercap) there is
 a need to call API which protects the reader and provide consistency of the EM
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -166,14 +166,10 @@
 
 struct em_perf_domain *em_cpu_get(int cpu);
 struct em_perf_domain *em_pd_get(struct device *dev);
-int em_dev_update_perf_domain(struct device *dev,
-			      struct em_perf_table __rcu *new_table);
 int em_dev_register_perf_domain(struct device *dev, unsigned int nr_states,
 				const struct em_data_callback *cb,
 				const cpumask_t *cpus, bool microwatts);
 void em_dev_unregister_perf_domain(struct device *dev);
-struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd);
-void em_table_free(struct em_perf_table __rcu *table);
 int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
 			 int nr_states);
 int em_dev_update_chip_binning(struct device *dev);
@@ -374,18 +370,6 @@
 	return 0;
 }
 static inline
-struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd)
-{
-	return NULL;
-}
-static inline void em_table_free(struct em_perf_table __rcu *table) {}
-static inline
-int em_dev_update_perf_domain(struct device *dev,
-			      struct em_perf_table __rcu *new_table)
-{
-	return -EINVAL;
-}
-static inline
 struct em_perf_state *em_perf_state_from_pd(struct em_perf_domain *pd)
 {
 	return NULL;
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -177,7 +177,7 @@
  *
  * No return values.
  */
-void em_table_free(struct em_perf_table __rcu *table)
+static void em_table_free(struct em_perf_table __rcu *table)
 {
 	kref_put(&table->kref, em_release_table_kref);
 }
@@ -190,7 +190,7 @@
  * has a user.
  * Returns allocated table or NULL.
  */
-struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd)
+static struct em_perf_table __rcu *em_table_alloc(struct em_perf_domain *pd)
 {
 	struct em_perf_table __rcu *table;
 	int table_size;
@@ -299,8 +299,8 @@
  *
  * Return 0 on success or an error code on failure.
  */
-int em_dev_update_perf_domain(struct device *dev,
-			      struct em_perf_table __rcu *new_table)
+static int em_dev_update_perf_domain(struct device *dev,
+				     struct em_perf_table __rcu *new_table)
 {
 	struct em_perf_table __rcu *old_table;
 	struct em_perf_domain *pd;
@@ -329,7 +329,6 @@
 	mutex_unlock(&em_pd_mutex);
 	return 0;
 }
-EXPORT_SYMBOL_GPL(em_dev_update_perf_domain);
 
 static int em_create_perf_table(struct device *dev, struct em_perf_domain *pd,
 				struct em_perf_state *table,




  parent reply	other threads:[~2025-03-05 21:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-05 21:06 [PATCH v1 0/3] PM: EM: API cleanups and elimination of __rcu-related sparse warnings Rafael J. Wysocki
2025-03-05 21:08 ` [PATCH v1 1/3] PM: EM: Consify two parameters of em_dev_register_perf_domain() Rafael J. Wysocki
2025-03-06  9:22   ` Lukasz Luba
2025-03-05 21:11 ` Rafael J. Wysocki [this message]
2025-03-06 10:01   ` [PATCH v1 2/3] PM: EM: Make three functions static Lukasz Luba
2025-03-06 10:37     ` Rafael J. Wysocki
2025-03-05 21:13 ` [PATCH v1 3/3] PM: EM: Address RCU-related sparse warnings Rafael J. Wysocki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1929404.tdWV9SEqCh@rjwysocki.net \
    --to=rjw@rjwysocki.net \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=ricardo.neri-calderon@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox