mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 13:55:32 +00:00
![Daniel Lezcano](/assets/img/avatar_default.png)
On the embedded world, the complexity of the SoC leads to an increasing number of hotspots which need to be monitored and mitigated as a whole in order to prevent the temperature to go above the normative and legally stated 'skin temperature'. Another aspect is to sustain the performance for a given power budget, for example virtual reality where the user can feel dizziness if the GPU performance is capped while a big CPU is processing something else. Or reduce the battery charging because the dissipated power is too high compared with the power consumed by other devices. The userspace is the most adequate place to dynamically act on the different devices by limiting their power given an application profile: it has the knowledge of the platform. These userspace daemons are in charge of the Dynamic Thermal Power Management (DTPM). Nowadays, the dtpm daemons are abusing the thermal framework as they act on the cooling device state to force a specific and arbitrary state without taking care of the governor decisions. Given the closed loop of some governors that can confuse the logic or directly enter in a decision conflict. As the number of cooling device support is limited today to the CPU and the GPU, the dtpm daemons have little control on the power dissipation of the system. The out of tree solutions are hacking around here and there in the drivers, in the frameworks to have control on the devices. The common solution is to declare them as cooling devices. There is no unification of the power limitation unit, opaque states are used. This patch provides a way to create a hierarchy of constraints using the powercap framework. The devices which are registered as power limit-able devices are represented in this hierarchy as a tree. They are linked together with intermediate nodes which are just there to propagate the constraint to the children. The leaves of the tree are the real devices, the intermediate nodes are virtual, aggregating the children constraints and power characteristics. Each node have a weight on a 2^10 basis, in order to reflect the percentage of power distribution of the children's node. This percentage is used to dispatch the power limit to the children. The weight is computed against the max power of the siblings. This simple approach allows to do a fair distribution of the power limit. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Tested-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
75 lines
1.6 KiB
C
75 lines
1.6 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (C) 2020 Linaro Ltd
|
|
*
|
|
* Author: Daniel Lezcano <daniel.lezcano@linaro.org>
|
|
*/
|
|
#ifndef ___DTPM_H__
|
|
#define ___DTPM_H__
|
|
|
|
#include <linux/powercap.h>
|
|
|
|
#define MAX_DTPM_DESCR 8
|
|
#define MAX_DTPM_CONSTRAINTS 1
|
|
|
|
struct dtpm {
|
|
struct powercap_zone zone;
|
|
struct dtpm *parent;
|
|
struct list_head sibling;
|
|
struct list_head children;
|
|
struct dtpm_ops *ops;
|
|
unsigned long flags;
|
|
u64 power_limit;
|
|
u64 power_max;
|
|
u64 power_min;
|
|
int weight;
|
|
void *private;
|
|
};
|
|
|
|
struct dtpm_ops {
|
|
u64 (*set_power_uw)(struct dtpm *, u64);
|
|
u64 (*get_power_uw)(struct dtpm *);
|
|
void (*release)(struct dtpm *);
|
|
};
|
|
|
|
struct dtpm_descr;
|
|
|
|
typedef int (*dtpm_init_t)(struct dtpm_descr *);
|
|
|
|
struct dtpm_descr {
|
|
struct dtpm *parent;
|
|
const char *name;
|
|
dtpm_init_t init;
|
|
};
|
|
|
|
/* Init section thermal table */
|
|
extern struct dtpm_descr *__dtpm_table[];
|
|
extern struct dtpm_descr *__dtpm_table_end[];
|
|
|
|
#define DTPM_TABLE_ENTRY(name) \
|
|
static typeof(name) *__dtpm_table_entry_##name \
|
|
__used __section("__dtpm_table") = &name
|
|
|
|
#define DTPM_DECLARE(name) DTPM_TABLE_ENTRY(name)
|
|
|
|
#define for_each_dtpm_table(__dtpm) \
|
|
for (__dtpm = __dtpm_table; \
|
|
__dtpm < __dtpm_table_end; \
|
|
__dtpm++)
|
|
|
|
static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
|
|
{
|
|
return container_of(zone, struct dtpm, zone);
|
|
}
|
|
|
|
int dtpm_update_power(struct dtpm *dtpm, u64 power_min, u64 power_max);
|
|
|
|
int dtpm_release_zone(struct powercap_zone *pcz);
|
|
|
|
struct dtpm *dtpm_alloc(struct dtpm_ops *ops);
|
|
|
|
void dtpm_unregister(struct dtpm *dtpm);
|
|
|
|
int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
|
|
|
|
#endif
|