bladerf2: wrap quick tune profile indices instead of running out - #1078
Open
wormuz wants to merge 1 commit into
Open
bladerf2: wrap quick tune profile indices instead of running out#1078wormuz wants to merge 1 commit into
wormuz wants to merge 1 commit into
Conversation
The Nios quick tune profile counter only ever incremented, and was reset
in exactly one place: board initialisation. An application that keeps
requesting quick tunes therefore had a hard budget of
NUM_BBP_FASTLOCK_PROFILES (256) for the lifetime of the device handle.
Past that, every further bladerf_get_quick_tune() failed with
BLADERF_ERR_UNEXPECTED and there was no way to recover short of closing
and reopening the device.
That budget is not a hardware limit on how many retune targets may exist
over time. Both the RFIC and the Nios hold caches that this code already
overwrites: the RFFE index is assigned modulo NUM_RFFE_FASTLOCK_PROFILES,
so profile 8 has always overwritten profile 0. Letting the Nios index
wrap the same way makes the two consistent and keeps long-running
frequency sweeps working.
Measured on a bladeRF 2.0 micro xA4 sweeping 70 MHz - 6 GHz with 4700
distinct stops, taking a quick tune profile on first visit to each:
before: 320 stops -> counter stuck at 256, every later stop logged
"Reached maximum number of RX quick tune profiles"
after: 600 stops -> 600 profiles, no errors
3392 stops in 90 s -> 3392 profiles, no errors
The counter is uint16_t and 65536 is a multiple of 256, so wrapping it
does not disturb the modulo alignment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Nios quick tune profile counter (
quick_tune_rx_profile/quick_tune_tx_profile) only ever increments, and is reset in exactly one place: board initialisation. An application that keeps requesting quick tunes therefore has a hard budget ofNUM_BBP_FASTLOCK_PROFILES(256) for the lifetime of the device handle.Past that, every further
bladerf_get_quick_tune()fails:and returns
BLADERF_ERR_UNEXPECTED, with no way to recover short of closing and reopening the device.This is easy to hit with a wideband sweep that takes a profile on first visit to each stop: 4700 distinct stops over 70 MHz – 6 GHz exhausts the budget within the first few minutes of operation.
Why wrapping is the right fix
The 256 budget is not a hardware limit on how many retune targets may exist over time. Both the RFIC and the Nios hold caches that this code already overwrites — the RFFE index is assigned modulo
NUM_RFFE_FASTLOCK_PROFILES, so profile 8 has always overwritten profile 0.Letting the Nios index wrap the same way makes the two consistent and keeps long-running sweeps working. Applications that need a stable profile for a specific frequency already have to re-request it, since the RFFE slot underneath may have been reused.
Measured
bladeRF 2.0 micro xA4, FPGA 0.15.0, sweeping 70 MHz – 6 GHz with 4700 distinct stops, taking a quick tune profile on first visit to each:
The counter is
uint16_tand 65536 is a multiple of 256, so wrapping does not disturb the modulo alignment used for the RFFE index.