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 branches 'pm-core' and 'pm-runtime'

Merge a core power management update and runtime PM framework updates
for 6.19-rc1:

- Add WQ_UNBOUND to pm_wq workqueue (Marco Crivellari)

- Add runtime PM wrapper macros for ACQUIRE()/ACQUIRE_ERR() and use
them in the PCI core and the ACPI TAD driver (Rafael Wysocki)

- Improve runtime PM in the ACPI TAD driver (Rafael Wysocki)

- Update pm_runtime_allow/forbid() documentation (Rafael Wysocki)

- Fix typos in runtime.c comments (Malaya Kumar Rout)

* pm-core:
PM: WQ_UNBOUND added to pm_wq workqueue

* pm-runtime:
PCI/sysfs: Use PM_RUNTIME_ACQUIRE()/PM_RUNTIME_ACQUIRE_ERR()
ACPI: TAD: Use PM_RUNTIME_ACQUIRE()/PM_RUNTIME_ACQUIRE_ERR()
PM: runtime: Wrapper macros for ACQUIRE()/ACQUIRE_ERR()
PM: runtime: fix typos in runtime.c comments
ACPI: TAD: Improve runtime PM using guard macros
ACPI: TAD: Rearrange runtime PM operations in acpi_tad_remove()
PM: runtime: docs: Update pm_runtime_allow/forbid() documentation

+82 -54
-10
Documentation/power/runtime_pm.rst
··· 480 480 `bool pm_runtime_status_suspended(struct device *dev);` 481 481 - return true if the device's runtime PM status is 'suspended' 482 482 483 - `void pm_runtime_allow(struct device *dev);` 484 - - set the power.runtime_auto flag for the device and decrease its usage 485 - counter (used by the /sys/devices/.../power/control interface to 486 - effectively allow the device to be power managed at run time) 487 - 488 - `void pm_runtime_forbid(struct device *dev);` 489 - - unset the power.runtime_auto flag for the device and increase its usage 490 - counter (used by the /sys/devices/.../power/control interface to 491 - effectively prevent the device from being power managed at run time) 492 - 493 483 `void pm_runtime_no_callbacks(struct device *dev);` 494 484 - set the power.no_callbacks flag for the device and remove the runtime 495 485 PM attributes from /sys/devices/.../power (or prevent them from being
+39 -34
drivers/acpi/acpi_tad.c
··· 90 90 args[0].buffer.pointer = (u8 *)rt; 91 91 args[0].buffer.length = sizeof(*rt); 92 92 93 - pm_runtime_get_sync(dev); 93 + PM_RUNTIME_ACQUIRE(dev, pm); 94 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 95 + return -ENXIO; 94 96 95 97 status = acpi_evaluate_integer(handle, "_SRT", &arg_list, &retval); 96 - 97 - pm_runtime_put_sync(dev); 98 - 99 98 if (ACPI_FAILURE(status) || retval) 100 99 return -EIO; 101 100 102 101 return 0; 103 102 } 104 103 105 - static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt) 104 + static int acpi_tad_evaluate_grt(struct device *dev, struct acpi_tad_rt *rt) 106 105 { 107 106 acpi_handle handle = ACPI_HANDLE(dev); 108 107 struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER }; ··· 110 111 acpi_status status; 111 112 int ret = -EIO; 112 113 113 - pm_runtime_get_sync(dev); 114 - 115 114 status = acpi_evaluate_object(handle, "_GRT", NULL, &output); 116 - 117 - pm_runtime_put_sync(dev); 118 - 119 115 if (ACPI_FAILURE(status)) 120 116 goto out_free; 121 117 ··· 131 137 out_free: 132 138 ACPI_FREE(output.pointer); 133 139 return ret; 140 + } 141 + 142 + static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt) 143 + { 144 + int ret; 145 + 146 + PM_RUNTIME_ACQUIRE(dev, pm); 147 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 148 + return -ENXIO; 149 + 150 + ret = acpi_tad_evaluate_grt(dev, rt); 151 + if (ret) 152 + return ret; 153 + 154 + return 0; 134 155 } 135 156 136 157 static char *acpi_tad_rt_next_field(char *s, int *val) ··· 275 266 args[0].integer.value = timer_id; 276 267 args[1].integer.value = value; 277 268 278 - pm_runtime_get_sync(dev); 269 + PM_RUNTIME_ACQUIRE(dev, pm); 270 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 271 + return -ENXIO; 279 272 280 273 status = acpi_evaluate_integer(handle, method, &arg_list, &retval); 281 - 282 - pm_runtime_put_sync(dev); 283 - 284 274 if (ACPI_FAILURE(status) || retval) 285 275 return -EIO; 286 276 ··· 322 314 323 315 args[0].integer.value = timer_id; 324 316 325 - pm_runtime_get_sync(dev); 317 + PM_RUNTIME_ACQUIRE(dev, pm); 318 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 319 + return -ENXIO; 326 320 327 321 status = acpi_evaluate_integer(handle, method, &arg_list, &retval); 328 - 329 - pm_runtime_put_sync(dev); 330 - 331 322 if (ACPI_FAILURE(status)) 332 323 return -EIO; 333 324 ··· 377 370 378 371 args[0].integer.value = timer_id; 379 372 380 - pm_runtime_get_sync(dev); 373 + PM_RUNTIME_ACQUIRE(dev, pm); 374 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 375 + return -ENXIO; 381 376 382 377 status = acpi_evaluate_integer(handle, "_CWS", &arg_list, &retval); 383 - 384 - pm_runtime_put_sync(dev); 385 - 386 378 if (ACPI_FAILURE(status) || retval) 387 379 return -EIO; 388 380 ··· 417 411 418 412 args[0].integer.value = timer_id; 419 413 420 - pm_runtime_get_sync(dev); 414 + PM_RUNTIME_ACQUIRE(dev, pm); 415 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 416 + return -ENXIO; 421 417 422 418 status = acpi_evaluate_integer(handle, "_GWS", &arg_list, &retval); 423 - 424 - pm_runtime_put_sync(dev); 425 - 426 419 if (ACPI_FAILURE(status)) 427 420 return -EIO; 428 421 ··· 568 563 569 564 device_init_wakeup(dev, false); 570 565 571 - pm_runtime_get_sync(dev); 572 - 573 566 if (dd->capabilities & ACPI_TAD_RT) 574 567 sysfs_remove_group(&dev->kobj, &acpi_tad_time_attr_group); 575 568 ··· 576 573 577 574 sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group); 578 575 579 - acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER); 580 - acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER); 581 - if (dd->capabilities & ACPI_TAD_DC_WAKE) { 582 - acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER); 583 - acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER); 576 + scoped_guard(pm_runtime_noresume, dev) { 577 + acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER); 578 + acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER); 579 + if (dd->capabilities & ACPI_TAD_DC_WAKE) { 580 + acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER); 581 + acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER); 582 + } 584 583 } 585 584 586 - pm_runtime_put_sync(dev); 585 + pm_runtime_suspend(dev); 587 586 pm_runtime_disable(dev); 588 587 acpi_remove_cmos_rtc_space_handler(handle); 589 588 }
+16 -7
drivers/base/power/runtime.c
··· 90 90 /* 91 91 * Because ktime_get_mono_fast_ns() is not monotonic during 92 92 * timekeeping updates, ensure that 'now' is after the last saved 93 - * timesptamp. 93 + * timestamp. 94 94 */ 95 95 if (now < last) 96 96 return; ··· 217 217 * resume/suspend callback of any one of its ancestors(or the 218 218 * block device itself), the deadlock may be triggered inside the 219 219 * memory allocation since it might not complete until the block 220 - * device becomes active and the involed page I/O finishes. The 220 + * device becomes active and the involved page I/O finishes. The 221 221 * situation is pointed out first by Alan Stern. Network device 222 222 * are involved in iSCSI kind of situation. 223 223 * ··· 1210 1210 * 1211 1211 * Otherwise, if its runtime PM status is %RPM_ACTIVE and (1) @ign_usage_count 1212 1212 * is set, or (2) @dev is not ignoring children and its active child count is 1213 - * nonero, or (3) the runtime PM usage counter of @dev is not zero, increment 1213 + * nonzero, or (3) the runtime PM usage counter of @dev is not zero, increment 1214 1214 * the usage counter of @dev and return 1. 1215 1215 * 1216 1216 * Otherwise, return 0 without changing the usage counter. ··· 1664 1664 * pm_runtime_forbid - Block runtime PM of a device. 1665 1665 * @dev: Device to handle. 1666 1666 * 1667 - * Increase the device's usage count and clear its power.runtime_auto flag, 1668 - * so that it cannot be suspended at run time until pm_runtime_allow() is called 1669 - * for it. 1667 + * Resume @dev if already suspended and block runtime suspend of @dev in such 1668 + * a way that it can be unblocked via the /sys/devices/.../power/control 1669 + * interface, or otherwise by calling pm_runtime_allow(). 1670 + * 1671 + * Calling this function many times in a row has the same effect as calling it 1672 + * once. 1670 1673 */ 1671 1674 void pm_runtime_forbid(struct device *dev) 1672 1675 { ··· 1690 1687 * pm_runtime_allow - Unblock runtime PM of a device. 1691 1688 * @dev: Device to handle. 1692 1689 * 1693 - * Decrease the device's usage count and set its power.runtime_auto flag. 1690 + * Unblock runtime suspend of @dev after it has been blocked by 1691 + * pm_runtime_forbid() (for instance, if it has been blocked via the 1692 + * /sys/devices/.../power/control interface), check if @dev can be 1693 + * suspended and suspend it in that case. 1694 + * 1695 + * Calling this function many times in a row has the same effect as calling it 1696 + * once. 1694 1697 */ 1695 1698 void pm_runtime_allow(struct device *dev) 1696 1699 {
+2 -2
drivers/pci/pci-sysfs.c
··· 1517 1517 return count; 1518 1518 } 1519 1519 1520 - ACQUIRE(pm_runtime_active_try, pm)(dev); 1521 - if (ACQUIRE_ERR(pm_runtime_active_try, &pm)) 1520 + PM_RUNTIME_ACQUIRE(dev, pm); 1521 + if (PM_RUNTIME_ACQUIRE_ERR(&pm)) 1522 1522 return -ENXIO; 1523 1523 1524 1524 if (sysfs_streq(buf, "default")) {
+24
include/linux/pm_runtime.h
··· 637 637 DEFINE_GUARD_COND(pm_runtime_active_auto, _try_enabled, 638 638 pm_runtime_resume_and_get(_T), _RET == 0) 639 639 640 + /* ACQUIRE() wrapper macros for the guards defined above. */ 641 + 642 + #define PM_RUNTIME_ACQUIRE(_dev, _var) \ 643 + ACQUIRE(pm_runtime_active_try, _var)(_dev) 644 + 645 + #define PM_RUNTIME_ACQUIRE_AUTOSUSPEND(_dev, _var) \ 646 + ACQUIRE(pm_runtime_active_auto_try, _var)(_dev) 647 + 648 + #define PM_RUNTIME_ACQUIRE_IF_ENABLED(_dev, _var) \ 649 + ACQUIRE(pm_runtime_active_try_enabled, _var)(_dev) 650 + 651 + #define PM_RUNTIME_ACQUIRE_IF_ENABLED_AUTOSUSPEND(_dev, _var) \ 652 + ACQUIRE(pm_runtime_active_auto_try_enabled, _var)(_dev) 653 + 654 + /* 655 + * ACQUIRE_ERR() wrapper macro for guard pm_runtime_active. 656 + * 657 + * Always check PM_RUNTIME_ACQUIRE_ERR() after using one of the 658 + * PM_RUNTIME_ACQUIRE*() macros defined above (yes, it can be used with 659 + * any of them) and if it is nonzero, avoid accessing the given device. 660 + */ 661 + #define PM_RUNTIME_ACQUIRE_ERR(_var_ptr) \ 662 + ACQUIRE_ERR(pm_runtime_active, _var_ptr) 663 + 640 664 /** 641 665 * pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0. 642 666 * @dev: Target device.
+1 -1
kernel/power/main.c
··· 1068 1068 1069 1069 static int __init pm_start_workqueue(void) 1070 1070 { 1071 - pm_wq = alloc_workqueue("pm", WQ_FREEZABLE, 0); 1071 + pm_wq = alloc_workqueue("pm", WQ_FREEZABLE | WQ_UNBOUND, 0); 1072 1072 1073 1073 return pm_wq ? 0 : -ENOMEM; 1074 1074 }