Repository navigation
Conversation
LLM reviewThis series adds a debugfs interface and a dedicated IIO device ( run: 29838719279
|
dff7523 to
2b7e61a
Compare
104691a to
f066077
Compare
nunojsa
left a comment
There was a problem hiding this comment.
As said, not sure I'm convinced about the debugfs added value but if you choose to keep it and, as a nit, swap the patches. Make the real feature (the iio buffer) be the first patch and the debug thing a follow up. Makes more sense to me
|
|
||
| ret = devm_add_action(&spi->dev, adrv904x_free_capture_data, phy); | ||
| if (ret) | ||
| return ret; |
There was a problem hiding this comment.
This should likely be in adrv904x_ramc_probe(). Another oddity is why aren't we using devm_add_action_or_reset()?
There was a problem hiding this comment.
rx_capture_data is allocated by debugfs (DBGFS_RX_DATA_CAPTURE), not by RAMC - so the cleanup belongs here after adrv904x_register_debugfs(), not in adrv904x_ramc_probe().
Changed to devm_add_action_or_reset().
|
|
||
| /* Scan buffer: I + Q + timestamp */ | ||
| u8 scan_data[ALIGN(2 * sizeof(s32), sizeof(s64)) + sizeof(s64)] | ||
| __aligned(IIO_DMA_MINALIGN); |
There was a problem hiding this comment.
Needs to the last in the struct! Also please check if we have this helpers:
https://elixir.bootlin.com/linux/v7.2-rc5/source/include/linux/iio/iio.h#L935
If not, might be worth it to backport them (if easy enough)
| * re-enable the buffer (or use iio_readdev which handles this automatically). | ||
| */ | ||
|
|
||
| #include "adrv904x.h" |
There was a problem hiding this comment.
This should go after the "system" includes
| .write = adrv904x_ramc_sample_count_store, | ||
| .shared = IIO_SHARED_BY_ALL, | ||
| }, | ||
| {}, |
There was a problem hiding this comment.
add a space and not need for comma here
| i_val = sign_extend_28bit(bank1[2 * i + 1]); | ||
| scan_s32[0] = i_val; | ||
| scan_s32[1] = q_val; | ||
| iio_push_to_buffers_with_timestamp(st->indio_dev, |
There was a problem hiding this comment.
| dev_err(st->dev, "Failed to capture channel 0x%lx: %d\n", | ||
| active_channel, ret); | ||
| return -EIO; | ||
| } |
There was a problem hiding this comment.
Do we need to lock the whole thing or just adi_adrv904x_RxOrxDataCaptureStart(). This also makes me wonder if we shouldn't just use the device lock for the the whole ram device
There was a problem hiding this comment.
Lock scope reduced to just the API call..
We use a separate st->lock for RAMC state to avoid blocking other phy operations while changing sample_count. But using phy->lock for everything would be simpler - let me know if you prefer that.
| /* Allocate buffer: up to 12 chars per value (including newline) */ | ||
| buf_size = phy->rx_capture_len * 12 + 1; | ||
| out_buf = kvzalloc(buf_size, GFP_KERNEL); | ||
| if (!out_buf) |
There was a problem hiding this comment.
Use __free(kvfree) and avoid some leaks. Also what sizes are talking about here? IIRC, kvalloc() is for things in the megabyte range
| result = simple_read_from_buffer(userbuf, count, ppos, out_buf, pos); | ||
| kvfree(out_buf); | ||
| return result; | ||
| } |
There was a problem hiding this comment.
I would also prefer to move this into an helper function
| } | ||
|
|
||
| kvfree(phy->rx_capture_data); | ||
| phy->rx_capture_data = capture_buf; |
There was a problem hiding this comment.
So here we have phy->rx_capture_data. So the action in the other patch is just wrong (needs to be in the same patch as debugfs). Also not sure if all of this handling in terms of allocation makes the debugfs thing worth it! What's the big advantaged when compared with using IIO buffering?
Another side note is maybe kvrealloc() would also make this simpler?
f931c3f to
3ac56dd
Compare
Add a dedicated IIO device (adrv904x-ramc) for RX/ORx data capture with proper I/Q channel representation and standard IIO buffer interface. Features: - 10 channel pairs (RX0-7, ORX0-1) with I/Q modifiers - Channels appear as voltage0_i/voltage0_q through voltage9_i/voltage9_q - Hardware constraint enforced via available_scan_masks: only one I/Q pair can be captured at a time - Single-shot capture: enabling the buffer triggers one capture that fills the buffer, then stops. This matches the hardware behavior (capture RAM is a snapshot mechanism, not continuous streaming) - Configurable capture size via sample_count attribute (32-32768) - 28-bit two's complement data using sign_extend32() - Bank interleaving and Q negation per hardware specification The single-shot behavior is intentional: continuous RX data is available through the JESD streaming interface (axi-adrv904x-rx-hpc). RAM capture is designed for debugging, calibration verification, and signal analysis where point-in-time snapshots are needed. Usage with iio_readdev: iio_readdev -s 1024 adrv904x-ramc voltage0_i voltage0_q > capture.bin Signed-off-by: Stefan Popa <stefan.popa@analog.com>
Add a debugfs interface for triggering single-shot RX/ORx data captures from the ADRV904x capture RAM. This provides a simple mechanism for debugging and signal analysis without requiring full IIO buffer setup. The rx_data_capture debugfs file accepts channel and capture length: echo "<channel> <length>" > rx_data_capture cat rx_data_capture Channel mapping: 0-7 for RX0-RX7, 8-9 for ORX0-ORX1. Capture length must be a hardware-supported size (32 to 32768 samples). ORX channels are limited to 12288 samples maximum. The captured data is stored as raw 32-bit values (one per line) and contains interleaved I/Q samples in hardware format. Memory allocation is performed before taking the device mutex to avoid sleeping with locks held. Signed-off-by: Stefan Popa <stefan.popa@analog.com>
3ac56dd to
720ecd7
Compare
|
changelog v2:
|
|
@nunojsa any remarks on v2? Thanks! |
|
@nunojsa when you get the chance, could you please take a look on v2? |
PR Description
PR Type
PR Checklist