Skip to content

Commit

Permalink
greybus: tracing: define bundle traces
Browse files Browse the repository at this point in the history
Define a new gb_bundle trace point event class, used to trace events
associated with the bundle abstraction.  Define four basic trace
points for this--creation time, drop of last reference, before
adding it to its interface and when removed when its interface
is destroyed.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
  • Loading branch information
Alex Elder authored and Greg Kroah-Hartman committed Jun 4, 2016
1 parent 6879dbf commit 4f9c5c0
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/staging/greybus/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

#include "greybus.h"
#include "greybus_trace.h"

static ssize_t bundle_class_show(struct device *dev,
struct device_attribute *attr, char *buf)
Expand Down Expand Up @@ -82,6 +83,8 @@ static void gb_bundle_release(struct device *dev)
{
struct gb_bundle *bundle = to_gb_bundle(dev);

trace_gb_bundle_release(bundle);

kfree(bundle->state);
kfree(bundle->cport_desc);
kfree(bundle);
Expand Down Expand Up @@ -136,6 +139,8 @@ struct gb_bundle *gb_bundle_create(struct gb_interface *intf, u8 bundle_id,

list_add(&bundle->links, &intf->bundles);

trace_gb_bundle_create(bundle);

return bundle;
}

Expand All @@ -149,6 +154,8 @@ int gb_bundle_add(struct gb_bundle *bundle)
return ret;
}

trace_gb_bundle_add(bundle);

return 0;
}

Expand All @@ -157,6 +164,8 @@ int gb_bundle_add(struct gb_bundle *bundle)
*/
void gb_bundle_destroy(struct gb_bundle *bundle)
{
trace_gb_bundle_destroy(bundle);

if (device_is_registered(&bundle->dev))
device_del(&bundle->dev);

Expand Down
56 changes: 56 additions & 0 deletions drivers/staging/greybus/greybus_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

struct gb_message;
struct gb_operation;
struct gb_bundle;
struct gb_host_device;

#define gb_bundle_name(message) \
Expand Down Expand Up @@ -161,6 +162,61 @@ DEFINE_OPERATION_EVENT(gb_operation_put_active);

#undef DEFINE_OPERATION_EVENT

DECLARE_EVENT_CLASS(gb_bundle,

TP_PROTO(struct gb_bundle *bundle),

TP_ARGS(bundle),

TP_STRUCT__entry(
__field(u8, intf_id)
__field(u8, id)
__field(u8, class)
__field(size_t, num_cports)
),

TP_fast_assign(
__entry->intf_id = bundle->intf->interface_id;
__entry->id = bundle->id;
__entry->class = bundle->class;
__entry->num_cports = bundle->num_cports;
),

TP_printk("intf_id=0x%02x id=%02x class=0x%02x num_cports=%zu",
__entry->intf_id, __entry->id, __entry->class,
__entry->num_cports)
);

#define DEFINE_BUNDLE_EVENT(name) \
DEFINE_EVENT(gb_bundle, name, \
TP_PROTO(struct gb_bundle *bundle), \
TP_ARGS(bundle))

/*
* Occurs after a new bundle is successfully created.
*/
DEFINE_BUNDLE_EVENT(gb_bundle_create);

/*
* Occurs when the last reference to a bundle has been dropped,
* before its resources are freed.
*/
DEFINE_BUNDLE_EVENT(gb_bundle_release);

/*
* Occurs when a bundle is added to an interface when the interface
* is enabled.
*/
DEFINE_BUNDLE_EVENT(gb_bundle_add);

/*
* Occurs when a registered bundle gets destroyed, normally at the
* time an interface is disabled.
*/
DEFINE_BUNDLE_EVENT(gb_bundle_destroy);

#undef DEFINE_BUNDLE_EVENT

DECLARE_EVENT_CLASS(gb_interface,

TP_PROTO(struct gb_interface *intf),
Expand Down

0 comments on commit 4f9c5c0

Please sign in to comment.