Staging/xlnx/ad9084 cfir sparse mode support#3254
Conversation
Three small correctness fixes in ad9088_parse_cfilt() plus a thorough
kernel-doc rewrite so the cfir_config sysfs blob format is actually
discoverable:
- enable: and coeff_transfer: both claimed BIT(6) in read_mask, so
a blob containing both silently dropped one of them and ran the
enable-path with uninitialized enable/enable_profile. Move enable
to BIT(8) and widen read_mask to u16.
- gain: was parsed into a u32 via %d, breaking negative-dB values
that ad9088_cfir_gain_enc() expects (-18/-12/-6). Use a dedicated
s32.
- Bound the %s conversions in "enable: " and "selection_mode: " to
the destination buffer size (%15s). Also applied to the matching
pfilt parser.
The new kdoc enumerates every directive, its value set, the bit it
claims in read_mask, the Apollo API call it feeds, and the post-parse
programming order.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
|
Automated review run: https://github.com/analogdevicesinc/linux/actions/runs/24449775287 This series ( ✅
|
The cfir_config sysfs blob accepts sparse_filt_en but never programs
the sparse-mode control values, so enabling sparse mode leaves hsel
and mem_sel at stale HW/profile defaults and the filter silently
produces garbage.
Extend ad9088_parse_cfilt() to:
- switch the coefficient-line scanner to "<i> <q> <hsel>" when
sparse_filt_en: 1 has already been parsed (I/Q columns stay in the
same position as the non-sparse layout, hsel 0..63 appended);
- accept an optional "sparse_mem_sel: <m0> <m1> <m2>" directive
(each 0..3) for explicit Dstore0/2/5/7 spacing;
- require exactly ADI_APOLLO_CFIR_COEFF_NUM (16) taps in sparse mode;
- push the values down via adi_apollo_cfir_sparse_coeff_sel_pgm()
and adi_apollo_cfir_sparse_mem_sel_pgm() right after the ordinary
coefficient load, before cfir_pgm() flips the sparse-enable bit.
The kdoc now documents both the Dstore/hsel model
and the UG sec. 6389 limitation on hsel=15/31/47/63 when Dstores are
non-contiguous.
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Two real fixes plus a thorough kernel-doc rewrite for the pfilt_config
sysfs blob format:
- The pfilt_mask / bank_mask forms in the "dest:" directive scanned
the full line ("dest: rx pfilt_maskN bank_X") with a format string
anchored at "pfilt_mask%u" / "bank_mask%u", so the mask values never
matched and whatever stale value was in the local was used instead.
Scan the pre-extracted pfilt/bank substrings.
- When "dest:" was absent the debug prints and the two Apollo API
calls that followed ran with uninitialized terminal/pfilt_sel/
bank_sel. Error out with -EINVAL like the CFIR parser does.
The new kdoc enumerates every directive and its value set, maps the
gain slots to the UG matrix-mode Ga/Gb/Gc/Gd labelling, documents the
scalar_gain encoding, explains when mode_switch / hc_delay apply, lists
the per-mode coefficient-count requirement, and spells out the
selection_mode variants (including the 2-GPIO config-0/config-1 split
that CFIR lacks).
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
3bc9ff8 to
81d51e8
Compare
|
Fixed:
Did not fix:
%i parses decimals as well as hex values - that's what we need. |
nunojsa
left a comment
There was a problem hiding this comment.
Just one remark from me
| } | ||
| } else { | ||
| ret = sscanf(line, "%i %i", &sval_i, &sval_q); | ||
| if (ret == 2) { |
There was a problem hiding this comment.
Should we ignore errors? Same for all the abov e
There was a problem hiding this comment.
I'll take a look
Replace generic "malformed filter file" messages with specific per- directive errors that name the offending keyword/value. Route all Apollo API return values through ad9088_check_apollo_error() for consistent human-readable error strings and proper errno mapping. Key changes: - Validate sysfs_match_string() results before storing (PFILT mode: previously stored negative returns as enum values) - Report which directive and value failed (e.g. "dest: unknown terminal 'foo'", "mode: unknown Q mode 'bar'") - Log coefficient overflow with the max count - API failures now return error codes instead of silently returning size (success) - Remove goto out/out1 spaghetti in favour of direct returns - Skip empty lines alongside comment lines - Move selection_mode debug print inside the BIT(9) guard to avoid printing uninitialized data - Capture return value of adi_apollo_cfir_profile_sel() which was previously unchecked Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Change ad9088_iiochan_to_cfir() from void to int so callers can detect failure. Previously, if ad9088_get_chan_map() returned NULL or the switch hit the default case, the output parameters (terminal, cfir_sel, dp_sel) were left uninitialized and passed straight into Apollo API calls — flagged by clang's core.CallAndMessage checker. Return -EINVAL on both the NULL-map and unhandled-FDDC paths, and check the return value at all four call sites. Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
PR Description
Two commits touching ad9088_parse_cfilt() (the parser behind the cfir_config sysfs bin attribute):
- enable: and coeff_transfer: both claimed BIT(6) in read_mask, silently dropping one when both were present and running the enable-path with uninitialized locals. Moved enable: to BIT(8) and widened read_mask to u16.
- gain: was read into a u32 via %d, breaking negative-dB values. Use a dedicated s32.
- Bound %s conversions in enable: / selection_mode: (cfir + pfilt) to %15s.
- Rewrote the kernel-doc to enumerate every directive, its value set, the read_mask bit, the Apollo API it feeds, and the post-parse programming order.
- The blob accepted sparse_filt_en but never called adi_apollo_cfir_sparse_coeff_sel_pgm() / adi_apollo_cfir_sparse_mem_sel_pgm(), so sparse mode silently used stale HW state.
- When sparse_filt_en: 1 precedes the coefficient block, each tap line is now
PR Type