All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
  2024-03-14 14:04 [PATCH 0/4] Update Energy Model after chip binning adjusted voltages Lukasz Luba
@ 2024-03-14 14:04   ` Lukasz Luba
  0 siblings, 0 replies; 11+ messages in thread
From: Lukasz Luba @ 2024-03-14 14:04 UTC (permalink / raw)
  To: linux-kernel, linux-pm
  Cc: lukasz.luba, dietmar.eggemann, linux-arm-kernel, sboyd, nm,
	linux-samsung-soc, daniel.lezcano, rafael, viresh.kumar,
	krzysztof.kozlowski, alim.akhtar, m.szyprowski, mhiramat

Add a function which allows to modify easily the EM after the new voltage
information is available. The device drivers for the chip can adjust
the voltage values after setup. The voltage for the same frequency in OPP
can be different due to chip binning. The voltage impacts the power usage
and the EM power values can be updated to reflect that.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 include/linux/energy_model.h |  5 ++++
 kernel/power/energy_model.c  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
index 770755df852f1..d30d67c2f07cf 100644
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -172,6 +172,7 @@ 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);
 
 /**
  * em_pd_get_efficient_state() - Get an efficient performance state from the EM
@@ -387,6 +388,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
 {
 	return -EINVAL;
 }
+static inline int em_dev_update_chip_binning(struct device *dev)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 6960dd7393b2d..1494a909844a4 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -808,3 +808,54 @@ static void em_update_workfn(struct work_struct *work)
 {
 	em_check_capacity_update();
 }
+
+/**
+ * em_dev_update_chip_binning() - Update Energy Model with new values after
+ *			the new voltage information is present in the OPPs.
+ * @dev		: Device for which the Energy Model has to be updated.
+ *
+ * This function allows to update easily the EM with new values available in
+ * the OPP framework and DT. It can be used after the chip has been properly
+ * verified by device drivers and the voltages adjusted for the 'chip binning'.
+ * It uses the "dynamic-power-coefficient" DT property to calculate the power
+ * values for EM. For power calculation it uses the new adjusted voltage
+ * values known for OPPs, which might be changed after boot.
+ */
+int em_dev_update_chip_binning(struct device *dev)
+{
+	struct em_perf_table __rcu *em_table;
+	struct em_perf_domain *pd;
+	int i, ret;
+
+	if (IS_ERR_OR_NULL(dev))
+		return -EINVAL;
+
+	pd = em_pd_get(dev);
+	if (!pd) {
+		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
+		return -EINVAL;
+	}
+
+	em_table = em_table_dup(pd);
+	if (!em_table) {
+		dev_warn(dev, "EM: allocation failed\n");
+		return -ENOMEM;
+	}
+
+	/* Update power values which might change due to new voltage in OPPs */
+	for (i = 0; i < pd->nr_perf_states; i++) {
+		unsigned long freq = em_table->state[i].frequency;
+		unsigned long power;
+
+		ret = dev_pm_opp_calc_power(dev, &power, &freq);
+		if (ret) {
+			em_table_free(em_table);
+			return ret;
+		}
+
+		em_table->state[i].power = power;
+	}
+
+	return em_recalc_and_update(dev, pd, em_table);
+}
+EXPORT_SYMBOL_GPL(em_dev_update_chip_binning);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
@ 2024-03-14 14:04   ` Lukasz Luba
  0 siblings, 0 replies; 11+ messages in thread
From: Lukasz Luba @ 2024-03-14 14:04 UTC (permalink / raw)
  To: linux-kernel, linux-pm
  Cc: lukasz.luba, dietmar.eggemann, linux-arm-kernel, sboyd, nm,
	linux-samsung-soc, daniel.lezcano, rafael, viresh.kumar,
	krzysztof.kozlowski, alim.akhtar, m.szyprowski, mhiramat

Add a function which allows to modify easily the EM after the new voltage
information is available. The device drivers for the chip can adjust
the voltage values after setup. The voltage for the same frequency in OPP
can be different due to chip binning. The voltage impacts the power usage
and the EM power values can be updated to reflect that.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
---
 include/linux/energy_model.h |  5 ++++
 kernel/power/energy_model.c  | 51 ++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
index 770755df852f1..d30d67c2f07cf 100644
--- a/include/linux/energy_model.h
+++ b/include/linux/energy_model.h
@@ -172,6 +172,7 @@ 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);
 
 /**
  * em_pd_get_efficient_state() - Get an efficient performance state from the EM
@@ -387,6 +388,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
 {
 	return -EINVAL;
 }
+static inline int em_dev_update_chip_binning(struct device *dev)
+{
+	return -EINVAL;
+}
 #endif
 
 #endif
diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
index 6960dd7393b2d..1494a909844a4 100644
--- a/kernel/power/energy_model.c
+++ b/kernel/power/energy_model.c
@@ -808,3 +808,54 @@ static void em_update_workfn(struct work_struct *work)
 {
 	em_check_capacity_update();
 }
+
+/**
+ * em_dev_update_chip_binning() - Update Energy Model with new values after
+ *			the new voltage information is present in the OPPs.
+ * @dev		: Device for which the Energy Model has to be updated.
+ *
+ * This function allows to update easily the EM with new values available in
+ * the OPP framework and DT. It can be used after the chip has been properly
+ * verified by device drivers and the voltages adjusted for the 'chip binning'.
+ * It uses the "dynamic-power-coefficient" DT property to calculate the power
+ * values for EM. For power calculation it uses the new adjusted voltage
+ * values known for OPPs, which might be changed after boot.
+ */
+int em_dev_update_chip_binning(struct device *dev)
+{
+	struct em_perf_table __rcu *em_table;
+	struct em_perf_domain *pd;
+	int i, ret;
+
+	if (IS_ERR_OR_NULL(dev))
+		return -EINVAL;
+
+	pd = em_pd_get(dev);
+	if (!pd) {
+		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
+		return -EINVAL;
+	}
+
+	em_table = em_table_dup(pd);
+	if (!em_table) {
+		dev_warn(dev, "EM: allocation failed\n");
+		return -ENOMEM;
+	}
+
+	/* Update power values which might change due to new voltage in OPPs */
+	for (i = 0; i < pd->nr_perf_states; i++) {
+		unsigned long freq = em_table->state[i].frequency;
+		unsigned long power;
+
+		ret = dev_pm_opp_calc_power(dev, &power, &freq);
+		if (ret) {
+			em_table_free(em_table);
+			return ret;
+		}
+
+		em_table->state[i].power = power;
+	}
+
+	return em_recalc_and_update(dev, pd, em_table);
+}
+EXPORT_SYMBOL_GPL(em_dev_update_chip_binning);
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
  2024-03-14 14:04   ` Lukasz Luba
@ 2024-03-14 14:32     ` Christian Loehle
  -1 siblings, 0 replies; 11+ messages in thread
From: Christian Loehle @ 2024-03-14 14:32 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm
  Cc: dietmar.eggemann, linux-arm-kernel, sboyd, nm, linux-samsung-soc,
	daniel.lezcano, rafael, viresh.kumar, krzysztof.kozlowski,
	alim.akhtar, m.szyprowski, mhiramat

On 14/03/2024 14:04, Lukasz Luba wrote:
> Add a function which allows to modify easily the EM after the new voltage
> information is available. The device drivers for the chip can adjust
> the voltage values after setup. The voltage for the same frequency in OPP
> can be different due to chip binning. The voltage impacts the power usage
> and the EM power values can be updated to reflect that.
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>  include/linux/energy_model.h |  5 ++++
>  kernel/power/energy_model.c  | 51 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
> index 770755df852f1..d30d67c2f07cf 100644
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -172,6 +172,7 @@ 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);
>  
>  /**
>   * em_pd_get_efficient_state() - Get an efficient performance state from the EM
> @@ -387,6 +388,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
>  {
>  	return -EINVAL;
>  }
> +static inline int em_dev_update_chip_binning(struct device *dev)
> +{
> +	return -EINVAL;
> +}
>  #endif
>  
>  #endif
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index 6960dd7393b2d..1494a909844a4 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -808,3 +808,54 @@ static void em_update_workfn(struct work_struct *work)
>  {
>  	em_check_capacity_update();
>  }
> +
> +/**
> + * em_dev_update_chip_binning() - Update Energy Model with new values after
> + *			the new voltage information is present in the OPPs.
> + * @dev		: Device for which the Energy Model has to be updated.
> + *
> + * This function allows to update easily the EM with new values available in
> + * the OPP framework and DT. It can be used after the chip has been properly
> + * verified by device drivers and the voltages adjusted for the 'chip binning'.
> + * It uses the "dynamic-power-coefficient" DT property to calculate the power
> + * values for EM. For power calculation it uses the new adjusted voltage
> + * values known for OPPs, which might be changed after boot.
> + */
> +int em_dev_update_chip_binning(struct device *dev)
> +{
> +	struct em_perf_table __rcu *em_table;
> +	struct em_perf_domain *pd;
> +	int i, ret;
> +
> +	if (IS_ERR_OR_NULL(dev))
> +		return -EINVAL;
> +
> +	pd = em_pd_get(dev);
> +	if (!pd) {
> +		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);

ret is uninitialized at this point, I guess just
+		dev_warn(dev, "Couldn't find Energy Model\n");
already contains everything relevant.

> [...]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
@ 2024-03-14 14:32     ` Christian Loehle
  0 siblings, 0 replies; 11+ messages in thread
From: Christian Loehle @ 2024-03-14 14:32 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm
  Cc: dietmar.eggemann, linux-arm-kernel, sboyd, nm, linux-samsung-soc,
	daniel.lezcano, rafael, viresh.kumar, krzysztof.kozlowski,
	alim.akhtar, m.szyprowski, mhiramat

On 14/03/2024 14:04, Lukasz Luba wrote:
> Add a function which allows to modify easily the EM after the new voltage
> information is available. The device drivers for the chip can adjust
> the voltage values after setup. The voltage for the same frequency in OPP
> can be different due to chip binning. The voltage impacts the power usage
> and the EM power values can be updated to reflect that.
> 
> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
> ---
>  include/linux/energy_model.h |  5 ++++
>  kernel/power/energy_model.c  | 51 ++++++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
> index 770755df852f1..d30d67c2f07cf 100644
> --- a/include/linux/energy_model.h
> +++ b/include/linux/energy_model.h
> @@ -172,6 +172,7 @@ 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);
>  
>  /**
>   * em_pd_get_efficient_state() - Get an efficient performance state from the EM
> @@ -387,6 +388,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
>  {
>  	return -EINVAL;
>  }
> +static inline int em_dev_update_chip_binning(struct device *dev)
> +{
> +	return -EINVAL;
> +}
>  #endif
>  
>  #endif
> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
> index 6960dd7393b2d..1494a909844a4 100644
> --- a/kernel/power/energy_model.c
> +++ b/kernel/power/energy_model.c
> @@ -808,3 +808,54 @@ static void em_update_workfn(struct work_struct *work)
>  {
>  	em_check_capacity_update();
>  }
> +
> +/**
> + * em_dev_update_chip_binning() - Update Energy Model with new values after
> + *			the new voltage information is present in the OPPs.
> + * @dev		: Device for which the Energy Model has to be updated.
> + *
> + * This function allows to update easily the EM with new values available in
> + * the OPP framework and DT. It can be used after the chip has been properly
> + * verified by device drivers and the voltages adjusted for the 'chip binning'.
> + * It uses the "dynamic-power-coefficient" DT property to calculate the power
> + * values for EM. For power calculation it uses the new adjusted voltage
> + * values known for OPPs, which might be changed after boot.
> + */
> +int em_dev_update_chip_binning(struct device *dev)
> +{
> +	struct em_perf_table __rcu *em_table;
> +	struct em_perf_domain *pd;
> +	int i, ret;
> +
> +	if (IS_ERR_OR_NULL(dev))
> +		return -EINVAL;
> +
> +	pd = em_pd_get(dev);
> +	if (!pd) {
> +		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);

ret is uninitialized at this point, I guess just
+		dev_warn(dev, "Couldn't find Energy Model\n");
already contains everything relevant.

> [...]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
  2024-03-14 14:04   ` Lukasz Luba
@ 2024-03-15 15:54     ` kernel test robot
  -1 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-03-15 15:54 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm
  Cc: oe-kbuild-all, lukasz.luba, dietmar.eggemann, linux-arm-kernel,
	sboyd, nm, linux-samsung-soc, daniel.lezcano, rafael,
	viresh.kumar, krzysztof.kozlowski, alim.akhtar, m.szyprowski,
	mhiramat

Hi Lukasz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on linus/master next-20240315]
[cannot apply to krzk/for-next clk/clk-next soc/for-next rafael-pm/acpi-bus rafael-pm/devprop v6.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lukasz-Luba/OPP-OF-Export-dev_opp_pm_calc_power-for-usage-from-EM/20240314-220719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20240314140421.3563571-4-lukasz.luba%40arm.com
patch subject: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
config: x86_64-randconfig-123-20240315 (https://download.01.org/0day-ci/archive/20240315/202403152322.1OIlZSAj-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240315/202403152322.1OIlZSAj-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403152322.1OIlZSAj-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   kernel/power/energy_model.c:168:15: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_table [noderef] __rcu *table @@     got struct em_perf_table * @@
   kernel/power/energy_model.c:168:15: sparse:     expected struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:168:15: sparse:     got struct em_perf_table *
   kernel/power/energy_model.c:169:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *objp @@     got struct em_perf_table [noderef] __rcu *table @@
   kernel/power/energy_model.c:169:15: sparse:     expected void const *objp
   kernel/power/energy_model.c:169:15: sparse:     got struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:177:15: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_table [noderef] __rcu *table @@     got struct em_perf_table * @@
   kernel/power/energy_model.c:177:15: sparse:     expected struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:177:15: sparse:     got struct em_perf_table *
   kernel/power/energy_model.c:179:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct callback_head *head @@     got struct callback_head [noderef] __rcu * @@
   kernel/power/energy_model.c:179:19: sparse:     expected struct callback_head *head
   kernel/power/energy_model.c:179:19: sparse:     got struct callback_head [noderef] __rcu *
   kernel/power/energy_model.c:190:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kref *kref @@     got struct kref [noderef] __rcu * @@
   kernel/power/energy_model.c:190:19: sparse:     expected struct kref *kref
   kernel/power/energy_model.c:190:19: sparse:     got struct kref [noderef] __rcu *
   kernel/power/energy_model.c:208:15: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_table [noderef] __rcu *table @@     got void * @@
   kernel/power/energy_model.c:208:15: sparse:     expected struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:208:15: sparse:     got void *
   kernel/power/energy_model.c:212:20: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kref *kref @@     got struct kref [noderef] __rcu * @@
   kernel/power/energy_model.c:212:20: sparse:     expected struct kref *kref
   kernel/power/energy_model.c:212:20: sparse:     got struct kref [noderef] __rcu *
   kernel/power/energy_model.c:328:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kref *kref @@     got struct kref [noderef] __rcu * @@
   kernel/power/energy_model.c:328:19: sparse:     expected struct kref *kref
   kernel/power/energy_model.c:328:19: sparse:     got struct kref [noderef] __rcu *
   kernel/power/energy_model.c:333:45: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:333:45: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:333:45: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:433:45: sparse: sparse: incorrect type in argument 3 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:433:45: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:433:45: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:450:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *objp @@     got struct em_perf_table [noderef] __rcu *[assigned] em_table @@
   kernel/power/energy_model.c:450:15: sparse:     expected void const *objp
   kernel/power/energy_model.c:450:15: sparse:     got struct em_perf_table [noderef] __rcu *[assigned] em_table
   kernel/power/energy_model.c:621:55: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:621:55: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:621:55: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:676:16: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_state *new_ps @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:676:16: sparse:     expected struct em_perf_state *new_ps
   kernel/power/energy_model.c:676:16: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:694:37: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:694:37: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:694:37: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:729:38: sparse: sparse: incorrect type in argument 3 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:729:38: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:729:38: sparse:     got struct em_perf_state [noderef] __rcu *
>> kernel/power/energy_model.c:836:53: sparse: sparse: dereference of noderef expression
   kernel/power/energy_model.c:845:32: sparse: sparse: dereference of noderef expression

vim +836 kernel/power/energy_model.c

   800	
   801	/**
   802	 * em_dev_update_chip_binning() - Update Energy Model with new values after
   803	 *			the new voltage information is present in the OPPs.
   804	 * @dev		: Device for which the Energy Model has to be updated.
   805	 *
   806	 * This function allows to update easily the EM with new values available in
   807	 * the OPP framework and DT. It can be used after the chip has been properly
   808	 * verified by device drivers and the voltages adjusted for the 'chip binning'.
   809	 * It uses the "dynamic-power-coefficient" DT property to calculate the power
   810	 * values for EM. For power calculation it uses the new adjusted voltage
   811	 * values known for OPPs, which might be changed after boot.
   812	 */
   813	int em_dev_update_chip_binning(struct device *dev)
   814	{
   815		struct em_perf_table __rcu *em_table;
   816		struct em_perf_domain *pd;
   817		int i, ret;
   818	
   819		if (IS_ERR_OR_NULL(dev))
   820			return -EINVAL;
   821	
   822		pd = em_pd_get(dev);
   823		if (!pd) {
   824			dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
   825			return -EINVAL;
   826		}
   827	
   828		em_table = em_table_dup(pd);
   829		if (!em_table) {
   830			dev_warn(dev, "EM: allocation failed\n");
   831			return -ENOMEM;
   832		}
   833	
   834		/* Update power values which might change due to new voltage in OPPs */
   835		for (i = 0; i < pd->nr_perf_states; i++) {
 > 836			unsigned long freq = em_table->state[i].frequency;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
@ 2024-03-15 15:54     ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-03-15 15:54 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm
  Cc: oe-kbuild-all, lukasz.luba, dietmar.eggemann, linux-arm-kernel,
	sboyd, nm, linux-samsung-soc, daniel.lezcano, rafael,
	viresh.kumar, krzysztof.kozlowski, alim.akhtar, m.szyprowski,
	mhiramat

Hi Lukasz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on linus/master next-20240315]
[cannot apply to krzk/for-next clk/clk-next soc/for-next rafael-pm/acpi-bus rafael-pm/devprop v6.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lukasz-Luba/OPP-OF-Export-dev_opp_pm_calc_power-for-usage-from-EM/20240314-220719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20240314140421.3563571-4-lukasz.luba%40arm.com
patch subject: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
config: x86_64-randconfig-123-20240315 (https://download.01.org/0day-ci/archive/20240315/202403152322.1OIlZSAj-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240315/202403152322.1OIlZSAj-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403152322.1OIlZSAj-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   kernel/power/energy_model.c:168:15: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_table [noderef] __rcu *table @@     got struct em_perf_table * @@
   kernel/power/energy_model.c:168:15: sparse:     expected struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:168:15: sparse:     got struct em_perf_table *
   kernel/power/energy_model.c:169:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *objp @@     got struct em_perf_table [noderef] __rcu *table @@
   kernel/power/energy_model.c:169:15: sparse:     expected void const *objp
   kernel/power/energy_model.c:169:15: sparse:     got struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:177:15: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_table [noderef] __rcu *table @@     got struct em_perf_table * @@
   kernel/power/energy_model.c:177:15: sparse:     expected struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:177:15: sparse:     got struct em_perf_table *
   kernel/power/energy_model.c:179:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct callback_head *head @@     got struct callback_head [noderef] __rcu * @@
   kernel/power/energy_model.c:179:19: sparse:     expected struct callback_head *head
   kernel/power/energy_model.c:179:19: sparse:     got struct callback_head [noderef] __rcu *
   kernel/power/energy_model.c:190:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kref *kref @@     got struct kref [noderef] __rcu * @@
   kernel/power/energy_model.c:190:19: sparse:     expected struct kref *kref
   kernel/power/energy_model.c:190:19: sparse:     got struct kref [noderef] __rcu *
   kernel/power/energy_model.c:208:15: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_table [noderef] __rcu *table @@     got void * @@
   kernel/power/energy_model.c:208:15: sparse:     expected struct em_perf_table [noderef] __rcu *table
   kernel/power/energy_model.c:208:15: sparse:     got void *
   kernel/power/energy_model.c:212:20: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kref *kref @@     got struct kref [noderef] __rcu * @@
   kernel/power/energy_model.c:212:20: sparse:     expected struct kref *kref
   kernel/power/energy_model.c:212:20: sparse:     got struct kref [noderef] __rcu *
   kernel/power/energy_model.c:328:19: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected struct kref *kref @@     got struct kref [noderef] __rcu * @@
   kernel/power/energy_model.c:328:19: sparse:     expected struct kref *kref
   kernel/power/energy_model.c:328:19: sparse:     got struct kref [noderef] __rcu *
   kernel/power/energy_model.c:333:45: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:333:45: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:333:45: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:433:45: sparse: sparse: incorrect type in argument 3 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:433:45: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:433:45: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:450:15: sparse: sparse: incorrect type in argument 1 (different address spaces) @@     expected void const *objp @@     got struct em_perf_table [noderef] __rcu *[assigned] em_table @@
   kernel/power/energy_model.c:450:15: sparse:     expected void const *objp
   kernel/power/energy_model.c:450:15: sparse:     got struct em_perf_table [noderef] __rcu *[assigned] em_table
   kernel/power/energy_model.c:621:55: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:621:55: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:621:55: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:676:16: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct em_perf_state *new_ps @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:676:16: sparse:     expected struct em_perf_state *new_ps
   kernel/power/energy_model.c:676:16: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:694:37: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:694:37: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:694:37: sparse:     got struct em_perf_state [noderef] __rcu *
   kernel/power/energy_model.c:729:38: sparse: sparse: incorrect type in argument 3 (different address spaces) @@     expected struct em_perf_state *table @@     got struct em_perf_state [noderef] __rcu * @@
   kernel/power/energy_model.c:729:38: sparse:     expected struct em_perf_state *table
   kernel/power/energy_model.c:729:38: sparse:     got struct em_perf_state [noderef] __rcu *
>> kernel/power/energy_model.c:836:53: sparse: sparse: dereference of noderef expression
   kernel/power/energy_model.c:845:32: sparse: sparse: dereference of noderef expression

vim +836 kernel/power/energy_model.c

   800	
   801	/**
   802	 * em_dev_update_chip_binning() - Update Energy Model with new values after
   803	 *			the new voltage information is present in the OPPs.
   804	 * @dev		: Device for which the Energy Model has to be updated.
   805	 *
   806	 * This function allows to update easily the EM with new values available in
   807	 * the OPP framework and DT. It can be used after the chip has been properly
   808	 * verified by device drivers and the voltages adjusted for the 'chip binning'.
   809	 * It uses the "dynamic-power-coefficient" DT property to calculate the power
   810	 * values for EM. For power calculation it uses the new adjusted voltage
   811	 * values known for OPPs, which might be changed after boot.
   812	 */
   813	int em_dev_update_chip_binning(struct device *dev)
   814	{
   815		struct em_perf_table __rcu *em_table;
   816		struct em_perf_domain *pd;
   817		int i, ret;
   818	
   819		if (IS_ERR_OR_NULL(dev))
   820			return -EINVAL;
   821	
   822		pd = em_pd_get(dev);
   823		if (!pd) {
   824			dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
   825			return -EINVAL;
   826		}
   827	
   828		em_table = em_table_dup(pd);
   829		if (!em_table) {
   830			dev_warn(dev, "EM: allocation failed\n");
   831			return -ENOMEM;
   832		}
   833	
   834		/* Update power values which might change due to new voltage in OPPs */
   835		for (i = 0; i < pd->nr_perf_states; i++) {
 > 836			unsigned long freq = em_table->state[i].frequency;

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
  2024-03-14 14:04   ` Lukasz Luba
@ 2024-03-15 16:36     ` kernel test robot
  -1 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-03-15 16:36 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm
  Cc: oe-kbuild-all, lukasz.luba, dietmar.eggemann, linux-arm-kernel,
	sboyd, nm, linux-samsung-soc, daniel.lezcano, rafael,
	viresh.kumar, krzysztof.kozlowski, alim.akhtar, m.szyprowski,
	mhiramat

Hi Lukasz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on linus/master next-20240315]
[cannot apply to krzk/for-next clk/clk-next soc/for-next rafael-pm/acpi-bus rafael-pm/devprop v6.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lukasz-Luba/OPP-OF-Export-dev_opp_pm_calc_power-for-usage-from-EM/20240314-220719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20240314140421.3563571-4-lukasz.luba%40arm.com
patch subject: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
config: i386-randconfig-141-20240315 (https://download.01.org/0day-ci/archive/20240316/202403160033.Kh6R75dh-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240316/202403160033.Kh6R75dh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403160033.Kh6R75dh-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/power/energy_model.c:824:52: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
     824 |                 dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
         |                                                                  ^~~
   include/linux/dev_printk.h:146:70: note: expanded from macro 'dev_warn'
     146 |         dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                                             ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                                     ^~~~~~~~~~~
   kernel/power/energy_model.c:817:12: note: initialize the variable 'ret' to silence this warning
     817 |         int i, ret;
         |                   ^
         |                    = 0
   1 warning generated.


vim +/ret +824 kernel/power/energy_model.c

   800	
   801	/**
   802	 * em_dev_update_chip_binning() - Update Energy Model with new values after
   803	 *			the new voltage information is present in the OPPs.
   804	 * @dev		: Device for which the Energy Model has to be updated.
   805	 *
   806	 * This function allows to update easily the EM with new values available in
   807	 * the OPP framework and DT. It can be used after the chip has been properly
   808	 * verified by device drivers and the voltages adjusted for the 'chip binning'.
   809	 * It uses the "dynamic-power-coefficient" DT property to calculate the power
   810	 * values for EM. For power calculation it uses the new adjusted voltage
   811	 * values known for OPPs, which might be changed after boot.
   812	 */
   813	int em_dev_update_chip_binning(struct device *dev)
   814	{
   815		struct em_perf_table __rcu *em_table;
   816		struct em_perf_domain *pd;
   817		int i, ret;
   818	
   819		if (IS_ERR_OR_NULL(dev))
   820			return -EINVAL;
   821	
   822		pd = em_pd_get(dev);
   823		if (!pd) {
 > 824			dev_warn(dev, "Couldn't find Energy Model %d\n", ret);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
@ 2024-03-15 16:36     ` kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-03-15 16:36 UTC (permalink / raw)
  To: Lukasz Luba, linux-kernel, linux-pm
  Cc: oe-kbuild-all, lukasz.luba, dietmar.eggemann, linux-arm-kernel,
	sboyd, nm, linux-samsung-soc, daniel.lezcano, rafael,
	viresh.kumar, krzysztof.kozlowski, alim.akhtar, m.szyprowski,
	mhiramat

Hi Lukasz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on linus/master next-20240315]
[cannot apply to krzk/for-next clk/clk-next soc/for-next rafael-pm/acpi-bus rafael-pm/devprop v6.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lukasz-Luba/OPP-OF-Export-dev_opp_pm_calc_power-for-usage-from-EM/20240314-220719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20240314140421.3563571-4-lukasz.luba%40arm.com
patch subject: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
config: i386-randconfig-141-20240315 (https://download.01.org/0day-ci/archive/20240316/202403160033.Kh6R75dh-lkp@intel.com/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240316/202403160033.Kh6R75dh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403160033.Kh6R75dh-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> kernel/power/energy_model.c:824:52: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
     824 |                 dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
         |                                                                  ^~~
   include/linux/dev_printk.h:146:70: note: expanded from macro 'dev_warn'
     146 |         dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
         |                                                                             ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
     110 |                 _p_func(dev, fmt, ##__VA_ARGS__);                       \
         |                                     ^~~~~~~~~~~
   kernel/power/energy_model.c:817:12: note: initialize the variable 'ret' to silence this warning
     817 |         int i, ret;
         |                   ^
         |                    = 0
   1 warning generated.


vim +/ret +824 kernel/power/energy_model.c

   800	
   801	/**
   802	 * em_dev_update_chip_binning() - Update Energy Model with new values after
   803	 *			the new voltage information is present in the OPPs.
   804	 * @dev		: Device for which the Energy Model has to be updated.
   805	 *
   806	 * This function allows to update easily the EM with new values available in
   807	 * the OPP framework and DT. It can be used after the chip has been properly
   808	 * verified by device drivers and the voltages adjusted for the 'chip binning'.
   809	 * It uses the "dynamic-power-coefficient" DT property to calculate the power
   810	 * values for EM. For power calculation it uses the new adjusted voltage
   811	 * values known for OPPs, which might be changed after boot.
   812	 */
   813	int em_dev_update_chip_binning(struct device *dev)
   814	{
   815		struct em_perf_table __rcu *em_table;
   816		struct em_perf_domain *pd;
   817		int i, ret;
   818	
   819		if (IS_ERR_OR_NULL(dev))
   820			return -EINVAL;
   821	
   822		pd = em_pd_get(dev);
   823		if (!pd) {
 > 824			dev_warn(dev, "Couldn't find Energy Model %d\n", ret);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
@ 2024-03-16  2:06 kernel test robot
  0 siblings, 0 replies; 11+ messages in thread
From: kernel test robot @ 2024-03-16  2:06 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20240314140421.3563571-4-lukasz.luba@arm.com>
References: <20240314140421.3563571-4-lukasz.luba@arm.com>
TO: Lukasz Luba <lukasz.luba@arm.com>
TO: linux-kernel@vger.kernel.org
TO: linux-pm@vger.kernel.org
CC: lukasz.luba@arm.com
CC: dietmar.eggemann@arm.com
CC: linux-arm-kernel@lists.infradead.org
CC: sboyd@kernel.org
CC: nm@ti.com
CC: linux-samsung-soc@vger.kernel.org
CC: daniel.lezcano@linaro.org
CC: rafael@kernel.org
CC: viresh.kumar@linaro.org
CC: krzysztof.kozlowski@linaro.org
CC: alim.akhtar@samsung.com
CC: m.szyprowski@samsung.com
CC: mhiramat@kernel.org

Hi Lukasz,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rafael-pm/linux-next]
[also build test WARNING on linus/master next-20240315]
[cannot apply to krzk/for-next clk/clk-next soc/for-next rafael-pm/acpi-bus rafael-pm/devprop v6.8]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lukasz-Luba/OPP-OF-Export-dev_opp_pm_calc_power-for-usage-from-EM/20240314-220719
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git linux-next
patch link:    https://lore.kernel.org/r/20240314140421.3563571-4-lukasz.luba%40arm.com
patch subject: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: powerpc64-randconfig-r071-20240315 (https://download.01.org/0day-ci/archive/20240316/202403160905.OfEMtk76-lkp@intel.com/config)
compiler: powerpc64-linux-gcc (GCC) 13.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202403160905.OfEMtk76-lkp@intel.com/

smatch warnings:
kernel/power/energy_model.c:824 em_dev_update_chip_binning() error: uninitialized symbol 'ret'.

vim +/ret +824 kernel/power/energy_model.c

3114fc30ea7e1fd Lukasz Luba 2024-03-14  800  
3114fc30ea7e1fd Lukasz Luba 2024-03-14  801  /**
3114fc30ea7e1fd Lukasz Luba 2024-03-14  802   * em_dev_update_chip_binning() - Update Energy Model with new values after
3114fc30ea7e1fd Lukasz Luba 2024-03-14  803   *			the new voltage information is present in the OPPs.
3114fc30ea7e1fd Lukasz Luba 2024-03-14  804   * @dev		: Device for which the Energy Model has to be updated.
3114fc30ea7e1fd Lukasz Luba 2024-03-14  805   *
3114fc30ea7e1fd Lukasz Luba 2024-03-14  806   * This function allows to update easily the EM with new values available in
3114fc30ea7e1fd Lukasz Luba 2024-03-14  807   * the OPP framework and DT. It can be used after the chip has been properly
3114fc30ea7e1fd Lukasz Luba 2024-03-14  808   * verified by device drivers and the voltages adjusted for the 'chip binning'.
3114fc30ea7e1fd Lukasz Luba 2024-03-14  809   * It uses the "dynamic-power-coefficient" DT property to calculate the power
3114fc30ea7e1fd Lukasz Luba 2024-03-14  810   * values for EM. For power calculation it uses the new adjusted voltage
3114fc30ea7e1fd Lukasz Luba 2024-03-14  811   * values known for OPPs, which might be changed after boot.
3114fc30ea7e1fd Lukasz Luba 2024-03-14  812   */
3114fc30ea7e1fd Lukasz Luba 2024-03-14  813  int em_dev_update_chip_binning(struct device *dev)
3114fc30ea7e1fd Lukasz Luba 2024-03-14  814  {
3114fc30ea7e1fd Lukasz Luba 2024-03-14  815  	struct em_perf_table __rcu *em_table;
3114fc30ea7e1fd Lukasz Luba 2024-03-14  816  	struct em_perf_domain *pd;
3114fc30ea7e1fd Lukasz Luba 2024-03-14  817  	int i, ret;
3114fc30ea7e1fd Lukasz Luba 2024-03-14  818  
3114fc30ea7e1fd Lukasz Luba 2024-03-14  819  	if (IS_ERR_OR_NULL(dev))
3114fc30ea7e1fd Lukasz Luba 2024-03-14  820  		return -EINVAL;
3114fc30ea7e1fd Lukasz Luba 2024-03-14  821  
3114fc30ea7e1fd Lukasz Luba 2024-03-14  822  	pd = em_pd_get(dev);
3114fc30ea7e1fd Lukasz Luba 2024-03-14  823  	if (!pd) {
3114fc30ea7e1fd Lukasz Luba 2024-03-14 @824  		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
  2024-03-14 14:32     ` Christian Loehle
@ 2024-03-22 10:26       ` Lukasz Luba
  -1 siblings, 0 replies; 11+ messages in thread
From: Lukasz Luba @ 2024-03-22 10:26 UTC (permalink / raw)
  To: Christian Loehle
  Cc: dietmar.eggemann, linux-pm, linux-kernel, linux-arm-kernel, sboyd,
	nm, linux-samsung-soc, daniel.lezcano, rafael, viresh.kumar,
	krzysztof.kozlowski, alim.akhtar, m.szyprowski, mhiramat

Hi Christian,

On 3/14/24 14:32, Christian Loehle wrote:
> On 14/03/2024 14:04, Lukasz Luba wrote:
>> Add a function which allows to modify easily the EM after the new voltage
>> information is available. The device drivers for the chip can adjust
>> the voltage values after setup. The voltage for the same frequency in OPP
>> can be different due to chip binning. The voltage impacts the power usage
>> and the EM power values can be updated to reflect that.
>>
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>> ---
>>   include/linux/energy_model.h |  5 ++++
>>   kernel/power/energy_model.c  | 51 ++++++++++++++++++++++++++++++++++++
>>   2 files changed, 56 insertions(+)
>>
>> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
>> index 770755df852f1..d30d67c2f07cf 100644
>> --- a/include/linux/energy_model.h
>> +++ b/include/linux/energy_model.h
>> @@ -172,6 +172,7 @@ 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);
>>   
>>   /**
>>    * em_pd_get_efficient_state() - Get an efficient performance state from the EM
>> @@ -387,6 +388,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
>>   {
>>   	return -EINVAL;
>>   }
>> +static inline int em_dev_update_chip_binning(struct device *dev)
>> +{
>> +	return -EINVAL;
>> +}
>>   #endif
>>   
>>   #endif
>> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
>> index 6960dd7393b2d..1494a909844a4 100644
>> --- a/kernel/power/energy_model.c
>> +++ b/kernel/power/energy_model.c
>> @@ -808,3 +808,54 @@ static void em_update_workfn(struct work_struct *work)
>>   {
>>   	em_check_capacity_update();
>>   }
>> +
>> +/**
>> + * em_dev_update_chip_binning() - Update Energy Model with new values after
>> + *			the new voltage information is present in the OPPs.
>> + * @dev		: Device for which the Energy Model has to be updated.
>> + *
>> + * This function allows to update easily the EM with new values available in
>> + * the OPP framework and DT. It can be used after the chip has been properly
>> + * verified by device drivers and the voltages adjusted for the 'chip binning'.
>> + * It uses the "dynamic-power-coefficient" DT property to calculate the power
>> + * values for EM. For power calculation it uses the new adjusted voltage
>> + * values known for OPPs, which might be changed after boot.
>> + */
>> +int em_dev_update_chip_binning(struct device *dev)
>> +{
>> +	struct em_perf_table __rcu *em_table;
>> +	struct em_perf_domain *pd;
>> +	int i, ret;
>> +
>> +	if (IS_ERR_OR_NULL(dev))
>> +		return -EINVAL;
>> +
>> +	pd = em_pd_get(dev);
>> +	if (!pd) {
>> +		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
> 
> ret is uninitialized at this point, I guess just
> +		dev_warn(dev, "Couldn't find Energy Model\n");
> already contains everything relevant.
> 

Good catch, thanks! Yes, I agree it contains enough. I'm going
to send v2 with this.

Regards,
Lukasz

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning()
@ 2024-03-22 10:26       ` Lukasz Luba
  0 siblings, 0 replies; 11+ messages in thread
From: Lukasz Luba @ 2024-03-22 10:26 UTC (permalink / raw)
  To: Christian Loehle
  Cc: dietmar.eggemann, linux-pm, linux-kernel, linux-arm-kernel, sboyd,
	nm, linux-samsung-soc, daniel.lezcano, rafael, viresh.kumar,
	krzysztof.kozlowski, alim.akhtar, m.szyprowski, mhiramat

Hi Christian,

On 3/14/24 14:32, Christian Loehle wrote:
> On 14/03/2024 14:04, Lukasz Luba wrote:
>> Add a function which allows to modify easily the EM after the new voltage
>> information is available. The device drivers for the chip can adjust
>> the voltage values after setup. The voltage for the same frequency in OPP
>> can be different due to chip binning. The voltage impacts the power usage
>> and the EM power values can be updated to reflect that.
>>
>> Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
>> ---
>>   include/linux/energy_model.h |  5 ++++
>>   kernel/power/energy_model.c  | 51 ++++++++++++++++++++++++++++++++++++
>>   2 files changed, 56 insertions(+)
>>
>> diff --git a/include/linux/energy_model.h b/include/linux/energy_model.h
>> index 770755df852f1..d30d67c2f07cf 100644
>> --- a/include/linux/energy_model.h
>> +++ b/include/linux/energy_model.h
>> @@ -172,6 +172,7 @@ 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);
>>   
>>   /**
>>    * em_pd_get_efficient_state() - Get an efficient performance state from the EM
>> @@ -387,6 +388,10 @@ int em_dev_compute_costs(struct device *dev, struct em_perf_state *table,
>>   {
>>   	return -EINVAL;
>>   }
>> +static inline int em_dev_update_chip_binning(struct device *dev)
>> +{
>> +	return -EINVAL;
>> +}
>>   #endif
>>   
>>   #endif
>> diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c
>> index 6960dd7393b2d..1494a909844a4 100644
>> --- a/kernel/power/energy_model.c
>> +++ b/kernel/power/energy_model.c
>> @@ -808,3 +808,54 @@ static void em_update_workfn(struct work_struct *work)
>>   {
>>   	em_check_capacity_update();
>>   }
>> +
>> +/**
>> + * em_dev_update_chip_binning() - Update Energy Model with new values after
>> + *			the new voltage information is present in the OPPs.
>> + * @dev		: Device for which the Energy Model has to be updated.
>> + *
>> + * This function allows to update easily the EM with new values available in
>> + * the OPP framework and DT. It can be used after the chip has been properly
>> + * verified by device drivers and the voltages adjusted for the 'chip binning'.
>> + * It uses the "dynamic-power-coefficient" DT property to calculate the power
>> + * values for EM. For power calculation it uses the new adjusted voltage
>> + * values known for OPPs, which might be changed after boot.
>> + */
>> +int em_dev_update_chip_binning(struct device *dev)
>> +{
>> +	struct em_perf_table __rcu *em_table;
>> +	struct em_perf_domain *pd;
>> +	int i, ret;
>> +
>> +	if (IS_ERR_OR_NULL(dev))
>> +		return -EINVAL;
>> +
>> +	pd = em_pd_get(dev);
>> +	if (!pd) {
>> +		dev_warn(dev, "Couldn't find Energy Model %d\n", ret);
> 
> ret is uninitialized at this point, I guess just
> +		dev_warn(dev, "Couldn't find Energy Model\n");
> already contains everything relevant.
> 

Good catch, thanks! Yes, I agree it contains enough. I'm going
to send v2 with this.

Regards,
Lukasz

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-03-22 10:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-16  2:06 [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning() kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2024-03-14 14:04 [PATCH 0/4] Update Energy Model after chip binning adjusted voltages Lukasz Luba
2024-03-14 14:04 ` [PATCH 3/4] PM: EM: Add em_dev_update_chip_binning() Lukasz Luba
2024-03-14 14:04   ` Lukasz Luba
2024-03-14 14:32   ` Christian Loehle
2024-03-14 14:32     ` Christian Loehle
2024-03-22 10:26     ` Lukasz Luba
2024-03-22 10:26       ` Lukasz Luba
2024-03-15 15:54   ` kernel test robot
2024-03-15 15:54     ` kernel test robot
2024-03-15 16:36   ` kernel test robot
2024-03-15 16:36     ` kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.