Re: [PATCH v2 2/2] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters
From: Peter Wang
Date: Tue Nov 24 2026 - 01:20:44 EST
On Tue, 2026-11-24 at 09:29 +0800, Po-Wen Kao wrote:
> From: Brian Kao <powenkao@xxxxxxxxxx>
>
> MIPI UniPro v3.0 introduces the Transport Framing Structure (TFS)
> with
> Reed-Solomon Forward Error Correction (FEC) in the Physical Adapter
> (PA) layer, along with five PA MIB attributes (0x15C3-0x15C7) that
> count TFS frames with uncorrectable FEC errors, TFS CRC errors, TFS
> format errors, and 64-bit corrected FEC symbols. Exposing these
> counters allows observing pre-FEC symbol correction and framing
> errors
> for HS-G6 (1b1b) link-margin diagnostics without dropping the link.
>
> Define the PA_TFS_* attributes in include/ufs/unipro.h and expose
> them
> under debugfs:
>
> /sys/kernel/debug/ufshcd/<dev>/pa_err_stats/{host,device}/
> - fec_err_cnt
> - crc_err_cnt
> - format_err_cnt
> - recovered_fec_symbols
>
> Skip creation entirely on hosts setting UFSHCD_QUIRK_BROKEN_UIC_CMD.
> Otherwise gate each subdirectory independently: host/ is created when
> UFSHCI >= 5.0, and device/ is created when wSpecVersion >= 0x0500
> (the
> pa_err_stats parent directory is omitted if neither is supported).
>
> Each file reads the local (host) or peer (device) PA attribute and
> resets it to 0 when '0' is written. Writing PA_TFS_RecErrorCountL
> clears the full 64-bit PA_TFS_RecErrorCount counter per MIPI UniPro
> v3.0 Section 5.6.7, and reads sample the high/low words with a
> bounded
> hi-lo-hi retry loop to avoid 32-bit rollover tearing. Positive UIC
> command result codes are translated to standard negative errno
> values.
>
> Signed-off-by: Brian Kao <powenkao@xxxxxxxxxx>
> ---
Reviewed-by: Peter Wang <peter.wang@xxxxxxxxxxxx>