Skip to content

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 */

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.

  1. 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.

  2. 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

Edited by Roman Stratiienko

Merge request reports