1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Cell Broadband Engine OProfile Support
5 * (C) Copyright IBM Corporation 2006
7 * Author: Maynard Johnson <maynardj@us.ibm.com>
13 #include <linux/cpumask.h>
14 #include <linux/oprofile.h>
15 #include <asm/cell-pmu.h>
16 #include <asm/cell-regs.h>
19 /* Defines used for sync_start */
20 #define SKIP_GENERIC_SYNC 0
21 #define SYNC_START_ERROR -1
22 #define DO_GENERIC_SYNC 1
23 #define SPUS_PER_NODE 8
24 #define DEFAULT_TIMER_EXPIRE (HZ / 10)
26 extern struct delayed_work spu_work
;
27 extern int spu_prof_running
;
29 #define TRACE_ARRAY_SIZE 1024
31 extern spinlock_t oprof_spu_smpl_arry_lck
;
33 struct spu_overlay_info
{ /* map of sections within an SPU overlay */
34 unsigned int vma
; /* SPU virtual memory address from elf */
35 unsigned int size
; /* size of section from elf */
36 unsigned int offset
; /* offset of section into elf file */
40 struct vma_to_fileoffset_map
{ /* map of sections within an SPU program */
41 struct vma_to_fileoffset_map
*next
; /* list pointer */
42 unsigned int vma
; /* SPU virtual memory address from elf */
43 unsigned int size
; /* size of section from elf */
44 unsigned int offset
; /* offset of section into elf file */
45 unsigned int guard_ptr
;
46 unsigned int guard_val
;
48 * The guard pointer is an entry in the _ovly_buf_table,
49 * computed using ovly.buf as the index into the table. Since
50 * ovly.buf values begin at '1' to reference the first (or 0th)
51 * entry in the _ovly_buf_table, the computation subtracts 1
53 * The guard value is stored in the _ovly_buf_table entry and
54 * is an index (starting at 1) back to the _ovly_table entry
55 * that is pointing at this _ovly_buf_table entry. So, for
56 * example, for an overlay scenario with one overlay segment
57 * and two overlay sections:
58 * - Section 1 points to the first entry of the
59 * _ovly_buf_table, which contains a guard value
60 * of '1', referencing the first (index=0) entry of
62 * - Section 2 points to the second entry of the
63 * _ovly_buf_table, which contains a guard value
64 * of '2', referencing the second (index=1) entry of
74 unsigned int head
, tail
;
78 /* The three functions below are for maintaining and accessing
79 * the vma-to-fileoffset map.
81 struct vma_to_fileoffset_map
*create_vma_map(const struct spu
*spu
,
82 unsigned long objectid
);
83 unsigned int vma_map_lookup(struct vma_to_fileoffset_map
*map
,
84 unsigned int vma
, const struct spu
*aSpu
,
86 void vma_map_free(struct vma_to_fileoffset_map
*map
);
89 * Entry point for SPU profiling.
90 * cycles_reset is the SPU_CYCLES count value specified by the user.
92 int start_spu_profiling_cycles(unsigned int cycles_reset
);
93 void start_spu_profiling_events(void);
95 void stop_spu_profiling_cycles(void);
96 void stop_spu_profiling_events(void);
98 /* add the necessary profiling hooks */
99 int spu_sync_start(void);
101 /* remove the hooks */
102 int spu_sync_stop(void);
104 /* Record SPU program counter samples to the oprofile event buffer. */
105 void spu_sync_buffer(int spu_num
, unsigned int *samples
,
108 void set_spu_profiling_frequency(unsigned int freq_khz
, unsigned int cycles_reset
);
110 #endif /* PR_UTIL_H */