Merge "dal: teardown cwb on display flush"
diff --git a/composer/hwc_display_builtin.cpp b/composer/hwc_display_builtin.cpp
index 35051f6..a8e559b 100644
--- a/composer/hwc_display_builtin.cpp
+++ b/composer/hwc_display_builtin.cpp
@@ -1386,10 +1386,6 @@
   HandleFrameOutput();
   PostCommitStitchLayers();
 
-  if (flush_ && layer_stack_.output_buffer == nullptr) {
-    display_intf_->FlushConcurrentWriteback();
-  }
-
   auto status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
 /*  display_intf_->GetConfig(&fixed_info);
   is_cmd_mode_ = fixed_info.is_cmdmode;
diff --git a/composer/hwc_display_pluggable.cpp b/composer/hwc_display_pluggable.cpp
index 53efc3c..5c970c6 100644
--- a/composer/hwc_display_pluggable.cpp
+++ b/composer/hwc_display_pluggable.cpp
@@ -181,10 +181,6 @@
   auto status = HWC2::Error::None;
 
   HandleFrameOutput();
-
-  if (flush_ && layer_stack_.output_buffer == nullptr) {
-    display_intf_->FlushConcurrentWriteback();
-  }
   status = HWCDisplay::PostCommitLayerStack(out_retire_fence);
 
   return status;
diff --git a/sdm/libs/dal/hw_device_drm.cpp b/sdm/libs/dal/hw_device_drm.cpp
index 1662462..d93e006 100644
--- a/sdm/libs/dal/hw_device_drm.cpp
+++ b/sdm/libs/dal/hw_device_drm.cpp
@@ -1949,11 +1949,25 @@
   // dpps commit feature ops doesn't use the obj id, set it as -1
   drm_atomic_intf_->Perform(DRMOps::DPPS_COMMIT_FEATURE, -1);
 
+  if (cwb_config_.cwb_disp_id == display_id_ && cwb_config_.enabled) {
+    drm_atomic_intf_->Perform(DRMOps::CONNECTOR_SET_CRTC, cwb_config_.token.conn_id, 0);
+    DLOGI("Tearing down the CWB topology");
+  }
+
   int ret = NullCommit(sync_commit /* synchronous */, false /* retain_planes*/);
   if (ret) {
     DLOGE("failed with error %d", ret);
     return kErrorHardware;
   }
+
+  if (cwb_config_.cwb_disp_id == display_id_) {
+    if (cwb_config_.enabled) {
+      FlushConcurrentWriteback();
+    } else {
+      cwb_config_.cwb_disp_id = -1;
+    }
+  }
+
   return kErrorNone;
 }