Technical Explanation and Root Cause Analysis
1. Functions, Structs, Fields, and Files Involved
- Source Files:
- Structures and Fields:
struct dev_pm_info:
bool must_resume:1; (bitfield at bit offset 588, byte offset 73 / 0x49).
spinlock_t lock; (per-device power management spinlock).
- Superior devices:
dev->parent->power and link->supplier->power.
2. Root Cause Mechanism
During system sleep transitions in the "noirq suspend" phase (dpm_noirq_suspend_devices()), subordinate/leaf devices marked for asynchronous suspend run concurrently across multiple asynchronous worker threads (async_run_entry_fn() $\to$ async_suspend_noirq() $\to$ device_suspend_noirq()).
When each subordinate device completes its noirq suspend callback and determines that it must be resumed (dev->power.must_resume == true), it propagates this requirement up the hierarchy by invoking dpm_superior_set_must_resume(dev):
static void dpm_superior_set_must_resume(struct device *dev)
{
struct device_link *link;
int idx;
if (dev->parent)
dev->parent->power.must_resume = true;
idx = device_links_read_lock();
dev_for_each_link_to_supplier(link, dev)
link->supplier->power.must_resume = true;
device_links_read_unlock(idx);
}
-
Missing Mutual Exclusion:
Unlike analogous superior-update helpers in drivers/base/power/main.c (such as dpm_clear_superiors_direct_complete(), which acquires spin_lock_irq(&dev->parent->power.lock) and spin_lock_irq(&link->supplier->power.lock), or dpm_propagate_wakeup_to_parent(), which acquires spin_lock_irq(&parent->power.lock)), dpm_superior_set_must_resume() updates dev->parent->power.must_resume and link->supplier->power.must_resume without acquiring power.lock. device_links_read_lock() only takes an SRCU read lock (device_links_srcu) to safely traverse the links, providing no writer mutual exclusion.
-
Bitfield Read-Modify-Write:
In struct dev_pm_info under CONFIG_PM_SLEEP, must_resume:1 is a single-bit bitfield packed into byte offset 73 alongside:
wakeup_path:1
syscore:1
no_pm_callbacks:1
smart_suspend:1
must_resume:1
may_skip_resume:1
out_band_wakeup:1
strict_midlayer:1
Bitfield stores are non-atomic read-modify-write (RMW) operations on the containing byte. When multiple sibling devices or co-consumers suspend asynchronously on separate CPU cores, both tasks execute an unlocked 1-byte read-modify-write at the exact same address of their common parent or supplier (reported by KCSAN as read-write to 0xffff88810265b579 of 1 bytes in device_suspend_noirq).