2020-12-08 16:41:44 +00:00
|
|
|
/* 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;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dtpm_ops {
|
|
|
|
u64 (*set_power_uw)(struct dtpm *, u64);
|
|
|
|
u64 (*get_power_uw)(struct dtpm *);
|
powercap/drivers/dtpm: Encapsulate even more the code
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2126952
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for compliant platforms. This set cleans up
powercap and enables DTPM for edge systems to use in thermal and power
management; this is all in drivers/powercap. This set has been tested
via simple boot tests, and of course the CI loop. This may be difficult
to test on Arm due to DTPM being a very new feature. However, this is
exactly the same powercap framework used by intel_rapl, which should
continue to function properly regardless.
Conflicts:
include/linux/cpuhotplug.h
The enums are just in a very different order in this tree,
so context was way off, and in this case, the one enum being
added had already been added elsewhere in the file.
commit 4570ddda43387e5a130dd85e71a1947b0c11da77
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Fri Mar 12 14:04:07 2021 +0100
powercap/drivers/dtpm: Encapsulate even more the code
In order to increase the self-encapsulation of the dtpm generic code,
the following changes are adding a power update ops to the dtpm
ops. That allows the generic code to call directly the dtpm backend
function to update the power values.
The power update function does compute the power characteristics when
the function is invoked. In the case of the CPUs, the power
consumption depends on the number of online CPUs. The online CPUs mask
is not up to date at CPUHP_AP_ONLINE_DYN state in the tear down
callback. That is the reason why the online / offline are at separate
state. As there is already an existing state for DTPM, this one is
only moved to the DEAD state, so there is no addition of new state
with these changes. The dtpm node is not removed when the cpu is
unplugged.
That simplifies the code for the next changes and results in a more
self-encapsulated code.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://lore.kernel.org/r/20210312130411.29833-1-daniel.lezcano@linaro.org
(cherry picked from commit 4570ddda43387e5a130dd85e71a1947b0c11da77)
Signed-off-by: Al Stone <ahs3@redhat.com>
2022-09-16 16:47:47 +00:00
|
|
|
int (*update_power_uw)(struct dtpm *);
|
2020-12-08 16:41:44 +00:00
|
|
|
void (*release)(struct dtpm *);
|
|
|
|
};
|
|
|
|
|
powercap/drivers/dtpm: Add hierarchy creation
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2126952
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for compliant platforms. This set cleans up
powercap and enables DTPM for edge systems to use in thermal and power
management; this is all in drivers/powercap. This set has been tested
via simple boot tests, and of course the CI loop. This may be difficult
to test on Arm due to DTPM being a very new feature. However, this is
exactly the same powercap framework used by intel_rapl, which should
continue to function properly regardless.
commit 3759ec678e8944dc2ea70cab77a300408f78ae27
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Fri Jan 28 17:35:34 2022 +0100
powercap/drivers/dtpm: Add hierarchy creation
The DTPM framework is available but without a way to configure it.
This change provides a way to create a hierarchy of DTPM node where
the power consumption reflects the sum of the children's power
consumption.
It is up to the platform to specify an array of dtpm nodes where each
element has a pointer to its parent, except the top most one. The type
of the node gives the indication of which initialization callback to
call. At this time, we can create a virtual node, where its purpose is
to be a parent in the hierarchy, and a DT node where the name
describes its path.
In order to ensure a nice self-encapsulation, the DTPM subsys array
contains a couple of initialization functions, one to setup the DTPM
backend and one to initialize it up. With this approach, the DTPM
framework has a very few material to export.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20220128163537.212248-3-daniel.lezcano@linaro.org
(cherry picked from commit 3759ec678e8944dc2ea70cab77a300408f78ae27)
Signed-off-by: Al Stone <ahs3@redhat.com>
2022-09-16 16:47:51 +00:00
|
|
|
struct device_node;
|
|
|
|
|
2022-09-16 16:47:51 +00:00
|
|
|
struct dtpm_subsys_ops {
|
|
|
|
const char *name;
|
|
|
|
int (*init)(void);
|
2022-09-16 16:47:53 +00:00
|
|
|
void (*exit)(void);
|
powercap/drivers/dtpm: Add hierarchy creation
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2126952
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for compliant platforms. This set cleans up
powercap and enables DTPM for edge systems to use in thermal and power
management; this is all in drivers/powercap. This set has been tested
via simple boot tests, and of course the CI loop. This may be difficult
to test on Arm due to DTPM being a very new feature. However, this is
exactly the same powercap framework used by intel_rapl, which should
continue to function properly regardless.
commit 3759ec678e8944dc2ea70cab77a300408f78ae27
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Fri Jan 28 17:35:34 2022 +0100
powercap/drivers/dtpm: Add hierarchy creation
The DTPM framework is available but without a way to configure it.
This change provides a way to create a hierarchy of DTPM node where
the power consumption reflects the sum of the children's power
consumption.
It is up to the platform to specify an array of dtpm nodes where each
element has a pointer to its parent, except the top most one. The type
of the node gives the indication of which initialization callback to
call. At this time, we can create a virtual node, where its purpose is
to be a parent in the hierarchy, and a DT node where the name
describes its path.
In order to ensure a nice self-encapsulation, the DTPM subsys array
contains a couple of initialization functions, one to setup the DTPM
backend and one to initialize it up. With this approach, the DTPM
framework has a very few material to export.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20220128163537.212248-3-daniel.lezcano@linaro.org
(cherry picked from commit 3759ec678e8944dc2ea70cab77a300408f78ae27)
Signed-off-by: Al Stone <ahs3@redhat.com>
2022-09-16 16:47:51 +00:00
|
|
|
int (*setup)(struct dtpm *, struct device_node *);
|
|
|
|
};
|
|
|
|
|
|
|
|
enum DTPM_NODE_TYPE {
|
|
|
|
DTPM_NODE_VIRTUAL = 0,
|
|
|
|
DTPM_NODE_DT,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct dtpm_node {
|
|
|
|
enum DTPM_NODE_TYPE type;
|
|
|
|
const char *name;
|
|
|
|
struct dtpm_node *parent;
|
2020-12-08 16:41:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct dtpm *to_dtpm(struct powercap_zone *zone)
|
|
|
|
{
|
|
|
|
return container_of(zone, struct dtpm, zone);
|
|
|
|
}
|
|
|
|
|
powercap/drivers/dtpm: Encapsulate even more the code
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2126952
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for compliant platforms. This set cleans up
powercap and enables DTPM for edge systems to use in thermal and power
management; this is all in drivers/powercap. This set has been tested
via simple boot tests, and of course the CI loop. This may be difficult
to test on Arm due to DTPM being a very new feature. However, this is
exactly the same powercap framework used by intel_rapl, which should
continue to function properly regardless.
Conflicts:
include/linux/cpuhotplug.h
The enums are just in a very different order in this tree,
so context was way off, and in this case, the one enum being
added had already been added elsewhere in the file.
commit 4570ddda43387e5a130dd85e71a1947b0c11da77
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Fri Mar 12 14:04:07 2021 +0100
powercap/drivers/dtpm: Encapsulate even more the code
In order to increase the self-encapsulation of the dtpm generic code,
the following changes are adding a power update ops to the dtpm
ops. That allows the generic code to call directly the dtpm backend
function to update the power values.
The power update function does compute the power characteristics when
the function is invoked. In the case of the CPUs, the power
consumption depends on the number of online CPUs. The online CPUs mask
is not up to date at CPUHP_AP_ONLINE_DYN state in the tear down
callback. That is the reason why the online / offline are at separate
state. As there is already an existing state for DTPM, this one is
only moved to the DEAD state, so there is no addition of new state
with these changes. The dtpm node is not removed when the cpu is
unplugged.
That simplifies the code for the next changes and results in a more
self-encapsulated code.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://lore.kernel.org/r/20210312130411.29833-1-daniel.lezcano@linaro.org
(cherry picked from commit 4570ddda43387e5a130dd85e71a1947b0c11da77)
Signed-off-by: Al Stone <ahs3@redhat.com>
2022-09-16 16:47:47 +00:00
|
|
|
int dtpm_update_power(struct dtpm *dtpm);
|
2020-12-08 16:41:44 +00:00
|
|
|
|
|
|
|
int dtpm_release_zone(struct powercap_zone *pcz);
|
|
|
|
|
2022-09-16 16:47:48 +00:00
|
|
|
void dtpm_init(struct dtpm *dtpm, struct dtpm_ops *ops);
|
2020-12-08 16:41:44 +00:00
|
|
|
|
|
|
|
void dtpm_unregister(struct dtpm *dtpm);
|
|
|
|
|
|
|
|
int dtpm_register(const char *name, struct dtpm *dtpm, struct dtpm *parent);
|
|
|
|
|
powercap/drivers/dtpm: Add hierarchy creation
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2126952
Tested: This is one of a series of patch sets to enable Arm SystemReady IR
support in the kernel for compliant platforms. This set cleans up
powercap and enables DTPM for edge systems to use in thermal and power
management; this is all in drivers/powercap. This set has been tested
via simple boot tests, and of course the CI loop. This may be difficult
to test on Arm due to DTPM being a very new feature. However, this is
exactly the same powercap framework used by intel_rapl, which should
continue to function properly regardless.
commit 3759ec678e8944dc2ea70cab77a300408f78ae27
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Fri Jan 28 17:35:34 2022 +0100
powercap/drivers/dtpm: Add hierarchy creation
The DTPM framework is available but without a way to configure it.
This change provides a way to create a hierarchy of DTPM node where
the power consumption reflects the sum of the children's power
consumption.
It is up to the platform to specify an array of dtpm nodes where each
element has a pointer to its parent, except the top most one. The type
of the node gives the indication of which initialization callback to
call. At this time, we can create a virtual node, where its purpose is
to be a parent in the hierarchy, and a DT node where the name
describes its path.
In order to ensure a nice self-encapsulation, the DTPM subsys array
contains a couple of initialization functions, one to setup the DTPM
backend and one to initialize it up. With this approach, the DTPM
framework has a very few material to export.
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20220128163537.212248-3-daniel.lezcano@linaro.org
(cherry picked from commit 3759ec678e8944dc2ea70cab77a300408f78ae27)
Signed-off-by: Al Stone <ahs3@redhat.com>
2022-09-16 16:47:51 +00:00
|
|
|
int dtpm_create_hierarchy(struct of_device_id *dtpm_match_table);
|
2022-09-16 16:47:53 +00:00
|
|
|
|
|
|
|
void dtpm_destroy_hierarchy(void);
|
2020-12-08 16:41:44 +00:00
|
|
|
#endif
|