Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba2b137d authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull thermal management update from Zhang Rui:

 - Fix race condition in imx_thermal_probe() (Mikhail Lappo)

 - Add cooling device's statistics in sysfs (Viresh Kumar)

* 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux:
  thermal: Add cooling device's statistics in sysfs
  thermal: imx: Fix race condition in imx_thermal_probe()
parents 71893f11 b907b408
Loading
Loading
Loading
Loading
+31 −0
Original line number Diff line number Diff line
@@ -255,6 +255,7 @@ temperature) and throttle appropriate devices.
2. sysfs attributes structure

RO	read only value
WO	write only value
RW	read/write value

Thermal sysfs attributes will be represented under /sys/class/thermal.
@@ -286,6 +287,11 @@ Thermal cooling device sys I/F, created once it's registered:
    |---type:			Type of the cooling device(processor/fan/...)
    |---max_state:		Maximum cooling state of the cooling device
    |---cur_state:		Current cooling state of the cooling device
    |---stats:			Directory containing cooling device's statistics
    |---stats/reset:		Writing any value resets the statistics
    |---stats/time_in_state_ms:	Time (msec) spent in various cooling states
    |---stats/total_trans:	Total number of times cooling state is changed
    |---stats/trans_table:	Cooing state transition table


Then next two dynamic attributes are created/removed in pairs. They represent
@@ -490,6 +496,31 @@ cur_state
	- cur_state == max_state means the maximum cooling.
	RW, Required

stats/reset
	Writing any value resets the cooling device's statistics.
	WO, Required

stats/time_in_state_ms:
	The amount of time spent by the cooling device in various cooling
	states. The output will have "<state> <time>" pair in each line, which
	will mean this cooling device spent <time> msec of time at <state>.
	Output will have one line for each of the supported states.  usertime
	units here is 10mS (similar to other time exported in /proc).
	RO, Required

stats/total_trans:
	A single positive value showing the total number of times the state of a
	cooling device is changed.
	RO, Required

stats/trans_table:
	This gives fine grained information about all the cooling state
	transitions. The cat output here is a two dimensional matrix, where an
	entry <i,j> (row i, column j) represents the number of transitions from
	State_i to State_j. If the transition table is bigger than PAGE_SIZE,
	reading this will return an -EFBIG error.
	RO, Required

3. A simple implementation

ACPI thermal zone may support multiple trip points like critical, hot,
+7 −0
Original line number Diff line number Diff line
@@ -15,6 +15,13 @@ menuconfig THERMAL

if THERMAL

config THERMAL_STATISTICS
	bool "Thermal state transition statistics"
	help
	  Export thermal state transition statistics information through sysfs.

	  If in doubt, say N.

config THERMAL_EMERGENCY_POWEROFF_DELAY_MS
	int "Emergency poweroff delay in milli-seconds"
	depends on THERMAL
+3 −3
Original line number Diff line number Diff line
@@ -637,6 +637,9 @@ static int imx_thermal_probe(struct platform_device *pdev)
	regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
	regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);

	data->irq_enabled = true;
	data->mode = THERMAL_DEVICE_ENABLED;

	ret = devm_request_threaded_irq(&pdev->dev, data->irq,
			imx_thermal_alarm_irq, imx_thermal_alarm_irq_thread,
			0, "imx_thermal", data);
@@ -649,9 +652,6 @@ static int imx_thermal_probe(struct platform_device *pdev)
		return ret;
	}

	data->irq_enabled = true;
	data->mode = THERMAL_DEVICE_ENABLED;

	return 0;
}

+2 −1
Original line number Diff line number Diff line
@@ -972,8 +972,8 @@ __thermal_cooling_device_register(struct device_node *np,
	cdev->ops = ops;
	cdev->updated = false;
	cdev->device.class = &thermal_class;
	thermal_cooling_device_setup_sysfs(cdev);
	cdev->devdata = devdata;
	thermal_cooling_device_setup_sysfs(cdev);
	dev_set_name(&cdev->device, "cooling_device%d", cdev->id);
	result = device_register(&cdev->device);
	if (result) {
@@ -1106,6 +1106,7 @@ void thermal_cooling_device_unregister(struct thermal_cooling_device *cdev)

	ida_simple_remove(&thermal_cdev_ida, cdev->id);
	device_unregister(&cdev->device);
	thermal_cooling_device_destroy_sysfs(cdev);
}
EXPORT_SYMBOL_GPL(thermal_cooling_device_unregister);

+10 −0
Original line number Diff line number Diff line
@@ -73,6 +73,7 @@ int thermal_build_list_of_policies(char *buf);
int thermal_zone_create_device_groups(struct thermal_zone_device *, int);
void thermal_zone_destroy_device_groups(struct thermal_zone_device *);
void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *);
void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev);
/* used only at binding time */
ssize_t
thermal_cooling_device_trip_point_show(struct device *,
@@ -84,6 +85,15 @@ ssize_t thermal_cooling_device_weight_store(struct device *,
					    struct device_attribute *,
					    const char *, size_t);

#ifdef CONFIG_THERMAL_STATISTICS
void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
					 unsigned long new_state);
#else
static inline void
thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
				    unsigned long new_state) {}
#endif /* CONFIG_THERMAL_STATISTICS */

#ifdef CONFIG_THERMAL_GOV_STEP_WISE
int thermal_gov_step_wise_register(void);
void thermal_gov_step_wise_unregister(void);
Loading