adstraw commented on code in PR #12411:
URL: https://github.com/apache/tvm/pull/12411#discussion_r949031702


##########
src/runtime/hexagon/hexagon_user_dma.cc:
##########
@@ -90,32 +78,80 @@ int hexagon_user_dma_1d_sync_helper(void* dst, void* src, 
uint32_t length) {
   dma_desc_set_src(dma_desc, src32);
   dma_desc_set_dst(dma_desc, dst32);
 
-  dmstart(dma_desc);
-  unsigned int status = dmwait() & DM0_STATUS_MASK;
-  unsigned int done = dma_desc_get_done(dma_desc);
+  // only for first DMA
+  if (first_dma_) {
+    // reset DMA engine
+    auto status = Init();
+    if (status != DM0_STATUS_IDLE) {
+      return DMA_FAILURE;
+    }
+
+    // `dmstart` first descriptor
+    dmstart(dma_desc);
+    first_dma_ = false;
+  } else {
+    // `dmlink` descriptor to tail
+    dmlink(dma_descriptors_.back(), dma_desc);
+  }
 
-  free(dma_desc);
+  // set descriptor as new tail
+  dma_descriptors_.push_back(dma_desc);
 
-  if (status == DM0_STATUS_IDLE && done == DESC_DONE_COMPLETE) {
-    return DMA_SUCCESS;
+  return DMA_SUCCESS;
+}
+
+void HexagonUserDMA::Wait(uint32_t max_dmas_in_flight) {
+  // wait (forever) until max DMAs in flight <= actual DMAs in flight
+  while (DMAsInFlight() > max_dmas_in_flight) {

Review Comment:
   I agree completely.  Had the same thought about a buried log message.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to