EttusResearch / uhd

The USRP™ Hardware Driver Repository
http://uhd.ettus.com
Other
1k stars 666 forks source link

Streamer not released properly on destruction #806

Open nzqo opened 3 weeks ago

nzqo commented 3 weeks ago

Issue Description

It seems that streamers are not properly released on destruction of tx_streamer::sptr.

Setup Details

I encountered this problem on:

Expected Behavior

I am keeping a single variable in code for a tx streamer. Basically:

struct State {
    uhd::tx_streamer::sptr tx_stream;
}

void do_things(State* state) {
    // .....

    // This releases the stream, as is instructed in the docs.
    if (state->tx_stream) {
        state->tx_stream.reset();
        state->tx_stream = nullptr;
    }

    // ....
    state->tx_stream = usrp->get_tx_stream(stream_args);
}

The docs specify that to open another stream, I need to make sure to destroy the old one. Although that is what I am doing, and I am not keeping any other references to this streamer aside from what is shown, this crashes after a few tries.

Actual Behaviour

After a few runs of this function, I always encounter the error:

Trying to allocate more DMA channels than are available

Steps to reproduce the problem

Repeatedly reset and reacquire a tx_stream and you should encounter this issue.

mbr0wn commented 2 weeks ago

Oof, you're right, on destruction of streamers, we don't free up the PCIe DMA resources. I can confirm this is a bug, but I can also say that we won't have time to look at this in the near future (we don't get a lot of PCIe users).