1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 253b615ccSMing Lei 353b615ccSMing Lei #undef TRACE_SYSTEM 453b615ccSMing Lei #define TRACE_SYSTEM rpm 553b615ccSMing Lei 653b615ccSMing Lei #if !defined(_TRACE_RUNTIME_POWER_H) || defined(TRACE_HEADER_MULTI_READ) 753b615ccSMing Lei #define _TRACE_RUNTIME_POWER_H 853b615ccSMing Lei 953b615ccSMing Lei #include <linux/ktime.h> 1053b615ccSMing Lei #include <linux/tracepoint.h> 11313162d0SPaul Gortmaker 12313162d0SPaul Gortmaker struct device; 1353b615ccSMing Lei 1453b615ccSMing Lei /* 1553b615ccSMing Lei * The rpm_internal events are used for tracing some important 1653b615ccSMing Lei * runtime pm internal functions. 1753b615ccSMing Lei */ 1853b615ccSMing Lei DECLARE_EVENT_CLASS(rpm_internal, 1953b615ccSMing Lei 2053b615ccSMing Lei TP_PROTO(struct device *dev, int flags), 2153b615ccSMing Lei 2253b615ccSMing Lei TP_ARGS(dev, flags), 2353b615ccSMing Lei 2453b615ccSMing Lei TP_STRUCT__entry( 2553b615ccSMing Lei __string( name, dev_name(dev) ) 2653b615ccSMing Lei __field( int, flags ) 2753b615ccSMing Lei __field( int , usage_count ) 2853b615ccSMing Lei __field( int , disable_depth ) 2953b615ccSMing Lei __field( int , runtime_auto ) 3053b615ccSMing Lei __field( int , request_pending ) 3153b615ccSMing Lei __field( int , irq_safe ) 3253b615ccSMing Lei __field( int , child_count ) 3353b615ccSMing Lei ), 3453b615ccSMing Lei 3553b615ccSMing Lei TP_fast_assign( 36*2c92ca84SSteven Rostedt (Google) __assign_str(name); 3753b615ccSMing Lei __entry->flags = flags; 3853b615ccSMing Lei __entry->usage_count = atomic_read( 3953b615ccSMing Lei &dev->power.usage_count); 4053b615ccSMing Lei __entry->disable_depth = dev->power.disable_depth; 4153b615ccSMing Lei __entry->runtime_auto = dev->power.runtime_auto; 4253b615ccSMing Lei __entry->request_pending = dev->power.request_pending; 4353b615ccSMing Lei __entry->irq_safe = dev->power.irq_safe; 4453b615ccSMing Lei __entry->child_count = atomic_read( 4553b615ccSMing Lei &dev->power.child_count); 4653b615ccSMing Lei ), 4753b615ccSMing Lei 4853b615ccSMing Lei TP_printk("%s flags-%x cnt-%-2d dep-%-2d auto-%-1d p-%-1d" 4953b615ccSMing Lei " irq-%-1d child-%d", 5053b615ccSMing Lei __get_str(name), __entry->flags, 5153b615ccSMing Lei __entry->usage_count, 5253b615ccSMing Lei __entry->disable_depth, 5353b615ccSMing Lei __entry->runtime_auto, 5453b615ccSMing Lei __entry->request_pending, 5553b615ccSMing Lei __entry->irq_safe, 5653b615ccSMing Lei __entry->child_count 5753b615ccSMing Lei ) 5853b615ccSMing Lei ); 5953b615ccSMing Lei DEFINE_EVENT(rpm_internal, rpm_suspend, 6053b615ccSMing Lei 6153b615ccSMing Lei TP_PROTO(struct device *dev, int flags), 6253b615ccSMing Lei 6353b615ccSMing Lei TP_ARGS(dev, flags) 6453b615ccSMing Lei ); 6553b615ccSMing Lei DEFINE_EVENT(rpm_internal, rpm_resume, 6653b615ccSMing Lei 6753b615ccSMing Lei TP_PROTO(struct device *dev, int flags), 6853b615ccSMing Lei 6953b615ccSMing Lei TP_ARGS(dev, flags) 7053b615ccSMing Lei ); 7153b615ccSMing Lei DEFINE_EVENT(rpm_internal, rpm_idle, 7253b615ccSMing Lei 7353b615ccSMing Lei TP_PROTO(struct device *dev, int flags), 7453b615ccSMing Lei 7553b615ccSMing Lei TP_ARGS(dev, flags) 7653b615ccSMing Lei ); 77d2292906SMichał Mirosław DEFINE_EVENT(rpm_internal, rpm_usage, 78d2292906SMichał Mirosław 79d2292906SMichał Mirosław TP_PROTO(struct device *dev, int flags), 80d2292906SMichał Mirosław 81d2292906SMichał Mirosław TP_ARGS(dev, flags) 82d2292906SMichał Mirosław ); 8353b615ccSMing Lei 8453b615ccSMing Lei TRACE_EVENT(rpm_return_int, 8553b615ccSMing Lei TP_PROTO(struct device *dev, unsigned long ip, int ret), 8653b615ccSMing Lei TP_ARGS(dev, ip, ret), 8753b615ccSMing Lei 8853b615ccSMing Lei TP_STRUCT__entry( 8953b615ccSMing Lei __string( name, dev_name(dev)) 9053b615ccSMing Lei __field( unsigned long, ip ) 9153b615ccSMing Lei __field( int, ret ) 9253b615ccSMing Lei ), 9353b615ccSMing Lei 9453b615ccSMing Lei TP_fast_assign( 95*2c92ca84SSteven Rostedt (Google) __assign_str(name); 9653b615ccSMing Lei __entry->ip = ip; 9753b615ccSMing Lei __entry->ret = ret; 9853b615ccSMing Lei ), 9953b615ccSMing Lei 10053b615ccSMing Lei TP_printk("%pS:%s ret=%d", (void *)__entry->ip, __get_str(name), 10153b615ccSMing Lei __entry->ret) 10253b615ccSMing Lei ); 10353b615ccSMing Lei 104015abee4SVilas Bhat #define RPM_STATUS_STRINGS \ 105015abee4SVilas Bhat EM(RPM_INVALID, "RPM_INVALID") \ 106015abee4SVilas Bhat EM(RPM_ACTIVE, "RPM_ACTIVE") \ 107015abee4SVilas Bhat EM(RPM_RESUMING, "RPM_RESUMING") \ 108015abee4SVilas Bhat EM(RPM_SUSPENDED, "RPM_SUSPENDED") \ 109015abee4SVilas Bhat EMe(RPM_SUSPENDING, "RPM_SUSPENDING") 110015abee4SVilas Bhat 111015abee4SVilas Bhat /* Enums require being exported to userspace, for user tool parsing. */ 112015abee4SVilas Bhat #undef EM 113015abee4SVilas Bhat #undef EMe 114015abee4SVilas Bhat #define EM(a, b) TRACE_DEFINE_ENUM(a); 115015abee4SVilas Bhat #define EMe(a, b) TRACE_DEFINE_ENUM(a); 116015abee4SVilas Bhat 117015abee4SVilas Bhat RPM_STATUS_STRINGS 118015abee4SVilas Bhat 119015abee4SVilas Bhat /* 120015abee4SVilas Bhat * Now redefine the EM() and EMe() macros to map the enums to the strings that 121015abee4SVilas Bhat * will be printed in the output. 122015abee4SVilas Bhat */ 123015abee4SVilas Bhat #undef EM 124015abee4SVilas Bhat #undef EMe 125015abee4SVilas Bhat #define EM(a, b) { a, b }, 126015abee4SVilas Bhat #define EMe(a, b) { a, b } 127015abee4SVilas Bhat 128015abee4SVilas Bhat TRACE_EVENT(rpm_status, 129015abee4SVilas Bhat TP_PROTO(struct device *dev, enum rpm_status status), 130015abee4SVilas Bhat TP_ARGS(dev, status), 131015abee4SVilas Bhat 132015abee4SVilas Bhat TP_STRUCT__entry( 133015abee4SVilas Bhat __string(name, dev_name(dev)) 134015abee4SVilas Bhat __field(int, status) 135015abee4SVilas Bhat ), 136015abee4SVilas Bhat 137015abee4SVilas Bhat TP_fast_assign( 138*2c92ca84SSteven Rostedt (Google) __assign_str(name); 139015abee4SVilas Bhat __entry->status = status; 140015abee4SVilas Bhat ), 141015abee4SVilas Bhat 142015abee4SVilas Bhat TP_printk("%s status=%s", __get_str(name), 143015abee4SVilas Bhat __print_symbolic(__entry->status, RPM_STATUS_STRINGS)) 144015abee4SVilas Bhat ); 145015abee4SVilas Bhat 14653b615ccSMing Lei #endif /* _TRACE_RUNTIME_POWER_H */ 14753b615ccSMing Lei 14853b615ccSMing Lei /* This part must be outside protection */ 14953b615ccSMing Lei #include <trace/define_trace.h> 150