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

Pull power management fixes from Rafael Wysocki:
"These fix the usage of device links in the runtime PM core code and
update the DTPM (Dynamic Thermal Power Management) feature added
recently.

Specifics:

- Make the runtime PM core code avoid attempting to suspend supplier
devices before updating the PM-runtime status of a consumer to
'suspended' (Rafael Wysocki).

- Fix DTPM (Dynamic Thermal Power Management) root node
initialization and label that feature as EXPERIMENTAL in Kconfig
(Daniel Lezcano)"

* tag 'pm-5.12-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
powercap/drivers/dtpm: Add the experimental label to the option description
powercap/drivers/dtpm: Fix root node initialization
PM: runtime: Update device status before letting suppliers suspend

+41 -26
+37 -25
drivers/base/power/runtime.c
··· 325 325 static int __rpm_callback(int (*cb)(struct device *), struct device *dev) 326 326 __releases(&dev->power.lock) __acquires(&dev->power.lock) 327 327 { 328 - int retval, idx; 329 328 bool use_links = dev->power.links_count > 0; 329 + bool get = false; 330 + int retval, idx; 331 + bool put; 330 332 331 333 if (dev->power.irq_safe) { 332 334 spin_unlock(&dev->power.lock); 335 + } else if (!use_links) { 336 + spin_unlock_irq(&dev->power.lock); 333 337 } else { 338 + get = dev->power.runtime_status == RPM_RESUMING; 339 + 334 340 spin_unlock_irq(&dev->power.lock); 335 341 336 - /* 337 - * Resume suppliers if necessary. 338 - * 339 - * The device's runtime PM status cannot change until this 340 - * routine returns, so it is safe to read the status outside of 341 - * the lock. 342 - */ 343 - if (use_links && dev->power.runtime_status == RPM_RESUMING) { 342 + /* Resume suppliers if necessary. */ 343 + if (get) { 344 344 idx = device_links_read_lock(); 345 345 346 346 retval = rpm_get_suppliers(dev); ··· 355 355 356 356 if (dev->power.irq_safe) { 357 357 spin_lock(&dev->power.lock); 358 - } else { 359 - /* 360 - * If the device is suspending and the callback has returned 361 - * success, drop the usage counters of the suppliers that have 362 - * been reference counted on its resume. 363 - * 364 - * Do that if resume fails too. 365 - */ 366 - if (use_links 367 - && ((dev->power.runtime_status == RPM_SUSPENDING && !retval) 368 - || (dev->power.runtime_status == RPM_RESUMING && retval))) { 369 - idx = device_links_read_lock(); 358 + return retval; 359 + } 370 360 371 - fail: 372 - rpm_put_suppliers(dev); 361 + spin_lock_irq(&dev->power.lock); 373 362 374 - device_links_read_unlock(idx); 375 - } 363 + if (!use_links) 364 + return retval; 365 + 366 + /* 367 + * If the device is suspending and the callback has returned success, 368 + * drop the usage counters of the suppliers that have been reference 369 + * counted on its resume. 370 + * 371 + * Do that if the resume fails too. 372 + */ 373 + put = dev->power.runtime_status == RPM_SUSPENDING && !retval; 374 + if (put) 375 + __update_runtime_status(dev, RPM_SUSPENDED); 376 + else 377 + put = get && retval; 378 + 379 + if (put) { 380 + spin_unlock_irq(&dev->power.lock); 381 + 382 + idx = device_links_read_lock(); 383 + 384 + fail: 385 + rpm_put_suppliers(dev); 386 + 387 + device_links_read_unlock(idx); 376 388 377 389 spin_lock_irq(&dev->power.lock); 378 390 }
+1 -1
drivers/powercap/Kconfig
··· 45 45 on a per CPU basis. 46 46 47 47 config DTPM 48 - bool "Power capping for Dynamic Thermal Power Management" 48 + bool "Power capping for Dynamic Thermal Power Management (EXPERIMENTAL)" 49 49 help 50 50 This enables support for the power capping for the dynamic 51 51 thermal power management userspace engine.
+3
drivers/powercap/dtpm.c
··· 207 207 if (dtpm->ops) 208 208 dtpm->ops->release(dtpm); 209 209 210 + if (root == dtpm) 211 + root = NULL; 212 + 210 213 kfree(dtpm); 211 214 212 215 return 0;