[v3,2/2] power: detect supported driver

Message ID 20241010141737.1135905-2-wathsala.vithanage@arm.com (mailing list archive)
State Accepted
Delegated to: Thomas Monjalon
Headers
Series [v3,1/2] power: enable CPPC support in power library |

Checks

Context Check Description
ci/loongarch-compilation success Compilation OK
ci/checkpatch success coding style OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/github-robot: build success github build: passed
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-marvell-Functional success Functional Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing fail Testing issues
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Wathsala Wathawana Vithanage Oct. 10, 2024, 2:17 p.m. UTC
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(+)
  

Patch

diff --git a/lib/power/power_acpi_cpufreq.c b/lib/power/power_acpi_cpufreq.c
index 81996e1c13..abad53bef1 100644
--- a/lib/power/power_acpi_cpufreq.c
+++ b/lib/power/power_acpi_cpufreq.c
@@ -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);
diff --git a/lib/power/power_amd_pstate_cpufreq.c b/lib/power/power_amd_pstate_cpufreq.c
index 090a0d96cb..4809d45a22 100644
--- a/lib/power/power_amd_pstate_cpufreq.c
+++ b/lib/power/power_amd_pstate_cpufreq.c
@@ -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);
diff --git a/lib/power/power_cppc_cpufreq.c b/lib/power/power_cppc_cpufreq.c
index e68b39b424..e73f4520d0 100644
--- a/lib/power/power_cppc_cpufreq.c
+++ b/lib/power/power_cppc_cpufreq.c
@@ -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);
diff --git a/lib/power/power_pstate_cpufreq.c b/lib/power/power_pstate_cpufreq.c
index 2343121621..1c2a91a178 100644
--- a/lib/power/power_pstate_cpufreq.c
+++ b/lib/power/power_pstate_cpufreq.c
@@ -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);