diff mbox series

[v5,2/2] remoteproc: qcom: Add remoteproc tracing

Message ID 12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris@quicinc.com (mailing list archive)
State Changes Requested
Headers show
Series Patches for introducing traces in remoteproc. | expand

Commit Message

Gokul krishna Krishnakumar June 12, 2023, 10:03 p.m. UTC
This change attempts to add traces for start, stop, crash
subsystem/subdevice events, these will serve as standard checkpoints in
code and could help in debugging the failures in subdevice/subsystem
prepare, start, stop and unprepare functions. This will also breakdown
the time taken for each step in remoteproc bootup/shutdown process.

Signed-off-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
---
 drivers/remoteproc/qcom_common.c         | 37 ++++++++++++++++++++++++
 drivers/remoteproc/qcom_q6v5.c           |  9 ++++++
 drivers/remoteproc/remoteproc_core.c     |  5 ++++
 drivers/remoteproc/remoteproc_internal.h |  9 ++++--
 4 files changed, 58 insertions(+), 2 deletions(-)

Comments

kernel test robot June 13, 2023, 6:08 a.m. UTC | #1
Hi Gokul,

kernel test robot noticed the following build errors:

[auto build test ERROR on 1ca04f21b204e99dd704146231adfb79ea2fb366]

url:    https://github.com/intel-lab-lkp/linux/commits/Gokul-krishna-Krishnakumar/remoteproc-Introduce-traces-for-remoteproc-events/20230613-060527
base:   1ca04f21b204e99dd704146231adfb79ea2fb366
patch link:    https://lore.kernel.org/r/12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris%40quicinc.com
patch subject: [PATCH v5 2/2] remoteproc: qcom: Add remoteproc tracing
config: i386-randconfig-r025-20230612 (https://download.01.org/0day-ci/archive/20230613/202306131305.GXI4gstL-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build):
        git checkout 1ca04f21b204e99dd704146231adfb79ea2fb366
        b4 shazam https://lore.kernel.org/r/12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris@quicinc.com
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=i386 olddefconfig
        make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306131305.GXI4gstL-lkp@intel.com/

All errors (new ones prefixed by >>):

   ld: drivers/remoteproc/remoteproc_core.o: in function `trace_rproc_stop_event':
>> include/trace/events/remoteproc_tracepoints.h:82: undefined reference to `__tracepoint_rproc_stop_event'
>> ld: include/trace/events/remoteproc_tracepoints.h:82: undefined reference to `__SCT__tp_func_rproc_stop_event'
   ld: drivers/remoteproc/remoteproc_core.o: in function `trace_rproc_load_segment_event':
>> include/trace/events/remoteproc_tracepoints.h:17: undefined reference to `__tracepoint_rproc_load_segment_event'
>> ld: include/trace/events/remoteproc_tracepoints.h:17: undefined reference to `__SCT__tp_func_rproc_load_segment_event'
   ld: drivers/remoteproc/remoteproc_core.o: in function `trace_rproc_start_event':
>> include/trace/events/remoteproc_tracepoints.h:63: undefined reference to `__tracepoint_rproc_start_event'
>> ld: include/trace/events/remoteproc_tracepoints.h:63: undefined reference to `__SCT__tp_func_rproc_start_event'
   ld: drivers/remoteproc/remoteproc_core.o:(__jump_table+0x8): undefined reference to `__tracepoint_rproc_stop_event'
>> ld: drivers/remoteproc/remoteproc_core.o:(__jump_table+0x14): undefined reference to `__tracepoint_rproc_load_segment_event'
   ld: drivers/remoteproc/remoteproc_core.o:(__jump_table+0x20): undefined reference to `__tracepoint_rproc_start_event'


vim +82 include/trace/events/remoteproc_tracepoints.h

f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   13  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   14  /*
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   15   * Tracepoints for remoteproc and subdevice events
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   16   */
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12  @17  TRACE_EVENT(rproc_load_segment_event,
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   18  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   19  	TP_PROTO(struct rproc *rproc, int ret),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   20  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   21  	TP_ARGS(rproc, ret),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   22  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   23  	TP_STRUCT__entry(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   24  		__string(name, rproc->name)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   25  		__string(firmware, rproc->firmware)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   26  		__field(int, ret)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   27  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   28  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   29  	TP_fast_assign(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   30  		__assign_str(name, rproc->name);
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   31  		__assign_str(firmware, rproc->firmware);
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   32  		__entry->ret = ret;
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   33  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   34  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   35  	TP_printk("%s loading firmware %s returned %d",
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   36  			__get_str(name), __get_str(firmware),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   37  			__entry->ret)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   38  );
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   39  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   40  TRACE_EVENT(rproc_attach_event,
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   41  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   42  	TP_PROTO(struct rproc *rproc, int ret),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   43  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   44  	TP_ARGS(rproc, ret),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   45  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   46  	TP_STRUCT__entry(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   47  		__string(name, rproc->name)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   48  		__string(firmware, rproc->firmware)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   49  		__field(int, ret)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   50  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   51  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   52  	TP_fast_assign(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   53  		__assign_str(name, rproc->name);
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   54  		__assign_str(firmware, rproc->firmware);
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   55  		__entry->ret = ret;
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   56  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   57  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   58  	TP_printk("%s attaching returned %d",
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   59  			__get_str(name),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   60  			__entry->ret)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   61  );
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   62  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12  @63  TRACE_EVENT(rproc_start_event,
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   64  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   65  	TP_PROTO(struct rproc *rproc, int ret),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   66  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   67  	TP_ARGS(rproc, ret),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   68  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   69  	TP_STRUCT__entry(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   70  		__string(name, rproc->name)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   71  		__field(int, ret)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   72  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   73  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   74  	TP_fast_assign(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   75  		__assign_str(name, rproc->name);
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   76  		__entry->ret = ret;
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   77  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   78  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   79  	TP_printk("%s %d", __get_str(name), __entry->ret)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   80  );
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   81  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12  @82  TRACE_EVENT(rproc_stop_event,
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   83  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   84  	TP_PROTO(struct rproc *rproc, const char *crash_msg),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   85  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   86  	TP_ARGS(rproc, crash_msg),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   87  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   88  	TP_STRUCT__entry(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   89  		__string(name, rproc->name)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   90  		__string(crash_msg, crash_msg)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   91  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   92  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   93  	TP_fast_assign(
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   94  		__assign_str(name, rproc->name);
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   95  		__assign_str(crash_msg, crash_msg)
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   96  	),
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   97  
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   98  	TP_printk("%s %s", __get_str(name), __get_str(crash_msg))
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12   99  );
f73173f7e78a04 Gokul krishna Krishnakumar 2023-06-12  100
kernel test robot June 13, 2023, 6:19 a.m. UTC | #2
Hi Gokul,

kernel test robot noticed the following build errors:

[auto build test ERROR on 1ca04f21b204e99dd704146231adfb79ea2fb366]

url:    https://github.com/intel-lab-lkp/linux/commits/Gokul-krishna-Krishnakumar/remoteproc-Introduce-traces-for-remoteproc-events/20230613-060527
base:   1ca04f21b204e99dd704146231adfb79ea2fb366
patch link:    https://lore.kernel.org/r/12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris%40quicinc.com
patch subject: [PATCH v5 2/2] remoteproc: qcom: Add remoteproc tracing
config: hexagon-randconfig-r041-20230612 (https://download.01.org/0day-ci/archive/20230613/202306131424.QEYiIiQA-lkp@intel.com/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 1ca04f21b204e99dd704146231adfb79ea2fb366
        b4 shazam https://lore.kernel.org/r/12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris@quicinc.com
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang ~/bin/make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306131424.QEYiIiQA-lkp@intel.com/

All errors (new ones prefixed by >>):

>> ld.lld: error: undefined symbol: __tracepoint_rproc_start_event
   >>> referenced by jump_label.h:260 (include/linux/jump_label.h:260)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_boot) in archive vmlinux.a
   >>> referenced by jump_label.h:260 (include/linux/jump_label.h:260)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_boot) in archive vmlinux.a
   >>> referenced by jump_label.h:260 (include/linux/jump_label.h:260)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_boot) in archive vmlinux.a
   >>> referenced 1 more times
--
>> ld.lld: error: undefined symbol: __traceiter_rproc_start_event
   >>> referenced by remoteproc_tracepoints.h:63 (include/trace/events/remoteproc_tracepoints.h:63)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_boot) in archive vmlinux.a
   >>> referenced by remoteproc_tracepoints.h:63 (include/trace/events/remoteproc_tracepoints.h:63)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_boot) in archive vmlinux.a
   >>> referenced by remoteproc_tracepoints.h:63 (include/trace/events/remoteproc_tracepoints.h:63)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_boot) in archive vmlinux.a
   >>> referenced 1 more times
--
>> ld.lld: error: undefined symbol: __tracepoint_rproc_load_segment_event
   >>> referenced by remoteproc_internal.h:178 (drivers/remoteproc/remoteproc_internal.h:178)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_start) in archive vmlinux.a
   >>> referenced by remoteproc_internal.h:178 (drivers/remoteproc/remoteproc_internal.h:178)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_start) in archive vmlinux.a
--
>> ld.lld: error: undefined symbol: __traceiter_rproc_load_segment_event
   >>> referenced by remoteproc_tracepoints.h:17 (include/trace/events/remoteproc_tracepoints.h:17)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_start) in archive vmlinux.a
   >>> referenced by remoteproc_tracepoints.h:17 (include/trace/events/remoteproc_tracepoints.h:17)
   >>>               drivers/remoteproc/remoteproc_core.o:(rproc_start) in archive vmlinux.a
--
>> ld.lld: error: undefined symbol: __tracepoint_rproc_stop_event
   >>> referenced by jump_label.h:260 (include/linux/jump_label.h:260)
   >>>               drivers/remoteproc/remoteproc_core.o:(trace_rproc_stop_event) in archive vmlinux.a
   >>> referenced by jump_label.h:260 (include/linux/jump_label.h:260)
   >>>               drivers/remoteproc/remoteproc_core.o:(trace_rproc_stop_event) in archive vmlinux.a
--
>> ld.lld: error: undefined symbol: __traceiter_rproc_stop_event
   >>> referenced by remoteproc_tracepoints.h:82 (include/trace/events/remoteproc_tracepoints.h:82)
   >>>               drivers/remoteproc/remoteproc_core.o:(trace_rproc_stop_event) in archive vmlinux.a
   >>> referenced by remoteproc_tracepoints.h:82 (include/trace/events/remoteproc_tracepoints.h:82)
   >>>               drivers/remoteproc/remoteproc_core.o:(trace_rproc_stop_event) in archive vmlinux.a
kernel test robot June 13, 2023, 7:42 a.m. UTC | #3
Hi Gokul,

kernel test robot noticed the following build errors:

[auto build test ERROR on 1ca04f21b204e99dd704146231adfb79ea2fb366]

url:    https://github.com/intel-lab-lkp/linux/commits/Gokul-krishna-Krishnakumar/remoteproc-Introduce-traces-for-remoteproc-events/20230613-060527
base:   1ca04f21b204e99dd704146231adfb79ea2fb366
patch link:    https://lore.kernel.org/r/12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris%40quicinc.com
patch subject: [PATCH v5 2/2] remoteproc: qcom: Add remoteproc tracing
config: microblaze-randconfig-r003-20230612 (https://download.01.org/0day-ci/archive/20230613/202306131523.EwZZ3cVl-lkp@intel.com/config)
compiler: microblaze-linux-gcc (GCC) 12.3.0
reproduce (this is a W=1 build):
        mkdir -p ~/bin
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 1ca04f21b204e99dd704146231adfb79ea2fb366
        b4 shazam https://lore.kernel.org/r/12b533c73b8c6b039e90f20afef1c8dcd30b80de.1686606835.git.quic_gokukris@quicinc.com
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=microblaze olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.3.0 ~/bin/make.cross W=1 O=build_dir ARCH=microblaze SHELL=/bin/bash

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202306131523.EwZZ3cVl-lkp@intel.com/

All errors (new ones prefixed by >>):

   microblaze-linux-ld: drivers/remoteproc/remoteproc_core.o: in function `rproc_stop':
>> .tmp_gl_remoteproc_core.o:(.text+0xe1c): undefined reference to `__tracepoint_rproc_stop_event'
>> microblaze-linux-ld: .tmp_gl_remoteproc_core.o:(.text+0xe94): undefined reference to `__traceiter_rproc_stop_event'
   microblaze-linux-ld: drivers/remoteproc/remoteproc_core.o: in function `rproc_start':
>> .tmp_gl_remoteproc_core.o:(.text.unlikely+0x664): undefined reference to `__tracepoint_rproc_load_segment_event'
>> microblaze-linux-ld: .tmp_gl_remoteproc_core.o:(.text.unlikely+0x6dc): undefined reference to `__traceiter_rproc_load_segment_event'
   microblaze-linux-ld: drivers/remoteproc/remoteproc_core.o: in function `trace_rproc_start_event':
>> .tmp_gl_remoteproc_core.o:(.text.unlikely+0x8c8): undefined reference to `__tracepoint_rproc_start_event'
>> microblaze-linux-ld: .tmp_gl_remoteproc_core.o:(.text.unlikely+0x948): undefined reference to `__traceiter_rproc_start_event'
Steven Rostedt June 13, 2023, 3:28 p.m. UTC | #4
On Mon, 12 Jun 2023 15:03:26 -0700
Gokul krishna Krishnakumar <quic_gokukris@quicinc.com> wrote:

> diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
> index d4dbb8d1d80c..f7cb31b94a60 100644
> --- a/drivers/remoteproc/remoteproc_internal.h
> +++ b/drivers/remoteproc/remoteproc_internal.h
> @@ -14,6 +14,7 @@
>  
>  #include <linux/irqreturn.h>
>  #include <linux/firmware.h>
> +#include <trace/events/remoteproc_tracepoints.h>
>  
>  struct rproc;
>  
> @@ -171,8 +172,13 @@ u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
>  static inline
>  int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
>  {
> -	if (rproc->ops->load)
> -		return rproc->ops->load(rproc, fw);
> +	if (rproc->ops->load) {
> +		int ret;
> +
> +		ret = rproc->ops->load(rproc, fw);
> +		trace_rproc_load_segment_event(rproc, ret);
> +		return ret;
> +	}
>  
>  	return -EINVAL;
>  }

So, tracepoints in header files tend to cause problems due to the way they
are created. See the comment in include/linux/tracepoint-defs.h.

What you need to do is:

#include <linux/tracepoint-defs.h>

DECLARE_TRACEPOINT(rproc_load_segment_event);

extern void call_trace_rproc_load_segment_event(struct rproc *rproc, int ret);

static inline void test_trace_rproc_load_segment_event(struct rproc *rproc, int ret)
{
	if (trace_rproc_load_segment_event_enabled())
		call_trace_rproc_load_segment_event(rproc, ret);
}

After adding the above in the header. In the C file, add:

void call_trace_rproc_load_segment_event(struct rproc *rproc, int ret)
{
	trace_rproc_load_segment_event(rproc, ret);
}

-- Steve
diff mbox series

Patch

diff --git a/drivers/remoteproc/qcom_common.c b/drivers/remoteproc/qcom_common.c
index a0d4238492e9..857e5a74c1eb 100644
--- a/drivers/remoteproc/qcom_common.c
+++ b/drivers/remoteproc/qcom_common.c
@@ -18,6 +18,7 @@ 
 #include <linux/slab.h>
 #include <linux/soc/qcom/mdt_loader.h>
 #include <linux/soc/qcom/smem.h>
+#include <trace/events/remoteproc_tracepoints.h>
 
 #include "remoteproc_internal.h"
 #include "qcom_common.h"
@@ -191,6 +192,10 @@  static int glink_subdev_start(struct rproc_subdev *subdev)
 
 	glink->edge = qcom_glink_smem_register(glink->dev, glink->node);
 
+	trace_rproc_subdev_event(dev_name(glink->dev->parent),
+					"glink", "start",
+					PTR_ERR_OR_ZERO(glink->edge));
+
 	return PTR_ERR_OR_ZERO(glink->edge);
 }
 
@@ -199,6 +204,11 @@  static void glink_subdev_stop(struct rproc_subdev *subdev, bool crashed)
 	struct qcom_rproc_glink *glink = to_glink_subdev(subdev);
 
 	qcom_glink_smem_unregister(glink->edge);
+
+	trace_rproc_subdev_event(dev_name(glink->dev->parent),
+					"glink", "stop",
+					PTR_ERR_OR_ZERO(glink->edge));
+
 	glink->edge = NULL;
 }
 
@@ -206,6 +216,10 @@  static void glink_subdev_unprepare(struct rproc_subdev *subdev)
 {
 	struct qcom_rproc_glink *glink = to_glink_subdev(subdev);
 
+	trace_rproc_subdev_event(dev_name(glink->dev->parent),
+					"glink", "unprepare",
+					PTR_ERR_OR_ZERO(glink->edge));
+
 	qcom_glink_ssr_notify(glink->ssr_name);
 }
 
@@ -300,6 +314,10 @@  static int smd_subdev_start(struct rproc_subdev *subdev)
 {
 	struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
 
+	trace_rproc_subdev_event(dev_name(smd->dev->parent),
+					"smd", "start",
+					PTR_ERR_OR_ZERO(smd->edge));
+
 	smd->edge = qcom_smd_register_edge(smd->dev, smd->node);
 
 	return PTR_ERR_OR_ZERO(smd->edge);
@@ -309,6 +327,10 @@  static void smd_subdev_stop(struct rproc_subdev *subdev, bool crashed)
 {
 	struct qcom_rproc_subdev *smd = to_smd_subdev(subdev);
 
+	trace_rproc_subdev_event(dev_name(smd->dev->parent),
+					"smd", "stop",
+					PTR_ERR_OR_ZERO(smd->edge));
+
 	qcom_smd_unregister_edge(smd->edge);
 	smd->edge = NULL;
 }
@@ -425,6 +447,10 @@  static int ssr_notify_prepare(struct rproc_subdev *subdev)
 		.crashed = false,
 	};
 
+	trace_rproc_subdev_event(ssr->info->name,
+					"ssr", "QCOM_SSR_BEFORE_POWERUP",
+					data.crashed);
+
 	srcu_notifier_call_chain(&ssr->info->notifier_list,
 				 QCOM_SSR_BEFORE_POWERUP, &data);
 	return 0;
@@ -437,6 +463,9 @@  static int ssr_notify_start(struct rproc_subdev *subdev)
 		.name = ssr->info->name,
 		.crashed = false,
 	};
+	trace_rproc_subdev_event(ssr->info->name,
+					"ssr", "QCOM_SSR_AFTER_POWERUP",
+					data.crashed);
 
 	srcu_notifier_call_chain(&ssr->info->notifier_list,
 				 QCOM_SSR_AFTER_POWERUP, &data);
@@ -451,6 +480,10 @@  static void ssr_notify_stop(struct rproc_subdev *subdev, bool crashed)
 		.crashed = crashed,
 	};
 
+	trace_rproc_subdev_event(ssr->info->name,
+					"ssr", "QCOM_SSR_BEFORE_SHUTDOWN",
+					data.crashed);
+
 	srcu_notifier_call_chain(&ssr->info->notifier_list,
 				 QCOM_SSR_BEFORE_SHUTDOWN, &data);
 }
@@ -463,6 +496,10 @@  static void ssr_notify_unprepare(struct rproc_subdev *subdev)
 		.crashed = false,
 	};
 
+	trace_rproc_subdev_event(ssr->info->name,
+					"ssr", "QCOM_SSR_AFTER_SHUTDOWN",
+					data.crashed);
+
 	srcu_notifier_call_chain(&ssr->info->notifier_list,
 				 QCOM_SSR_AFTER_SHUTDOWN, &data);
 }
diff --git a/drivers/remoteproc/qcom_q6v5.c b/drivers/remoteproc/qcom_q6v5.c
index 192c7aa0e39e..bf14f01c88c4 100644
--- a/drivers/remoteproc/qcom_q6v5.c
+++ b/drivers/remoteproc/qcom_q6v5.c
@@ -15,6 +15,7 @@ 
 #include <linux/soc/qcom/smem.h>
 #include <linux/soc/qcom/smem_state.h>
 #include <linux/remoteproc.h>
+#include <trace/events/remoteproc_tracepoints.h>
 #include "qcom_common.h"
 #include "qcom_q6v5.h"
 
@@ -113,6 +114,7 @@  static irqreturn_t q6v5_wdog_interrupt(int irq, void *data)
 		dev_err(q6v5->dev, "watchdog without message\n");
 
 	q6v5->running = false;
+	trace_rproc_interrupt_event(q6v5->rproc, "q6v5_wdog", msg);
 	rproc_report_crash(q6v5->rproc, RPROC_WATCHDOG);
 
 	return IRQ_HANDLED;
@@ -134,6 +136,7 @@  static irqreturn_t q6v5_fatal_interrupt(int irq, void *data)
 		dev_err(q6v5->dev, "fatal error without message\n");
 
 	q6v5->running = false;
+	trace_rproc_interrupt_event(q6v5->rproc, "fatal", msg);
 	rproc_report_crash(q6v5->rproc, RPROC_FATAL_ERROR);
 
 	return IRQ_HANDLED;
@@ -165,6 +168,8 @@  int qcom_q6v5_wait_for_start(struct qcom_q6v5 *q6v5, int timeout)
 	if (!ret)
 		disable_irq(q6v5->handover_irq);
 
+	trace_rproc_interrupt_event(q6v5->rproc, "Ready", !ret ? "-ETIMEDOUT":"done");
+
 	return !ret ? -ETIMEDOUT : 0;
 }
 EXPORT_SYMBOL_GPL(qcom_q6v5_wait_for_start);
@@ -180,6 +185,8 @@  static irqreturn_t q6v5_handover_interrupt(int irq, void *data)
 
 	q6v5->handover_issued = true;
 
+	trace_rproc_interrupt_event(q6v5->rproc, "handover", "Proxy votes removed");
+
 	return IRQ_HANDLED;
 }
 
@@ -216,6 +223,8 @@  int qcom_q6v5_request_stop(struct qcom_q6v5 *q6v5, struct qcom_sysmon *sysmon)
 
 	qcom_smem_state_update_bits(q6v5->state, BIT(q6v5->stop_bit), 0);
 
+	trace_rproc_interrupt_event(q6v5->rproc, "Stop", ret ? "done":"-EETIMEDOUT");
+
 	return ret == 0 ? -ETIMEDOUT : 0;
 }
 EXPORT_SYMBOL_GPL(qcom_q6v5_request_stop);
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 695cce218e8c..64c09eff67fe 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -38,6 +38,7 @@ 
 #include <linux/virtio_ring.h>
 #include <asm/byteorder.h>
 #include <linux/platform_device.h>
+#include <trace/events/remoteproc_tracepoints.h>
 
 #include "remoteproc_internal.h"
 
@@ -1648,6 +1649,7 @@  static int rproc_attach(struct rproc *rproc)
 	if (ret)
 		goto clean_up_resources;
 
+	trace_rproc_start_event(rproc, ret);
 	return 0;
 
 clean_up_resources:
@@ -1730,6 +1732,8 @@  static int rproc_stop(struct rproc *rproc, bool crashed)
 		return ret;
 	}
 
+	trace_rproc_stop_event(rproc, crashed ? "crash stop" : "stop");
+
 	rproc_unprepare_subdevices(rproc);
 
 	rproc->state = RPROC_OFFLINE;
@@ -1951,6 +1955,7 @@  int rproc_boot(struct rproc *rproc)
 		}
 
 		ret = rproc_fw_boot(rproc, firmware_p);
+		trace_rproc_start_event(rproc, ret);
 
 		release_firmware(firmware_p);
 	}
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index d4dbb8d1d80c..f7cb31b94a60 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -14,6 +14,7 @@ 
 
 #include <linux/irqreturn.h>
 #include <linux/firmware.h>
+#include <trace/events/remoteproc_tracepoints.h>
 
 struct rproc;
 
@@ -171,8 +172,13 @@  u64 rproc_get_boot_addr(struct rproc *rproc, const struct firmware *fw)
 static inline
 int rproc_load_segments(struct rproc *rproc, const struct firmware *fw)
 {
-	if (rproc->ops->load)
-		return rproc->ops->load(rproc, fw);
+	if (rproc->ops->load) {
+		int ret;
+
+		ret = rproc->ops->load(rproc, fw);
+		trace_rproc_load_segment_event(rproc, ret);
+		return ret;
+	}
 
 	return -EINVAL;
 }