From: Wolfram Sang <wsa@the-dreams.de>
To: David Howells <dhowells@redhat.com>
Cc: wolfram@the-dreams.de, khali@linux-fr.org,
linux-i2c@vger.kernel.org, Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] i2c: Add message transfer tracepoints for I2C
Date: Tue, 18 Feb 2014 21:33:46 +0100 [thread overview]
Message-ID: <20140218203346.GG18768@katana> (raw)
In-Reply-To: <20140109214954.25590.73057.stgit@warthog.procyon.org.uk>
[-- Attachment #1: Type: text/plain, Size: 3152 bytes --]
Hi David,
On Thu, Jan 09, 2014 at 09:49:54PM +0000, David Howells wrote:
> Add tracepoints into the I2C message transfer function to retrieve the message
> sent or received. The following config options must be turned on to make use
> of the facility:
>
> CONFIG_FTRACE
> CONFIG_ENABLE_DEFAULT_TRACERS
>
> The I2C tracepoint can be enabled thusly:
>
> echo 1 >/sys/kernel/debug/tracing/events/i2c/i2c_transfer/enable
>
> and will dump messages that can be viewed in /sys/kernel/debug/tracing/trace
> that look like:
>
> ... i2c_write: i2c-5 #0 f=00 a=44 l=2 [0214]
> ... i2c_read: i2c-5 #1 f=01 a=44 l=4
> ... i2c_reply: i2c-5 #1 f=01 a=44 l=4 [33000000]
> ... i2c_result: i2c-5 n=2 ret=2
>
> formatted as:
>
> i2c-<adapter-nr>
> #<message-array-index>
> f=<flags>
> a=<addr>
> l=<datalen>
> n=<message-array-size>
> ret=<result>
> [<data>]
>
> The operation is done between the i2c_write/i2c_read lines and the i2c_reply
> and i2c_result lines so that if the hardware hangs, the trace buffer can be
> consulted to determine the problematic operation.
>
> The adapters to be traced can be selected by something like:
>
> echo adapter_nr==1 >/sys/kernel/debug/tracing/events/i2c/filter
>
> These changes are based on code from Steven Rostedt.
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> Signed-off-by: David Howells <dhowells@redhat.com>
> Reviewed-by: Steven Rostedt <rostedt@goodmis.org>
I like it very much, just have some comments about the format.
> +TRACE_EVENT_FN(i2c_write,
> + TP_PROTO(const struct i2c_adapter *adap, const struct i2c_msg *msg,
> + int num),
> + TP_ARGS(adap, msg, num),
> + TP_STRUCT__entry(
> + __field(int, adapter_nr )
> + __field(__u16, msg_nr )
> + __field(__u16, addr )
> + __field(__u16, flags )
> + __field(__u16, len )
> + __dynamic_array(__u8, buf, msg->len) ),
> + TP_fast_assign(
> + __entry->adapter_nr = adap->nr;
> + __entry->msg_nr = num;
> + __entry->addr = msg->addr;
> + __entry->flags = msg->flags;
> + __entry->len = msg->len;
> + memcpy(__get_dynamic_array(buf), msg->buf, msg->len);
> + ),
> + TP_printk("i2c-%d #%u f=%02x a=%02x l=%u [%*phN]",
'flags' are u16 and the whole range is needed -> %04x
'addr' is u16 and either 7 or 10 bits are needed. The core does the
following when assigning names because it is possible to have devices
0x50 (7-bit) and 0x050 (10-bit) on the bus:
/* For 10-bit clients, add an arbitrary offset to avoid collisions */
dev_set_name(&client->dev, "%d-%04x", i2c_adapter_id(adap),
client->addr | ((client->flags & I2C_CLIENT_TEN)
? 0xa000 : 0));
I don't know if this can be implemented. Actually, I don't think it
needs to be implemented since flags are printed, too. So, with this the
10-bit case is visible and for the address simply %03x should do.
And for the buffer: %*phN is difficult to read IMO. What about %*ph? Or
%*phD at least?
Thanks,
Wolfram
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2014-02-18 20:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-09 21:49 [PATCH 1/2] i2c: Add message transfer tracepoints for I2C David Howells
2014-01-09 21:50 ` [PATCH 2/2] i2c: Add message transfer tracepoints for SMBUS David Howells
2014-02-18 20:54 ` Wolfram Sang
2014-02-27 13:19 ` David Howells
2014-02-28 21:21 ` Wolfram Sang
2014-03-01 7:48 ` David Howells
2014-03-06 13:13 ` David Howells
2014-03-06 13:17 ` Wolfram Sang
2014-03-06 13:38 ` David Howells
2014-01-22 19:09 ` [PATCH 1/2] i2c: Add message transfer tracepoints for I2C Wolfram Sang
2014-02-18 20:33 ` Wolfram Sang [this message]
2014-02-27 13:07 ` David Howells
2014-02-28 21:17 ` Wolfram Sang
2014-03-01 7:54 ` David Howells
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=20140218203346.GG18768@katana \
--to=wsa@the-dreams.de \
--cc=dhowells@redhat.com \
--cc=khali@linux-fr.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=wolfram@the-dreams.de \
/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).