diff options
author | Pullakavi Srinivas <quic_spullaka@quicinc.com> | 2022-07-19 13:07:17 +0530 |
---|---|---|
committer | Pullakavi Srinivas <quic_spullaka@quicinc.com> | 2022-07-30 11:11:05 +0530 |
commit | 532ecdca6a44a5ab274c82893f4a8ebee56f4b5d (patch) | |
tree | 7af78e2ccfde78b576ead717e11b6a2158c6b8ac | |
parent | 94906538539b119a17ac743794673ef023ca30df (diff) |
hwc: Fix TUI concurrencies with suspend resume.
-- Add a finite timeout for refresh commit.
-- Bail out subsequent TUI end on timeouts.
CRs-Fixed: 3241281
Change-Id: Ibf6e00f871d1bebe75949cffcd32ae5545dc3ee3
-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 6e9a566c..4104bb36 100644 --- a/composer/hwc_session.h +++ b/composer/hwc_session.h @@ -636,6 +636,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); @@ -698,6 +699,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 |