drm_hwcomposer: Rework HwcDisplay disposal to avoid races
Depends on !191 (merged)
The code prior to this commit has a flaw:
HwcDisplay::~HwcDisplay() {
...
auto &main_lock = hwc2_->GetResMan().GetMainLock();
/* Unlock to allow pending vsync callbacks to finish */
main_lock.unlock();
At this point display is no longer in displays_[] list. After lock is released, hwc2 API thread starts to process transactions which may fail with BAD_SIAPLAY responce and cause SF to crash.
vsync_worker_.VSyncControl(false);
vsync_worker_.Exit();
main_lock.lock();
}
-
Rework the logic in order to avoid such scenariuos:
1.a. Temporary switch non-primary unplugged displays to headless state allowing remaining transactions to succeed without impacting the pipeline.
1.b. Give 100mSec delay before destroying / removing display from the displays_[] list to allow all pending hwc2 transactions to complete. -
Support hotswap of the DrmDisplayPipeline, which makes primary display reattaching process smoother. Now SF should be able to gracefully remove all layers.
Signed-off-by: Roman Stratiienko roman.o.stratiienko@globallogic.com