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.18-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI fix from Rafael Wysocki:
"Revert a commit that attempted to make the code in the ACPI processor
driver more straightforward, but it turned out to cause the kernel to
crash on at least one system, along with some further cleanups on top
of it"

* tag 'acpi-6.18-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
Revert "ACPI: processor: idle: Optimize ACPI idle driver registration"
Revert "ACPI: processor: Remove unused empty stubs of some functions"
Revert "ACPI: processor: idle: Rearrange declarations in header file"
Revert "ACPI: processor: idle: Redefine two functions as void"
Revert "ACPI: processor: Do not expose global variable acpi_idle_driver"

+78 -81
+2 -4
drivers/acpi/processor_driver.c
··· 166 166 if (result && !IS_ENABLED(CONFIG_ACPI_CPU_FREQ_PSS)) 167 167 dev_dbg(&device->dev, "CPPC data invalid or not present\n"); 168 168 169 - acpi_processor_power_init(pr); 169 + if (cpuidle_get_driver() == &acpi_idle_driver) 170 + acpi_processor_power_init(pr); 170 171 171 172 acpi_pss_perf_init(pr); 172 173 ··· 263 262 if (result < 0) 264 263 return result; 265 264 266 - acpi_processor_register_idle_driver(); 267 - 268 265 result = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, 269 266 "acpi/cpu-drv:online", 270 267 acpi_soft_cpu_online, NULL); ··· 301 302 302 303 cpuhp_remove_state_nocalls(hp_online); 303 304 cpuhp_remove_state_nocalls(CPUHP_ACPI_CPUDRV_DEAD); 304 - acpi_processor_unregister_idle_driver(); 305 305 driver_unregister(&acpi_processor_driver); 306 306 } 307 307
+48 -71
drivers/acpi/processor_idle.c
··· 51 51 52 52 static DEFINE_PER_CPU(struct cpuidle_device *, acpi_cpuidle_device); 53 53 54 - static struct cpuidle_driver acpi_idle_driver = { 54 + struct cpuidle_driver acpi_idle_driver = { 55 55 .name = "acpi_idle", 56 56 .owner = THIS_MODULE, 57 57 }; ··· 1357 1357 return 0; 1358 1358 } 1359 1359 1360 - void acpi_processor_register_idle_driver(void) 1360 + static int acpi_processor_registered; 1361 + 1362 + int acpi_processor_power_init(struct acpi_processor *pr) 1361 1363 { 1362 - struct acpi_processor *pr; 1363 - int ret = -ENODEV; 1364 - int cpu; 1365 - 1366 - /* 1367 - * Acpi idle driver is used by all possible CPUs. 1368 - * Install the idle handler by the processor power info of one in them. 1369 - * Note that we use previously set idle handler will be used on 1370 - * platforms that only support C1. 1371 - */ 1372 - for_each_cpu(cpu, (struct cpumask *)cpu_possible_mask) { 1373 - pr = per_cpu(processors, cpu); 1374 - if (!pr) 1375 - continue; 1376 - 1377 - ret = acpi_processor_get_power_info(pr); 1378 - if (!ret) { 1379 - pr->flags.power_setup_done = 1; 1380 - acpi_processor_setup_cpuidle_states(pr); 1381 - break; 1382 - } 1383 - } 1384 - 1385 - if (ret) { 1386 - pr_debug("No ACPI power information from any CPUs.\n"); 1387 - return; 1388 - } 1389 - 1390 - ret = cpuidle_register_driver(&acpi_idle_driver); 1391 - if (ret) { 1392 - pr_debug("register %s failed.\n", acpi_idle_driver.name); 1393 - return; 1394 - } 1395 - pr_debug("%s registered with cpuidle.\n", acpi_idle_driver.name); 1396 - } 1397 - 1398 - void acpi_processor_unregister_idle_driver(void) 1399 - { 1400 - cpuidle_unregister_driver(&acpi_idle_driver); 1401 - } 1402 - 1403 - void acpi_processor_power_init(struct acpi_processor *pr) 1404 - { 1364 + int retval; 1405 1365 struct cpuidle_device *dev; 1406 1366 1407 - /* 1408 - * The code below only works if the current cpuidle driver is the ACPI 1409 - * idle driver. 1410 - */ 1411 - if (cpuidle_get_driver() != &acpi_idle_driver) 1412 - return; 1413 - 1414 1367 if (disabled_by_idle_boot_param()) 1415 - return; 1368 + return 0; 1416 1369 1417 1370 acpi_processor_cstate_first_run_checks(); 1418 1371 1419 1372 if (!acpi_processor_get_power_info(pr)) 1420 1373 pr->flags.power_setup_done = 1; 1421 1374 1422 - if (!pr->flags.power) 1423 - return; 1424 - 1425 - dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1426 - if (!dev) 1427 - return; 1428 - 1429 - per_cpu(acpi_cpuidle_device, pr->id) = dev; 1430 - 1431 - acpi_processor_setup_cpuidle_dev(pr, dev); 1432 - 1433 1375 /* 1434 - * Register a cpuidle device for this CPU. The cpuidle driver using 1435 - * this device is expected to be registered. 1376 + * Install the idle handler if processor power management is supported. 1377 + * Note that we use previously set idle handler will be used on 1378 + * platforms that only support C1. 1436 1379 */ 1437 - if (cpuidle_register_device(dev)) { 1438 - per_cpu(acpi_cpuidle_device, pr->id) = NULL; 1439 - kfree(dev); 1380 + if (pr->flags.power) { 1381 + /* Register acpi_idle_driver if not already registered */ 1382 + if (!acpi_processor_registered) { 1383 + acpi_processor_setup_cpuidle_states(pr); 1384 + retval = cpuidle_register_driver(&acpi_idle_driver); 1385 + if (retval) 1386 + return retval; 1387 + pr_debug("%s registered with cpuidle\n", 1388 + acpi_idle_driver.name); 1389 + } 1390 + 1391 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 1392 + if (!dev) 1393 + return -ENOMEM; 1394 + per_cpu(acpi_cpuidle_device, pr->id) = dev; 1395 + 1396 + acpi_processor_setup_cpuidle_dev(pr, dev); 1397 + 1398 + /* Register per-cpu cpuidle_device. Cpuidle driver 1399 + * must already be registered before registering device 1400 + */ 1401 + retval = cpuidle_register_device(dev); 1402 + if (retval) { 1403 + if (acpi_processor_registered == 0) 1404 + cpuidle_unregister_driver(&acpi_idle_driver); 1405 + 1406 + per_cpu(acpi_cpuidle_device, pr->id) = NULL; 1407 + kfree(dev); 1408 + return retval; 1409 + } 1410 + acpi_processor_registered++; 1440 1411 } 1412 + return 0; 1441 1413 } 1442 1414 1443 - void acpi_processor_power_exit(struct acpi_processor *pr) 1415 + int acpi_processor_power_exit(struct acpi_processor *pr) 1444 1416 { 1445 1417 struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id); 1446 1418 1447 1419 if (disabled_by_idle_boot_param()) 1448 - return; 1420 + return 0; 1449 1421 1450 1422 if (pr->flags.power) { 1451 1423 cpuidle_unregister_device(dev); 1424 + acpi_processor_registered--; 1425 + if (acpi_processor_registered == 0) 1426 + cpuidle_unregister_driver(&acpi_idle_driver); 1427 + 1452 1428 kfree(dev); 1453 1429 } 1454 1430 1455 1431 pr->flags.power_setup_done = 0; 1432 + return 0; 1456 1433 } 1457 1434 1458 1435 MODULE_IMPORT_NS("ACPI_PROCESSOR_IDLE");
+28 -6
include/acpi/processor.h
··· 417 417 #endif /* CONFIG_ACPI_CPU_FREQ_PSS */ 418 418 419 419 /* in processor_idle.c */ 420 + extern struct cpuidle_driver acpi_idle_driver; 420 421 #ifdef CONFIG_ACPI_PROCESSOR_IDLE 421 - void acpi_processor_power_init(struct acpi_processor *pr); 422 - void acpi_processor_power_exit(struct acpi_processor *pr); 422 + int acpi_processor_power_init(struct acpi_processor *pr); 423 + int acpi_processor_power_exit(struct acpi_processor *pr); 423 424 int acpi_processor_power_state_has_changed(struct acpi_processor *pr); 424 425 int acpi_processor_hotplug(struct acpi_processor *pr); 425 - void acpi_processor_register_idle_driver(void); 426 - void acpi_processor_unregister_idle_driver(void); 427 - int acpi_processor_ffh_lpi_probe(unsigned int cpu); 428 - int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi); 426 + #else 427 + static inline int acpi_processor_power_init(struct acpi_processor *pr) 428 + { 429 + return -ENODEV; 430 + } 431 + 432 + static inline int acpi_processor_power_exit(struct acpi_processor *pr) 433 + { 434 + return -ENODEV; 435 + } 436 + 437 + static inline int acpi_processor_power_state_has_changed(struct acpi_processor *pr) 438 + { 439 + return -ENODEV; 440 + } 441 + 442 + static inline int acpi_processor_hotplug(struct acpi_processor *pr) 443 + { 444 + return -ENODEV; 445 + } 429 446 #endif /* CONFIG_ACPI_PROCESSOR_IDLE */ 430 447 431 448 /* in processor_thermal.c */ ··· 464 447 return; 465 448 } 466 449 #endif /* CONFIG_CPU_FREQ */ 450 + 451 + #ifdef CONFIG_ACPI_PROCESSOR_IDLE 452 + extern int acpi_processor_ffh_lpi_probe(unsigned int cpu); 453 + extern int acpi_processor_ffh_lpi_enter(struct acpi_lpi_state *lpi); 454 + #endif 467 455 468 456 void acpi_processor_init_invariance_cppc(void); 469 457