Skip to content

Commit 2192a6f

Browse files
Pop all remaining superpages
1 parent 2ef1710 commit 2192a6f

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -514,21 +514,19 @@ class ProgramDmaBench: public Program
514514
return mReadoutCount.fetch_add(1, std::memory_order_relaxed);
515515
}
516516

517-
/// Free the pages that were pushed in excess
517+
/// Free the pages that remain after stopping DMA (these may not be filled)
518518
int freeExcessPages(std::chrono::milliseconds timeout)
519519
{
520-
// First deal with the remaining filled superpages
521520
auto start = std::chrono::steady_clock::now();
522521
int popped = 0;
523522
while ((std::chrono::steady_clock::now() - start) < timeout) {
524-
if (mChannel->getReadyQueueSize() > 0) {
523+
auto size = mChannel->getReadyQueueSize();
524+
for (int i = 0; i < size; ++i) {
525525
auto superpage = mChannel->getSuperpage();
526-
if (superpage.isFilled()) {
527-
readoutPage(mBufferBaseAddress + superpage.getOffset(), superpage.getSize(), fetchAddReadoutCount());
528-
mChannel->popSuperpage();
529-
popped++;
530-
}
526+
readoutPage(mBufferBaseAddress + superpage.getOffset(), superpage.getSize(), fetchAddReadoutCount());
527+
mChannel->popSuperpage();
531528
}
529+
popped += size;
532530
}
533531
return popped;
534532
}

0 commit comments

Comments
 (0)