2 * processor_throttling.c - Throttling submodule of the ACPI processor driver
4 * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com>
5 * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com>
6 * Copyright (C) 2004 Dominik Brodowski <linux@brodo.de>
7 * Copyright (C) 2004 Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
8 * - Added processor hotplug support
10 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
29 #include <linux/kernel.h>
30 #include <linux/module.h>
31 #include <linux/init.h>
32 #include <linux/sched.h>
33 #include <linux/cpufreq.h>
34 #include <linux/proc_fs.h>
35 #include <linux/seq_file.h>
38 #include <asm/uaccess.h>
40 #include <acpi/acpi_bus.h>
41 #include <acpi/processor.h>
43 #define ACPI_PROCESSOR_COMPONENT 0x01000000
44 #define ACPI_PROCESSOR_CLASS "processor"
45 #define _COMPONENT ACPI_PROCESSOR_COMPONENT
46 ACPI_MODULE_NAME("processor_throttling");
48 static int acpi_processor_get_throttling(struct acpi_processor *pr);
49 int acpi_processor_set_throttling(struct acpi_processor *pr, int state);
51 static int acpi_processor_update_tsd_coord(void)
53 int count, count_target;
56 cpumask_t covered_cpus;
57 struct acpi_processor *pr, *match_pr;
58 struct acpi_tsd_package *pdomain, *match_pdomain;
59 struct acpi_processor_throttling *pthrottling, *match_pthrottling;
62 * Now that we have _TSD data from all CPUs, lets setup T-state
63 * coordination among all CPUs.
65 for_each_possible_cpu(i) {
70 /* Basic validity check for domain info */
71 pthrottling = &(pr->throttling);
74 * If tsd package for one cpu is invalid, the coordination
75 * among all CPUs is thought as invalid.
78 if (!pthrottling->tsd_valid_flag) {
86 cpus_clear(covered_cpus);
87 for_each_possible_cpu(i) {
92 if (cpu_isset(i, covered_cpus))
94 pthrottling = &pr->throttling;
96 pdomain = &(pthrottling->domain_info);
97 cpu_set(i, pthrottling->shared_cpu_map);
98 cpu_set(i, covered_cpus);
100 * If the number of processor in the TSD domain is 1, it is
101 * unnecessary to parse the coordination for this CPU.
103 if (pdomain->num_processors <= 1)
106 /* Validate the Domain info */
107 count_target = pdomain->num_processors;
110 for_each_possible_cpu(j) {
114 match_pr = processors[j];
118 match_pthrottling = &(match_pr->throttling);
119 match_pdomain = &(match_pthrottling->domain_info);
120 if (match_pdomain->domain != pdomain->domain)
123 /* Here i and j are in the same domain.
124 * If two TSD packages have the same domain, they
125 * should have the same num_porcessors and
126 * coordination type. Otherwise it will be regarded
129 if (match_pdomain->num_processors != count_target) {
134 if (pdomain->coord_type != match_pdomain->coord_type) {
139 cpu_set(j, covered_cpus);
140 cpu_set(j, pthrottling->shared_cpu_map);
143 for_each_possible_cpu(j) {
147 match_pr = processors[j];
151 match_pthrottling = &(match_pr->throttling);
152 match_pdomain = &(match_pthrottling->domain_info);
153 if (match_pdomain->domain != pdomain->domain)
157 * If some CPUS have the same domain, they
158 * will have the same shared_cpu_map.
160 match_pthrottling->shared_cpu_map =
161 pthrottling->shared_cpu_map;
166 for_each_possible_cpu(i) {
172 * Assume no coordination on any error parsing domain info.
173 * The coordination type will be forced as SW_ALL.
176 pthrottling = &(pr->throttling);
177 cpus_clear(pthrottling->shared_cpu_map);
178 cpu_set(i, pthrottling->shared_cpu_map);
179 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
187 * Update the T-state coordination after the _TSD
188 * data for all cpus is obtained.
190 void acpi_processor_throttling_init(void)
192 if (acpi_processor_update_tsd_coord())
193 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
194 "Assume no T-state coordination\n"));
200 * _TPC - Throttling Present Capabilities
202 static int acpi_processor_get_platform_limit(struct acpi_processor *pr)
204 acpi_status status = 0;
205 unsigned long tpc = 0;
209 status = acpi_evaluate_integer(pr->handle, "_TPC", NULL, &tpc);
210 if (ACPI_FAILURE(status)) {
211 if (status != AE_NOT_FOUND) {
212 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TPC"));
216 pr->throttling_platform_limit = (int)tpc;
220 int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
223 int throttling_limit;
225 struct acpi_processor_limit *limit;
228 result = acpi_processor_get_platform_limit(pr);
230 /* Throttling Limit is unsupported */
234 throttling_limit = pr->throttling_platform_limit;
235 if (throttling_limit >= pr->throttling.state_count) {
236 /* Uncorrect Throttling Limit */
240 current_state = pr->throttling.state;
241 if (current_state > throttling_limit) {
243 * The current state can meet the requirement of
244 * _TPC limit. But it is reasonable that OSPM changes
245 * t-states from high to low for better performance.
246 * Of course the limit condition of thermal
247 * and user should be considered.
250 target_state = throttling_limit;
251 if (limit->thermal.tx > target_state)
252 target_state = limit->thermal.tx;
253 if (limit->user.tx > target_state)
254 target_state = limit->user.tx;
255 } else if (current_state == throttling_limit) {
257 * Unnecessary to change the throttling state
262 * If the current state is lower than the limit of _TPC, it
263 * will be forced to switch to the throttling state defined
264 * by throttling_platfor_limit.
265 * Because the previous state meets with the limit condition
266 * of thermal and user, it is unnecessary to check it again.
268 target_state = throttling_limit;
270 return acpi_processor_set_throttling(pr, target_state);
274 * _PTC - Processor Throttling Control (and status) register location
276 static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
279 acpi_status status = 0;
280 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
281 union acpi_object *ptc = NULL;
282 union acpi_object obj = { 0 };
283 struct acpi_processor_throttling *throttling;
285 status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
286 if (ACPI_FAILURE(status)) {
287 if (status != AE_NOT_FOUND) {
288 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _PTC"));
293 ptc = (union acpi_object *)buffer.pointer;
294 if (!ptc || (ptc->type != ACPI_TYPE_PACKAGE)
295 || (ptc->package.count != 2)) {
296 printk(KERN_ERR PREFIX "Invalid _PTC data\n");
305 obj = ptc->package.elements[0];
307 if ((obj.type != ACPI_TYPE_BUFFER)
308 || (obj.buffer.length < sizeof(struct acpi_ptc_register))
309 || (obj.buffer.pointer == NULL)) {
310 printk(KERN_ERR PREFIX
311 "Invalid _PTC data (control_register)\n");
315 memcpy(&pr->throttling.control_register, obj.buffer.pointer,
316 sizeof(struct acpi_ptc_register));
322 obj = ptc->package.elements[1];
324 if ((obj.type != ACPI_TYPE_BUFFER)
325 || (obj.buffer.length < sizeof(struct acpi_ptc_register))
326 || (obj.buffer.pointer == NULL)) {
327 printk(KERN_ERR PREFIX "Invalid _PTC data (status_register)\n");
332 memcpy(&pr->throttling.status_register, obj.buffer.pointer,
333 sizeof(struct acpi_ptc_register));
335 throttling = &pr->throttling;
337 if ((throttling->control_register.bit_width +
338 throttling->control_register.bit_offset) > 32) {
339 printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
344 if ((throttling->status_register.bit_width +
345 throttling->status_register.bit_offset) > 32) {
346 printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
352 kfree(buffer.pointer);
358 * _TSS - Throttling Supported States
360 static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
363 acpi_status status = AE_OK;
364 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
365 struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
366 struct acpi_buffer state = { 0, NULL };
367 union acpi_object *tss = NULL;
370 status = acpi_evaluate_object(pr->handle, "_TSS", NULL, &buffer);
371 if (ACPI_FAILURE(status)) {
372 if (status != AE_NOT_FOUND) {
373 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSS"));
378 tss = buffer.pointer;
379 if (!tss || (tss->type != ACPI_TYPE_PACKAGE)) {
380 printk(KERN_ERR PREFIX "Invalid _TSS data\n");
385 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
386 tss->package.count));
388 pr->throttling.state_count = tss->package.count;
389 pr->throttling.states_tss =
390 kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
392 if (!pr->throttling.states_tss) {
397 for (i = 0; i < pr->throttling.state_count; i++) {
399 struct acpi_processor_tx_tss *tx =
400 (struct acpi_processor_tx_tss *)&(pr->throttling.
403 state.length = sizeof(struct acpi_processor_tx_tss);
406 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Extracting state %d\n", i));
408 status = acpi_extract_package(&(tss->package.elements[i]),
410 if (ACPI_FAILURE(status)) {
411 ACPI_EXCEPTION((AE_INFO, status, "Invalid _TSS data"));
413 kfree(pr->throttling.states_tss);
417 if (!tx->freqpercentage) {
418 printk(KERN_ERR PREFIX
419 "Invalid _TSS data: freq is zero\n");
421 kfree(pr->throttling.states_tss);
427 kfree(buffer.pointer);
433 * _TSD - T-State Dependencies
435 static int acpi_processor_get_tsd(struct acpi_processor *pr)
438 acpi_status status = AE_OK;
439 struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
440 struct acpi_buffer format = { sizeof("NNNNN"), "NNNNN" };
441 struct acpi_buffer state = { 0, NULL };
442 union acpi_object *tsd = NULL;
443 struct acpi_tsd_package *pdomain;
444 struct acpi_processor_throttling *pthrottling;
446 pthrottling = &pr->throttling;
447 pthrottling->tsd_valid_flag = 0;
449 status = acpi_evaluate_object(pr->handle, "_TSD", NULL, &buffer);
450 if (ACPI_FAILURE(status)) {
451 if (status != AE_NOT_FOUND) {
452 ACPI_EXCEPTION((AE_INFO, status, "Evaluating _TSD"));
457 tsd = buffer.pointer;
458 if (!tsd || (tsd->type != ACPI_TYPE_PACKAGE)) {
459 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
464 if (tsd->package.count != 1) {
465 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
470 pdomain = &(pr->throttling.domain_info);
472 state.length = sizeof(struct acpi_tsd_package);
473 state.pointer = pdomain;
475 status = acpi_extract_package(&(tsd->package.elements[0]),
477 if (ACPI_FAILURE(status)) {
478 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid _TSD data\n"));
483 if (pdomain->num_entries != ACPI_TSD_REV0_ENTRIES) {
484 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:num_entries\n"));
489 if (pdomain->revision != ACPI_TSD_REV0_REVISION) {
490 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Unknown _TSD:revision\n"));
495 pthrottling = &pr->throttling;
496 pthrottling->tsd_valid_flag = 1;
497 pthrottling->shared_type = pdomain->coord_type;
498 cpu_set(pr->id, pthrottling->shared_cpu_map);
500 * If the coordination type is not defined in ACPI spec,
501 * the tsd_valid_flag will be clear and coordination type
502 * will be forecd as DOMAIN_COORD_TYPE_SW_ALL.
504 if (pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ALL &&
505 pdomain->coord_type != DOMAIN_COORD_TYPE_SW_ANY &&
506 pdomain->coord_type != DOMAIN_COORD_TYPE_HW_ALL) {
507 pthrottling->tsd_valid_flag = 0;
508 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
512 kfree(buffer.pointer);
516 /* --------------------------------------------------------------------------
518 -------------------------------------------------------------------------- */
519 static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
529 if (!pr->flags.throttling)
532 pr->throttling.state = 0;
534 duty_mask = pr->throttling.state_count - 1;
536 duty_mask <<= pr->throttling.duty_offset;
540 value = inl(pr->throttling.address);
543 * Compute the current throttling state when throttling is enabled
547 duty_value = value & duty_mask;
548 duty_value >>= pr->throttling.duty_offset;
551 state = pr->throttling.state_count - duty_value;
554 pr->throttling.state = state;
558 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
559 "Throttling state is T%d (%d%% throttling applied)\n",
560 state, pr->throttling.states[state].performance));
566 static int acpi_throttling_rdmsr(struct acpi_processor *pr,
567 acpi_integer * value)
569 struct cpuinfo_x86 *c;
570 u64 msr_high, msr_low;
578 if ((c->x86_vendor != X86_VENDOR_INTEL) ||
579 !cpu_has(c, X86_FEATURE_ACPI)) {
580 printk(KERN_ERR PREFIX
581 "HARDWARE addr space,NOT supported yet\n");
585 rdmsr_safe(MSR_IA32_THERM_CONTROL,
586 (u32 *)&msr_low , (u32 *) &msr_high);
587 msr = (msr_high << 32) | msr_low;
588 *value = (acpi_integer) msr;
594 static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
596 struct cpuinfo_x86 *c;
604 if ((c->x86_vendor != X86_VENDOR_INTEL) ||
605 !cpu_has(c, X86_FEATURE_ACPI)) {
606 printk(KERN_ERR PREFIX
607 "HARDWARE addr space,NOT supported yet\n");
610 wrmsr_safe(MSR_IA32_THERM_CONTROL,
611 msr & 0xffffffff, msr >> 32);
617 static int acpi_throttling_rdmsr(struct acpi_processor *pr,
618 acpi_integer * value)
620 printk(KERN_ERR PREFIX
621 "HARDWARE addr space,NOT supported yet\n");
625 static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
627 printk(KERN_ERR PREFIX
628 "HARDWARE addr space,NOT supported yet\n");
633 static int acpi_read_throttling_status(struct acpi_processor *pr,
636 u32 bit_width, bit_offset;
639 struct acpi_processor_throttling *throttling;
642 throttling = &pr->throttling;
643 switch (throttling->status_register.space_id) {
644 case ACPI_ADR_SPACE_SYSTEM_IO:
646 bit_width = throttling->status_register.bit_width;
647 bit_offset = throttling->status_register.bit_offset;
649 acpi_os_read_port((acpi_io_address) throttling->status_register.
650 address, (u32 *) &ptc_value,
651 (u32) (bit_width + bit_offset));
652 ptc_mask = (1 << bit_width) - 1;
653 *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask);
656 case ACPI_ADR_SPACE_FIXED_HARDWARE:
657 ret = acpi_throttling_rdmsr(pr, value);
660 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
661 (u32) (throttling->status_register.space_id));
666 static int acpi_write_throttling_state(struct acpi_processor *pr,
669 u32 bit_width, bit_offset;
672 struct acpi_processor_throttling *throttling;
675 throttling = &pr->throttling;
676 switch (throttling->control_register.space_id) {
677 case ACPI_ADR_SPACE_SYSTEM_IO:
678 bit_width = throttling->control_register.bit_width;
679 bit_offset = throttling->control_register.bit_offset;
680 ptc_mask = (1 << bit_width) - 1;
681 ptc_value = value & ptc_mask;
683 acpi_os_write_port((acpi_io_address) throttling->
684 control_register.address,
685 (u32) (ptc_value << bit_offset),
686 (u32) (bit_width + bit_offset));
689 case ACPI_ADR_SPACE_FIXED_HARDWARE:
690 ret = acpi_throttling_wrmsr(pr, value);
693 printk(KERN_ERR PREFIX "Unknown addr space %d\n",
694 (u32) (throttling->control_register.space_id));
699 static int acpi_get_throttling_state(struct acpi_processor *pr,
704 for (i = 0; i < pr->throttling.state_count; i++) {
705 struct acpi_processor_tx_tss *tx =
706 (struct acpi_processor_tx_tss *)&(pr->throttling.
708 if (tx->control == value)
711 if (i > pr->throttling.state_count)
716 static int acpi_get_throttling_value(struct acpi_processor *pr,
717 int state, acpi_integer *value)
721 if (state >= 0 && state <= pr->throttling.state_count) {
722 struct acpi_processor_tx_tss *tx =
723 (struct acpi_processor_tx_tss *)&(pr->throttling.
725 *value = tx->control;
731 static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
740 if (!pr->flags.throttling)
743 pr->throttling.state = 0;
746 ret = acpi_read_throttling_status(pr, &value);
748 state = acpi_get_throttling_state(pr, value);
749 pr->throttling.state = state;
755 static int acpi_processor_get_throttling(struct acpi_processor *pr)
757 cpumask_t saved_mask;
763 if (!pr->flags.throttling)
766 * Migrate task to the cpu pointed by pr.
768 saved_mask = current->cpus_allowed;
769 set_cpus_allowed(current, cpumask_of_cpu(pr->id));
770 ret = pr->throttling.acpi_processor_get_throttling(pr);
771 /* restore the previous state */
772 set_cpus_allowed(current, saved_mask);
777 static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
781 if (!pr->throttling.address) {
782 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
784 } else if (!pr->throttling.duty_width) {
785 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
788 /* TBD: Support duty_cycle values that span bit 4. */
789 else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
790 printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
794 pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
797 * Compute state values. Note that throttling displays a linear power
798 * performance relationship (at 50% performance the CPU will consume
799 * 50% power). Values are in 1/10th of a percent to preserve accuracy.
802 step = (1000 / pr->throttling.state_count);
804 for (i = 0; i < pr->throttling.state_count; i++) {
805 pr->throttling.states[i].performance = 1000 - step * i;
806 pr->throttling.states[i].power = 1000 - step * i;
811 static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
821 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
824 if (!pr->flags.throttling)
827 if (state == pr->throttling.state)
830 if (state < pr->throttling_platform_limit)
833 * Calculate the duty_value and duty_mask.
836 duty_value = pr->throttling.state_count - state;
838 duty_value <<= pr->throttling.duty_offset;
840 /* Used to clear all duty_value bits */
841 duty_mask = pr->throttling.state_count - 1;
843 duty_mask <<= acpi_gbl_FADT.duty_offset;
844 duty_mask = ~duty_mask;
850 * Disable throttling by writing a 0 to bit 4. Note that we must
851 * turn it off before you can change the duty_value.
853 value = inl(pr->throttling.address);
856 outl(value, pr->throttling.address);
860 * Write the new duty_value and then enable throttling. Note
861 * that a state value of 0 leaves throttling disabled.
866 outl(value, pr->throttling.address);
869 outl(value, pr->throttling.address);
872 pr->throttling.state = state;
876 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
877 "Throttling state set to T%d (%d%%)\n", state,
878 (pr->throttling.states[state].performance ? pr->
879 throttling.states[state].performance / 10 : 0)));
884 static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
893 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
896 if (!pr->flags.throttling)
899 if (state == pr->throttling.state)
902 if (state < pr->throttling_platform_limit)
906 ret = acpi_get_throttling_value(pr, state, &value);
908 acpi_write_throttling_state(pr, value);
909 pr->throttling.state = state;
915 int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
917 cpumask_t saved_mask;
923 if (!pr->flags.throttling)
926 if ((state < 0) || (state > (pr->throttling.state_count - 1)))
930 * Migrate task to the cpu pointed by pr.
932 saved_mask = current->cpus_allowed;
933 set_cpus_allowed(current, cpumask_of_cpu(pr->id));
934 ret = pr->throttling.acpi_processor_set_throttling(pr, state);
935 /* restore the previous state */
936 set_cpus_allowed(current, saved_mask);
940 int acpi_processor_get_throttling_info(struct acpi_processor *pr)
943 struct acpi_processor_throttling *pthrottling;
945 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
946 "pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
947 pr->throttling.address,
948 pr->throttling.duty_offset,
949 pr->throttling.duty_width));
955 * Evaluate _PTC, _TSS and _TPC
956 * They must all be present or none of them can be used.
958 if (acpi_processor_get_throttling_control(pr) ||
959 acpi_processor_get_throttling_states(pr) ||
960 acpi_processor_get_platform_limit(pr))
962 pr->throttling.acpi_processor_get_throttling =
963 &acpi_processor_get_throttling_fadt;
964 pr->throttling.acpi_processor_set_throttling =
965 &acpi_processor_set_throttling_fadt;
966 if (acpi_processor_get_fadt_info(pr))
969 pr->throttling.acpi_processor_get_throttling =
970 &acpi_processor_get_throttling_ptc;
971 pr->throttling.acpi_processor_set_throttling =
972 &acpi_processor_set_throttling_ptc;
976 * If TSD package for one CPU can't be parsed successfully, it means
977 * that this CPU will have no coordination with other CPUs.
979 if (acpi_processor_get_tsd(pr)) {
980 pthrottling = &pr->throttling;
981 pthrottling->tsd_valid_flag = 0;
982 cpu_set(pr->id, pthrottling->shared_cpu_map);
983 pthrottling->shared_type = DOMAIN_COORD_TYPE_SW_ALL;
987 * PIIX4 Errata: We don't support throttling on the original PIIX4.
988 * This shouldn't be an issue as few (if any) mobile systems ever
991 if (errata.piix4.throttle) {
992 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
993 "Throttling not supported on PIIX4 A- or B-step\n"));
997 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
998 pr->throttling.state_count));
1000 pr->flags.throttling = 1;
1003 * Disable throttling (if enabled). We'll let subsequent policy (e.g.
1004 * thermal) decide to lower performance if it so chooses, but for now
1005 * we'll crank up the speed.
1008 result = acpi_processor_get_throttling(pr);
1012 if (pr->throttling.state) {
1013 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
1014 "Disabling throttling (was T%d)\n",
1015 pr->throttling.state));
1016 result = acpi_processor_set_throttling(pr, 0);
1023 pr->flags.throttling = 0;
1028 /* proc interface */
1030 static int acpi_processor_throttling_seq_show(struct seq_file *seq,
1033 struct acpi_processor *pr = seq->private;
1040 if (!(pr->throttling.state_count > 0)) {
1041 seq_puts(seq, "<not supported>\n");
1045 result = acpi_processor_get_throttling(pr);
1049 "Could not determine current throttling state.\n");
1053 seq_printf(seq, "state count: %d\n"
1054 "active state: T%d\n"
1055 "state available: T%d to T%d\n",
1056 pr->throttling.state_count, pr->throttling.state,
1057 pr->throttling_platform_limit,
1058 pr->throttling.state_count - 1);
1060 seq_puts(seq, "states:\n");
1061 if (pr->throttling.acpi_processor_get_throttling ==
1062 acpi_processor_get_throttling_fadt) {
1063 for (i = 0; i < pr->throttling.state_count; i++)
1064 seq_printf(seq, " %cT%d: %02d%%\n",
1065 (i == pr->throttling.state ? '*' : ' '), i,
1066 (pr->throttling.states[i].performance ? pr->
1067 throttling.states[i].performance / 10 : 0));
1069 for (i = 0; i < pr->throttling.state_count; i++)
1070 seq_printf(seq, " %cT%d: %02d%%\n",
1071 (i == pr->throttling.state ? '*' : ' '), i,
1072 (int)pr->throttling.states_tss[i].
1080 static int acpi_processor_throttling_open_fs(struct inode *inode,
1083 return single_open(file, acpi_processor_throttling_seq_show,
1087 static ssize_t acpi_processor_write_throttling(struct file *file,
1088 const char __user * buffer,
1089 size_t count, loff_t * data)
1092 struct seq_file *m = file->private_data;
1093 struct acpi_processor *pr = m->private;
1094 char state_string[12] = { '\0' };
1096 if (!pr || (count > sizeof(state_string) - 1))
1099 if (copy_from_user(state_string, buffer, count))
1102 state_string[count] = '\0';
1104 result = acpi_processor_set_throttling(pr,
1105 simple_strtoul(state_string,
1113 struct file_operations acpi_processor_throttling_fops = {
1114 .open = acpi_processor_throttling_open_fs,
1116 .write = acpi_processor_write_throttling,
1117 .llseek = seq_lseek,
1118 .release = single_release,