/* * acpi_cpufreq_early_init - initialize ACPI P-States library * * Initialize the ACPI P-States library (drivers/acpi/processor_perflib.c) * in order to determine correct frequency and voltage pairings. We can * do _PDC and _PSD and find out the processor dependency for the * actual init that will happen later... */ static int __init acpi_cpufreq_early_init(void) { unsigned int i; pr_debug("acpi_cpufreq_early_init\n"); acpi_perf_data = alloc_percpu(struct acpi_processor_performance); if (!acpi_perf_data) { pr_debug("Memory allocation error for acpi_perf_data.\n"); return -ENOMEM; } for_each_possible_cpu(i) { if (!zalloc_cpumask_var_node( &per_cpu_ptr(acpi_perf_data, i)->shared_cpu_map, GFP_KERNEL, cpu_to_node(i))) { /* Freeing a NULL pointer is OK: alloc_percpu zeroes. */ free_acpi_perf_data(); return -ENOMEM; } } /* Do initialization in ACPI core */ acpi_processor_preregister_performance(acpi_perf_data); return 0; }
static void __exit acpi_cpufreq_exit(void) { pr_debug("acpi_cpufreq_exit\n"); acpi_cpufreq_boost_exit(); cpufreq_unregister_driver(&acpi_cpufreq_driver); free_acpi_perf_data(); }
static int __init acpi_cpufreq_init(void) { int ret; if (acpi_disabled) return -ENODEV; /* don't keep reloading if cpufreq_driver exists */ if (cpufreq_get_current_driver()) return -EEXIST; pr_debug("acpi_cpufreq_init\n"); ret = acpi_cpufreq_early_init(); if (ret) return ret; #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB /* this is a sysfs file with a strange name and an even stranger * semantic - per CPU instantiation, but system global effect. * Lets enable it only on AMD CPUs for compatibility reasons and * only if configured. This is considered legacy code, which * will probably be removed at some point in the future. */ if (!check_amd_hwpstate_cpu(0)) { struct freq_attr **attr; pr_debug("CPB unsupported, do not expose it\n"); for (attr = acpi_cpufreq_attr; *attr; attr++) if (*attr == &cpb) { *attr = NULL; break; } } #endif acpi_cpufreq_boost_init(); ret = cpufreq_register_driver(&acpi_cpufreq_driver); if (ret) { free_acpi_perf_data(); acpi_cpufreq_boost_exit(); } return ret; }
static int __init acpi_cpufreq_init(void) { int ret; if (acpi_disabled) return -ENODEV; /* don't keep reloading if cpufreq_driver exists */ if (cpufreq_get_current_driver()) return -EEXIST; pr_debug("acpi_cpufreq_init\n"); ret = acpi_cpufreq_early_init(); if (ret) return ret; #ifdef CONFIG_X86_ACPI_CPUFREQ_CPB /* this is a sysfs file with a strange name and an even stranger * semantic - per CPU instantiation, but system global effect. * Lets enable it only on AMD CPUs for compatibility reasons and * only if configured. This is considered legacy code, which * will probably be removed at some point in the future. */ if (check_amd_hwpstate_cpu(0)) { struct freq_attr **iter; pr_debug("adding sysfs entry for cpb\n"); for (iter = acpi_cpufreq_attr; *iter != NULL; iter++) ; /* make sure there is a terminator behind it */ if (iter[1] == NULL) *iter = &cpb; } #endif acpi_cpufreq_boost_init(); ret = cpufreq_register_driver(&acpi_cpufreq_driver); if (ret) free_acpi_perf_data(); return ret; }