Path: blob/master/arch/powerpc/platforms/powernv/opal-tracepoints.c
26481 views
// SPDX-License-Identifier: GPL-2.01#include <linux/percpu.h>2#include <linux/jump_label.h>3#include <asm/trace.h>45#ifdef CONFIG_JUMP_LABEL6struct static_key opal_tracepoint_key = STATIC_KEY_INIT;78int opal_tracepoint_regfunc(void)9{10static_key_slow_inc(&opal_tracepoint_key);11return 0;12}1314void opal_tracepoint_unregfunc(void)15{16static_key_slow_dec(&opal_tracepoint_key);17}18#else19/*20* We optimise OPAL calls by placing opal_tracepoint_refcount21* directly in the TOC so we can check if the opal tracepoints are22* enabled via a single load.23*/2425/* NB: reg/unreg are called while guarded with the tracepoints_mutex */26extern long opal_tracepoint_refcount;2728int opal_tracepoint_regfunc(void)29{30opal_tracepoint_refcount++;31return 0;32}3334void opal_tracepoint_unregfunc(void)35{36opal_tracepoint_refcount--;37}38#endif3940/*41* Since the tracing code might execute OPAL calls we need to guard against42* recursion.43*/44static DEFINE_PER_CPU(unsigned int, opal_trace_depth);4546void __trace_opal_entry(unsigned long opcode, unsigned long *args)47{48unsigned long flags;49unsigned int *depth;5051local_irq_save(flags);5253depth = this_cpu_ptr(&opal_trace_depth);5455if (*depth)56goto out;5758(*depth)++;59preempt_disable();60trace_opal_entry(opcode, args);61(*depth)--;6263out:64local_irq_restore(flags);65}6667void __trace_opal_exit(long opcode, unsigned long retval)68{69unsigned long flags;70unsigned int *depth;7172local_irq_save(flags);7374depth = this_cpu_ptr(&opal_trace_depth);7576if (*depth)77goto out;7879(*depth)++;80trace_opal_exit(opcode, retval);81preempt_enable();82(*depth)--;8384out:85local_irq_restore(flags);86}878889