Skip to content

Commit 48af6bf

Browse files
committed
[cru] Last pages no longer need to be popped
1 parent f85d824 commit 48af6bf

File tree

3 files changed

+8
-54
lines changed

3 files changed

+8
-54
lines changed

src/CommandLineUtilities/ProgramDmaBench.cxx

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -346,8 +346,6 @@ class ProgramDmaBench : public Program
346346

347347
std::cout << "\n\n";
348348
mChannel->stopDma();
349-
int numPopped = freeExcessPages(10ms);
350-
getLogger() << "Popped " << numPopped << " remaining superpages" << endm;
351349

352350
outputErrors();
353351
outputStats();
@@ -550,39 +548,6 @@ class ProgramDmaBench : public Program
550548
lowPriorityFuture.get();
551549
}
552550

553-
/// Free the pages that remain after stopping DMA (these may not be filled)
554-
int freeExcessPages(std::chrono::milliseconds timeout)
555-
{
556-
auto start = std::chrono::steady_clock::now();
557-
int popped = 0;
558-
while ((std::chrono::steady_clock::now() - start) < timeout) {
559-
auto size = mChannel->getReadyQueueSize();
560-
for (int i = 0; i < size; ++i) {
561-
auto superpage = mChannel->popSuperpage();
562-
fetchAddSuperpagesReadOut();
563-
if ((mDataSource == DataSource::Fee) || (mDataSource == DataSource::Ddg)) {
564-
auto superpageAddress = mBufferBaseAddress + superpage.getOffset();
565-
size_t readoutBytes = 0;
566-
bool atStartOfSuperpage = true;
567-
while ((readoutBytes < superpage.getReceived())) { // At least one more dma page fits in the superpage
568-
auto pageAddress = superpageAddress + readoutBytes;
569-
auto readoutCount = fetchAddDmaPagesReadOut();
570-
size_t pageSize = readoutPage(pageAddress, readoutCount, atStartOfSuperpage);
571-
atStartOfSuperpage = false; // Update the boolean value as soon as we move...
572-
readoutBytes += pageSize;
573-
}
574-
575-
if (readoutBytes > mSuperpageSize) {
576-
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("RDH reports cumulative dma page sizes that exceed the superpage size"));
577-
}
578-
}
579-
std::cout << "[popped superpage " << i << " ], size= " << superpage.getSize() << " received= " << superpage.getReceived() << " isFilled=" << superpage.isFilled() << " isReady=" << superpage.isReady() << std::endl;
580-
}
581-
popped += size;
582-
}
583-
return popped;
584-
}
585-
586551
uint32_t getDataGeneratorCounterFromPage(uintptr_t pageAddress, size_t headerSize)
587552
{
588553
auto payload = reinterpret_cast<const volatile uint32_t*>(pageAddress + headerSize);

src/Cru/CruDmaChannel.cxx

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -164,22 +164,15 @@ void CruDmaChannel::deviceStopDma()
164164
int moved = 0;
165165
for (auto& link : mLinks) {
166166
int32_t superpageCount = getBar()->getSuperpageCount(link.id);
167-
if (superpageCount == 0) { // Do not pop superpages if the link has been inactive
168-
continue;
169-
}
170167
uint32_t amountAvailable = superpageCount - link.superpageCounter;
171168
//log((format("superpageCount %1% amountAvailable %2%") % superpageCount % amountAvailable).str());
172-
for (uint32_t i = 0; i < (amountAvailable + 1); ++i) { // get an extra, possibly partly filled superpage
169+
for (uint32_t i = 0; i < amountAvailable; ++i) {
173170
if (mReadyQueue.size() >= READY_QUEUE_CAPACITY) {
174171
break;
175172
}
176173

177174
if (!link.queue.empty()) { // care for the extra filled superpage
178-
if (i == amountAvailable) { // Propagate that it is the last popped to set the size only to the RDH (eox)
179-
transferSuperpageFromLinkToReady(link, true);
180-
} else {
181-
transferSuperpageFromLinkToReady(link);
182-
}
175+
transferSuperpageFromLinkToReady(link);
183176
moved++;
184177
}
185178
}
@@ -276,23 +269,19 @@ void CruDmaChannel::pushSuperpageToLink(Link& link, const Superpage& superpage)
276269
link.queue.push_back(superpage);
277270
}
278271

279-
void CruDmaChannel::transferSuperpageFromLinkToReady(Link& link, bool isPopped)
272+
void CruDmaChannel::transferSuperpageFromLinkToReady(Link& link)
280273
{
281274
if (link.queue.empty()) {
282275
BOOST_THROW_EXCEPTION(Exception() << ErrorInfo::Message("Could not transfer Superpage from link to ready queue, link queue is empty"));
283276
}
284277

285278
link.queue.front().setReady(true);
286279

287-
if (isPopped) {
288-
link.queue.front().setReceived(0x40); // Only RDH in case it's popped
280+
uint32_t superpageSize = getBar()->getSuperpageSize(link.id);
281+
if (superpageSize == 0) {
282+
link.queue.front().setReceived(link.queue.front().getSize()); // force the full superpage size for backwards compatibility
289283
} else {
290-
uint32_t superpageSize = getBar()->getSuperpageSize(link.id);
291-
if (superpageSize == 0) {
292-
link.queue.front().setReceived(link.queue.front().getSize()); // force the full superpage size for backwards compatibility
293-
} else {
294-
link.queue.front().setReceived(superpageSize);
295-
}
284+
link.queue.front().setReceived(superpageSize);
296285
}
297286

298287
mReadyQueue.push_back(link.queue.front());

src/Cru/CruDmaChannel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ class CruDmaChannel final : public DmaChannelPdaBase
115115
void pushSuperpageToLink(Link& link, const Superpage& superpage);
116116

117117
/// Mark the front superpage of a link ready and transfer it to the ready queue
118-
void transferSuperpageFromLinkToReady(Link& link, bool isPopped = false);
118+
void transferSuperpageFromLinkToReady(Link& link);
119119

120120
/// Enable debug mode by writing to the appropriate CRU register
121121
void enableDebugMode();

0 commit comments

Comments
 (0)