From: Sui Chen <suichen@google.com>
To: linux-i2c@vger.kernel.org
Subject: [RFC Patch 0/2] I2C statistics as sysfs attributes
Date: Mon, 11 Oct 2021 18:07:25 -0700 [thread overview]
Message-ID: <CAJOps0s4qY3O36BGUpffzzA=gxw_crDzf_iif2fq0RdVhfCydg@mail.gmail.com> (raw)
It appears bus errors and NACK counts are frequently found in many
I2C controllers; a few I2C bus drivers now export those counters to
debugfs. There is some effort in attempting to monitor a large
number of BMCs (board management controllers) and we are wondering if
it is possible to have a more stable and unified interface for those
counters to be exported to compared to the debugfs, so that a single
command can be used to obtain the counters from different types of I2C
controllers.
One possible prototype is included in the patchset where debug
counters are populated in /sys/class/i2c-adapter/i2c-X/stats/.
By default only an empty stats folder is created, and it is up to the
platform drivers to instantiate the counters and link the counters to
the data structures internal to the bus drivers.
From the kernel data structure point of view, the statistics are
a property of an i2c_adapter (and not an i2c_dev). From the driver
type point of view, the counters should only be instantiated by a
platform driver (such as bus drivers) and not a device driver (such
as mux drivers.) In this example, the npcm7xx driver instantiates the
counters.
The patchset is intended to request comments on whether the goal makes
sense and what a good approach looks like.
Patch 1: add i2c statistics to i2c_adapter
Patch 2: instantiate i2c statistics from the npcm7xx i2c bus driver
TODO:
- Decide on which counters to be included (maybe start with BER and
NACK?)
- Use enums and not strings as counter names
- Make binding more flexible so a counter can be backed by some
function and not only pointer to a value
The desired effect can be tested by building and running an OpenBMC
distribution targeted at the npcm7xx SoC and running the image in QEMU.
The testing steps are as follows:
1. Clone the OpenBMC repository
2. `devtool modify`and apply patch to the linux-nuvoton recipe
3. Build image for quanta-gsj
4. Build QEMU
5. Run the image-bmc image in QEMU
Results:
root@gsj:/sys/class/i2c-adapter/i2c-1/stats# ls
ber_cnt i2c_speed nack_cnt rec_fail_cnt rec_succ_cnt
timeout_cnt
root@gsj:/sys/class/i2c-adapter/i2c-1/stats# cat *
0
100000
0
0
0
0
Patch list:
Sui Chen (2):
i2c debug counters as sysfs attributes
add npcm7xx debug counters as sysfs attributes
drivers/i2c/busses/i2c-npcm7xx.c | 8 ++++++++
drivers/i2c/i2c-core-base.c | 3 +++
drivers/i2c/i2c-dev.c | 99
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/i2c.h | 21 +++++++++++++++++++++
4 files changed, 131 insertions(+)
next reply other threads:[~2021-10-12 1:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 1:07 Sui Chen [this message]
2021-11-29 17:09 ` [RFC Patch 0/2] I2C statistics as sysfs attributes Wolfram Sang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAJOps0s4qY3O36BGUpffzzA=gxw_crDzf_iif2fq0RdVhfCydg@mail.gmail.com' \
--to=suichen@google.com \
--cc=linux-i2c@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).