1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/percpu.h>
3 #include <linux/jump_label.h>
5 #include <asm/asm-prototypes.h>
7 #ifdef CONFIG_JUMP_LABEL
8 struct static_key opal_tracepoint_key
= STATIC_KEY_INIT
;
10 int opal_tracepoint_regfunc(void)
12 static_key_slow_inc(&opal_tracepoint_key
);
16 void opal_tracepoint_unregfunc(void)
18 static_key_slow_dec(&opal_tracepoint_key
);
22 * We optimise OPAL calls by placing opal_tracepoint_refcount
23 * directly in the TOC so we can check if the opal tracepoints are
24 * enabled via a single load.
27 /* NB: reg/unreg are called while guarded with the tracepoints_mutex */
28 extern long opal_tracepoint_refcount
;
30 int opal_tracepoint_regfunc(void)
32 opal_tracepoint_refcount
++;
36 void opal_tracepoint_unregfunc(void)
38 opal_tracepoint_refcount
--;
43 * Since the tracing code might execute OPAL calls we need to guard against
46 static DEFINE_PER_CPU(unsigned int, opal_trace_depth
);
48 void __trace_opal_entry(unsigned long opcode
, unsigned long *args
)
53 local_irq_save(flags
);
55 depth
= this_cpu_ptr(&opal_trace_depth
);
62 trace_opal_entry(opcode
, args
);
66 local_irq_restore(flags
);
69 void __trace_opal_exit(long opcode
, unsigned long retval
)
74 local_irq_save(flags
);
76 depth
= this_cpu_ptr(&opal_trace_depth
);
82 trace_opal_exit(opcode
, retval
);
87 local_irq_restore(flags
);