static int acpi_cpu_soft_notify(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; struct acpi_processor *pr = per_cpu(processors, cpu); if (action == CPU_ONLINE && pr) { /* CPU got physically hotplugged and onlined the first time: * Initialize missing things */ if (pr->flags.need_hotplug_init) { pr_info("Will online and init hotplugged CPU: %d\n", pr->id); WARN(acpi_processor_start(pr), "Failed to start CPU:" " %d\n", pr->id); pr->flags.need_hotplug_init = 0; /* Normal CPU soft online event */ } else { acpi_processor_ppc_has_changed(pr, 0); acpi_processor_hotplug(pr); acpi_processor_reevaluate_tstate(pr, action); acpi_processor_tstate_has_changed(pr); } } if (action == CPU_DEAD && pr) { /* invalidate the flag.throttling after one CPU is offline */ acpi_processor_reevaluate_tstate(pr, action); } return NOTIFY_OK; }
static int acpi_cpu_soft_notify(struct notifier_block *nfb, unsigned long action, void *hcpu) { unsigned int cpu = (unsigned long)hcpu; struct acpi_processor *pr = per_cpu(processors, cpu); if (action == CPU_ONLINE && pr) { if (pr->flags.need_hotplug_init) { struct cpuidle_driver *idle_driver = cpuidle_get_driver(); printk(KERN_INFO "Will online and init hotplugged " "CPU: %d\n", pr->id); WARN(acpi_processor_start(pr), "Failed to start CPU:" " %d\n", pr->id); pr->flags.need_hotplug_init = 0; if (idle_driver && !strcmp(idle_driver->name, "intel_idle")) { intel_idle_cpu_init(pr->id); } } else { acpi_processor_ppc_has_changed(pr, 0); acpi_processor_cst_has_changed(pr); acpi_processor_reevaluate_tstate(pr, action); acpi_processor_tstate_has_changed(pr); } } if (action == CPU_DEAD && pr) { acpi_processor_reevaluate_tstate(pr, action); } return NOTIFY_OK; }
static void acpi_processor_hotplug_notify(acpi_handle handle, u32 event, void *data) { struct acpi_processor *pr; struct acpi_device *device = NULL; int result; ACPI_FUNCTION_TRACE("acpi_processor_hotplug_notify"); switch (event) { case ACPI_NOTIFY_BUS_CHECK: case ACPI_NOTIFY_DEVICE_CHECK: printk("Processor driver received %s event\n", (event == ACPI_NOTIFY_BUS_CHECK) ? "ACPI_NOTIFY_BUS_CHECK" : "ACPI_NOTIFY_DEVICE_CHECK"); if (!is_processor_present(handle)) break; if (acpi_bus_get_device(handle, &device)) { result = acpi_processor_device_add(handle, &device); if (result) ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unable to add the device\n")); break; } pr = acpi_driver_data(device); if (!pr) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Driver data is NULL\n")); break; } if (pr->id >= 0 && (pr->id < NR_CPUS)) { kobject_hotplug(&device->kobj, KOBJ_OFFLINE); break; } result = acpi_processor_start(device); if ((!result) && ((pr->id >= 0) && (pr->id < NR_CPUS))) { kobject_hotplug(&device->kobj, KOBJ_ONLINE); } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Device [%s] failed to start\n", acpi_device_bid(device))); } break; case ACPI_NOTIFY_EJECT_REQUEST: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "received ACPI_NOTIFY_EJECT_REQUEST\n")); if (acpi_bus_get_device(handle, &device)) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Device don't exist, dropping EJECT\n")); break; } pr = acpi_driver_data(device); if (!pr) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Driver data is NULL, dropping EJECT\n")); return_VOID; } if ((pr->id < NR_CPUS) && (cpu_present(pr->id))) kobject_hotplug(&device->kobj, KOBJ_OFFLINE); break; default: ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Unsupported event [0x%x]\n", event)); break; } return_VOID; }
/* * Do not put anything in here which needs the core to be online. * For example MSR access or setting up things which check for cpuinfo_x86 * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc. * Such things have to be put in and set up above in acpi_processor_start() */ static int __cpuinit acpi_processor_add(struct acpi_device *device) { struct acpi_processor *pr = NULL; int result = 0; struct device *dev; pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); if (!pr) return -ENOMEM; if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { result = -ENOMEM; goto err_free_pr; } pr->handle = device->handle; strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); device->driver_data = pr; result = acpi_processor_get_info(device); if (result) { /* Processor is physically not present */ return 0; } #ifdef CONFIG_SMP if (pr->id >= setup_max_cpus && pr->id != 0) return 0; #endif BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); /* * Buggy BIOS check * ACPI id of processors can be reported wrongly by the BIOS. * Don't trust it blindly */ if (per_cpu(processor_device_array, pr->id) != NULL && per_cpu(processor_device_array, pr->id) != device) { printk(KERN_WARNING "BIOS reported wrong ACPI id " "for the processor\n"); result = -ENODEV; goto err_free_cpumask; } per_cpu(processor_device_array, pr->id) = device; per_cpu(processors, pr->id) = pr; dev = get_cpu_device(pr->id); if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { result = -EFAULT; goto err_clear_processor; } /* * Do not start hotplugged CPUs now, but when they * are onlined the first time */ if (pr->flags.need_hotplug_init) return 0; result = acpi_processor_start(pr); if (result) goto err_remove_sysfs; return 0; err_remove_sysfs: sysfs_remove_link(&device->dev.kobj, "sysdev"); err_clear_processor: /* * processor_device_array is not cleared to allow checks for buggy BIOS */ per_cpu(processors, pr->id) = NULL; err_free_cpumask: free_cpumask_var(pr->throttling.shared_cpu_map); err_free_pr: kfree(pr); return result; }
static int __cpuinit acpi_processor_add(struct acpi_device *device) { struct acpi_processor *pr = NULL; int result = 0; struct device *dev; pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); if (!pr) return -ENOMEM; if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { result = -ENOMEM; goto err_free_pr; } pr->handle = device->handle; strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); device->driver_data = pr; result = acpi_processor_get_info(device); if (result) { return 0; } #ifdef CONFIG_SMP if (pr->id >= setup_max_cpus && pr->id != 0) return 0; #endif BUG_ON((pr->id >= nr_cpu_ids) || (pr->id < 0)); if (per_cpu(processor_device_array, pr->id) != NULL && per_cpu(processor_device_array, pr->id) != device) { printk(KERN_WARNING "BIOS reported wrong ACPI id " "for the processor\n"); result = -ENODEV; goto err_free_cpumask; } per_cpu(processor_device_array, pr->id) = device; per_cpu(processors, pr->id) = pr; dev = get_cpu_device(pr->id); if (sysfs_create_link(&device->dev.kobj, &dev->kobj, "sysdev")) { result = -EFAULT; goto err_clear_processor; } if (pr->flags.need_hotplug_init) return 0; result = acpi_processor_start(pr); if (result) goto err_remove_sysfs; return 0; err_remove_sysfs: sysfs_remove_link(&device->dev.kobj, "sysdev"); err_clear_processor: per_cpu(processors, pr->id) = NULL; err_free_cpumask: free_cpumask_var(pr->throttling.shared_cpu_map); err_free_pr: kfree(pr); return result; }