[v3,2/2] power: detect supported driver
Checks
Commit Message
Check if the frequency scaling driver is supported before attempting
to initialize.
Signed-off-by: Wathsala Vithanage <wathsala.vithanage@arm.com>
Reviewed-by: Dhruv Tripathi <dhruv.tripathi@arm.com>
---
lib/power/power_acpi_cpufreq.c | 6 ++++++
lib/power/power_amd_pstate_cpufreq.c | 6 ++++++
lib/power/power_cppc_cpufreq.c | 6 ++++++
lib/power/power_pstate_cpufreq.c | 6 ++++++
4 files changed, 24 insertions(+)
@@ -236,6 +236,12 @@ power_acpi_cpufreq_init(unsigned int lcore_id)
struct acpi_power_info *pi;
uint32_t exp_state;
+ if (!power_acpi_cpufreq_check_supported()) {
+ POWER_LOG(ERR, "%s driver is not supported",
+ POWER_ACPI_DRIVER);
+ return -1;
+ }
+
if (lcore_id >= RTE_MAX_LCORE) {
POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
lcore_id, RTE_MAX_LCORE - 1U);
@@ -354,6 +354,12 @@ power_amd_pstate_cpufreq_init(unsigned int lcore_id)
struct amd_pstate_power_info *pi;
uint32_t exp_state;
+ if (!power_amd_pstate_cpufreq_check_supported()) {
+ POWER_LOG(ERR, "%s driver is not supported",
+ POWER_AMD_PSTATE_DRIVER);
+ return -1;
+ }
+
if (lcore_id >= RTE_MAX_LCORE) {
POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
lcore_id, RTE_MAX_LCORE - 1U);
@@ -340,6 +340,12 @@ power_cppc_cpufreq_init(unsigned int lcore_id)
struct cppc_power_info *pi;
uint32_t exp_state;
+ if (!power_cppc_cpufreq_check_supported()) {
+ POWER_LOG(ERR, "%s driver is not supported",
+ POWER_CPPC_DRIVER);
+ return -1;
+ }
+
if (lcore_id >= RTE_MAX_LCORE) {
POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
lcore_id, RTE_MAX_LCORE - 1U);
@@ -542,6 +542,12 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
struct pstate_power_info *pi;
uint32_t exp_state;
+ if (!power_pstate_cpufreq_check_supported()) {
+ POWER_LOG(ERR, "%s driver is not supported",
+ POWER_PSTATE_DRIVER);
+ return -1;
+ }
+
if (lcore_id >= RTE_MAX_LCORE) {
POWER_LOG(ERR, "Lcore id %u can not exceed %u",
lcore_id, RTE_MAX_LCORE - 1U);