| 418 | } |
| 419 | |
| 420 | int |
| 421 | power_cppc_cpufreq_exit(unsigned int lcore_id) |
| 422 | { |
| 423 | struct cppc_power_info *pi; |
| 424 | uint32_t exp_state; |
| 425 | |
| 426 | if (lcore_id >= RTE_MAX_LCORE) { |
| 427 | RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n", |
| 428 | lcore_id, RTE_MAX_LCORE - 1U); |
| 429 | return -1; |
| 430 | } |
| 431 | pi = &lcore_power_info[lcore_id]; |
| 432 | exp_state = POWER_USED; |
| 433 | /* The power in use state works as a guard variable between |
| 434 | * the CPU frequency control initialization and exit process. |
| 435 | * The ACQUIRE memory ordering here pairs with the RELEASE |
| 436 | * ordering below as lock to make sure the frequency operations |
| 437 | * in the critical section are done under the correct state. |
| 438 | */ |
| 439 | if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state, |
| 440 | POWER_ONGOING, |
| 441 | rte_memory_order_acquire, rte_memory_order_relaxed)) { |
| 442 | RTE_LOG(INFO, POWER, "Power management of lcore %u is " |
| 443 | "not used\n", lcore_id); |
| 444 | return -1; |
| 445 | } |
| 446 | |
| 447 | /* Close FD of setting freq */ |
| 448 | fclose(pi->f); |
| 449 | pi->f = NULL; |
| 450 | |
| 451 | /* Set the governor back to the original */ |
| 452 | if (power_set_governor_original(pi) < 0) { |
| 453 | RTE_LOG(ERR, POWER, "Cannot set the governor of %u back " |
| 454 | "to the original\n", lcore_id); |
| 455 | goto fail; |
| 456 | } |
| 457 | |
| 458 | RTE_LOG(INFO, POWER, "Power management of lcore %u has exited from " |
| 459 | "'userspace' mode and been set back to the " |
| 460 | "original\n", lcore_id); |
| 461 | rte_atomic_store_explicit(&(pi->state), POWER_IDLE, rte_memory_order_release); |
| 462 | |
| 463 | return 0; |
| 464 | |
| 465 | fail: |
| 466 | rte_atomic_store_explicit(&(pi->state), POWER_UNKNOWN, rte_memory_order_release); |
| 467 | |
| 468 | return -1; |
| 469 | } |
| 470 | |
| 471 | uint32_t |
| 472 | power_cppc_cpufreq_freqs(unsigned int lcore_id, uint32_t *freqs, uint32_t num) |
no test coverage detected