Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752534AbdFGTQR (ORCPT ); Wed, 7 Jun 2017 15:16:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:40160 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752316AbdFGTQO (ORCPT ); Wed, 7 Jun 2017 15:16:14 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C160923954 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Wed, 7 Jun 2017 15:16:10 -0400 From: Steven Rostedt To: Christopher Bostic Cc: robh+dt@kernel.org, mark.rutland@arm.com, linux@armlinux.org.uk, mingo@redhat.com, gregkh@linuxfoundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Jeremy Kerr , joel@jms.id.au, linux-kernel@vger.kernel.org, andrew@aj.id.au, alistair@popple.id.au, benh@kernel.crashing.org Subject: Re: [PATCH v8 16/24] drivers/fsi: Add tracepoints for low-level operations Message-ID: <20170607151610.52f7bc88@gandalf.local.home> In-Reply-To: <20170606210859.80431-17-cbostic@linux.vnet.ibm.com> References: <20170606210859.80431-1-cbostic@linux.vnet.ibm.com> <20170606210859.80431-17-cbostic@linux.vnet.ibm.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6356 Lines: 242 On Tue, 6 Jun 2017 16:08:51 -0500 Christopher Bostic wrote: > From: Jeremy Kerr > > Trace low level read and write FSI bus operations. > > Signed-off-by: Jeremy Kerr > Signed-off-by: Joel Stanley > Signed-off-by: Christopher Bostic > --- > v8 - type cast to 'int' to clean up build warnings > --- > drivers/fsi/fsi-core.c | 27 +++++++--- > include/trace/events/fsi.h | 127 +++++++++++++++++++++++++++++++++++++++++++++ > 2 files changed, 148 insertions(+), 6 deletions(-) > create mode 100644 include/trace/events/fsi.h > > diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c > index 3681365..db54561 100644 > --- a/drivers/fsi/fsi-core.c > +++ b/drivers/fsi/fsi-core.c > @@ -23,6 +23,9 @@ > > #include "fsi-master.h" > > +#define CREATE_TRACE_POINTS > +#include > + > #define FSI_SLAVE_CONF_NEXT_MASK GENMASK(31, 31) > #define FSI_SLAVE_CONF_SLOTS_MASK GENMASK(23, 16) > #define FSI_SLAVE_CONF_SLOTS_SHIFT 16 > @@ -542,11 +545,16 @@ static int fsi_master_read(struct fsi_master *master, int link, > { > int rc; > > + trace_fsi_master_read(master, link, slave_id, addr, size); > + > rc = fsi_check_access(addr, size); > - if (rc) > - return rc; > + if (!rc) > + rc = master->read(master, link, slave_id, addr, val, size); > + > + trace_fsi_master_rw_result(master, link, slave_id, addr, size, > + false, val, rc); > > - return master->read(master, link, slave_id, addr, val, size); > + return rc; > } > > static int fsi_master_write(struct fsi_master *master, int link, > @@ -554,11 +562,16 @@ static int fsi_master_write(struct fsi_master *master, int link, > { > int rc; > > + trace_fsi_master_write(master, link, slave_id, addr, size, val); > + > rc = fsi_check_access(addr, size); > - if (rc) > - return rc; > + if (!rc) > + rc = master->write(master, link, slave_id, addr, val, size); > > - return master->write(master, link, slave_id, addr, val, size); > + trace_fsi_master_rw_result(master, link, slave_id, addr, size, > + true, val, rc); > + > + return rc; > } > > static int fsi_master_link_enable(struct fsi_master *master, int link) > @@ -574,6 +587,8 @@ static int fsi_master_link_enable(struct fsi_master *master, int link) > */ > static int fsi_master_break(struct fsi_master *master, int link) > { > + trace_fsi_master_break(master, link); > + > if (master->send_break) > return master->send_break(master, link); > > diff --git a/include/trace/events/fsi.h b/include/trace/events/fsi.h > new file mode 100644 > index 0000000..697ee66 > --- /dev/null > +++ b/include/trace/events/fsi.h > @@ -0,0 +1,127 @@ > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM fsi > + > +#if !defined(_TRACE_FSI_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_FSI_H > + > +#include > + > +TRACE_EVENT(fsi_master_read, > + TP_PROTO(const struct fsi_master *master, int link, int id, > + uint32_t addr, size_t size), > + TP_ARGS(master, link, id, addr, size), > + TP_STRUCT__entry( > + __field(int, master_idx) > + __field(int, link) > + __field(int, id) > + __field(__u32, addr) > + __field(size_t, size) > + ), > + TP_fast_assign( > + __entry->master_idx = master->idx; > + __entry->link = link; > + __entry->id = id; > + __entry->addr = addr; > + __entry->size = size; > + ), > + TP_printk("fsi%d:%02d:%02d %08x[%zd]", > + __entry->master_idx, > + __entry->link, > + __entry->id, > + __entry->addr, > + __entry->size > + ) > +); > + > +TRACE_EVENT(fsi_master_write, > + TP_PROTO(const struct fsi_master *master, int link, int id, > + uint32_t addr, size_t size, const void *data), > + TP_ARGS(master, link, id, addr, size, data), > + TP_STRUCT__entry( > + __field(int, master_idx) > + __field(int, link) > + __field(int, id) > + __field(__u32, addr) > + __field(size_t, size) > + __field(__u32, data) > + ), > + TP_fast_assign( > + __entry->master_idx = master->idx; > + __entry->link = link; > + __entry->id = id; > + __entry->addr = addr; > + __entry->size = size; > + __entry->data = 0; > + memcpy(&__entry->data, data, size); Um, can size ever be greater than 4? If so, this is a bug. I think you may want to use a dynamic array here. TP_STRUCT__entry( [..] __dynamic_array(char, data, size) [..] TP_fast_assign( [..] memcpy(__get_dynamic_array(data), data, size); [..] TP_printk(... [..] __entry->size, __get_dynamic_array(data) You may also want to look at __print_array() too. Same with below. -- Steve > + ), > + TP_printk("fsi%d:%02d:%02d %08x[%zd] <= {%*ph}", > + __entry->master_idx, > + __entry->link, > + __entry->id, > + __entry->addr, > + __entry->size, > + (int)__entry->size, &__entry->data > + ) > +); > + > +TRACE_EVENT(fsi_master_rw_result, > + TP_PROTO(const struct fsi_master *master, int link, int id, > + uint32_t addr, size_t size, > + bool write, const void *data, int ret), > + TP_ARGS(master, link, id, addr, size, write, data, ret), > + TP_STRUCT__entry( > + __field(int, master_idx) > + __field(int, link) > + __field(int, id) > + __field(__u32, addr) > + __field(size_t, size) > + __field(bool, write) > + __field(__u32, data) > + __field(int, ret) > + ), > + TP_fast_assign( > + __entry->master_idx = master->idx; > + __entry->link = link; > + __entry->id = id; > + __entry->addr = addr; > + __entry->size = size; > + __entry->write = write; > + __entry->data = 0; > + __entry->ret = ret; > + if (__entry->write || !__entry->ret) > + memcpy(&__entry->data, data, size); > + ), > + TP_printk("fsi%d:%02d:%02d %08x[%zd] %s {%*ph} ret %d", > + __entry->master_idx, > + __entry->link, > + __entry->id, > + __entry->addr, > + __entry->size, > + __entry->write ? "<=" : "=>", > + (int)__entry->size, &__entry->data, > + __entry->ret > + ) > +); > + > +TRACE_EVENT(fsi_master_break, > + TP_PROTO(const struct fsi_master *master, int link), > + TP_ARGS(master, link), > + TP_STRUCT__entry( > + __field(int, master_idx) > + __field(int, link) > + ), > + TP_fast_assign( > + __entry->master_idx = master->idx; > + __entry->link = link; > + ), > + TP_printk("fsi%d:%d", > + __entry->master_idx, > + __entry->link > + ) > +); > + > + > +#endif /* _TRACE_FSI_H */ > + > +#include