[PATCH v3 0/3] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters

From: Po-Wen Kao

Date: Wed Nov 25 2026 - 06:34:44 EST


From: Brian Kao <powenkao@xxxxxxxxxx>

This series exposes the MIPI UniPro v3.0 PA layer TFS/FEC error
counters (0x15C3-0x15C7) under debugfs:

/sys/kernel/debug/ufshcd/<dev>/pa_err_stats/{host,device}/

Patch 1 fixes an existing teardown race by removing debugfs and
disabling debugfs_ee_work before scsi_remove_host() removes the WLUN.
Patch 2 defers debugfs creation until after device init while keeping
debugfs_ee_work initialization before IRQs are enabled. Patch 3 adds
the PA_TFS_* and UniPro 2.0/3.0 definitions and creates
pa_err_stats/{host,device}/ based on PA_LOCALVERINFO / PA_REMOTEVERINFO.

Changes in v3 (suggested by Bart Van Assche):
- Split the ufshcd_remove() teardown fix into patch 1 with Fixes and
stable tags.
- Patch 2: Initialize debugfs_ee_work and debugfs_ee_rate_limit_ms
before IRQs are enabled via ufs_debugfs_ee_init(), and document the
later fault-injection attribute initialization.
- Patch 3: Gate host/ and device/ on UniPro version (PA_LOCALVERINFO /
PA_REMOTEVERINFO >= UFS_UNIPRO_VER_3_0), merge the duplicated host
and device attribute arrays into one via debugfs_create_file_aux_num(),
update the hba_from_file() comment, and clarify the 64-bit read/reset
comments.

Changes in v2:
- Defer ufs_debugfs_hba_init() until after device init (suggested by
Peter Wang).
- Create pa_err_stats/host/ and device/ only when supported instead of
returning -EOPNOTSUPP on read/write.

Link: https://lore.kernel.org/linux-scsi/20261124012951.3143833-1-powenkao@xxxxxxxxxx/
Link: https://lore.kernel.org/linux-scsi/20261123025745.1743640-1-powenkao@xxxxxxxxxx/

Brian Kao (3):
scsi: ufs: core: Remove debugfs before removing SCSI host
scsi: ufs: core: Defer debugfs init until after device init
scsi: ufs: core: Add debugfs for PA TFS/FEC error counters

drivers/ufs/core/ufs-debugfs.c | 244 ++++++++++++++++++++++++++++++++-
drivers/ufs/core/ufs-debugfs.h | 2 +
drivers/ufs/core/ufshcd.c | 8 +-
include/ufs/unipro.h | 9 +-
4 files changed, 252 insertions(+), 11 deletions(-)


base-commit: 08fec21faae44fe002467976befd68e6e62969b5
--
2.56.1.839.g22a8290db9-goog