linux/drivers/acpi
Kuan-Wei Chiu 233323f9b9 ACPI: processor_idle: Fix invalid comparison with insertion sort for latency
The acpi_cst_latency_cmp() comparison function currently used for
sorting C-state latencies does not satisfy transitivity, causing
incorrect sorting results.

Specifically, if there are two valid acpi_processor_cx elements A and B
and one invalid element C, it may occur that A < B, A = C, and B = C.
Sorting algorithms assume that if A < B and A = C, then C < B, leading
to incorrect ordering.

Given the small size of the array (<=8), we replace the library sort
function with a simple insertion sort that properly ignores invalid
elements and sorts valid ones based on latency. This change ensures
correct ordering of the C-state latencies.

Fixes: 65ea8f2c6e ("ACPI: processor idle: Fix up C-state latency if not ordered")
Reported-by: Julian Sikorski <belegdol@gmail.com>
Closes: https://lore.kernel.org/lkml/70674dc7-5586-4183-8953-8095567e73df@gmail.com
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Tested-by: Julian Sikorski <belegdol@gmail.com>
Cc: All applicable <stable@vger.kernel.org>
Link: https://patch.msgid.link/20240701205639.117194-1-visitorckw@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2024-07-02 20:35:29 +02:00
..
acpica ACPICA: Revert "ACPICA: avoid Info: mapping multiple BARs. Your kernel is fine." 2024-06-17 21:13:25 +02:00
apei Merge branches 'acpi-ec', 'acpi-apei' and 'pnp' 2024-06-05 16:58:09 +02:00
arm64 Char/Misc and other driver subsystem changes for 6.10-rc1 2024-05-22 12:26:46 -07:00
dptf
nfit
numa
pmic
riscv
x86 ACPI: x86: Force StorageD3Enable on more products 2024-06-07 20:24:07 +02:00
Kconfig
Makefile
ac.c ACPI: AC: Properly notify powermanagement core about changes 2024-05-28 21:56:40 +02:00
acpi_adxl.c
acpi_apd.c
acpi_configfs.c
acpi_dbg.c
acpi_extlog.c
acpi_ffh.c
acpi_fpdt.c
acpi_ipmi.c
acpi_lpat.c
acpi_lpit.c
acpi_memhotplug.c
acpi_pad.c
acpi_pcc.c
acpi_platform.c
acpi_pnp.c
acpi_processor.c
acpi_tad.c
acpi_video.c
acpi_watchdog.c
battery.c
bgrt.c
bus.c
button.c
container.c
cppc_acpi.c
debugfs.c
device_pm.c
device_sysfs.c
dock.c
ec.c ACPI: EC: Evaluate orphan _REG under EC device 2024-06-13 11:28:54 +02:00
ec_sys.c
event.c
evged.c
fan.h
fan_attr.c
fan_core.c
glue.c
hed.c
internal.h ACPI: scan: Ignore camera graph port nodes on all Dell Tiger, Alder and Raptor Lake models 2024-06-17 21:34:15 +02:00
ioapic.c
irq.c
mipi-disco-img.c ACPI: mipi-disco-img: Switch to new Intel CPU model defines 2024-06-17 21:37:57 +02:00
nhlt.c
nvs.c
osi.c
osl.c
pci_irq.c
pci_link.c
pci_mcfg.c
pci_root.c
pci_slot.c
pfr_telemetry.c
pfr_update.c
platform_profile.c
power.c
pptt.c
prmt.c
proc.c
processor_core.c
processor_driver.c
processor_idle.c ACPI: processor_idle: Fix invalid comparison with insertion sort for latency 2024-07-02 20:35:29 +02:00
processor_pdc.c
processor_perflib.c
processor_thermal.c
processor_throttling.c
property.c
reboot.c
resource.c
sbs.c ACPI: AC: Properly notify powermanagement core about changes 2024-05-28 21:56:40 +02:00
sbshc.c
sbshc.h
scan.c IOMMU Updates for Linux v6.10 2024-05-18 10:55:13 -07:00
sleep.c
sleep.h
spcr.c
sysfs.c
tables.c
thermal.c thermal: ACPI: Invalidate trip points with temperature of 0 or below 2024-06-07 13:52:17 +02:00
thermal_lib.c
tiny-power-button.c
utils.c
video_detect.c
viot.c
wakeup.c