From patchwork Tue Jan 8 14:59:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hunt, David" X-Patchwork-Id: 49495 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 02F2A1B39D; Tue, 8 Jan 2019 15:59:38 +0100 (CET) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id BA0D61B395 for ; Tue, 8 Jan 2019 15:59:36 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Jan 2019 06:59:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,454,1539673200"; d="scan'208";a="116449518" Received: from silpixa00399952.ir.intel.com (HELO silpixa00399952.ger.corp.intel.com) ([10.237.223.64]) by orsmga003.jf.intel.com with ESMTP; 08 Jan 2019 06:59:34 -0800 From: David Hunt To: dev@dpdk.org Cc: david.hunt@intel.com, liang.j.ma@intel.com Date: Tue, 8 Jan 2019 14:59:26 +0000 Message-Id: <20190108145926.37367-1-david.hunt@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] lib/power: fix error handling on setting governor 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" In the power_set_governor_*() functions, we using fputs() on /sys filesystem. However, we also need to call fflush() to ensure that the write completes successfully. Otherwise the attempt to set the power governor fails and the function returns as if it has succeeded. This patch adds an fflush to ensure that the write succeeds, otherwise returns an error. Fixes: e6c6dc0f96c8 ("power: add p-state driver compatibility") Signed-off-by: David Hunt --- lib/librte_power/power_acpi_cpufreq.c | 4 ++++ lib/librte_power/power_pstate_cpufreq.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/lib/librte_power/power_acpi_cpufreq.c b/lib/librte_power/power_acpi_cpufreq.c index 98dcde31d..45412f0b9 100644 --- a/lib/librte_power/power_acpi_cpufreq.c +++ b/lib/librte_power/power_acpi_cpufreq.c @@ -166,6 +166,10 @@ power_set_governor_userspace(struct rte_power_info *pi) val = fputs(POWER_GOVERNOR_USERSPACE, f); FOPS_OR_ERR_GOTO(val, out); + /* We need to flush to see if the fputs succeeds */ + val = fflush(f); + FOPS_OR_ERR_GOTO(val, out); + ret = 0; RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been " "set to user space successfully\n", pi->lcore_id); diff --git a/lib/librte_power/power_pstate_cpufreq.c b/lib/librte_power/power_pstate_cpufreq.c index 9ec5da511..c4d972fc0 100644 --- a/lib/librte_power/power_pstate_cpufreq.c +++ b/lib/librte_power/power_pstate_cpufreq.c @@ -308,6 +308,10 @@ power_set_governor_performance(struct pstate_power_info *pi) val = fputs(POWER_GOVERNOR_PERF, f); FOPS_OR_ERR_GOTO(val, out); + /* We need to flush to see if the fputs succeeds */ + val = fflush(f); + FOPS_OR_ERR_GOTO(val, out); + ret = 0; RTE_LOG(INFO, POWER, "Power management governor of lcore %u has been " "set to performance successfully\n", pi->lcore_id);