Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'acpi-6.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI fix from Rafael Wysocki:
"Fix the sorting of _CST output data in the ACPI processor idle driver
(Kuan-Wei Chiu)"

* tag 'acpi-6.10-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
ACPI: processor_idle: Fix invalid comparison with insertion sort for latency

+16 -21
+16 -21
drivers/acpi/processor_idle.c
··· 16 16 #include <linux/acpi.h> 17 17 #include <linux/dmi.h> 18 18 #include <linux/sched.h> /* need_resched() */ 19 - #include <linux/sort.h> 20 19 #include <linux/tick.h> 21 20 #include <linux/cpuidle.h> 22 21 #include <linux/cpu.h> ··· 385 386 acpi_write_bit_register(ACPI_BITREG_BUS_MASTER_RLD, 1); 386 387 } 387 388 388 - static int acpi_cst_latency_cmp(const void *a, const void *b) 389 + static void acpi_cst_latency_sort(struct acpi_processor_cx *states, size_t length) 389 390 { 390 - const struct acpi_processor_cx *x = a, *y = b; 391 + int i, j, k; 391 392 392 - if (!(x->valid && y->valid)) 393 - return 0; 394 - if (x->latency > y->latency) 395 - return 1; 396 - if (x->latency < y->latency) 397 - return -1; 398 - return 0; 399 - } 400 - static void acpi_cst_latency_swap(void *a, void *b, int n) 401 - { 402 - struct acpi_processor_cx *x = a, *y = b; 393 + for (i = 1; i < length; i++) { 394 + if (!states[i].valid) 395 + continue; 403 396 404 - if (!(x->valid && y->valid)) 405 - return; 406 - swap(x->latency, y->latency); 397 + for (j = i - 1, k = i; j >= 0; j--) { 398 + if (!states[j].valid) 399 + continue; 400 + 401 + if (states[j].latency > states[k].latency) 402 + swap(states[j].latency, states[k].latency); 403 + 404 + k = j; 405 + } 406 + } 407 407 } 408 408 409 409 static int acpi_processor_power_verify(struct acpi_processor *pr) ··· 447 449 448 450 if (buggy_latency) { 449 451 pr_notice("FW issue: working around C-state latencies out of order\n"); 450 - sort(&pr->power.states[1], max_cstate, 451 - sizeof(struct acpi_processor_cx), 452 - acpi_cst_latency_cmp, 453 - acpi_cst_latency_swap); 452 + acpi_cst_latency_sort(&pr->power.states[1], max_cstate); 454 453 } 455 454 456 455 lapic_timer_propagate_broadcast(pr);