MCPcopy Create free account
hub / github.com/F-Stack/f-stack / power_cppc_cpufreq_init

Function power_cppc_cpufreq_init

dpdk/lib/power/power_cppc_cpufreq.c:337–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

335}
336
337int
338power_cppc_cpufreq_init(unsigned int lcore_id)
339{
340 struct cppc_power_info *pi;
341 uint32_t exp_state;
342
343 if (lcore_id >= RTE_MAX_LCORE) {
344 RTE_LOG(ERR, POWER, "Lcore id %u can not exceeds %u\n",
345 lcore_id, RTE_MAX_LCORE - 1U);
346 return -1;
347 }
348
349 pi = &lcore_power_info[lcore_id];
350 exp_state = POWER_IDLE;
351 /* The power in use state works as a guard variable between
352 * the CPU frequency control initialization and exit process.
353 * The ACQUIRE memory ordering here pairs with the RELEASE
354 * ordering below as lock to make sure the frequency operations
355 * in the critical section are done under the correct state.
356 */
357 if (!rte_atomic_compare_exchange_strong_explicit(&(pi->state), &exp_state,
358 POWER_ONGOING,
359 rte_memory_order_acquire, rte_memory_order_relaxed)) {
360 RTE_LOG(INFO, POWER, "Power management of lcore %u is "
361 "in use\n", lcore_id);
362 return -1;
363 }
364
365 if (power_get_lcore_mapped_cpu_id(lcore_id, &pi->lcore_id) < 0) {
366 RTE_LOG(ERR, POWER, "Cannot get CPU ID mapped for lcore %u\n", lcore_id);
367 return -1;
368 }
369
370 /* Check and set the governor */
371 if (power_set_governor_userspace(pi) < 0) {
372 RTE_LOG(ERR, POWER, "Cannot set governor of lcore %u to "
373 "userspace\n", lcore_id);
374 goto fail;
375 }
376
377 /* Get the available frequencies */
378 if (power_get_available_freqs(pi) < 0) {
379 RTE_LOG(ERR, POWER, "Cannot get available frequencies of "
380 "lcore %u\n", lcore_id);
381 goto fail;
382 }
383
384 /* Init for setting lcore frequency */
385 if (power_init_for_setting_freq(pi) < 0) {
386 RTE_LOG(ERR, POWER, "Cannot init for setting frequency for "
387 "lcore %u\n", lcore_id);
388 goto fail;
389 }
390
391 /* Set freq to max by default */
392 if (power_cppc_cpufreq_freq_max(lcore_id) < 0) {
393 RTE_LOG(ERR, POWER, "Cannot set frequency of lcore %u "
394 "to max\n", lcore_id);

Callers 1

rte_power_initFunction · 0.85

Tested by

no test coverage detected