Applications need to set uncore environment first by calling the API
rte_power_set_uncore_env, please see the commit 3b3af56d3c9c ("power:
fix uncore configuration").

Now, rte_power_set_uncore_env() supports automatic detection of uncore
drivers, the automatic detection environment code can be deleted.

Signed-off-by: Huisong Li <[email protected]>
---
 lib/power/rte_power_uncore.c | 32 +++++++-------------------------
 1 file changed, 7 insertions(+), 25 deletions(-)

diff --git a/lib/power/rte_power_uncore.c b/lib/power/rte_power_uncore.c
index 64a8c2648d..8b61b073e0 100644
--- a/lib/power/rte_power_uncore.c
+++ b/lib/power/rte_power_uncore.c
@@ -140,32 +140,14 @@ RTE_EXPORT_SYMBOL(rte_power_uncore_init)
 int
 rte_power_uncore_init(unsigned int pkg, unsigned int die)
 {
-       int ret = -1;
-       struct rte_power_uncore_ops *ops;
-       uint8_t env;
+       if (global_uncore_env == RTE_UNCORE_PM_ENV_NOT_SET ||
+           global_uncore_env == RTE_UNCORE_PM_ENV_AUTO_DETECT ||
+           global_uncore_ops == NULL) {
+               POWER_LOG(ERR, "Please set uncore environment first.");
+               return -1;
+       }
 
-       if ((global_uncore_env != RTE_UNCORE_PM_ENV_NOT_SET) &&
-               (global_uncore_env != RTE_UNCORE_PM_ENV_AUTO_DETECT))
-               return global_uncore_ops->init(pkg, die);
-
-       /* Auto Detect Environment */
-       RTE_TAILQ_FOREACH(ops, &uncore_ops_list, next)
-               if (ops) {
-                       POWER_LOG(INFO,
-                               "Attempting to initialise %s power 
management...",
-                               ops->name);
-                       ret = ops->init(pkg, die);
-                       if (ret == 0) {
-                               for (env = 0; env < RTE_DIM(uncore_env_str); 
env++)
-                                       if (strncmp(ops->name, 
uncore_env_str[env],
-                                               RTE_POWER_UNCORE_DRIVER_NAMESZ) 
== 0) {
-                                               rte_power_set_uncore_env(env);
-                                               goto out;
-                                       }
-                       }
-               }
-out:
-       return ret;
+       return global_uncore_ops->init(pkg, die);
 }
 
 RTE_EXPORT_SYMBOL(rte_power_uncore_exit)
-- 
2.33.0

Reply via email to