From patchwork Mon Jan 7 14:40:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 49481 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 37A461B442; Mon, 7 Jan 2019 15:40:57 +0100 (CET) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id A931D1B3E8 for ; Mon, 7 Jan 2019 15:40:55 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jan 2019 06:40:54 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,451,1539673200"; d="scan'208";a="309651914" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by fmsmga005.fm.intel.com with ESMTP; 07 Jan 2019 06:40:53 -0800 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, liang.j.ma@intel.com Date: Mon, 7 Jan 2019 14:40:51 +0000 Message-Id: <20190107144051.7097-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] test/power: fix unit test to handle pstate mode X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Signed-off-by: David Hunt --- test/test/test_power_acpi_cpufreq.c | 38 +++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/test/test/test_power_acpi_cpufreq.c b/test/test/test_power_acpi_cpufreq.c index 6d637cc77..61b1da05a 100644 --- a/test/test/test_power_acpi_cpufreq.c +++ b/test/test/test_power_acpi_cpufreq.c @@ -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;