test/power: handle p-state mode
authorDavid Hunt <david.hunt@intel.com>
Mon, 7 Jan 2019 14:40:51 +0000 (14:40 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 15 Jan 2019 01:40:41 +0000 (02:40 +0100)
The cpufreq test breakes when the system is using the intel_pstate
driver for frequency management. The power library has recentyly been
updated to allow use of the intel_pstate driver, this patch fixes the
cpufreq test so that it can now use either acpi or pstate modes.
The library will auto-detect, and set the environment appropriately.

Fixes: ed7c51a6a680 ("app/test: vm power management")
Cc: stable@dpdk.org
Signed-off-by: David Hunt <david.hunt@intel.com>
test/test/test_power_acpi_cpufreq.c

index 6d637cc..61b1da0 100644 (file)
@@ -372,18 +372,22 @@ test_power_acpi_cpufreq(void)
        int ret = -1;
        enum power_management_env env;
 
-       ret = rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
-       if (ret != 0) {
-               printf("Failed on setting environment to PM_ENV_ACPI_CPUFREQ, this "
-                               "may occur if environment is not configured correctly or "
-                               " operating in another valid Power management environment\n");
-               return -1;
+       /* Test initialisation of a valid lcore */
+       ret = rte_power_init(TEST_POWER_LCORE_ID);
+       if (ret < 0) {
+               printf("Cannot initialise power management for lcore %u, this "
+                               "may occur if environment is not configured "
+                               "correctly(APCI cpufreq) or operating in another valid "
+                               "Power management environment\n",
+                               TEST_POWER_LCORE_ID);
+               rte_power_unset_env();
+               return TEST_SKIPPED;
        }
 
        /* Test environment configuration */
        env = rte_power_get_env();
-       if (env != PM_ENV_ACPI_CPUFREQ) {
-               printf("Unexpectedly got an environment other than ACPI cpufreq\n");
+       if ((env != PM_ENV_ACPI_CPUFREQ) && (env != PM_ENV_PSTATE_CPUFREQ)) {
+               printf("Unexpectedly got an environment other than ACPI/PSTATE\n");
                goto fail_all;
        }
 
@@ -424,6 +428,14 @@ test_power_acpi_cpufreq(void)
                goto fail_all;
        }
 
+       ret = rte_power_exit(TEST_POWER_LCORE_ID);
+       if (ret < 0) {
+               printf("Cannot exit power management for lcore %u\n",
+                                               TEST_POWER_LCORE_ID);
+               rte_power_unset_env();
+               return -1;
+       }
+
        /* test of init power management for an invalid lcore */
        ret = rte_power_init(TEST_POWER_LCORE_INVALID);
        if (ret == 0) {
@@ -532,12 +544,6 @@ test_power_acpi_caps(void)
        struct rte_power_core_capabilities caps;
        int ret;
 
-       ret = rte_power_set_env(PM_ENV_ACPI_CPUFREQ);
-       if (ret) {
-               printf("Error setting ACPI environment\n");
-               return -1;
-       }
-
        ret = rte_power_init(TEST_POWER_LCORE_ID);
        if (ret < 0) {
                printf("Cannot initialise power management for lcore %u, this "
@@ -550,11 +556,11 @@ test_power_acpi_caps(void)
 
        ret = rte_power_get_capabilities(TEST_POWER_LCORE_ID, &caps);
        if (ret) {
-               printf("ACPI: Error getting capabilities\n");
+               printf("POWER: Error getting capabilities\n");
                return -1;
        }
 
-       printf("ACPI: Capabilities %"PRIx64"\n", caps.capabilities);
+       printf("POWER: Capabilities %"PRIx64"\n", caps.capabilities);
 
        rte_power_unset_env();
        return 0;