diff options
author | qctecmdr <qctecmdr@localhost> | 2022-08-01 23:13:03 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2022-08-01 23:13:03 -0700 |
commit | 0613cba214addb81425bae84e7093fb33b71945d (patch) | |
tree | df672dda8f627454944f9abea2b7694d769db8d7 | |
parent | 91aa24bf8ef114d34940d3ef70a7def9c6e4a5e0 (diff) | |
parent | 532ecdca6a44a5ab274c82893f4a8ebee56f4b5d (diff) |
Merge "hwc: Fix TUI concurrencies with suspend resume."
-rw-r--r-- | composer/hwc_session.cpp | 23 | ||||
-rw-r--r-- | composer/hwc_session.h | 3 |
2 files changed, 24 insertions, 2 deletions
diff --git a/composer/hwc_session.cpp b/composer/hwc_session.cpp index 9c01d444..aaf225ab 100644 --- a/composer/hwc_session.cpp +++ b/composer/hwc_session.cpp @@ -4010,6 +4010,16 @@ int32_t HWCSession::SetActiveConfigWithConstraints( vsync_period_change_constraints, out_timeline); } +int HWCSession::WaitForCommitDoneAsync(hwc2_display_t display, int client_id) { + std::chrono::milliseconds span(5000); + commit_done_future_ = std::async([](HWCSession* session, hwc2_display_t display, int client_id) { + return session->WaitForCommitDone(display, client_id); + }, this, display, client_id); + auto ret = (commit_done_future_.wait_for(span) == std::future_status::timeout) ? + -EINVAL : commit_done_future_.get(); + return ret; +} + int HWCSession::WaitForCommitDone(hwc2_display_t display, int client_id) { shared_ptr<Fence> retire_fence = nullptr; int timeout_ms = -1; @@ -4141,7 +4151,7 @@ android::status_t HWCSession::TUITransitionStart(int disp_id) { } callbacks_.Refresh(target_display); - int ret = WaitForCommitDone(target_display, kClientTrustedUI); + int ret = WaitForCommitDoneAsync(target_display, kClientTrustedUI); if (ret != 0) { DLOGE("WaitForCommitDone failed with error = %d", ret); return -EINVAL; @@ -4189,11 +4199,17 @@ android::status_t HWCSession::TUITransitionStart(int disp_id) { return -ENODEV; } } + + tui_start_success_ = true; return 0; } android::status_t HWCSession::TUITransitionEnd(int disp_id) { // Hold this lock so that any deferred hotplug events will not be handled during the commit // and will be handled at the end of TUITransitionPrepare. + if (!tui_start_success_) { + DLOGI("Bailing out TUI end"); + return -EINVAL; + } SCOPE_LOCK(pluggable_handler_lock_); hwc2_display_t target_display = GetDisplayIndex(disp_id); bool needs_refresh = false; @@ -4225,9 +4241,10 @@ android::status_t HWCSession::TUITransitionEnd(int disp_id) { callbacks_.Refresh(target_display); DLOGI("Waiting for device unassign"); - int ret = WaitForCommitDone(target_display, kClientTrustedUI); + int ret = WaitForCommitDoneAsync(target_display, kClientTrustedUI); if (ret != 0) { DLOGE("Device unassign failed with error %d", ret); + tui_start_success_ = false; return -EINVAL; } } @@ -4298,6 +4315,8 @@ android::status_t HWCSession::TUITransitionUnPrepare(int disp_id) { // Do hotplug handling in a different thread to avoid blocking TUI thread. std::thread(&HWCSession::HandlePluggableDisplays, this, true).detach(); } + // Reset tui session state variable. + tui_start_success_ = false; DLOGI("End of TUI session on display %d", disp_id); return 0; } diff --git a/composer/hwc_session.h b/composer/hwc_session.h index c3a77641..72d1d59f 100644 --- a/composer/hwc_session.h +++ b/composer/hwc_session.h @@ -645,6 +645,7 @@ class HWCSession : hwc2_device_t, HWCUEventListener, public qClient::BnQClient, HWC2::Error status); void PostCommitLocked(hwc2_display_t display, shared_ptr<Fence> &retire_fence); int WaitForCommitDone(hwc2_display_t display, int client_id); + int WaitForCommitDoneAsync(hwc2_display_t display, int client_id); void NotifyDisplayAttributes(hwc2_display_t display, hwc2_config_t config); int WaitForVmRelease(hwc2_display_t display, int timeout_ms); @@ -707,6 +708,8 @@ class HWCSession : hwc2_device_t, HWCUEventListener, public qClient::BnQClient, Locker primary_display_lock_; bool disable_vds_hwc_ = false; bool vds_allow_hwc_ = false; + bool tui_start_success_ = false; + std::future<int> commit_done_future_; }; } // namespace sdm |