The locre ID in cpufreq power must be enabled core in application.
Use rte_lcore_is_enabled to verify it.

Fixes: 6f987b594fa6 ("power: refactor core power management")
Cc: [email protected]

Signed-off-by: Huisong Li <[email protected]>
---
 .../power/intel_pstate/intel_pstate_cpufreq.c | 56 +++++++++----------
 1 file changed, 28 insertions(+), 28 deletions(-)

diff --git a/drivers/power/intel_pstate/intel_pstate_cpufreq.c 
b/drivers/power/intel_pstate/intel_pstate_cpufreq.c
index 8e27570e3c..fe19802c25 100644
--- a/drivers/power/intel_pstate/intel_pstate_cpufreq.c
+++ b/drivers/power/intel_pstate/intel_pstate_cpufreq.c
@@ -548,9 +548,8 @@ power_pstate_cpufreq_init(unsigned int lcore_id)
                return -1;
        }
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Lcore id %u can not exceed %u",
-                               lcore_id, RTE_MAX_LCORE - 1U);
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -630,11 +629,11 @@ power_pstate_cpufreq_exit(unsigned int lcore_id)
        struct pstate_power_info *pi;
        uint32_t exp_state;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Lcore id %u can not exceeds %u",
-                               lcore_id, RTE_MAX_LCORE - 1U);
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
+
        pi = &lcore_power_info[lcore_id];
 
        exp_state = POWER_USED;
@@ -688,8 +687,8 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t 
*freqs, uint32_t num)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return 0;
        }
 
@@ -711,8 +710,8 @@ power_pstate_cpufreq_freqs(unsigned int lcore_id, uint32_t 
*freqs, uint32_t num)
 uint32_t
 power_pstate_cpufreq_get_freq(unsigned int lcore_id)
 {
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return RTE_POWER_INVALID_FREQ_INDEX;
        }
 
@@ -723,8 +722,8 @@ power_pstate_cpufreq_get_freq(unsigned int lcore_id)
 int
 power_pstate_cpufreq_set_freq(unsigned int lcore_id, uint32_t index)
 {
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -736,8 +735,8 @@ power_pstate_cpufreq_freq_up(unsigned int lcore_id)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -755,8 +754,8 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -771,8 +770,8 @@ power_pstate_cpufreq_freq_down(unsigned int lcore_id)
 int
 power_pstate_cpufreq_freq_max(unsigned int lcore_id)
 {
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -796,8 +795,8 @@ power_pstate_cpufreq_freq_min(unsigned int lcore_id)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -813,8 +812,8 @@ power_pstate_turbo_status(unsigned int lcore_id)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -828,8 +827,8 @@ power_pstate_enable_turbo(unsigned int lcore_id)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -854,8 +853,8 @@ power_pstate_disable_turbo(unsigned int lcore_id)
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
 
@@ -882,10 +881,11 @@ int power_pstate_get_capabilities(unsigned int lcore_id,
 {
        struct pstate_power_info *pi;
 
-       if (lcore_id >= RTE_MAX_LCORE) {
-               POWER_LOG(ERR, "Invalid lcore ID");
+       if (!rte_lcore_is_enabled(lcore_id)) {
+               POWER_LOG(ERR, "lcore id %u is not enabled", lcore_id);
                return -1;
        }
+
        if (caps == NULL) {
                POWER_LOG(ERR, "Invalid argument");
                return -1;
-- 
2.33.0

Reply via email to