Lines Matching +full:device +full:- +full:handle

1 // SPDX-License-Identifier: GPL-2.0-only
3 * acpi_processor.c - ACPI processor enumeration support
16 #include <linux/device.h>
44 return pr->handle; in acpi_get_processor_handle()
56 return -EINVAL; in acpi_processor_errata_piix4()
62 switch (dev->revision) { in acpi_processor_errata_piix4()
64 dev_dbg(&dev->dev, "Found PIIX4 A-step\n"); in acpi_processor_errata_piix4()
67 dev_dbg(&dev->dev, "Found PIIX4 B-step\n"); in acpi_processor_errata_piix4()
70 dev_dbg(&dev->dev, "Found PIIX4E\n"); in acpi_processor_errata_piix4()
73 dev_dbg(&dev->dev, "Found PIIX4M\n"); in acpi_processor_errata_piix4()
76 dev_dbg(&dev->dev, "Found unknown PIIX4\n"); in acpi_processor_errata_piix4()
80 switch (dev->revision) { in acpi_processor_errata_piix4()
82 case 0: /* PIIX4 A-step */ in acpi_processor_errata_piix4()
83 case 1: /* PIIX4 B-step */ in acpi_processor_errata_piix4()
97 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA in acpi_processor_errata_piix4()
103 * BM-IDE in acpi_processor_errata_piix4()
104 * ------ in acpi_processor_errata_piix4()
119 * Type-F DMA in acpi_processor_errata_piix4()
120 * ---------- in acpi_processor_errata_piix4()
122 * DMA controller's status to see if Type-F (Fast) DMA mode in acpi_processor_errata_piix4()
142 dev_dbg(&dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n"); in acpi_processor_errata_piix4()
144 dev_dbg(&dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n"); in acpi_processor_errata_piix4()
168 /* Create a platform device to represent a CPU frequency control mechanism. */
175 pr_info("%s device creation failed: %pe\n", name, pdev); in cpufreq_add_device()
183 acpi_handle handle; in acpi_pcc_cpufreq_init() local
185 status = acpi_get_handle(NULL, "\\_SB", &handle); in acpi_pcc_cpufreq_init()
189 if (acpi_has_method(handle, "PCCH")) in acpi_pcc_cpufreq_init()
190 cpufreq_add_device("pcc-cpufreq"); in acpi_pcc_cpufreq_init()
200 struct acpi_device *device) in acpi_processor_set_per_cpu() argument
202 BUG_ON(pr->id >= nr_cpu_ids); in acpi_processor_set_per_cpu()
209 if (per_cpu(processor_device_array, pr->id) != NULL && in acpi_processor_set_per_cpu()
210 per_cpu(processor_device_array, pr->id) != device) { in acpi_processor_set_per_cpu()
211 dev_warn(&device->dev, in acpi_processor_set_per_cpu()
213 pr->id); in acpi_processor_set_per_cpu()
214 return -EINVAL; in acpi_processor_set_per_cpu()
220 per_cpu(processor_device_array, pr->id) = device; in acpi_processor_set_per_cpu()
221 per_cpu(processors, pr->id) = pr; in acpi_processor_set_per_cpu()
228 struct acpi_device *device) in acpi_processor_hotadd_init() argument
232 if (invalid_phys_cpuid(pr->phys_id)) in acpi_processor_hotadd_init()
233 return -ENODEV; in acpi_processor_hotadd_init()
238 ret = acpi_map_cpu(pr->handle, pr->phys_id, pr->acpi_id, &pr->id); in acpi_processor_hotadd_init()
242 ret = acpi_processor_set_per_cpu(pr, device); in acpi_processor_hotadd_init()
244 acpi_unmap_cpu(pr->id); in acpi_processor_hotadd_init()
248 ret = arch_register_cpu(pr->id); in acpi_processor_hotadd_init()
250 /* Leave the processor device array in place to detect buggy bios */ in acpi_processor_hotadd_init()
251 per_cpu(processors, pr->id) = NULL; in acpi_processor_hotadd_init()
252 acpi_unmap_cpu(pr->id); in acpi_processor_hotadd_init()
257 * CPU got hot-added, but cpu_data is not initialized yet. Do in acpi_processor_hotadd_init()
261 pr_info("CPU%d has been hot-added\n", pr->id); in acpi_processor_hotadd_init()
270 struct acpi_device *device) in acpi_processor_hotadd_init() argument
272 return -ENODEV; in acpi_processor_hotadd_init()
276 static int acpi_processor_get_info(struct acpi_device *device) in acpi_processor_get_info() argument
280 struct acpi_processor *pr = acpi_driver_data(device); in acpi_processor_get_info()
294 pr->flags.bm_control = 1; in acpi_processor_get_info()
295 dev_dbg(&device->dev, "Bus mastering arbitration control present\n"); in acpi_processor_get_info()
297 dev_dbg(&device->dev, "No bus mastering arbitration control\n"); in acpi_processor_get_info()
299 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) { in acpi_processor_get_info()
301 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer); in acpi_processor_get_info()
303 dev_err(&device->dev, in acpi_processor_get_info()
306 return -ENODEV; in acpi_processor_get_info()
309 pr->acpi_id = object.processor.proc_id; in acpi_processor_get_info()
312 * Declared with "Device" statement; match _UID. in acpi_processor_get_info()
314 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID, in acpi_processor_get_info()
317 dev_err(&device->dev, in acpi_processor_get_info()
320 return -ENODEV; in acpi_processor_get_info()
323 pr->acpi_id = value; in acpi_processor_get_info()
326 if (acpi_duplicate_processor_id(pr->acpi_id)) { in acpi_processor_get_info()
327 if (pr->acpi_id == 0xff) in acpi_processor_get_info()
328 dev_info_once(&device->dev, in acpi_processor_get_info()
329 "Entry not well-defined, consider updating BIOS\n"); in acpi_processor_get_info()
331 dev_err(&device->dev, in acpi_processor_get_info()
333 pr->acpi_id); in acpi_processor_get_info()
334 return -ENODEV; in acpi_processor_get_info()
337 pr->phys_id = acpi_get_phys_id(pr->handle, device_declaration, in acpi_processor_get_info()
338 pr->acpi_id); in acpi_processor_get_info()
339 if (invalid_phys_cpuid(pr->phys_id)) in acpi_processor_get_info()
340 dev_dbg(&device->dev, "Failed to get CPU physical ID.\n"); in acpi_processor_get_info()
342 pr->id = acpi_map_cpuid(pr->phys_id, pr->acpi_id); in acpi_processor_get_info()
346 * Handle UP system running SMP kernel, with no CPU in acpi_processor_get_info()
349 if (!acpi_has_cpu_in_madt() && invalid_logical_cpuid(pr->id) && in acpi_processor_get_info()
351 pr->id = 0; in acpi_processor_get_info()
357 if (acpi_has_method(pr->handle, "_PCT")) in acpi_processor_get_info()
358 cpufreq_add_device("acpi-cpufreq"); in acpi_processor_get_info()
369 if (!get_cpu_device(pr->id)) in acpi_processor_get_info()
370 ret = acpi_processor_hotadd_init(pr, device); in acpi_processor_get_info()
372 ret = acpi_processor_set_per_cpu(pr, device); in acpi_processor_get_info()
381 * Rename the processor device bus id. And the new bus id will be in acpi_processor_get_info()
385 sprintf(acpi_device_bid(device), "CPU%X", pr->id); in acpi_processor_get_info()
386 dev_dbg(&device->dev, "Processor [%d:%d]\n", pr->id, pr->acpi_id); in acpi_processor_get_info()
389 dev_dbg(&device->dev, "No PBLK (NULL address)\n"); in acpi_processor_get_info()
391 dev_err(&device->dev, "Invalid PBLK length [%d]\n", in acpi_processor_get_info()
394 pr->throttling.address = object.processor.pblk_address; in acpi_processor_get_info()
395 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset; in acpi_processor_get_info()
396 pr->throttling.duty_width = acpi_gbl_FADT.duty_width; in acpi_processor_get_info()
398 pr->pblk = object.processor.pblk_address; in acpi_processor_get_info()
406 status = acpi_evaluate_integer(pr->handle, "_SUN", NULL, &value); in acpi_processor_get_info()
408 arch_fix_phys_package_id(pr->id, value); in acpi_processor_get_info()
419 static int acpi_processor_add(struct acpi_device *device, in acpi_processor_add() argument
423 struct device *dev; in acpi_processor_add()
426 if (!acpi_device_is_enabled(device)) in acpi_processor_add()
427 return -ENODEV; in acpi_processor_add()
431 return -ENOMEM; in acpi_processor_add()
433 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) { in acpi_processor_add()
434 result = -ENOMEM; in acpi_processor_add()
438 pr->handle = device->handle; in acpi_processor_add()
439 strscpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME); in acpi_processor_add()
440 strscpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS); in acpi_processor_add()
441 device->driver_data = pr; in acpi_processor_add()
443 result = acpi_processor_get_info(device); in acpi_processor_add()
447 dev = get_cpu_device(pr->id); in acpi_processor_add()
449 result = -ENODEV; in acpi_processor_add()
453 result = acpi_bind_one(dev, device); in acpi_processor_add()
457 pr->dev = dev; in acpi_processor_add()
467 per_cpu(processors, pr->id) = NULL; in acpi_processor_add()
469 device->driver_data = NULL; in acpi_processor_add()
470 free_cpumask_var(pr->throttling.shared_cpu_map); in acpi_processor_add()
478 static void acpi_processor_post_eject(struct acpi_device *device) in acpi_processor_post_eject() argument
482 if (!device || !acpi_driver_data(device)) in acpi_processor_post_eject()
485 pr = acpi_driver_data(device); in acpi_processor_post_eject()
486 if (pr->id >= nr_cpu_ids) in acpi_processor_post_eject()
490 * The only reason why we ever get here is CPU hot-removal. The CPU is in acpi_processor_post_eject()
491 * already offline and the ACPI device removal locking prevents it from in acpi_processor_post_eject()
494 * Unbind the driver from the processor device and detach it from the in acpi_processor_post_eject()
497 device_release_driver(pr->dev); in acpi_processor_post_eject()
498 acpi_unbind_one(pr->dev); in acpi_processor_post_eject()
504 arch_unregister_cpu(pr->id); in acpi_processor_post_eject()
505 acpi_unmap_cpu(pr->id); in acpi_processor_post_eject()
508 per_cpu(processor_device_array, pr->id) = NULL; in acpi_processor_post_eject()
509 per_cpu(processors, pr->id) = NULL; in acpi_processor_post_eject()
514 try_offline_node(cpu_to_node(pr->id)); in acpi_processor_post_eject()
517 free_cpumask_var(pr->throttling.shared_cpu_map); in acpi_processor_post_eject()
523 bool __init processor_physically_present(acpi_handle handle) in processor_physically_present() argument
533 status = acpi_get_type(handle, &acpi_type); in processor_physically_present()
539 status = acpi_evaluate_object(handle, NULL, NULL, &buffer); in processor_physically_present()
545 status = acpi_evaluate_integer(handle, METHOD_NAME__UID, in processor_physically_present()
565 cpuid = acpi_get_cpuid(handle, type, acpi_id); in processor_physically_present()
571 static u8 sb_uuid_str[] = "4077A616-290C-47BE-9EBD-D87058713953";
573 static acpi_status __init acpi_processor_osc(acpi_handle handle, u32 lvl, in acpi_processor_osc() argument
585 if (!processor_physically_present(handle)) in acpi_processor_osc()
590 status = acpi_run_osc(handle, &osc_context); in acpi_processor_osc()
677 [0 ... NR_CPUS - 1] = -1,
682 [0 ... NR_CPUS - 1] = -1,
720 static acpi_status __init acpi_processor_ids_walk(acpi_handle handle, in acpi_processor_ids_walk() argument
731 status = acpi_get_type(handle, &acpi_type); in acpi_processor_ids_walk()
737 status = acpi_evaluate_object(handle, NULL, NULL, &buffer); in acpi_processor_ids_walk()
744 status = acpi_evaluate_integer(handle, "_UID", NULL, &uid); in acpi_processor_ids_walk()
757 acpi_handle_info(handle, "Invalid processor object\n"); in acpi_processor_ids_walk()
798 * acpi_processor_claim_cst_control - Request _CST control from the platform.
821 * acpi_processor_evaluate_cst - Evaluate the processor _CST control method.
822 * @handle: ACPI handle of the processor object containing the _CST.
824 * @info: Object write the C-states information into.
826 * Extract the C-state information for the given CPU from the output of the _CST
828 * device object) and populate @info with it.
830 * If any ACPI_ADR_SPACE_FIXED_HARDWARE C-states are found, invoke
834 int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, in acpi_processor_evaluate_cst() argument
844 status = acpi_evaluate_object(handle, "_CST", NULL, &buffer); in acpi_processor_evaluate_cst()
846 acpi_handle_debug(handle, "No _CST\n"); in acpi_processor_evaluate_cst()
847 return -ENODEV; in acpi_processor_evaluate_cst()
853 if (!cst || cst->type != ACPI_TYPE_PACKAGE || cst->package.count < 2) { in acpi_processor_evaluate_cst()
854 acpi_handle_warn(handle, "Invalid _CST output\n"); in acpi_processor_evaluate_cst()
855 ret = -EFAULT; in acpi_processor_evaluate_cst()
859 count = cst->package.elements[0].integer.value; in acpi_processor_evaluate_cst()
861 /* Validate the number of C-states. */ in acpi_processor_evaluate_cst()
862 if (count < 1 || count != cst->package.count - 1) { in acpi_processor_evaluate_cst()
863 acpi_handle_warn(handle, "Inconsistent _CST data\n"); in acpi_processor_evaluate_cst()
864 ret = -EFAULT; in acpi_processor_evaluate_cst()
875 * If there is not enough space for all C-states, skip the in acpi_processor_evaluate_cst()
878 if (last_index >= ACPI_PROCESSOR_MAX_POWER - 1) { in acpi_processor_evaluate_cst()
879 acpi_handle_warn(handle, in acpi_processor_evaluate_cst()
881 ACPI_PROCESSOR_MAX_POWER - 1); in acpi_processor_evaluate_cst()
887 element = &cst->package.elements[i]; in acpi_processor_evaluate_cst()
888 if (element->type != ACPI_TYPE_PACKAGE) { in acpi_processor_evaluate_cst()
889 acpi_handle_info(handle, "_CST C%d type(%x) is not package, skip...\n", in acpi_processor_evaluate_cst()
890 i, element->type); in acpi_processor_evaluate_cst()
894 if (element->package.count != 4) { in acpi_processor_evaluate_cst()
895 acpi_handle_info(handle, "_CST C%d package count(%d) is not 4, skip...\n", in acpi_processor_evaluate_cst()
896 i, element->package.count); in acpi_processor_evaluate_cst()
900 obj = &element->package.elements[0]; in acpi_processor_evaluate_cst()
902 if (obj->type != ACPI_TYPE_BUFFER) { in acpi_processor_evaluate_cst()
903 acpi_handle_info(handle, "_CST C%d package element[0] type(%x) is not buffer, skip...\n", in acpi_processor_evaluate_cst()
904 i, obj->type); in acpi_processor_evaluate_cst()
908 reg = (struct acpi_power_register *)obj->buffer.pointer; in acpi_processor_evaluate_cst()
910 obj = &element->package.elements[1]; in acpi_processor_evaluate_cst()
911 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_processor_evaluate_cst()
912 acpi_handle_info(handle, "_CST C[%d] package element[1] type(%x) is not integer, skip...\n", in acpi_processor_evaluate_cst()
913 i, obj->type); in acpi_processor_evaluate_cst()
917 cx.type = obj->integer.value; in acpi_processor_evaluate_cst()
926 cx.address = reg->address; in acpi_processor_evaluate_cst()
929 if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) { in acpi_processor_evaluate_cst()
933 * a FIXED_HARDWARE C-state, but if the command in acpi_processor_evaluate_cst()
952 …acpi_handle_info(handle, "_CST C%d declares FIXED_HARDWARE C-state but not supported in hardware, … in acpi_processor_evaluate_cst()
956 } else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { in acpi_processor_evaluate_cst()
961 acpi_handle_info(handle, "_CST C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n", in acpi_processor_evaluate_cst()
962 i, reg->space_id); in acpi_processor_evaluate_cst()
969 obj = &element->package.elements[2]; in acpi_processor_evaluate_cst()
970 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_processor_evaluate_cst()
971 acpi_handle_info(handle, "_CST C%d package element[2] type(%x) not integer, skip...\n", in acpi_processor_evaluate_cst()
972 i, obj->type); in acpi_processor_evaluate_cst()
976 cx.latency = obj->integer.value; in acpi_processor_evaluate_cst()
978 obj = &element->package.elements[3]; in acpi_processor_evaluate_cst()
979 if (obj->type != ACPI_TYPE_INTEGER) { in acpi_processor_evaluate_cst()
980 acpi_handle_info(handle, "_CST C%d package element[3] type(%x) not integer, skip...\n", in acpi_processor_evaluate_cst()
981 i, obj->type); in acpi_processor_evaluate_cst()
985 memcpy(&info->states[++last_index], &cx, sizeof(cx)); in acpi_processor_evaluate_cst()
988 acpi_handle_debug(handle, "Found %d idle states\n", last_index); in acpi_processor_evaluate_cst()
990 info->count = last_index; in acpi_processor_evaluate_cst()