Skip to content

Commit

Permalink
Don't disable Rx DMA when stopping stream.
Browse files Browse the repository at this point in the history
  • Loading branch information
rjonaitis committed Sep 11, 2024
1 parent bb9d640 commit 62d0a53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/comms/PCIe/linux-kernel-module/limepcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ static void limepcie_dma_stop(struct limepcie_dma *dma)
dma_dir_str(dma->direction),
transfersDone);
dma->enabled = false;
dma->transferCounter = 0;
wake_up_interruptible(&dma->wait_transfer);
}

Expand Down
7 changes: 5 additions & 2 deletions src/streaming/TRXLooper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,11 @@ void TRXLooper::Stop()
return;
lime::debug("TRXLooper::Stop()");
mStreamEnabled = false;
fpga->StopStreaming();

// wait for loop ends
if (mRx.stage.load(std::memory_order_relaxed) == Stream::ReadyStage::Active)
{
mRx.terminate.store(true, std::memory_order_relaxed);
mRxArgs.dma->Enable(false);
lime::debug("TRXLooper: wait for Rx loop end.");
{
std::unique_lock lck{ mRx.mutex };
Expand Down Expand Up @@ -268,6 +266,11 @@ void TRXLooper::Stop()
}
}

// Disable FPGA streaming only after data transfer threads finish work.
// Becase stream disable halts DMA, and threads could get stuck waiting for interrupt
// of the next data batch.
fpga->StopStreaming();

if (mRx.stagingPacket != nullptr)
{
mRx.memPool->Free(mRx.stagingPacket);
Expand Down
8 changes: 4 additions & 4 deletions tests/streaming/streaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ TEST_F(SDRDevice_streaming, RepeatedStartStopWorks)
samplesGot = device->StreamRx(moduleIndex, rxSamples, toRead, &rxMeta);
if (firstRead)
{
EXPECT_TRUE(rxMeta.timestamp == 0);
EXPECT_EQ(rxMeta.timestamp, 0);
firstRead = false;
}

Expand All @@ -144,7 +144,7 @@ TEST_F(SDRDevice_streaming, RepeatedStartStopWorks)
break;
samplesReceived += samplesGot;
samplesRemaining -= toRead;
EXPECT_TRUE(rxMeta.timestamp >= lastTimestamp);
EXPECT_GE(rxMeta.timestamp, lastTimestamp);
lastTimestamp = rxMeta.timestamp;
}

Expand All @@ -165,7 +165,7 @@ TEST_F(SDRDevice_streaming, RepeatedStartStopWorks)
samplesGot = device->StreamRx(moduleIndex, rxSamples, toRead, &rxMeta);
if (firstRead)
{
EXPECT_TRUE(rxMeta.timestamp == 0);
EXPECT_EQ(rxMeta.timestamp, 0);
firstRead = false;
}

Expand All @@ -175,7 +175,7 @@ TEST_F(SDRDevice_streaming, RepeatedStartStopWorks)
break;
samplesReceived += samplesGot;
samplesRemaining -= toRead;
EXPECT_TRUE(rxMeta.timestamp >= lastTimestamp);
EXPECT_GE(rxMeta.timestamp, lastTimestamp);
lastTimestamp = rxMeta.timestamp;
}
ASSERT_EQ(samplesRemaining, 0);
Expand Down

0 comments on commit 62d0a53

Please sign in to comment.