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 ACPI: DPTF: Add Lunar Lake support 2024-04-08 16:10:27 +02:00
nfit ACPI: NFIT: Switch to use acpi_evaluate_dsm_typed() 2024-02-02 17:31:50 +01:00
numa ACPI/NUMA: Squash acpi_numa_memory_affinity_init() into acpi_parse_memory_affinity() 2024-05-07 13:47:15 +02:00
pmic
riscv ACPI: RISC-V: Add CPPC driver 2024-03-19 18:30:54 -07:00
x86 ACPI: x86: Force StorageD3Enable on more products 2024-06-07 20:24:07 +02:00
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: processor: Check for null return of devm_kzalloc() in fch_misc_setup() 2023-03-20 18:04:58 +01:00
acpi_configfs.c
acpi_dbg.c
acpi_extlog.c ACPI: extlog: Clear Extended Error Log status when RAS_CEC handled the error 2023-12-13 13:50:00 +01:00
acpi_ffh.c ACPI: FFH: Drop the inclusion of linux/arm-smccc.h 2023-06-12 19:28:20 +02:00
acpi_fpdt.c ACPI: FPDT: properly handle invalid FPDT subtables 2023-10-03 21:12:22 +02:00
acpi_ipmi.c ACPI: IPMI: Add helper to wait for when SMI is selected 2024-04-28 10:07:34 -07:00
acpi_lpat.c
acpi_lpit.c ACPI: LPIT: Avoid u32 multiplication overflow 2023-11-22 20:55:20 +01:00
acpi_memhotplug.c mm/memory_hotplug: allow memmap on memory hotplug request to fallback 2023-08-21 13:37:48 -07:00
acpi_pad.c Many singleton patches against the MM code. The patch series which are 2023-11-02 19:38:47 -10:00
acpi_pcc.c
acpi_platform.c ACPI: platform: Move SMB0001 HID to the header and reuse 2023-07-04 19:28:20 +02:00
acpi_pnp.c
acpi_processor.c Merge branches 'acpi-x86', 'acpi-video', 'acpi-apei' and 'acpi-misc' 2024-03-11 14:42:30 +01:00
acpi_tad.c ACPI: TAD: Convert to platform remove callback returning void 2024-02-27 15:57:33 +01:00
acpi_video.c ACPI: video: Handle fetching EDID that is longer than 256 bytes 2024-02-08 14:03:47 +01:00
acpi_watchdog.c ACPI: use %pe for better readability of errors while printing 2024-02-16 19:31:12 +01:00
battery.c ACPI: bus: Add context argument to acpi_dev_install_notify_handler() 2023-10-06 17:32:51 +02:00
bgrt.c treewide: Use sysfs_bin_attr_simple_read() helper 2024-04-11 16:02:25 +02:00
bus.c Merge branches 'acpi-scan' and 'acpi-tables' 2024-05-13 19:31:06 +02:00
button.c ACPI: button: trigger wakeup key events 2023-12-29 18:47:49 +01:00
container.c
cppc_acpi.c Merge branch 'pm-cpufreq' 2024-05-13 20:13:48 +02:00
debugfs.c
device_pm.c ACPI: PM: Add acpi_device_fix_up_power_children() function 2023-11-20 17:31:49 +01:00
device_sysfs.c Merge branches 'acpi-ec', 'acpi-sysfs', 'acpi-misc' and 'acpi-uid' 2023-10-26 14:59:52 +02:00
dock.c ACPI: scan: Introduce typedef:s for struct acpi_hotplug_context members 2024-04-04 21:19:02 +02:00
ec_sys.c
ec.c ACPI: EC: Evaluate orphan _REG under EC device 2024-06-13 11:28:54 +02:00
event.c
evged.c ACPI: GED: Convert to platform remove callback returning void 2024-02-27 15:57:33 +01:00
fan_attr.c
fan_core.c ACPI: fan: Convert to platform remove callback returning void 2024-02-27 15:57:34 +01:00
fan.h ACPI: DPTF: Add Lunar Lake support 2024-04-08 16:10:27 +02:00
glue.c
hed.c ACPI: bus: Add context argument to acpi_dev_install_notify_handler() 2023-10-06 17:32:51 +02:00
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 ACPI: irq: Fix incorrect return value in acpi_register_gsi() 2023-10-18 13:11:04 +02:00
Kconfig ACPI: NHLT: Introduce API for the table 2024-03-27 16:36:45 +01:00
Makefile Merge branches 'acpi-x86', 'acpi-dptf' and 'acpi-apei' 2024-05-13 20:58:14 +02:00
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 ACPI: NHLT: Streamline struct naming 2024-03-27 16:36:45 +01:00
nvs.c
osi.c ACPI: OSI: refactor deprecated strncpy() 2023-09-21 20:55:43 +02:00
osl.c ACPI: OSL: Use spin locks without disabling interrupts 2023-12-28 14:13:52 +01:00
pci_irq.c
pci_link.c
pci_mcfg.c
pci_root.c ACPI: PCI: Switch to use acpi_evaluate_dsm_typed() 2023-10-03 15:46:14 +02:00
pci_slot.c ACPI: use %pe for better readability of errors while printing 2024-02-16 19:31:12 +01:00
pfr_telemetry.c ACPI: pfr_telemetry: Convert to platform remove callback returning void 2024-02-27 15:57:34 +01:00
pfr_update.c ACPI: pfr_update: Convert to platform remove callback returning void 2024-02-27 15:57:34 +01:00
platform_profile.c ACPI: platform-profile: add platform_profile_cycle() 2024-04-15 15:46:56 +02:00
power.c ACPI: PM: Do not turn of unused power resources on the Toshiba Click Mini 2023-04-27 18:44:43 +02:00
pptt.c ACPI: PPTT: Fix to avoid sleep in the atomic context when PPTT is absent 2023-03-14 20:34:38 +01:00
prmt.c ACPI: PRM: Annotate struct prm_module_info with __counted_by 2023-10-03 21:24:10 +02:00
proc.c
processor_core.c arm64, irqchip/gic-v3, ACPI: Move MADT GICC enabled check into a helper 2023-10-24 15:12:09 +01:00
processor_driver.c ACPI: cpufreq: Add highest perf change notification 2024-01-31 14:54:50 +01:00
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 ACPI: processor: Fix uninitialized access of buf in acpi_set_pdc_bits() 2023-09-18 12:16:16 +02:00
processor_perflib.c
processor_thermal.c ACPI: processor: reduce CPUFREQ thermal reduction pctg for Tegra241 2023-12-06 20:52:47 +01:00
processor_throttling.c
property.c ACPI: property: Add reference to UEFI DSD Guide 2024-04-26 19:00:47 +02:00
reboot.c
resource.c ACPI: resource: Skip IRQ override on Asus Vivobook Pro N6506MV 2024-04-30 21:22:42 +02:00
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 More ACPI updates for 6.9-rc1 2024-03-19 11:15:14 -07:00
sleep.h
spcr.c ACPI: SPCR: Amend indentation 2023-03-27 20:50:28 +02:00
sysfs.c ACPI: sysfs: Enable ACPI sysfs support for CCEL records 2023-03-27 20:43:58 +02:00
tables.c lib/firmware_table: Provide buffer length argument to cdat_table_parse() 2024-03-13 00:03:21 -07:00
thermal_lib.c ACPI: thermal_lib: Initialize temp_decik to zero 2024-02-22 20:36:17 +01:00
thermal.c thermal: ACPI: Invalidate trip points with temperature of 0 or below 2024-06-07 13:52:17 +02:00
tiny-power-button.c ACPI: tiny-power-button: Eliminate the driver notify callback 2023-06-16 19:48:09 +02:00
utils.c ACPI: utils: Make acpi_handle_path() not static 2024-02-15 21:06:06 +01:00
video_detect.c ACPI: video: Add backlight=native quirk for Lenovo Slim 7 16ARH7 2024-05-07 13:43:19 +02:00
viot.c ACPI: VIOT: Initialize the correct IOMMU fwspec 2023-03-30 19:20:42 +02:00
wakeup.c