1 // SPDX-License-Identifier: GPL-2.0-only
3 * acpi_processor.c - ACPI processor enumeration support
5 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
6 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
7 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
8 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
9 * Copyright (C) 2013, Intel Corporation
10 * Rafael J. Wysocki <rafael.j.wysocki@intel.com>
12 #define pr_fmt(fmt) "ACPI: " fmt
14 #include <linux/acpi.h>
15 #include <linux/cpu.h>
16 #include <linux/device.h>
17 #include <linux/dmi.h>
18 #include <linux/kernel.h>
19 #include <linux/module.h>
20 #include <linux/pci.h>
21 #include <linux/platform_device.h>
23 #include <acpi/processor.h>
31 DEFINE_PER_CPU(struct acpi_processor *, processors);
32 EXPORT_PER_CPU_SYMBOL(processors);
35 struct acpi_processor_errata errata __read_mostly;
36 EXPORT_SYMBOL_GPL(errata);
38 static int acpi_processor_errata_piix4(struct pci_dev *dev)
48 * Note that 'dev' references the PIIX4 ACPI Controller.
51 switch (dev->revision) {
53 dev_dbg(&dev->dev, "Found PIIX4 A-step\n");
56 dev_dbg(&dev->dev, "Found PIIX4 B-step\n");
59 dev_dbg(&dev->dev, "Found PIIX4E\n");
62 dev_dbg(&dev->dev, "Found PIIX4M\n");
65 dev_dbg(&dev->dev, "Found unknown PIIX4\n");
69 switch (dev->revision) {
71 case 0: /* PIIX4 A-step */
72 case 1: /* PIIX4 B-step */
74 * See specification changes #13 ("Manual Throttle Duty Cycle")
75 * and #14 ("Enabling and Disabling Manual Throttle"), plus
76 * erratum #5 ("STPCLK# Deassertion Time") from the January
77 * 2002 PIIX4 specification update. Applies to only older
80 errata.piix4.throttle = 1;
86 * See erratum #18 ("C3 Power State/BMIDE and Type-F DMA
87 * Livelock") from the January 2002 PIIX4 specification update.
88 * Applies to all PIIX4 models.
94 * Find the PIIX4 IDE Controller and get the Bus Master IDE
95 * Status register address. We'll use this later to read
96 * each IDE controller's DMA status to make sure we catch all
99 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
100 PCI_DEVICE_ID_INTEL_82371AB,
101 PCI_ANY_ID, PCI_ANY_ID, NULL);
103 errata.piix4.bmisx = pci_resource_start(dev, 4);
110 * Find the PIIX4 ISA Controller and read the Motherboard
111 * DMA controller's status to see if Type-F (Fast) DMA mode
112 * is enabled (bit 7) on either channel. Note that we'll
113 * disable C3 support if this is enabled, as some legacy
114 * devices won't operate well if fast DMA is disabled.
116 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
117 PCI_DEVICE_ID_INTEL_82371AB_0,
118 PCI_ANY_ID, PCI_ANY_ID, NULL);
120 pci_read_config_byte(dev, 0x76, &value1);
121 pci_read_config_byte(dev, 0x77, &value2);
122 if ((value1 & 0x80) || (value2 & 0x80))
123 errata.piix4.fdma = 1;
130 if (errata.piix4.bmisx)
131 dev_dbg(&dev->dev, "Bus master activity detection (BM-IDE) erratum enabled\n");
132 if (errata.piix4.fdma)
133 dev_dbg(&dev->dev, "Type-F DMA livelock erratum (C3 disabled)\n");
138 static int acpi_processor_errata(void)
141 struct pci_dev *dev = NULL;
146 dev = pci_get_subsys(PCI_VENDOR_ID_INTEL,
147 PCI_DEVICE_ID_INTEL_82371AB_3, PCI_ANY_ID,
150 result = acpi_processor_errata_piix4(dev);
157 /* Create a platform device to represent a CPU frequency control mechanism. */
158 static void cpufreq_add_device(const char *name)
160 struct platform_device *pdev;
162 pdev = platform_device_register_simple(name, PLATFORM_DEVID_NONE, NULL, 0);
164 pr_info("%s device creation failed: %ld\n", name, PTR_ERR(pdev));
168 /* Check presence of Processor Clocking Control by searching for \_SB.PCCH. */
169 static void __init acpi_pcc_cpufreq_init(void)
174 status = acpi_get_handle(NULL, "\\_SB", &handle);
175 if (ACPI_FAILURE(status))
178 if (acpi_has_method(handle, "PCCH"))
179 cpufreq_add_device("pcc-cpufreq");
182 static void __init acpi_pcc_cpufreq_init(void) {}
183 #endif /* CONFIG_X86 */
186 #ifdef CONFIG_ACPI_HOTPLUG_CPU
187 int __weak acpi_map_cpu(acpi_handle handle,
188 phys_cpuid_t physid, u32 acpi_id, int *pcpu)
193 int __weak acpi_unmap_cpu(int cpu)
198 int __weak arch_register_cpu(int cpu)
203 void __weak arch_unregister_cpu(int cpu) {}
205 static int acpi_processor_hotadd_init(struct acpi_processor *pr)
207 unsigned long long sta;
211 if (invalid_phys_cpuid(pr->phys_id))
214 status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
215 if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
218 cpu_maps_update_begin();
221 ret = acpi_map_cpu(pr->handle, pr->phys_id, pr->acpi_id, &pr->id);
225 ret = arch_register_cpu(pr->id);
227 acpi_unmap_cpu(pr->id);
232 * CPU got hot-added, but cpu_data is not initialized yet. Set a flag
233 * to delay cpu_idle/throttling initialization and do it when the CPU
234 * gets online for the first time.
236 pr_info("CPU%d has been hot-added\n", pr->id);
237 pr->flags.need_hotplug_init = 1;
241 cpu_maps_update_done();
245 static inline int acpi_processor_hotadd_init(struct acpi_processor *pr)
249 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
251 static int acpi_processor_get_info(struct acpi_device *device)
253 union acpi_object object = { 0 };
254 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
255 struct acpi_processor *pr = acpi_driver_data(device);
256 int device_declaration = 0;
257 acpi_status status = AE_OK;
258 static int cpu0_initialized;
259 unsigned long long value;
261 acpi_processor_errata();
264 * Check to see if we have bus mastering arbitration control. This
265 * is required for proper C3 usage (to maintain cache coherency).
267 if (acpi_gbl_FADT.pm2_control_block && acpi_gbl_FADT.pm2_control_length) {
268 pr->flags.bm_control = 1;
269 dev_dbg(&device->dev, "Bus mastering arbitration control present\n");
271 dev_dbg(&device->dev, "No bus mastering arbitration control\n");
273 if (!strcmp(acpi_device_hid(device), ACPI_PROCESSOR_OBJECT_HID)) {
274 /* Declared with "Processor" statement; match ProcessorID */
275 status = acpi_evaluate_object(pr->handle, NULL, NULL, &buffer);
276 if (ACPI_FAILURE(status)) {
277 dev_err(&device->dev,
278 "Failed to evaluate processor object (0x%x)\n",
283 pr->acpi_id = object.processor.proc_id;
286 * Declared with "Device" statement; match _UID.
288 status = acpi_evaluate_integer(pr->handle, METHOD_NAME__UID,
290 if (ACPI_FAILURE(status)) {
291 dev_err(&device->dev,
292 "Failed to evaluate processor _UID (0x%x)\n",
296 device_declaration = 1;
300 if (acpi_duplicate_processor_id(pr->acpi_id)) {
301 if (pr->acpi_id == 0xff)
302 dev_info_once(&device->dev,
303 "Entry not well-defined, consider updating BIOS\n");
305 dev_err(&device->dev,
306 "Failed to get unique processor _UID (0x%x)\n",
311 pr->phys_id = acpi_get_phys_id(pr->handle, device_declaration,
313 if (invalid_phys_cpuid(pr->phys_id))
314 dev_dbg(&device->dev, "Failed to get CPU physical ID.\n");
316 pr->id = acpi_map_cpuid(pr->phys_id, pr->acpi_id);
317 if (!cpu0_initialized) {
318 cpu0_initialized = 1;
320 * Handle UP system running SMP kernel, with no CPU
323 if (!acpi_has_cpu_in_madt() && invalid_logical_cpuid(pr->id) &&
324 (num_online_cpus() == 1))
327 * Check availability of Processor Performance Control by
328 * looking at the presence of the _PCT object under the first
329 * processor definition.
331 if (acpi_has_method(pr->handle, "_PCT"))
332 cpufreq_add_device("acpi-cpufreq");
336 * Extra Processor objects may be enumerated on MP systems with
337 * less than the max # of CPUs. They should be ignored _iff
338 * they are physically not present.
340 * NOTE: Even if the processor has a cpuid, it may not be present
341 * because cpuid <-> apicid mapping is persistent now.
343 if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) {
344 int ret = acpi_processor_hotadd_init(pr);
351 * On some boxes several processors use the same processor bus id.
352 * But they are located in different scope. For example:
355 * Rename the processor device bus id. And the new bus id will be
356 * generated as the following format:
359 sprintf(acpi_device_bid(device), "CPU%X", pr->id);
360 dev_dbg(&device->dev, "Processor [%d:%d]\n", pr->id, pr->acpi_id);
362 if (!object.processor.pblk_address)
363 dev_dbg(&device->dev, "No PBLK (NULL address)\n");
364 else if (object.processor.pblk_length != 6)
365 dev_err(&device->dev, "Invalid PBLK length [%d]\n",
366 object.processor.pblk_length);
368 pr->throttling.address = object.processor.pblk_address;
369 pr->throttling.duty_offset = acpi_gbl_FADT.duty_offset;
370 pr->throttling.duty_width = acpi_gbl_FADT.duty_width;
372 pr->pblk = object.processor.pblk_address;
376 * If ACPI describes a slot number for this CPU, we can use it to
377 * ensure we get the right value in the "physical id" field
380 status = acpi_evaluate_integer(pr->handle, "_SUN", NULL, &value);
381 if (ACPI_SUCCESS(status))
382 arch_fix_phys_package_id(pr->id, value);
388 * Do not put anything in here which needs the core to be online.
389 * For example MSR access or setting up things which check for cpuinfo_x86
390 * (cpu_data(cpu)) values, like CPU feature flags, family, model, etc.
391 * Such things have to be put in and set up by the processor driver's .probe().
393 static DEFINE_PER_CPU(void *, processor_device_array);
395 static int acpi_processor_add(struct acpi_device *device,
396 const struct acpi_device_id *id)
398 struct acpi_processor *pr;
402 pr = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL);
406 if (!zalloc_cpumask_var(&pr->throttling.shared_cpu_map, GFP_KERNEL)) {
411 pr->handle = device->handle;
412 strcpy(acpi_device_name(device), ACPI_PROCESSOR_DEVICE_NAME);
413 strcpy(acpi_device_class(device), ACPI_PROCESSOR_CLASS);
414 device->driver_data = pr;
416 result = acpi_processor_get_info(device);
417 if (result) /* Processor is not physically present or unavailable */
420 BUG_ON(pr->id >= nr_cpu_ids);
424 * ACPI id of processors can be reported wrongly by the BIOS.
425 * Don't trust it blindly
427 if (per_cpu(processor_device_array, pr->id) != NULL &&
428 per_cpu(processor_device_array, pr->id) != device) {
429 dev_warn(&device->dev,
430 "BIOS reported wrong ACPI id %d for the processor\n",
432 /* Give up, but do not abort the namespace scan. */
436 * processor_device_array is not cleared on errors to allow buggy BIOS
439 per_cpu(processor_device_array, pr->id) = device;
440 per_cpu(processors, pr->id) = pr;
442 dev = get_cpu_device(pr->id);
448 result = acpi_bind_one(dev, device);
454 /* Trigger the processor driver's .probe() if present. */
455 if (device_attach(dev) >= 0)
458 dev_err(dev, "Processor driver could not be attached\n");
459 acpi_unbind_one(dev);
462 free_cpumask_var(pr->throttling.shared_cpu_map);
463 device->driver_data = NULL;
464 per_cpu(processors, pr->id) = NULL;
470 #ifdef CONFIG_ACPI_HOTPLUG_CPU
472 static void acpi_processor_remove(struct acpi_device *device)
474 struct acpi_processor *pr;
476 if (!device || !acpi_driver_data(device))
479 pr = acpi_driver_data(device);
480 if (pr->id >= nr_cpu_ids)
484 * The only reason why we ever get here is CPU hot-removal. The CPU is
485 * already offline and the ACPI device removal locking prevents it from
486 * being put back online at this point.
488 * Unbind the driver from the processor device and detach it from the
489 * ACPI companion object.
491 device_release_driver(pr->dev);
492 acpi_unbind_one(pr->dev);
495 per_cpu(processor_device_array, pr->id) = NULL;
496 per_cpu(processors, pr->id) = NULL;
498 cpu_maps_update_begin();
501 /* Remove the CPU. */
502 arch_unregister_cpu(pr->id);
503 acpi_unmap_cpu(pr->id);
506 cpu_maps_update_done();
508 try_offline_node(cpu_to_node(pr->id));
511 free_cpumask_var(pr->throttling.shared_cpu_map);
514 #endif /* CONFIG_ACPI_HOTPLUG_CPU */
516 #ifdef CONFIG_ARCH_MIGHT_HAVE_ACPI_PDC
517 bool __init processor_physically_present(acpi_handle handle)
522 acpi_object_type acpi_type;
523 unsigned long long tmp;
524 union acpi_object object = {};
525 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
527 status = acpi_get_type(handle, &acpi_type);
528 if (ACPI_FAILURE(status))
532 case ACPI_TYPE_PROCESSOR:
533 status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
534 if (ACPI_FAILURE(status))
536 acpi_id = object.processor.proc_id;
538 case ACPI_TYPE_DEVICE:
539 status = acpi_evaluate_integer(handle, METHOD_NAME__UID,
541 if (ACPI_FAILURE(status))
549 if (xen_initial_domain())
551 * When running as a Xen dom0 the number of processors Linux
552 * sees can be different from the real number of processors on
553 * the system, and we still need to execute _PDC or _OSC for
556 return xen_processor_present(acpi_id);
558 type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
559 cpuid = acpi_get_cpuid(handle, type, acpi_id);
561 return !invalid_logical_cpuid(cpuid);
564 /* vendor specific UUID indicating an Intel platform */
565 static u8 sb_uuid_str[] = "4077A616-290C-47BE-9EBD-D87058713953";
567 static acpi_status __init acpi_processor_osc(acpi_handle handle, u32 lvl,
568 void *context, void **rv)
571 struct acpi_osc_context osc_context = {
572 .uuid_str = sb_uuid_str,
575 .cap.pointer = capbuf,
579 if (!processor_physically_present(handle))
582 arch_acpi_set_proc_cap_bits(&capbuf[OSC_SUPPORT_DWORD]);
584 status = acpi_run_osc(handle, &osc_context);
585 if (ACPI_FAILURE(status))
588 kfree(osc_context.ret.pointer);
593 static bool __init acpi_early_processor_osc(void)
597 acpi_proc_quirk_mwait_check();
599 status = acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
600 ACPI_UINT32_MAX, acpi_processor_osc, NULL,
602 if (ACPI_FAILURE(status))
605 status = acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_osc,
607 if (ACPI_FAILURE(status))
613 void __init acpi_early_processor_control_setup(void)
615 if (acpi_early_processor_osc()) {
616 pr_info("_OSC evaluated successfully for all CPUs\n");
618 pr_info("_OSC evaluation for CPUs failed, trying _PDC\n");
619 acpi_early_processor_set_pdc();
625 * The following ACPI IDs are known to be suitable for representing as
628 static const struct acpi_device_id processor_device_ids[] = {
630 { ACPI_PROCESSOR_OBJECT_HID, },
631 { ACPI_PROCESSOR_DEVICE_HID, },
636 static struct acpi_scan_handler processor_handler = {
637 .ids = processor_device_ids,
638 .attach = acpi_processor_add,
639 #ifdef CONFIG_ACPI_HOTPLUG_CPU
640 .detach = acpi_processor_remove,
647 static int acpi_processor_container_attach(struct acpi_device *dev,
648 const struct acpi_device_id *id)
653 static const struct acpi_device_id processor_container_ids[] = {
654 { ACPI_PROCESSOR_CONTAINER_HID, },
658 static struct acpi_scan_handler processor_container_handler = {
659 .ids = processor_container_ids,
660 .attach = acpi_processor_container_attach,
663 /* The number of the unique processor IDs */
664 static int nr_unique_ids __initdata;
666 /* The number of the duplicate processor IDs */
667 static int nr_duplicate_ids;
669 /* Used to store the unique processor IDs */
670 static int unique_processor_ids[] __initdata = {
671 [0 ... NR_CPUS - 1] = -1,
674 /* Used to store the duplicate processor IDs */
675 static int duplicate_processor_ids[] = {
676 [0 ... NR_CPUS - 1] = -1,
679 static void __init processor_validated_ids_update(int proc_id)
683 if (nr_unique_ids == NR_CPUS||nr_duplicate_ids == NR_CPUS)
687 * Firstly, compare the proc_id with duplicate IDs, if the proc_id is
688 * already in the IDs, do nothing.
690 for (i = 0; i < nr_duplicate_ids; i++) {
691 if (duplicate_processor_ids[i] == proc_id)
696 * Secondly, compare the proc_id with unique IDs, if the proc_id is in
697 * the IDs, put it in the duplicate IDs.
699 for (i = 0; i < nr_unique_ids; i++) {
700 if (unique_processor_ids[i] == proc_id) {
701 duplicate_processor_ids[nr_duplicate_ids] = proc_id;
708 * Lastly, the proc_id is a unique ID, put it in the unique IDs.
710 unique_processor_ids[nr_unique_ids] = proc_id;
714 static acpi_status __init acpi_processor_ids_walk(acpi_handle handle,
720 acpi_object_type acpi_type;
721 unsigned long long uid;
722 union acpi_object object = { 0 };
723 struct acpi_buffer buffer = { sizeof(union acpi_object), &object };
725 status = acpi_get_type(handle, &acpi_type);
726 if (ACPI_FAILURE(status))
730 case ACPI_TYPE_PROCESSOR:
731 status = acpi_evaluate_object(handle, NULL, NULL, &buffer);
732 if (ACPI_FAILURE(status))
734 uid = object.processor.proc_id;
737 case ACPI_TYPE_DEVICE:
738 status = acpi_evaluate_integer(handle, "_UID", NULL, &uid);
739 if (ACPI_FAILURE(status))
746 processor_validated_ids_update(uid);
750 /* Exit on error, but don't abort the namespace walk */
751 acpi_handle_info(handle, "Invalid processor object\n");
756 static void __init acpi_processor_check_duplicates(void)
758 /* check the correctness for all processors in ACPI namespace */
759 acpi_walk_namespace(ACPI_TYPE_PROCESSOR, ACPI_ROOT_OBJECT,
761 acpi_processor_ids_walk,
763 acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk,
767 bool acpi_duplicate_processor_id(int proc_id)
772 * compare the proc_id with duplicate IDs, if the proc_id is already
773 * in the duplicate IDs, return true, otherwise, return false.
775 for (i = 0; i < nr_duplicate_ids; i++) {
776 if (duplicate_processor_ids[i] == proc_id)
782 void __init acpi_processor_init(void)
784 acpi_processor_check_duplicates();
785 acpi_scan_add_handler_with_hotplug(&processor_handler, "processor");
786 acpi_scan_add_handler(&processor_container_handler);
787 acpi_pcc_cpufreq_init();
790 #ifdef CONFIG_ACPI_PROCESSOR_CSTATE
792 * acpi_processor_claim_cst_control - Request _CST control from the platform.
794 bool acpi_processor_claim_cst_control(void)
796 static bool cst_control_claimed;
799 if (!acpi_gbl_FADT.cst_control || cst_control_claimed)
802 status = acpi_os_write_port(acpi_gbl_FADT.smi_command,
803 acpi_gbl_FADT.cst_control, 8);
804 if (ACPI_FAILURE(status)) {
805 pr_warn("ACPI: Failed to claim processor _CST control\n");
809 cst_control_claimed = true;
812 EXPORT_SYMBOL_GPL(acpi_processor_claim_cst_control);
815 * acpi_processor_evaluate_cst - Evaluate the processor _CST control method.
816 * @handle: ACPI handle of the processor object containing the _CST.
817 * @cpu: The numeric ID of the target CPU.
818 * @info: Object write the C-states information into.
820 * Extract the C-state information for the given CPU from the output of the _CST
821 * control method under the corresponding ACPI processor object (or processor
822 * device object) and populate @info with it.
824 * If any ACPI_ADR_SPACE_FIXED_HARDWARE C-states are found, invoke
825 * acpi_processor_ffh_cstate_probe() to verify them and update the
826 * cpu_cstate_entry data for @cpu.
828 int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
829 struct acpi_processor_power *info)
831 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
832 union acpi_object *cst;
838 status = acpi_evaluate_object(handle, "_CST", NULL, &buffer);
839 if (ACPI_FAILURE(status)) {
840 acpi_handle_debug(handle, "No _CST\n");
844 cst = buffer.pointer;
846 /* There must be at least 2 elements. */
847 if (!cst || cst->type != ACPI_TYPE_PACKAGE || cst->package.count < 2) {
848 acpi_handle_warn(handle, "Invalid _CST output\n");
853 count = cst->package.elements[0].integer.value;
855 /* Validate the number of C-states. */
856 if (count < 1 || count != cst->package.count - 1) {
857 acpi_handle_warn(handle, "Inconsistent _CST data\n");
862 for (i = 1; i <= count; i++) {
863 union acpi_object *element;
864 union acpi_object *obj;
865 struct acpi_power_register *reg;
866 struct acpi_processor_cx cx;
869 * If there is not enough space for all C-states, skip the
870 * excess ones and log a warning.
872 if (last_index >= ACPI_PROCESSOR_MAX_POWER - 1) {
873 acpi_handle_warn(handle,
874 "No room for more idle states (limit: %d)\n",
875 ACPI_PROCESSOR_MAX_POWER - 1);
879 memset(&cx, 0, sizeof(cx));
881 element = &cst->package.elements[i];
882 if (element->type != ACPI_TYPE_PACKAGE) {
883 acpi_handle_info(handle, "_CST C%d type(%x) is not package, skip...\n",
888 if (element->package.count != 4) {
889 acpi_handle_info(handle, "_CST C%d package count(%d) is not 4, skip...\n",
890 i, element->package.count);
894 obj = &element->package.elements[0];
896 if (obj->type != ACPI_TYPE_BUFFER) {
897 acpi_handle_info(handle, "_CST C%d package element[0] type(%x) is not buffer, skip...\n",
902 reg = (struct acpi_power_register *)obj->buffer.pointer;
904 obj = &element->package.elements[1];
905 if (obj->type != ACPI_TYPE_INTEGER) {
906 acpi_handle_info(handle, "_CST C[%d] package element[1] type(%x) is not integer, skip...\n",
911 cx.type = obj->integer.value;
913 * There are known cases in which the _CST output does not
914 * contain C1, so if the type of the first state found is not
915 * C1, leave an empty slot for C1 to be filled in later.
917 if (i == 1 && cx.type != ACPI_STATE_C1)
920 cx.address = reg->address;
921 cx.index = last_index + 1;
923 if (reg->space_id == ACPI_ADR_SPACE_FIXED_HARDWARE) {
924 if (!acpi_processor_ffh_cstate_probe(cpu, &cx, reg)) {
926 * In the majority of cases _CST describes C1 as
927 * a FIXED_HARDWARE C-state, but if the command
928 * line forbids using MWAIT, use CSTATE_HALT for
931 if (cx.type == ACPI_STATE_C1 &&
932 boot_option_idle_override == IDLE_NOMWAIT) {
933 cx.entry_method = ACPI_CSTATE_HALT;
934 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
936 cx.entry_method = ACPI_CSTATE_FFH;
938 } else if (cx.type == ACPI_STATE_C1) {
940 * In the special case of C1, FIXED_HARDWARE can
941 * be handled by executing the HLT instruction.
943 cx.entry_method = ACPI_CSTATE_HALT;
944 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI HLT");
946 acpi_handle_info(handle, "_CST C%d declares FIXED_HARDWARE C-state but not supported in hardware, skip...\n",
950 } else if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_IO) {
951 cx.entry_method = ACPI_CSTATE_SYSTEMIO;
952 snprintf(cx.desc, ACPI_CX_DESC_LEN, "ACPI IOPORT 0x%x",
955 acpi_handle_info(handle, "_CST C%d space_id(%x) neither FIXED_HARDWARE nor SYSTEM_IO, skip...\n",
960 if (cx.type == ACPI_STATE_C1)
963 obj = &element->package.elements[2];
964 if (obj->type != ACPI_TYPE_INTEGER) {
965 acpi_handle_info(handle, "_CST C%d package element[2] type(%x) not integer, skip...\n",
970 cx.latency = obj->integer.value;
972 obj = &element->package.elements[3];
973 if (obj->type != ACPI_TYPE_INTEGER) {
974 acpi_handle_info(handle, "_CST C%d package element[3] type(%x) not integer, skip...\n",
979 memcpy(&info->states[++last_index], &cx, sizeof(cx));
982 acpi_handle_info(handle, "Found %d idle states\n", last_index);
984 info->count = last_index;
987 kfree(buffer.pointer);
991 EXPORT_SYMBOL_GPL(acpi_processor_evaluate_cst);
992 #endif /* CONFIG_ACPI_PROCESSOR_CSTATE */