Skip to contentSkip to conversation

linux-next: build failure after merge of the thermal tree

PATCH In review Stephen Rothwell 4 participants 7 messages Dec 15, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

After merging the thermal tree, today's linux-next build (arm multi_v7_defconfig) failed like this:

drivers/thermal/devfreq_cooling.c: In function 'devfreq_cooling_set_cur_state':
drivers/thermal/devfreq_cooling.c:102:9: error: 'struct device' has no member named 'em_pd'
102 | if (dev->em_pd) {
| ^~
drivers/thermal/devfreq_cooling.c:104:13: error: 'struct device' has no member named 'em_pd'
104 | freq = dev->em_pd->table[perf_idx].frequency * 1000;
| ^~
drivers/thermal/devfreq_cooling.c: In function 'devfreq_cooling_get_requested_power':
drivers/thermal/devfreq_cooling.c:207:23: error: 'struct device' has no member named 'em_pd'
207 | dfc->res_util = dev->em_pd->table[state].power;
| ^~
drivers/thermal/devfreq_cooling.c:217:30: error: 'struct device' has no member named 'em_pd'
217 | perf_idx = get_perf_idx(dev->em_pd, freq / 1000);
| ^~
drivers/thermal/devfreq_cooling.c:226:15: error: 'struct device' has no member named 'em_pd'
226 | *power = dev->em_pd->table[perf_idx].power;
| ^~
drivers/thermal/devfreq_cooling.c: In function 'devfreq_cooling_state2power':
drivers/thermal/devfreq_cooling.c:252:14: error: 'struct device' has no member named 'em_pd'
252 | *power = dev->em_pd->table[perf_idx].power;
| ^~
drivers/thermal/devfreq_cooling.c: In function 'devfreq_cooling_power2state':
drivers/thermal/devfreq_cooling.c:290:23: error: 'struct device' has no member named 'em_pd'
290 | if (est_power >= dev->em_pd->table[i].power)
| ^~
drivers/thermal/devfreq_cooling.c: In function 'of_devfreq_cooling_register_power':
drivers/thermal/devfreq_cooling.c:377:9: error: 'struct device' has no member named 'em_pd'
377 | if (dev->em_pd) {
| ^~
drivers/thermal/devfreq_cooling.c:385:38: error: 'struct device' has no member named 'em_pd'
385 | num_opps = em_pd_nr_perf_states(dev->em_pd);
| ^~

Caused by commit

615510fe13bd ("thermal: devfreq_cooling: remove old power model and use EM")

em_pd is only available when CONFIG_ENERGY_MODEL is set.

I have used the thermal tree from next-20201214 for today.

Signature · 2 lines
Cheers,
Stephen Rothwell
#1 lore raw

PATCH 1/1 thermal/drivers/devfreq: Fix missing dependency with the energy model

The devfreq cooling device has been converted to use the energy model.

Add the dependency on the ENERGY_MODEL option to reflect this change and prevent build failure if the option is not set.

Fixes 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")
---
 drivers/thermal/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/thermal/Kconfig +1 -0
index 7edc8dc6bbab..ee62d51ef351 100644
@@ -193,6 +193,7 @@ config DEVFREQ_THERMAL
 	bool "Generic device cooling support"
 	depends on PM_DEVFREQ
 	depends on PM_OPP
+	depends on ENERGY_MODEL
 	help
 	  This implements the generic devfreq cooling mechanism through
 	  frequency reduction for devices using devfreq.
Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH] thermal/drivers/devfreq: Fix missing dependency with the energy model

A separate patch should add the select ENERGY_MODEL in the multi_v7_defconfig so the devfreq cooling device continues to build by default as before.

Arnd?

Quoted 24 lines · Daniel Lezcano

The devfreq cooling device has been converted to use the energy model.

Add the dependency on the ENERGY_MODEL option to reflect this change and prevent build failure if the option is not set.

Fixes 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")
---
 drivers/thermal/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/thermal/Kconfig +1 -0
index 7edc8dc6bbab..ee62d51ef351 100644
@@ -193,6 +193,7 @@ config DEVFREQ_THERMAL
 	bool "Generic device cooling support"
 	depends on PM_DEVFREQ
 	depends on PM_OPP
+	depends on ENERGY_MODEL
 	help
 	  This implements the generic devfreq cooling mechanism through
 	  frequency reduction for devices using devfreq.
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#3 lore raw

Re: [PATCH] thermal/drivers/devfreq: Fix missing dependency with the energy model

In reply to Daniel Lezcano

Hi Daniel,

Quoted 7 lines · On Tue, 15 Dec 2020 09:35:20 +0100 Daniel Lezcano <[email protected]>…

The devfreq cooling device has been converted to use the energy model.

Add the dependency on the ENERGY_MODEL option to reflect this change and prevent build failure if the option is not set.

Fixes 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")
Quoted 10 lines
---
 drivers/thermal/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/thermal/Kconfig +0 -0
index 7edc8dc6bbab..ee62d51ef351 100644

drivers/thermal/Kconfig config DEVFREQ_THERMAL · line 199

Quoted 7 lines
drivers/thermal/Kconfig +1 -0
@@ -193,6 +193,7 @@ config DEVFREQ_THERMAL
 	bool "Generic device cooling support"
 	depends on PM_DEVFREQ
 	depends on PM_OPP
+	depends on ENERGY_MODEL
 	help
 	  This implements the generic devfreq cooling mechanism through
 	  frequency reduction for devices using devfreq.

Looks good to me.

Signature · 2 lines
Cheers,
Stephen Rothwell
reviewer Reviewed-by
#4 lore raw

Re: [PATCH] thermal/drivers/devfreq: Fix missing dependency with the energy model

Quoted 18 lines · Stephen Rothwell

Hi Daniel,

Quoted 7 lines · On Tue, 15 Dec 2020 09:35:20 +0100 Daniel Lezcano <[email protected]>…

The devfreq cooling device has been converted to use the energy model.

Add the dependency on the ENERGY_MODEL option to reflect this change and prevent build failure if the option is not set.

Fixes 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")
Quoted 5 lines
---
  drivers/thermal/Kconfig | 1 +
  1 file changed, 1 insertion(+)
Quoted 15 lines

drivers/thermal/Kconfig config DEVFREQ_THERMAL · line 199

Quoted 12 lines
drivers/thermal/Kconfig +1 -0
index 7edc8dc6bbab..ee62d51ef351 100644
@@ -193,6 +193,7 @@ config DEVFREQ_THERMAL
  	bool "Generic device cooling support"
  	depends on PM_DEVFREQ
  	depends on PM_OPP
+	depends on ENERGY_MODEL
  	help
  	  This implements the generic devfreq cooling mechanism through
  	  frequency reduction for devices using devfreq.

Looks good to me.

My apologies. I've tested it on odroidxu3 with
exynos_defconfig which has the energy model set.

Regards,
Lukasz

reviewer
#5 lore raw

PATCH 1/1 thermal: devfreq_cooling: fix the build when !ENERGY_MODEL

In reply to Stephen Rothwell

Prevent build failure if the option CONFIG_ENERGY_MODEL is not set. The devfreq cooling is able to operate without the Energy Model. Don't use dev->em_pd directly and use local pointer.

Fixes 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")

---
Hi Daniel,

The devfreq cooling implementation can work without the EM and it has been design to handle it. There is only one bit that needs to be changed and used as in v2 (where there was this 'em' private field). Implementation is similar to the cpufreq cooling.
We don't need to put the ENERGY_MODEL dependency in Kconfig.

Regards,
Lukasz

 drivers/thermal/devfreq_cooling.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/thermal/devfreq_cooling.c +12 -13
index df1049a34777..fed3121ff2a1 100644
@@ -48,6 +48,7 @@ static DEFINE_IDA(devfreq_ida);
  * @capped_state:	index to cooling state with in dynamic power budget
  * @req_max_freq:	PM QoS request for limiting the maximum frequency
  *			of the devfreq device.
+ * @em_pd:		Energy Model for the associated Devfreq device
  */
 struct devfreq_cooling_device {
 	int id;
@@ -60,6 +61,7 @@ struct devfreq_cooling_device {
 	u32 res_util;
 	int capped_state;
 	struct dev_pm_qos_request req_max_freq;
+	struct em_perf_domain *em_pd;
 };
 
 static int devfreq_cooling_get_max_state(struct thermal_cooling_device *cdev,
@@ -99,9 +101,9 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev,
 	if (state > dfc->max_state)
 		return -EINVAL;
 
-	if (dev->em_pd) {
+	if (dfc->em_pd) {
 		perf_idx = dfc->max_state - state;
-		freq = dev->em_pd->table[perf_idx].frequency * 1000;
+		freq = dfc->em_pd->table[perf_idx].frequency * 1000;
 	} else {
 		freq = dfc->freq_table[state];
 	}
@@ -181,7 +183,6 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 {
 	struct devfreq_cooling_device *dfc = cdev->devdata;
 	struct devfreq *df = dfc->devfreq;
-	struct device *dev = df->dev.parent;
 	struct devfreq_dev_status status;
 	unsigned long state;
 	unsigned long freq;
@@ -204,7 +205,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 		res = dfc->power_ops->get_real_power(df, power, freq, voltage);
 		if (!res) {
 			state = dfc->capped_state;
-			dfc->res_util = dev->em_pd->table[state].power;
+			dfc->res_util = dfc->em_pd->table[state].power;
 			dfc->res_util *= SCALE_ERROR_MITIGATION;
 
 			if (*power > 1)
@@ -214,7 +215,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 		}
 	} else {
 		/* Energy Model frequencies are in kHz */
-		perf_idx = get_perf_idx(dev->em_pd, freq / 1000);
+		perf_idx = get_perf_idx(dfc->em_pd, freq / 1000);
 		if (perf_idx < 0) {
 			res = -EAGAIN;
 			goto fail;
@@ -223,7 +224,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 		_normalize_load(&status);
 
 		/* Scale power for utilization */
-		*power = dev->em_pd->table[perf_idx].power;
+		*power = dfc->em_pd->table[perf_idx].power;
 		*power *= status.busy_time;
 		*power >>= 10;
 	}
@@ -241,15 +242,13 @@ static int devfreq_cooling_state2power(struct thermal_cooling_device *cdev,
 				       unsigned long state, u32 *power)
 {
 	struct devfreq_cooling_device *dfc = cdev->devdata;
-	struct devfreq *df = dfc->devfreq;
-	struct device *dev = df->dev.parent;
 	int perf_idx;
 
 	if (state > dfc->max_state)
 		return -EINVAL;
 
 	perf_idx = dfc->max_state - state;
-	*power = dev->em_pd->table[perf_idx].power;
+	*power = dfc->em_pd->table[perf_idx].power;
 
 	return 0;
 }
@@ -259,7 +258,6 @@ static int devfreq_cooling_power2state(struct thermal_cooling_device *cdev,
 {
 	struct devfreq_cooling_device *dfc = cdev->devdata;
 	struct devfreq *df = dfc->devfreq;
-	struct device *dev = df->dev.parent;
 	struct devfreq_dev_status status;
 	unsigned long freq;
 	s32 est_power;
@@ -287,7 +285,7 @@ static int devfreq_cooling_power2state(struct thermal_cooling_device *cdev,
 	 * budget. The EM power table is sorted ascending.
 	 */
 	for (i = dfc->max_state; i > 0; i--)
-		if (est_power >= dev->em_pd->table[i].power)
+		if (est_power >= dfc->em_pd->table[i].power)
 			break;
 
 	*state = dfc->max_state - i;
@@ -374,7 +372,8 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
 
 	dfc->devfreq = df;
 
-	if (dev->em_pd) {
+	dfc->em_pd = em_pd_get(dev);
+	if (dfc->em_pd) {
 		devfreq_cooling_ops.get_requested_power =
 			devfreq_cooling_get_requested_power;
 		devfreq_cooling_ops.state2power = devfreq_cooling_state2power;
@@ -382,7 +381,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
 
 		dfc->power_ops = dfc_power;
 
-		num_opps = em_pd_nr_perf_states(dev->em_pd);
+		num_opps = em_pd_nr_perf_states(dfc->em_pd);
 	} else {
 		/* Backward compatibility for drivers which do not use IPA */
 		dev_dbg(dev, "missing EM for cooling device\n");
Signature · 1 line
2.17.1
merge bot Applied
#6 lore raw

[thermal: thermal/next] thermal/drivers/devfreq_cooling: Fix the build when !ENERGY_MODEL

The following commit has been merged into the thermal/next branch of thermal:

The following commit has been merged into the thermal/next branch of thermal:

Commit-ID:     4401117bf7fc11dc738c0963fa0c94814abc8dcd
Gitweb:        https://git.kernel.org/pub/scm/linux/kernel/git/thermal/linux.git//4401117bf7fc11dc738c0963fa0c94814abc8dcd
Author:        Lukasz Luba <[email protected]>
AuthorDate:    Tue, 15 Dec 2020 15:42:21 
Committer:     Daniel Lezcano <[email protected]>
CommitterDate: Tue, 15 Dec 2020 17:03:56 +01:00

thermal/drivers/devfreq_cooling: Fix the build when !ENERGY_MODEL

Prevent build failure if the option CONFIG_ENERGY_MODEL is not set. The devfreq cooling is able to operate without the Energy Model. Don't use dev->em_pd directly and use local pointer.

Fixes 615510fe13bd2 ("thermal: devfreq_cooling: remove old power model and use EM")
---
 drivers/thermal/devfreq_cooling.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
drivers/thermal/devfreq_cooling.c +12 -13
index df1049a..fed3121 100644
@@ -48,6 +48,7 @@ static DEFINE_IDA(devfreq_ida);
  * @capped_state:	index to cooling state with in dynamic power budget
  * @req_max_freq:	PM QoS request for limiting the maximum frequency
  *			of the devfreq device.
+ * @em_pd:		Energy Model for the associated Devfreq device
  */
 struct devfreq_cooling_device {
 	int id;
@@ -60,6 +61,7 @@ struct devfreq_cooling_device {
 	u32 res_util;
 	int capped_state;
 	struct dev_pm_qos_request req_max_freq;
+	struct em_perf_domain *em_pd;
 };
 
 static int devfreq_cooling_get_max_state(struct thermal_cooling_device *cdev,
@@ -99,9 +101,9 @@ static int devfreq_cooling_set_cur_state(struct thermal_cooling_device *cdev,
 	if (state > dfc->max_state)
 		return -EINVAL;
 
-	if (dev->em_pd) {
+	if (dfc->em_pd) {
 		perf_idx = dfc->max_state - state;
-		freq = dev->em_pd->table[perf_idx].frequency * 1000;
+		freq = dfc->em_pd->table[perf_idx].frequency * 1000;
 	} else {
 		freq = dfc->freq_table[state];
 	}
@@ -181,7 +183,6 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 {
 	struct devfreq_cooling_device *dfc = cdev->devdata;
 	struct devfreq *df = dfc->devfreq;
-	struct device *dev = df->dev.parent;
 	struct devfreq_dev_status status;
 	unsigned long state;
 	unsigned long freq;
@@ -204,7 +205,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 		res = dfc->power_ops->get_real_power(df, power, freq, voltage);
 		if (!res) {
 			state = dfc->capped_state;
-			dfc->res_util = dev->em_pd->table[state].power;
+			dfc->res_util = dfc->em_pd->table[state].power;
 			dfc->res_util *= SCALE_ERROR_MITIGATION;
 
 			if (*power > 1)
@@ -214,7 +215,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 		}
 	} else {
 		/* Energy Model frequencies are in kHz */
-		perf_idx = get_perf_idx(dev->em_pd, freq / 1000);
+		perf_idx = get_perf_idx(dfc->em_pd, freq / 1000);
 		if (perf_idx < 0) {
 			res = -EAGAIN;
 			goto fail;
@@ -223,7 +224,7 @@ static int devfreq_cooling_get_requested_power(struct thermal_cooling_device *cd
 		_normalize_load(&status);
 
 		/* Scale power for utilization */
-		*power = dev->em_pd->table[perf_idx].power;
+		*power = dfc->em_pd->table[perf_idx].power;
 		*power *= status.busy_time;
 		*power >>= 10;
 	}
@@ -241,15 +242,13 @@ static int devfreq_cooling_state2power(struct thermal_cooling_device *cdev,
 				       unsigned long state, u32 *power)
 {
 	struct devfreq_cooling_device *dfc = cdev->devdata;
-	struct devfreq *df = dfc->devfreq;
-	struct device *dev = df->dev.parent;
 	int perf_idx;
 
 	if (state > dfc->max_state)
 		return -EINVAL;
 
 	perf_idx = dfc->max_state - state;
-	*power = dev->em_pd->table[perf_idx].power;
+	*power = dfc->em_pd->table[perf_idx].power;
 
 	return 0;
 }
@@ -259,7 +258,6 @@ static int devfreq_cooling_power2state(struct thermal_cooling_device *cdev,
 {
 	struct devfreq_cooling_device *dfc = cdev->devdata;
 	struct devfreq *df = dfc->devfreq;
-	struct device *dev = df->dev.parent;
 	struct devfreq_dev_status status;
 	unsigned long freq;
 	s32 est_power;
@@ -287,7 +285,7 @@ static int devfreq_cooling_power2state(struct thermal_cooling_device *cdev,
 	 * budget. The EM power table is sorted ascending.
 	 */
 	for (i = dfc->max_state; i > 0; i--)
-		if (est_power >= dev->em_pd->table[i].power)
+		if (est_power >= dfc->em_pd->table[i].power)
 			break;
 
 	*state = dfc->max_state - i;
@@ -374,7 +372,8 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
 
 	dfc->devfreq = df;
 
-	if (dev->em_pd) {
+	dfc->em_pd = em_pd_get(dev);
+	if (dfc->em_pd) {
 		devfreq_cooling_ops.get_requested_power =
 			devfreq_cooling_get_requested_power;
 		devfreq_cooling_ops.state2power = devfreq_cooling_state2power;
@@ -382,7 +381,7 @@ of_devfreq_cooling_register_power(struct device_node *np, struct devfreq *df,
 
 		dfc->power_ops = dfc_power;
 
-		num_opps = em_pd_nr_perf_states(dev->em_pd);
+		num_opps = em_pd_nr_perf_states(dfc->em_pd);
 	} else {
 		/* Backward compatibility for drivers which do not use IPA */
 		dev_dbg(dev, "missing EM for cooling device\n");