aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/processor_driver.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/processor_driver.c')
-rw-r--r--drivers/acpi/processor_driver.c74
1 files changed, 52 insertions, 22 deletions
diff --git a/drivers/acpi/processor_driver.c b/drivers/acpi/processor_driver.c
index bd4e5dca3ff7..e83311bf1ebd 100644
--- a/drivers/acpi/processor_driver.c
+++ b/drivers/acpi/processor_driver.c
@@ -44,6 +44,7 @@
44#include <linux/moduleparam.h> 44#include <linux/moduleparam.h>
45#include <linux/cpuidle.h> 45#include <linux/cpuidle.h>
46#include <linux/slab.h> 46#include <linux/slab.h>
47#include <linux/acpi.h>
47 48
48#include <asm/io.h> 49#include <asm/io.h>
49#include <asm/cpu.h> 50#include <asm/cpu.h>
@@ -282,7 +283,9 @@ static int acpi_processor_get_info(struct acpi_device *device)
282 /* Declared with "Processor" statement; match ProcessorID */ 283 /* Declared with "Processor" statement; match ProcessorID */
283 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); 284 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
284 if (ACPI_FAILURE(status)) { 285 if (ACPI_FAILURE(status)) {
285 printk(KERN_ERR PREFIX "Evaluating processor object\n"); 286 dev_err(&device->dev,
287 "Failed to evaluate processor object (0x%x)\n",
288 status);
286 return -ENODEV; 289 return -ENODEV;
287 } 290 }
288 291
@@ -301,8 +304,9 @@ static int acpi_processor_get_info(struct acpi_device *device)
301 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, 304 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
302 NULL, &value); 305 NULL, &value);
303 if (ACPI_FAILURE(status)) { 306 if (ACPI_FAILURE(status)) {
304 printk(KERN_ERR PREFIX 307 dev_err(&device->dev,
305 "Evaluating processor _UID [%#x]\n", status); 308 "Failed to evaluate processor _UID (0x%x)\n",
309 status);
306 return -ENODEV; 310 return -ENODEV;
307 } 311 }
308 device_declaration = 1; 312 device_declaration = 1;
@@ -345,7 +349,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
345 if (!object.processor.pblk_address) 349 if (!object.processor.pblk_address)
346 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n")); 350 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No PBLK (NULL address)\n"));
347 else if (object.processor.pblk_length != 6) 351 else if (object.processor.pblk_length != 6)
348 printk(KERN_ERR PREFIX "Invalid PBLK length [%d]\n", 352 dev_err(&device->dev, "Invalid PBLK length [%d]\n",
349 object.processor.pblk_length); 353 object.processor.pblk_length);
350 else { 354 else {
351 pr->throttling.address = object.processor.pblk_address; 355 pr->throttling.address = object.processor.pblk_address;
@@ -430,8 +434,8 @@ static int acpi_cpu_soft_notify(struct notifier_block *nfb,
430 * Initialize missing things 434 * Initialize missing things
431 */ 435 */
432 if (pr->flags.need_hotplug_init) { 436 if (pr->flags.need_hotplug_init) {
433 printk(KERN_INFO "Will online and init hotplugged " 437 pr_info("Will online and init hotplugged CPU: %d\n",
434 "CPU: %d\n", pr->id); 438 pr->id);
435 WARN(acpi_processor_start(pr), "Failed to start CPU:" 439 WARN(acpi_processor_start(pr), "Failed to start CPU:"
436 " %d\n", pr->id); 440 " %d\n", pr->id);
437 pr->flags.need_hotplug_init = 0; 441 pr->flags.need_hotplug_init = 0;
@@ -492,14 +496,16 @@ static __ref int acpi_processor_start(struct acpi_processor *pr)
492 &pr->cdev->device.kobj, 496 &pr->cdev->device.kobj,
493 "thermal_cooling"); 497 "thermal_cooling");
494 if (result) { 498 if (result) {
495 printk(KERN_ERR PREFIX "Create sysfs link\n"); 499 dev_err(&device->dev,
500 "Failed to create sysfs link 'thermal_cooling'\n");
496 goto err_thermal_unregister; 501 goto err_thermal_unregister;
497 } 502 }
498 result = sysfs_create_link(&pr->cdev->device.kobj, 503 result = sysfs_create_link(&pr->cdev->device.kobj,
499 &device->dev.kobj, 504 &device->dev.kobj,
500 "device"); 505 "device");
501 if (result) { 506 if (result) {
502 printk(KERN_ERR PREFIX "Create sysfs link\n"); 507 dev_err(&pr->cdev->device,
508 "Failed to create sysfs link 'device'\n");
503 goto err_remove_sysfs_thermal; 509 goto err_remove_sysfs_thermal;
504 } 510 }
505 511
@@ -561,8 +567,9 @@ static int __cpuinit acpi_processor_add(struct acpi_device *device)
561 */ 567 */
562 if (per_cpu(processor_device_array, pr->id) != NULL && 568 if (per_cpu(processor_device_array, pr->id) != NULL &&
563 per_cpu(processor_device_array, pr->id) != device) { 569 per_cpu(processor_device_array, pr->id) != device) {
564 printk(KERN_WARNING "BIOS reported wrong ACPI id " 570 dev_warn(&device->dev,
565 "for the processor\n"); 571 "BIOS reported wrong ACPI id %d for the processor\n",
572 pr->id);
566 result = -ENODEV; 573 result = -ENODEV;
567 goto err_free_cpumask; 574 goto err_free_cpumask;
568 } 575 }
@@ -695,8 +702,8 @@ int acpi_processor_device_add(acpi_handle handle, struct acpi_device **device)
695static void acpi_processor_hotplug_notify(acpi_handle handle, 702static void acpi_processor_hotplug_notify(acpi_handle handle,
696 u32 event, void *data) 703 u32 event, void *data)
697{ 704{
698 struct acpi_processor *pr;
699 struct acpi_device *device = NULL; 705 struct acpi_device *device = NULL;
706 struct acpi_eject_event *ej_event = NULL;
700 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */ 707 u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; /* default */
701 int result; 708 int result;
702 709
@@ -716,7 +723,7 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
716 723
717 result = acpi_processor_device_add(handle, &device); 724 result = acpi_processor_device_add(handle, &device);
718 if (result) { 725 if (result) {
719 printk(KERN_ERR PREFIX "Unable to add the device\n"); 726 acpi_handle_err(handle, "Unable to add the device\n");
720 break; 727 break;
721 } 728 }
722 729
@@ -728,20 +735,29 @@ static void acpi_processor_hotplug_notify(acpi_handle handle,
728 "received ACPI_NOTIFY_EJECT_REQUEST\n")); 735 "received ACPI_NOTIFY_EJECT_REQUEST\n"));
729 736
730 if (acpi_bus_get_device(handle, &device)) { 737 if (acpi_bus_get_device(handle, &device)) {
731 printk(KERN_ERR PREFIX 738 acpi_handle_err(handle,
732 "Device don't exist, dropping EJECT\n"); 739 "Device don't exist, dropping EJECT\n");
733 break; 740 break;
734 } 741 }
735 pr = acpi_driver_data(device); 742 if (!acpi_driver_data(device)) {
736 if (!pr) { 743 acpi_handle_err(handle,
737 printk(KERN_ERR PREFIX 744 "Driver data is NULL, dropping EJECT\n");
738 "Driver data is NULL, dropping EJECT\n");
739 break; 745 break;
740 } 746 }
741 747
742 /* REVISIT: update when eject is supported */ 748 ej_event = kmalloc(sizeof(*ej_event), GFP_KERNEL);
743 ost_code = ACPI_OST_SC_EJECT_NOT_SUPPORTED; 749 if (!ej_event) {
744 break; 750 acpi_handle_err(handle, "No memory, dropping EJECT\n");
751 break;
752 }
753
754 ej_event->handle = handle;
755 ej_event->event = ACPI_NOTIFY_EJECT_REQUEST;
756 acpi_os_hotplug_execute(acpi_bus_hot_remove_device,
757 (void *)ej_event);
758
759 /* eject is performed asynchronously */
760 return;
745 761
746 default: 762 default:
747 ACPI_DEBUG_PRINT((ACPI_DB_INFO, 763 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
@@ -841,7 +857,7 @@ static acpi_status acpi_processor_hotadd_init(struct acpi_processor *pr)
841 * and do it when the CPU gets online the first time 857 * and do it when the CPU gets online the first time
842 * TBD: Cleanup above functions and try to do this more elegant. 858 * TBD: Cleanup above functions and try to do this more elegant.
843 */ 859 */
844 printk(KERN_INFO "CPU %d got hotplugged\n", pr->id); 860 pr_info("CPU %d got hotplugged\n", pr->id);
845 pr->flags.need_hotplug_init = 1; 861 pr->flags.need_hotplug_init = 1;
846 862
847 return AE_OK; 863 return AE_OK;
@@ -852,8 +868,22 @@ static int acpi_processor_handle_eject(struct acpi_processor *pr)
852 if (cpu_online(pr->id)) 868 if (cpu_online(pr->id))
853 cpu_down(pr->id); 869 cpu_down(pr->id);
854 870
871 get_online_cpus();
872 /*
873 * The cpu might become online again at this point. So we check whether
874 * the cpu has been onlined or not. If the cpu became online, it means
875 * that someone wants to use the cpu. So acpi_processor_handle_eject()
876 * returns -EAGAIN.
877 */
878 if (unlikely(cpu_online(pr->id))) {
879 put_online_cpus();
880 pr_warn("Failed to remove CPU %d, because other task "
881 "brought the CPU back online\n", pr->id);
882 return -EAGAIN;
883 }
855 arch_unregister_cpu(pr->id); 884 arch_unregister_cpu(pr->id);
856 acpi_unmap_lsapic(pr->id); 885 acpi_unmap_lsapic(pr->id);
886 put_online_cpus();
857 return (0); 887 return (0);
858} 888}
859#else 889#else