X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;ds=sidebyside;f=lib%2Flibrte_power%2Fpower_acpi_cpufreq.c;h=f443fce69f5d9eb0f90e3fef36425a34205c211f;hb=78542ed2c7bf68ecc6ee294b1883fe08b6b852a3;hp=45412f0b998ccb54fe22ced250fffb526751d5e2;hpb=2e6ccdb4e0887e881de97fe51a038cacca1aedad;p=dpdk.git diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index 45412f0b99..f443fce69f 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -12,8 +12,10 @@ #include #include -#include #include +#include +#include +#include #include "power_acpi_cpufreq.h" #include "power_common.h" @@ -28,7 +30,7 @@ #define FOPEN_OR_ERR_RET(f, retval) do { \ if ((f) == NULL) { \ - RTE_LOG(ERR, POWER, "File not openned\n"); \ + RTE_LOG(ERR, POWER, "File not opened\n"); \ return retval; \ } \ } while (0) @@ -107,7 +109,7 @@ set_freq_internal(struct rte_power_info *pi, uint32_t idx) if (idx == pi->curr_idx) return 0; - POWER_DEBUG_TRACE("Freqency[%u] %u to be set for lcore %u\n", + POWER_DEBUG_TRACE("Frequency[%u] %u to be set for lcore %u\n", idx, pi->freqs[idx], pi->lcore_id); if (fseek(pi->f, 0, SEEK_SET) < 0) { RTE_LOG(ERR, POWER, "Fail to set file position indicator to 0 " @@ -147,6 +149,8 @@ power_set_governor_userspace(struct rte_power_info *pi) s = fgets(buf, sizeof(buf), f); FOPS_OR_NULL_GOTO(s, out); + /* Strip off terminating '\n' */ + strtok(buf, "\n"); /* Check if current governor is userspace */ if (strncmp(buf, POWER_GOVERNOR_USERSPACE, @@ -157,7 +161,7 @@ power_set_governor_userspace(struct rte_power_info *pi) goto out; } /* Save the original governor */ - snprintf(pi->governor_ori, sizeof(pi->governor_ori), "%s", buf); + strlcpy(pi->governor_ori, buf, sizeof(pi->governor_ori)); /* Write 'userspace' to the governor */ val = fseek(f, 0, SEEK_SET); @@ -440,8 +444,8 @@ power_acpi_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) { struct rte_power_info *pi; - if (lcore_id >= RTE_MAX_LCORE || !freqs) { - RTE_LOG(ERR, POWER, "Invalid input parameter\n"); + if (lcore_id >= RTE_MAX_LCORE) { + RTE_LOG(ERR, POWER, "Invalid lcore ID\n"); return 0; } @@ -511,7 +515,8 @@ power_acpi_cpufreq_freq_up(unsigned int lcore_id) } pi = &lcore_power_info[lcore_id]; - if (pi->curr_idx == 0) + if (pi->curr_idx == 0 || + (pi->curr_idx == 1 && pi->turbo_available && !pi->turbo_enable)) return 0; /* Frequencies in the array are from high to low. */