1 #include <linux/percpu.h>
2 #include <linux/jump_label.h>
4 #include <asm/asm-prototypes.h>
7 struct static_key opal_tracepoint_key
= STATIC_KEY_INIT
;
9 void opal_tracepoint_regfunc(void)
11 static_key_slow_inc(&opal_tracepoint_key
);
14 void opal_tracepoint_unregfunc(void)
16 static_key_slow_dec(&opal_tracepoint_key
);
20 * We optimise OPAL calls by placing opal_tracepoint_refcount
21 * directly in the TOC so we can check if the opal tracepoints are
22 * enabled via a single load.
25 /* NB: reg/unreg are called while guarded with the tracepoints_mutex */
26 extern long opal_tracepoint_refcount
;
28 void opal_tracepoint_regfunc(void)
30 opal_tracepoint_refcount
++;
33 void opal_tracepoint_unregfunc(void)
35 opal_tracepoint_refcount
--;
40 * Since the tracing code might execute OPAL calls we need to guard against
43 static DEFINE_PER_CPU(unsigned int, opal_trace_depth
);
45 void __trace_opal_entry(unsigned long opcode
, unsigned long *args
)
50 local_irq_save(flags
);
52 depth
= this_cpu_ptr(&opal_trace_depth
);
59 trace_opal_entry(opcode
, args
);
63 local_irq_restore(flags
);
66 void __trace_opal_exit(long opcode
, unsigned long retval
)
71 local_irq_save(flags
);
73 depth
= this_cpu_ptr(&opal_trace_depth
);
79 trace_opal_exit(opcode
, retval
);
84 local_irq_restore(flags
);