This change renames the I2C debug counters as suggested, and moves their processing into the i2c core: - bus_errors - transfers - nacks - recovery_successes - recovery_failures - timeouts Did some brief tests with a few test programs that saves/replays I2C trace by reading hwmon sensors. The test program and hardware run in QEMU. The test programs are located at https://gerrit.openbmc-project.xyz/c/openbmc/openbmc-tools/+/52527 (A normal read) root@gsj:/tmp# cat /sys/class/i2c-adapter/i2c-1/stats/transfers 264 root@gsj:/tmp# ./i2c_bmk_bmc 0 idx=0 Processing 1 inputs /sys/class/hwmon/hwmon0/temp1_input (../../devices/platform/ahb/ahb:apb/f0081000.i2c/i2c-1/1-005c/hwmon/hwmon0): 0 [FindTraceEntries] t0=391.000000 t1=393.000000 Found 4 interesting I2C trace entries: i2c_write: i2c-1 #0 a=05c f=0000 l=1 [00] i2c_read: i2c-1 #1 a=05c f=0001 l=2 i2c_reply: i2c-1 #1 a=05c f=0001 l=2 [00-00] i2c_result: i2c-1 n=2 ret=2 root@gsj:/tmp# cat /sys/class/i2c-adapter/i2c-1/stats/transfers 265 (Read from an inexistent address, NACK) root@gsj:/tmp# cat /sys/class/i2c-adapter/i2c-1/stats/nacks 6 root@gsj:/tmp# cat /sys/class/i2c-adapter/i2c-1/stats/transfers 265 root@gsj:/tmp# cat i2c_trace.txt i2c_write: i2c-1 #0 a=0ff f=0000 l=1 [00] i2c_read: i2c-1 #1 a=0ff f=0001 l=2 root@gsj:/tmp# ./i2c_replay_bmc i2c_trace.txt (program runs and finishes with 6 errors) root@gsj:/tmp# cat /sys/class/i2c-adapter/i2c-1/stats/nacks 12 root@gsj:/tmp# cat /sys/class/i2c-adapter/i2c-1/stats/transfers 265 The program makes 2 attempts, performing 3 I2C operations at each attempt, which translates to the 6 nack events. We will do more testing. Sui Chen (1): i2c debug counters as sysfs attributes drivers/i2c/i2c-core-base.c | 32 ++++++++++++- drivers/i2c/i2c-dev.c | 94 +++++++++++++++++++++++++++++++++++++ include/linux/i2c.h | 26 ++++++++++ 3 files changed, 151 insertions(+), 1 deletion(-) -- 2.35.1.1094.g7c7d902a7c-goog