cregit-Linux how code gets into the kernel

Release 4.14 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. Wysocki12267.03%112.50%
Andy Grover5027.47%337.50%
Greg Kroah-Hartman73.85%112.50%
Len Brown21.10%225.00%
Sudeep Holla10.55%112.50%
Total182100.00%8100.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. Wysocki9475.20%114.29%
Len Brown1512.00%228.57%
Sebastian Andrzej Siewior97.20%114.29%
Dominik Brodowski43.20%114.29%
Patrick Mochel21.60%114.29%
Adrian Bunk10.80%114.29%
Total125100.00%7100.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 Siewior4378.18%114.29%
Len Brown59.09%228.57%
Rafael J. Wysocki35.45%114.29%
Patrick Mochel23.64%114.29%
Andy Grover11.82%114.29%
Dave Jones11.82%114.29%
Total55100.00%7100.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. Wysocki9141.94%16.25%
Andy Grover3817.51%16.25%
Alexey Y. Starikovskiy167.37%212.50%
Lan Tianyu146.45%16.25%
Toshi Kani146.45%16.25%
Ashwin Chaugule135.99%16.25%
Len Brown94.15%212.50%
Linus Torvalds62.76%16.25%
Yasuaki Ishimatsu41.84%16.25%
Myron Stowe41.84%16.25%
Srinivas Pandruvada31.38%16.25%
Yakui Zhao31.38%16.25%
Björn Helgaas10.46%16.25%
Ashok Raj10.46%16.25%
Total217100.00%16100.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 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 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 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_dbg(&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; result = -ENODEV; acpi_pss_perf_exit(pr, device); err_power_exit: acpi_processor_power_exit(pr); return result; }

Contributors

PersonTokensPropCommitsCommitProp
Ashwin Chaugule11775.00%222.22%
Srinivas Pandruvada159.62%222.22%
Thomas Gleixner127.69%111.11%
Len Brown74.49%222.22%
Rafael J. Wysocki42.56%111.11%
Hanjun Guo10.64%111.11%
Total156100.00%9100.00%


static int acpi_processor_start(struct device *dev) { struct acpi_device *device = ACPI_COMPANION(dev); int ret; if (!device) return -ENODEV; /* Protect against concurrent CPU hotplug operations */ cpu_hotplug_disable(); ret = __acpi_processor_start(device); cpu_hotplug_enable(); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Rafael J. Wysocki1734.00%114.29%
Thomas Gleixner1530.00%228.57%
Len Brown1122.00%228.57%
Lan Tianyu612.00%114.29%
Thomas Renninger12.00%114.29%
Total50100.00%7100.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. Wysocki5467.50%114.29%
Len Brown1012.50%228.57%
Ashwin Chaugule78.75%228.57%
Lan Tianyu67.50%114.29%
Venkatesh Pallipadi33.75%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 Siewior4545.92%17.69%
Andy Grover1717.35%215.38%
Len Brown1010.20%215.38%
Yinghai Lu77.14%17.69%
Dominik Brodowski66.12%215.38%
Rafael J. Wysocki44.08%17.69%
Deepthi Dharwar33.06%17.69%
Yakui Zhao33.06%17.69%
Patrick Mochel22.04%17.69%
Akinobu 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 Grover1336.11%114.29%
Sebastian Andrzej Siewior719.44%114.29%
Dominik Brodowski616.67%228.57%
Yinghai Lu513.89%114.29%
Rafael J. Wysocki411.11%114.29%
Len 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. Wysocki42032.53%11.54%
Ashwin Chaugule24418.90%23.08%
Andy Grover19114.79%812.31%
Sebastian Andrzej Siewior1098.44%11.54%
Len Brown876.74%1218.46%
Thomas Renninger362.79%34.62%
Thomas Gleixner272.09%34.62%
Lan Tianyu262.01%23.08%
Toshi Kani181.39%23.08%
Srinivas Pandruvada181.39%34.62%
Dominik Brodowski161.24%23.08%
Alexey Y. Starikovskiy161.24%23.08%
Patrick Mochel141.08%23.08%
Yinghai Lu120.93%11.54%
Myron Stowe100.77%23.08%
Greg Kroah-Hartman70.54%11.54%
Linus Torvalds60.46%11.54%
Yakui Zhao60.46%23.08%
Yasuaki Ishimatsu40.31%11.54%
Yu Luming40.31%11.54%
Björn Helgaas30.23%23.08%
Deepthi Dharwar30.23%11.54%
Venkatesh Pallipadi30.23%11.54%
Tejun Heo30.23%11.54%
Sudeep Holla10.08%11.54%
Dave Jones10.08%11.54%
Alexander Chiang10.08%11.54%
Jarkko Nikula10.08%11.54%
Akinobu Mita10.08%11.54%
Adrian Bunk10.08%11.54%
Hanjun Guo10.08%11.54%
Ashok Raj10.08%11.54%
Total1291100.00%65100.00%
Directory: drivers/acpi
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.