-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stm32mp1 cpu opp #7219
base: master
Are you sure you want to change the base?
Stm32mp1 cpu opp #7219
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello Pascal, here is a round of comments for this series.
Could you remove the Change-Id
tags from the commit messages.
* @channel_id: SCMI channel ID | ||
* @domain_id: SCMI performance domain ID | ||
* @level: Target performance level | ||
* @latency: Output latency value (microsecond) for the target level |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
* @channel_id: SCMI channel ID | ||
* @domain_id: SCMI performance domain ID | ||
* @start_index: Level index to start from. | ||
* @elt: If NULL, function returns, else output level array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @elt: Array where to store levels or NULL if querying only @nb_elts
* @nb_elts: [in] @elt array size, [out] number of levels
*
* When @elt is NULL, @nb_elt output value gives full number of levels
* remaining starting from @start_index. When @elt is not NULL,
* @nb_elt output value gives the number of levels stored in @elt.
Nitpicking: can return remove the terminal dot at lines 453 and 455 (and at line 441).
int32_t __weak plat_scmi_perf_level_power_cost(unsigned int channel_id __unused, | ||
unsigned int domain_id __unused, | ||
unsigned int level __unused, | ||
unsigned int *cost __unused) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
core/arch/arm/plat-stm32mp1/main.c
Outdated
return false; | ||
|
||
if (get_part_number(&part_number)) { | ||
DMSG("Cannot get part number\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can drop trailing \n
.
Ditto at line 742.
core/drivers/stm32_cpu_opp.c
Outdated
* @opp_count: Number of cells of @dvfs | ||
* @clock: CPU clock handle | ||
* @regul: CPU regulator supply handle | ||
* @dvfs: Arrays of the supported CPU operating points |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Arrays/Array/
904abd3
to
ada6a12
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes in commit "plat-stm32mp1: SCMI performance domain for CPU DVFS" related to stm32_cpu_opp.c
and stm32_cpu_opp.h
(pm + sustained level) should be squashed in commit "drivers: add stm32 CPU DVFS driver".
core/drivers/stm32_cpu_opp.c
Outdated
|
||
/* nothing to do if OPP is managed by Linux and not by SCMI */ | ||
if (!IS_ENABLED(CFG_SCMI_MSG_PERF_DOMAIN)) | ||
return TEE_SUCCESS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer no call register_pm_driver_cb()
if build config tells the PM sequences are not needed.
ada6a12
to
1b6525b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for commit "drivers: add stm32 CPU DVFS driver".
In the commit message: s/cpu_opp.c/stm32_cpu_opp.c/ + s/ah higher/a higher/
#include <drivers/clk_dt.h> | ||
#include <drivers/regulator.h> | ||
#include <drivers/stm32_cpu_opp.h> | ||
#ifdef CFG_STM32MP13 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could remove this #ifdef / #endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is for compatibility issue with MP2
core/drivers/stm32_cpu_opp.c
Outdated
#include <trace.h> | ||
|
||
/* | ||
* struct cpu_dvfs - CPU DVFS registered operating points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/points/point/
core/drivers/stm32_cpu_opp.c
Outdated
* @opp_count: Number of cells of @dvfs | ||
* @clock: CPU clock handle | ||
* @regul: CPU regulator supply handle | ||
* @dvfs: Arrays of the supported CPU operating points |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Arrays/Array/
TEE_Result res = TEE_ERROR_GENERIC; | ||
unsigned int opp = 0; | ||
|
||
DMSG("Set OPP to %ukHz", level); |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
|
||
TEE_Result stm32_cpu_opp_read_level(unsigned int *level) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For consistency, here also we should check the OPPs are defined:
if (!cpu_opp.opp_count) {
EMSG("No CPU OPP defined");
return TEE_ERROR_GENERIC;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad: I may have been confusing. Testing whether OPP support was initialized or not, we should test a unique pattern. This function check cpu_opp.opp_count != 0
whereas stm32_cpu_opp_set_level()
checks cpu_opp.dvfs != NULL
. On the ohter hand, stm32_cpu_opp_get_dt_subnode()
only resets cpu_opp.opp_count
, not cpu_opp_dvfs
upon failure. Could you make all these more consistent?
|
||
return TEE_SUCCESS; | ||
|
||
err: |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
core/drivers/stm32_cpu_opp.c
Outdated
return TEE_SUCCESS; | ||
} | ||
|
||
driver_init(stm32_cpu_initcall); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use early_init()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
for commit:
- "dts: stm32: describe CPU OPP for STM32MP13"
*"plat-stm32mp1: default enable CFG_STM32_CPU_OPP for STM32MP13" (s/OPP/OPPs/ in commit message) - "drivers: stm32_cpu_opp: skip OPP with unsupported voltage" (with a minor comment).
core/drivers/stm32_cpu_opp.c
Outdated
*/ | ||
static bool opp_voltage_is_supported(struct regulator *regul, uint32_t *volt_uv) | ||
{ | ||
const int target_volt_uv = *volt_uv; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think their should be a cast here to convert the unsigned value into a signed value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments for commits "plat-stm32mp1: retrieve chip id from syscfg"
and "plat-stm32mp1: chip and STM32MP15 platform identification":
- For consistency of these 2 commit messages, I propose to squash them into a single commit "plat-stm32mp1: chip identification and supported features".
- Replace "id" with "ID" in the former commit message (header line and body).
core/arch/arm/plat-stm32mp1/main.c
Outdated
|
||
bool stm32mp_supports_second_core(void) | ||
{ | ||
uint32_t __maybe_unused part_number = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove __maybe_unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
for commits
"dts: stm32: describe supported-hw on CPU OPP for STM32MP13" and
"drivers: stm32_cpu_opp: skip OPP unsupported by SOC".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For commit "plat-stm32mp1: SCMI performance domain for CPU DVFS":
could you move all changes on stm32_cpu_opp.c|.h from this commit back into 1st commit "drivers: add stm32 CPU DVFS driver" where, I think, they belong.
core/drivers/scmi-msg/perf_domain.c
Outdated
@@ -0,0 +1,402 @@ | |||
/* SPDX-License-Identifier: BSD-3-Clause */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address this comment.
drivers/cpu_opp.c implements dynamic voltage and frequency scaling for the CPU. It is used at boot time to set an higher operating point than the one used to boot. It will be used by the SCMI performance service. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
- Move PM callback from last patches - Check OPP is well initialized in several functions. - Register driver in early init. - Fix Comments. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Describe CPU operating points for STM32MP13 boards. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Enable CFG_STM32_CPU_OPP for STM32MP13 and increase CFG_STM32MP_OPP_COUNT to 3 OPP. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Remove operating points that could not be handled by the regulator supplying the CPU. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Cast unsigned int to int Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Chip ID is read from SYSCFG. Add the associated read function and new CHIP IDs. Use the chip id to dynamically detect the CRYPTO hardware support, the second CPU core, and CPU OPP. Signed-off-by: Lionel Debieve <lionel.debieve@st.com> Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Remove __maybe_unused Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
New platform function to get the chip identification using DBGMCU SoC register. Signed-off-by: Lionel Debieve <lionel.debieve@foss.st.com> Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Describe supported hardware for each OPP. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Use device ID to remove not supported OPP. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Implement some of the SCMI performance domain management messages in scmi-msg drivers to support basic DVFS scenario. Co-developed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
- Fix License issue. - Return Default latency value. - Fix indentation issue. - Improve comments Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Implement scmi-msg perf protocol platform handlers to drive CPU voltage/frequency scaling support. Co-developed-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
Enable CFG_SCMI_MSG_PERF_DOMAIN for STM32MP13 that is used to provide CPU OPP to linux. Signed-off-by: Pascal Paillet <p.paillet@foss.st.com>
1b6525b
to
1006f41
Compare
{ | ||
if (opp >= cpu_opp.opp_count) { | ||
EMSG("Bad OPP number"); | ||
return TEE_ERROR_BAD_PARAMETERS; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these lines (current function does not return a TEE_Result
value). The assertion below is enough.
DMSG("Set OPP to %ukHz", level); | ||
|
||
if (!cpu_opp.dvfs) | ||
return TEE_ERROR_GENERIC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either the assertion at line 226 or this test, we don't really need both.
I think we should prefer this test since stm32_cpu_opp_set_level()
is called straight from the SCMI client interface.
} | ||
|
||
TEE_Result stm32_cpu_opp_read_level(unsigned int *level) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad: I may have been confusing. Testing whether OPP support was initialized or not, we should test a unique pattern. This function check cpu_opp.opp_count != 0
whereas stm32_cpu_opp_set_level()
checks cpu_opp.dvfs != NULL
. On the ohter hand, stm32_cpu_opp_get_dt_subnode()
only resets cpu_opp.opp_count
, not cpu_opp_dvfs
upon failure. Could you make all these more consistent?
int subnode = 0; | ||
TEE_Result res = TEE_ERROR_GENERIC; | ||
|
||
cpu_opp.dvfs = calloc(CFG_STM32MP_OPP_COUNT, sizeof(*cpu_opp.dvfs)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we always allocate CFG_STM32MP_OPP_COUNT
cells, maybe worth to make the array size statically defined in the struct:
struct cpu_opp {
unsigned int current_opp;
unsigned int opp_count;
struct clk *clock;
struct regulator *regul;
- struct cpu_dvfs *dvfs;
+ struct cpu_dvfs dvfs[CFG_STM32MP_OPP_COUNT];
unsigned int sustained_freq_khz;
};
|
||
/* | ||
* Get power cost value related to target performance level. | ||
* A default (weak) implementation output latency of 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/latency/power cost/
|
||
/* | ||
* Get latency is microseconds for transition to target performance level. | ||
* A default (weak) implementation output cost value of 0. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/cost value of 0/latency of 1 microsecond/
The goal of this patch-set is to be able to use SCMI performance protocol to drive the CPU frequency of STM32MP1: