DPDK patches and discussions
 help / color / mirror / Atom feed
From: Hajkowski <marcinx.hajkowski@intel.com>
To: david.hunt@intel.com
Cc: dev@dpdk.org, Marcin Hajkowski <marcinx.hajkowski@intel.com>
Subject: [dpdk-dev] [PATCH v2 2/4] power: return error in set env when power env already set
Date: Mon, 18 Mar 2019 12:56:45 +0100	[thread overview]
Message-ID: <20190318115647.14784-2-marcinx.hajkowski@intel.com> (raw)
Message-ID: <20190318115645.Z9l_CRmAJPooOIqiWqGLZx47QP2Dfd6WHfA-phJ3kYo@z> (raw)
In-Reply-To: <20190318115647.14784-1-marcinx.hajkowski@intel.com>

From: Marcin Hajkowski <marcinx.hajkowski@intel.com>

On attempt to set_env in already initialized state notify
user by returning error that operation cannot be performed.

Signed-off-by: Marcin Hajkowski <marcinx.hajkowski@intel.com>
---
 doc/guides/rel_notes/release_19_05.rst | 4 ++++
 lib/librte_power/rte_power.c           | 3 ++-
 lib/librte_power/rte_power.h           | 3 ++-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/doc/guides/rel_notes/release_19_05.rst b/doc/guides/rel_notes/release_19_05.rst
index 65371e4c8..0da26b937 100644
--- a/doc/guides/rel_notes/release_19_05.rst
+++ b/doc/guides/rel_notes/release_19_05.rst
@@ -120,9 +120,13 @@ API Changes
    Also, make sure to start the actual text at the margin.
    =========================================================
 
+
    * power: ``rte_power_set_env`` and ``rte_power_unset_env`` functions
      have been modified to be thread safe.
 
+   * power: Function ``rte_power_set_env`` modified to return -1 if environment
+     has been already set.
+
 ABI Changes
 -----------
 
diff --git a/lib/librte_power/rte_power.c b/lib/librte_power/rte_power.c
index 540d69be7..ed701087d 100644
--- a/lib/librte_power/rte_power.c
+++ b/lib/librte_power/rte_power.c
@@ -33,8 +33,9 @@ rte_power_set_env(enum power_management_env env)
 	rte_spinlock_lock(&global_env_cfg_lock);
 
 	if (global_default_env != PM_ENV_NOT_SET) {
+		RTE_LOG(ERR, POWER, "Power Management Environment already set.\n");
 		rte_spinlock_unlock(&global_env_cfg_lock);
-		return 0;
+		return -1;
 	}
 
 	int ret = 0;
diff --git a/lib/librte_power/rte_power.h b/lib/librte_power/rte_power.h
index 54b76b4ee..a3130e709 100644
--- a/lib/librte_power/rte_power.h
+++ b/lib/librte_power/rte_power.h
@@ -26,7 +26,8 @@ enum power_management_env {PM_ENV_NOT_SET, PM_ENV_ACPI_CPUFREQ, PM_ENV_KVM_VM,
 /**
  * Set the default power management implementation. If this is not called prior
  * to rte_power_init(), then auto-detect of the environment will take place.
- * It is thread safe.
+ * It is thread safe. New env can be set only in unitialized state
+ * (thus rte_power_unset_env must be called if different env was already set).
  *
  * @param env
  *  env. The environment in which to initialise Power Management for.
-- 
2.17.2


  parent reply	other threads:[~2019-03-18 11:57 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 11:56 [dpdk-dev] [PATCH v2 1/4] power: fix non thread-safe power env modification Hajkowski
2019-03-18 11:56 ` Hajkowski
2019-03-18 11:56 ` Hajkowski [this message]
2019-03-18 11:56   ` [dpdk-dev] [PATCH v2 2/4] power: return error in set env when power env already set Hajkowski
2019-03-19 10:57   ` Burakov, Anatoly
2019-03-19 10:57     ` Burakov, Anatoly
2019-03-18 11:56 ` [dpdk-dev] [PATCH v2 3/4] power: reset function pointers on unset env Hajkowski
2019-03-18 11:56   ` Hajkowski
2019-03-19 10:58   ` Burakov, Anatoly
2019-03-19 10:58     ` Burakov, Anatoly
2019-03-18 11:56 ` [dpdk-dev] [PATCH v2 4/4] power: add UTs for all power env types Hajkowski
2019-03-18 11:56   ` Hajkowski
2019-03-19 11:58   ` Burakov, Anatoly
2019-03-19 11:58     ` Burakov, Anatoly
2019-03-18 15:01 ` [dpdk-dev] [PATCH v2 1/4] power: fix non thread-safe power env modification Stephen Hemminger
2019-03-18 15:01   ` Stephen Hemminger
2019-03-19 10:57 ` Burakov, Anatoly
2019-03-19 10:57   ` Burakov, Anatoly
2019-03-29 14:14 ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon
2019-03-29 14:14   ` Thomas Monjalon
2019-03-29 15:09   ` Burakov, Anatoly
2019-03-29 15:09     ` Burakov, Anatoly
2020-10-25 18:22     ` Thomas Monjalon
2020-10-28 13:53       ` David Hunt
2020-10-28 14:16         ` Thomas Monjalon
2019-04-05 14:35 ` [dpdk-dev] [PATCH] " Hajkowski
2019-04-05 14:35   ` Hajkowski
2019-04-22 20:22   ` Thomas Monjalon
2019-04-22 20:22     ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190318115647.14784-2-marcinx.hajkowski@intel.com \
    --to=marcinx.hajkowski@intel.com \
    --cc=david.hunt@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).