1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/percpu.h>
3 #include <linux/jump_label.h>
6 #ifdef CONFIG_JUMP_LABEL
7 struct static_key opal_tracepoint_key
= STATIC_KEY_INIT
;
9 int opal_tracepoint_regfunc(void)
11 static_key_slow_inc(&opal_tracepoint_key
);
15 void opal_tracepoint_unregfunc(void)
17 static_key_slow_dec(&opal_tracepoint_key
);
21 * We optimise OPAL calls by placing opal_tracepoint_refcount
22 * directly in the TOC so we can check if the opal tracepoints are
23 * enabled via a single load.
26 /* NB: reg/unreg are called while guarded with the tracepoints_mutex */
27 extern long opal_tracepoint_refcount
;
29 int opal_tracepoint_regfunc(void)
31 opal_tracepoint_refcount
++;
35 void opal_tracepoint_unregfunc(void)
37 opal_tracepoint_refcount
--;
42 * Since the tracing code might execute OPAL calls we need to guard against
45 static DEFINE_PER_CPU(unsigned int, opal_trace_depth
);
47 void __trace_opal_entry(unsigned long opcode
, unsigned long *args
)
52 local_irq_save(flags
);
54 depth
= this_cpu_ptr(&opal_trace_depth
);
61 trace_opal_entry(opcode
, args
);
65 local_irq_restore(flags
);
68 void __trace_opal_exit(long opcode
, unsigned long retval
)
73 local_irq_save(flags
);
75 depth
= this_cpu_ptr(&opal_trace_depth
);
81 trace_opal_exit(opcode
, retval
);
86 local_irq_restore(flags
);