Synchronize device tree transitions
|Reported by:||Jiri Svoboda||Owned by:|
|Blocker for:||Depends on:|
Operations on the device tree (in Devman) requite fine-grained synchronization. Simple mutex or rw-locking is too cumbersome, some operations can be performed while others are in progress.
Currently there is one global RW lock for the entire three which is held for a short time when actual modifications of tree topology take place.
When we are onlining or offlining (or removing) a node in one fibril, we don't want another fibril to attempt to online/offline/remove the same node concurrently. Currently there is no mechanism to prevent it. These transitions are currently not tracked via states.
The proposed solution: add appropriate transitional states and a method to wait for the (function/device?) node to enter a stable (non-transitional) state. This can be achieved by introducing a CV for each node. Since CVs operate in conjunction with mutexes, not RW-locks, the global tree RW lock needs to be replaced with global mutex. This should be acceptable - since the lock is always held for a short time and not on performance-sensitive code paths, not much contention is expected.