cregit-Linux how code gets into the kernel

Release 4.10 drivers/acpi/processor_driver.c

Directory: drivers/acpi
/*
 * processor_driver.c - ACPI Processor Driver
 *
 *  Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
 *  Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
 *  Copyright (C) 2004       Dominik Brodowski <linux@brodo.de>
 *  Copyright (C) 2004  Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
 *                      - Added processor hotplug support
 *  Copyright (C) 2013, Intel Corporation
 *                      Rafael J. Wysocki <rafael.j.wysocki@intel.com>
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or (at
 *  your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful, but
 *  WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  General Public License for more details.
 *
 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 */

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/cpufreq.h>
#include <linux/cpu.h>
#include <linux/cpuidle.h>
#include <linux/slab.h>
#include <linux/acpi.h>

#include <acpi/processor.h>

#include "internal.h"


#define ACPI_PROCESSOR_NOTIFY_PERFORMANCE 0x80

#define ACPI_PROCESSOR_NOTIFY_POWER	0x81

#define ACPI_PROCESSOR_NOTIFY_THROTTLING	0x82


#define _COMPONENT		ACPI_PROCESSOR_COMPONENT
ACPI_MODULE_NAME("processor_driver");

MODULE_AUTHOR("Paul Diefenbaugh");
MODULE_DESCRIPTION("ACPI Processor Driver");
MODULE_LICENSE("GPL");

static int acpi_processor_start(struct device *dev);
static int acpi_processor_stop(struct device *dev);


static const struct acpi_device_id processor_device_ids[] = {
	{ACPI_PROCESSOR_OBJECT_HID, 0},
	{ACPI_PROCESSOR_DEVICE_HID, 0},
	{"", 0},
};
MODULE_DEVICE_TABLE(acpi, processor_device_ids);


static struct device_driver acpi_processor_driver = {
	.name = "processor",
	.bus = &cpu_subsys,
	.acpi_match_table = processor_device_ids,
	.probe = acpi_processor_start,
	.remove = acpi_processor_stop,
};


static void acpi_processor_notify(acpi_handle handle, u32 event, void *data) { struct acpi_device *device = data; struct acpi_processor *pr; int saved; if (device->handle != handle) return; pr = acpi_driver_data(device); if (!pr) return; switch (event) { case ACPI_PROCESSOR_NOTIFY_PERFORMANCE: saved = pr->performance_platform_limit; acpi_processor_ppc_has_changed(pr, 1); if (saved == pr->performance_platform_limit) break; acpi_bus_generate_netlink_event(device->pnp.device_class, dev_name(&device->dev), event, pr->performance_platform_limit); break; case ACPI_PROCESSOR_NOTIFY_POWER: acpi_processor_power_state_has_changed(pr); acpi_bus_generate_netlink_event(device->pnp.device_class, dev_name(&device->dev), event, 0); break; case ACPI_PROCESSOR_NOTIFY_THROTTLING: acpi_processor_tstate_has_changed(pr); acpi_bus_generate_netlink_event(device->pnp.device_class, dev_name(&device->dev), event, 0); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported event [0x%x]\n", event)); break; } return; }

Contributors

PersonTokensPropCommitsCommitProp
rafael j. wysockirafael j. wysocki12065.93%325.00%
len brownlen brown2915.93%216.67%
andy groverandy grover2312.64%325.00%
toshi kanitoshi kani94.95%325.00%
sudeep hollasudeep holla10.55%18.33%
Total182100.00%12100.00%

static int __acpi_processor_start(struct acpi_device *device);
static int acpi_soft_cpu_online(unsigned int cpu) { struct acpi_processor *pr = per_cpu(processors, cpu); struct acpi_device *device; if (!pr || acpi_bus_get_device(pr->handle, &device)) return 0; /* * CPU got physically hotplugged and onlined for the first time: * Initialize missing things. */ if (pr->flags.need_hotplug_init) { int ret; pr_info("Will online and init hotplugged CPU: %d\n", pr->id); pr->flags.need_hotplug_init = 0; ret = __acpi_processor_start(device); WARN(ret, "Failed to start CPU: %d\n", pr->id); } else { /* Normal CPU soft online event. */ acpi_processor_ppc_has_changed(pr, 0); acpi_processor_hotplug(pr); acpi_processor_reevaluate_tstate(pr, false); acpi_processor_tstate_has_changed(pr); } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
rafael j. wysockirafael j. wysocki7560.00%125.00%
toshi kanitoshi kani3628.80%125.00%
sebastian andrzej siewiorsebastian andrzej siewior97.20%125.00%
len brownlen brown54.00%125.00%
Total125100.00%4100.00%


static int acpi_soft_cpu_dead(unsigned int cpu) { struct acpi_processor *pr = per_cpu(processors, cpu); struct acpi_device *device; if (!pr || acpi_bus_get_device(pr->handle, &device)) return 0; acpi_processor_reevaluate_tstate(pr, true); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
sebastian andrzej siewiorsebastian andrzej siewior4378.18%133.33%
len brownlen brown916.36%133.33%
rafael j. wysockirafael j. wysocki35.45%133.33%
Total55100.00%3100.00%

#ifdef CONFIG_ACPI_CPU_FREQ_PSS
static int acpi_pss_perf_init(struct acpi_processor *pr, struct acpi_device *device) { int result = 0; acpi_processor_ppc_has_changed(pr, 0); acpi_processor_get_throttling_info(pr); if (pr->flags.throttling) pr->flags.limit = 1; pr->cdev = thermal_cooling_device_register("Processor", device, &processor_cooling_ops); if (IS_ERR(pr->cdev)) { result = PTR_ERR(pr->cdev); return result; } dev_dbg(&device->dev, "registered as cooling_device%d\n", pr->cdev->id); result = sysfs_create_link(&device->dev.kobj, &pr->cdev->device.kobj, "thermal_cooling"); if (result) { dev_err(&device->dev, "Failed to create sysfs link 'thermal_cooling'\n"); goto err_thermal_unregister; } result = sysfs_create_link(&pr->cdev->device.kobj, &device->dev.kobj, "device"); if (result) { dev_err(&pr->cdev->device, "Failed to create sysfs link 'device'\n"); goto err_remove_sysfs_thermal; } return 0; err_remove_sysfs_thermal: sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); err_thermal_unregister: thermal_cooling_device_unregister(pr->cdev); return result; }

Contributors

PersonTokensPropCommitsCommitProp
rafael j. wysockirafael j. wysocki12959.45%18.33%
len brownlen brown198.76%216.67%
thomas renningerthomas renninger198.76%216.67%
lan tianyulan tianyu146.45%18.33%
ashwin chauguleashwin chaugule135.99%18.33%
andy groverandy grover115.07%216.67%
rui zhangrui zhang52.30%18.33%
yasuaki ishimatsuyasuaki ishimatsu41.84%18.33%
srinivas pandruvadasrinivas pandruvada31.38%18.33%
Total217100.00%12100.00%


static void acpi_pss_perf_exit(struct acpi_processor *pr, struct acpi_device *device) { if (pr->cdev) { sysfs_remove_link(&device->dev.kobj, "thermal_cooling"); sysfs_remove_link(&pr->cdev->device.kobj, "device"); thermal_cooling_device_unregister(pr->cdev); pr->cdev = NULL; } }

Contributors

PersonTokensPropCommitsCommitProp
ashwin chauguleashwin chaugule63100.00%1100.00%
Total63100.00%1100.00%

#else
static inline int acpi_pss_perf_init(struct acpi_processor *pr, struct acpi_device *device) { return 0; }

Contributors

PersonTokensPropCommitsCommitProp
ashwin chauguleashwin chaugule20100.00%1100.00%
Total20100.00%1100.00%


static inline void acpi_pss_perf_exit(struct acpi_processor *pr, struct acpi_device *device) {}

Contributors

PersonTokensPropCommitsCommitProp
ashwin chauguleashwin chaugule16100.00%1100.00%
Total16100.00%1100.00%

#endif /* CONFIG_ACPI_CPU_FREQ_PSS */
static int __acpi_processor_start(struct acpi_device *device) { struct acpi_processor *pr = acpi_driver_data(device); acpi_status status; int result = 0; if (!pr) return -ENODEV; if (pr->flags.need_hotplug_init) return 0; result = acpi_cppc_processor_probe(pr); if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS)) dev_warn(&device->dev, "CPPC data invalid or not present\n"); if (!cpuidle_get_driver() || cpuidle_get_driver() == &acpi_idle_driver) acpi_processor_power_init(pr); result = acpi_pss_perf_init(pr, device); if (result) goto err_power_exit; status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify, device); if (ACPI_SUCCESS(status)) return 0; err_power_exit: acpi_processor_power_exit(pr); return result; }

Contributors

PersonTokensPropCommitsCommitProp
ashwin chauguleashwin chaugule11781.25%228.57%
srinivas pandruvadasrinivas pandruvada1611.11%228.57%
len brownlen brown74.86%228.57%
rafael j. wysockirafael j. wysocki42.78%114.29%
Total144100.00%7100.00%


static int acpi_processor_start(struct device *dev) { struct acpi_device *device = ACPI_COMPANION(dev); if (!device) return -ENODEV; return __acpi_processor_start(device); }

Contributors

PersonTokensPropCommitsCommitProp
rafael j. wysockirafael j. wysocki1850.00%120.00%
len brownlen brown1130.56%240.00%
lan tianyulan tianyu616.67%120.00%
thomas renningerthomas renninger12.78%120.00%
Total36100.00%5100.00%


static int acpi_processor_stop(struct device *dev) { struct acpi_device *device = ACPI_COMPANION(dev); struct acpi_processor *pr; if (!device) return 0; acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, acpi_processor_notify); pr = acpi_driver_data(device); if (!pr) return 0; acpi_processor_power_exit(pr); acpi_pss_perf_exit(pr, device); acpi_cppc_processor_exit(pr); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
rafael j. wysockirafael j. wysocki5467.50%114.29%
len brownlen brown911.25%228.57%
ashwin chauguleashwin chaugule78.75%228.57%
lan tianyulan tianyu67.50%114.29%
venkatesh pallipadivenkatesh pallipadi45.00%114.29%
Total80100.00%7100.00%

/* * We keep the driver loaded even when ACPI is not running. * This is needed for the powernow-k8 driver, that works even without * ACPI, but needs symbols from this driver */ static enum cpuhp_state hp_online;
static int __init acpi_processor_driver_init(void) { int result = 0; if (acpi_disabled) return 0; result = driver_register(&acpi_processor_driver); if (result < 0) return result; result = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN, "acpi/cpu-drv:online", acpi_soft_cpu_online, NULL); if (result < 0) goto err; hp_online = result; cpuhp_setup_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD, "acpi/cpu-drv:dead", NULL, acpi_soft_cpu_dead); acpi_thermal_cpufreq_init(); acpi_processor_ppc_init(); acpi_processor_throttling_init(); return 0; err: driver_unregister(&acpi_processor_driver); return result; }

Contributors

PersonTokensPropCommitsCommitProp
sebastian andrzej siewiorsebastian andrzej siewior4545.92%17.69%
andy groverandy grover1717.35%215.38%
len brownlen brown1010.20%215.38%
yinghai luyinghai lu77.14%17.69%
dominik brodowskidominik brodowski66.12%215.38%
rafael j. wysockirafael j. wysocki44.08%17.69%
yakui zhaoyakui zhao33.06%17.69%
deepthi dharwardeepthi dharwar33.06%17.69%
patrick mochelpatrick mochel22.04%17.69%
akinobu mitaakinobu mita11.02%17.69%
Total98100.00%13100.00%


static void __exit acpi_processor_driver_exit(void) { if (acpi_disabled) return; acpi_processor_ppc_exit(); acpi_thermal_cpufreq_exit(); cpuhp_remove_state_nocalls(hp_online); cpuhp_remove_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD); driver_unregister(&acpi_processor_driver); }

Contributors

PersonTokensPropCommitsCommitProp
andy groverandy grover1336.11%114.29%
sebastian andrzej siewiorsebastian andrzej siewior719.44%114.29%
dominik brodowskidominik brodowski616.67%228.57%
yinghai luyinghai lu513.89%114.29%
rafael j. wysockirafael j. wysocki411.11%114.29%
len brownlen brown12.78%114.29%
Total36100.00%7100.00%

module_init(acpi_processor_driver_init); module_exit(acpi_processor_driver_exit); MODULE_ALIAS("processor");

Overall Contributors

PersonTokensPropCommitsCommitProp
rafael j. wysockirafael j. wysocki43834.62%35.66%
ashwin chauguleashwin chaugule24419.29%23.77%
andy groverandy grover13610.75%815.09%
len brownlen brown1179.25%916.98%
sebastian andrzej siewiorsebastian andrzej siewior1098.62%11.89%
thomas renningerthomas renninger554.35%35.66%
toshi kanitoshi kani493.87%47.55%
lan tianyulan tianyu262.06%23.77%
srinivas pandruvadasrinivas pandruvada191.50%35.66%
dominik brodowskidominik brodowski120.95%23.77%
yinghai luyinghai lu120.95%11.89%
patrick mochelpatrick mochel100.79%23.77%
myron stowemyron stowe60.47%11.89%
rui zhangrui zhang50.40%11.89%
yasuaki ishimatsuyasuaki ishimatsu40.32%11.89%
yu lumingyu luming40.32%11.89%
venkatesh pallipadivenkatesh pallipadi40.32%11.89%
yakui zhaoyakui zhao30.24%11.89%
deepthi dharwardeepthi dharwar30.24%11.89%
tejun heotejun heo30.24%11.89%
bjorn helgaasbjorn helgaas20.16%11.89%
akinobu mitaakinobu mita10.08%11.89%
sudeep hollasudeep holla10.08%11.89%
jarkko nikulajarkko nikula10.08%11.89%
alex chiangalex chiang10.08%11.89%
Total1265100.00%53100.00%
Directory: drivers/acpi
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.