Skip to content

Commit dbea997

Browse files
authored
Merge pull request #416 from sy-c/master
v0.44.2
2 parents 2aa179a + 3c8adb9 commit dbea997

File tree

5 files changed

+65
-1
lines changed

5 files changed

+65
-1
lines changed

doc/releaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,6 @@ This file describes the main feature changes for released versions of ReadoutCar
5858
- Updated list of CRORC firmwares: hash truncated to 7 chars, because CRORC does not report all 8.
5959
- roc-status:
6060
- added pciAddress for user logic link 15
61+
62+
## v0.44.2 - 23/06/2023
63+
- Added a workaround to avoid HW lock issues for CRORC: prevent concurrency in the calls to feed superpages to the card. Added a check to detect write discrepencies.

src/Crorc/CrorcBar.cxx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,13 +372,64 @@ void CrorcBar::stopDataReceiver()
372372
Utilities::setBit(CSRRegister, Crorc::Registers::DATA_RX_ON_OFF_BIT, true);
373373
writeRegister(Crorc::Registers::CHANNEL_CSR.index, CSRRegister);
374374
}
375+
376+
nSPpush = 0;
377+
nSPpushErr = 0;
378+
nSPcounter = 0;
375379
}
376380

377381
void CrorcBar::pushSuperpageAddressAndSize(uintptr_t blockAddress, uint32_t blockLength)
378382
{
383+
/*
379384
writeRegister(Crorc::Registers::SP_WR_ADDR_HIGH.index, arch64() ? (blockAddress >> 32) : 0x0);
380385
writeRegister(Crorc::Registers::SP_WR_ADDR_LOW.index, blockAddress & 0xffffffff);
381386
writeRegister(Crorc::Registers::SP_WR_SIZE.index, blockLength);
387+
*/
388+
389+
uint32_t vwr; // value to write
390+
uint32_t vxp; // value expected on read back (not always = vwr)
391+
uint32_t vrd; // value read back
392+
size_t ix; // address index
393+
394+
auto checkSuccess = [&] () {
395+
if (vrd != vxp) {
396+
char err[1024];
397+
snprintf(err,1024, "pushSuperpageAddress : write failed ix = 0x%X write = 0x%X expected = 0x%X != read 0x%X", (int)ix, (int)vwr, (int)vxp, (int)vrd);
398+
log(err, LogErrorDevel_(4699));
399+
nSPpushErr++;
400+
return -1;
401+
}
402+
return 0;
403+
};
404+
405+
try {
406+
nSPpush++;
407+
408+
ix = Crorc::Registers::SP_WR_ADDR_HIGH.index;
409+
vxp = vwr = arch64() ? (blockAddress >> 32) : 0x0;
410+
writeRegister(ix, vwr);
411+
vrd = readRegister(ix);
412+
checkSuccess();
413+
414+
ix = Crorc::Registers::SP_WR_ADDR_LOW.index;
415+
vxp = vwr = blockAddress & 0xffffffff;
416+
writeRegister(ix, vwr);
417+
vrd = readRegister(ix);
418+
checkSuccess();
419+
420+
ix = Crorc::Registers::SP_WR_SIZE.index;
421+
vxp = vwr = blockLength;
422+
vxp = (vwr << 8) | (++nSPcounter); // weird feature of crorc
423+
writeRegister(ix, vwr);
424+
vrd = readRegister(ix);
425+
if (!checkSuccess()) {
426+
nSPcounter = vrd & 0xFF;
427+
}
428+
} catch(...) {
429+
nSPpushErr++;
430+
log("pushSuperpageAddress exception", LogErrorDevel_(4699));
431+
}
432+
return;
382433
}
383434

384435
void CrorcBar::startDataGenerator()

src/Crorc/CrorcBar.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ class CrorcBar final : public BarInterfaceBase
7272
void setSiuLoopback();
7373
Crorc::PacketMonitoringInfo monitorPackets();
7474

75+
int nSPpush = 0; // total pages pushed
76+
int nSPpushErr = 0; // number of push errors
77+
uint8_t nSPcounter = 0; // 8-bit push counter as in device
78+
7579
private:
7680
std::map<int, Crorc::Link> initializeLinkMap();
7781

src/Crorc/CrorcDmaChannel.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,14 @@ bool CrorcDmaChannel::isASuperpageAvailable()
267267
return diff > 0;
268268
}
269269

270+
std::mutex lockFillSuperpages;
271+
270272
void CrorcDmaChannel::fillSuperpages()
271273
{
274+
// ensure there is no concurrency to access registers
275+
// because this causes HW problems, cf issue O2-3772
276+
std::unique_lock<std::mutex> lock(lockFillSuperpages);
277+
272278
// Check for arrivals & handle them
273279
if (!mIntermediateQueue.isEmpty() && isASuperpageAvailable()) {
274280

src/ReadoutCardVersion.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#include "ReadoutCard/Version.h"
1313

14-
#define O2_READOUTCARD_VERSION "0.44.1"
14+
#define O2_READOUTCARD_VERSION "0.44.2"
1515

1616
namespace o2
1717
{

0 commit comments

Comments
 (0)