cregit-Linux how code gets into the kernel

Release 4.11 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. Wysocki12065.93%325.00%
Len Brown2915.93%216.67%
Andy Grover2312.64%325.00%
Toshi Kani94.95%325.00%
Sudeep 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. Wysocki7560.00%125.00%
Toshi Kani3628.80%125.00%
Sebastian Andrzej Siewior97.20%125.00%
Len 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 Siewior4378.18%133.33%
Len Brown916.36%133.33%
Rafael 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. Wysocki12959.45%18.33%
Thomas Renninger198.76%216.67%
Len Brown198.76%216.67%
Lan Tianyu146.45%18.33%
Ashwin Chaugule135.99%18.33%
Andy Grover115.07%216.67%
Rui Zhang52.30%18.33%
Yasuaki Ishimatsu41.84%18.33%
Srinivas 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 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_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 Chaugule11781.25%228.57%
Srinivas Pandruvada1611.11%228.57%
Len Brown74.86%228.57%
Rafael 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. Wysocki1850.00%120.00%
Len Brown1130.56%240.00%
Lan Tianyu616.67%120.00%
Thomas 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. Wysocki5467.50%114.29%
Len Brown911.25%228.57%
Ashwin Chaugule78.75%228.57%
Lan Tianyu67.50%114.29%
Venkatesh 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 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. Wysocki43834.62%35.66%
Ashwin Chaugule24419.29%23.77%
Andy Grover13610.75%815.09%
Len Brown1179.25%916.98%
Sebastian Andrzej Siewior1098.62%11.89%
Thomas Renninger554.35%35.66%
Toshi Kani493.87%47.55%
Lan Tianyu262.06%23.77%
Srinivas Pandruvada191.50%35.66%
Dominik Brodowski120.95%23.77%
Yinghai Lu120.95%11.89%
Patrick Mochel100.79%23.77%
Myron Stowe60.47%11.89%
Rui Zhang50.40%11.89%
Yasuaki Ishimatsu40.32%11.89%
Yu Luming40.32%11.89%
Venkatesh Pallipadi40.32%11.89%
Tejun Heo30.24%11.89%
Deepthi Dharwar30.24%11.89%
Yakui Zhao30.24%11.89%
Björn Helgaas20.16%11.89%
Alexander Chiang10.08%11.89%
Akinobu Mita10.08%11.89%
Sudeep Holla10.08%11.89%
Jarkko Nikula10.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.
Created with cregit.