mirror of
https://github.com/torvalds/linux.git
synced 2024-12-28 22:02:28 +00:00
76222808fc
We originally added asm-prototypes.h in commit42f5b4cacd
("powerpc: Introduce asm-prototypes.h"). It's purpose was for prototypes of C functions that are only called from asm, in order to fix sparse warnings about missing prototypes. A few months later Nick added a different use case in commit4efca4ed05
("kbuild: modversions for EXPORT_SYMBOL() for asm") for C prototypes for exported asm functions. This is basically the inverse of our original usage. Since then we've added various prototypes to asm-prototypes.h for both reasons, meaning we now need to unstitch it all. Dispatch prototypes of C functions into relevant headers and keep only the prototypes for functions defined in assembly. For the time being, leave prom_init() there because moving it into asm/prom.h or asm/setup.h conflicts with drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowrom.o This will be fixed later by untaggling asm/pci.h and asm/prom.h or by renaming the function in shadowrom.c Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/62d46904eca74042097acf4cb12c175e3067f3d1.1646413435.git.christophe.leroy@csgroup.eu
88 lines
1.6 KiB
C
88 lines
1.6 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <linux/percpu.h>
|
|
#include <linux/jump_label.h>
|
|
#include <asm/trace.h>
|
|
|
|
#ifdef CONFIG_JUMP_LABEL
|
|
struct static_key opal_tracepoint_key = STATIC_KEY_INIT;
|
|
|
|
int opal_tracepoint_regfunc(void)
|
|
{
|
|
static_key_slow_inc(&opal_tracepoint_key);
|
|
return 0;
|
|
}
|
|
|
|
void opal_tracepoint_unregfunc(void)
|
|
{
|
|
static_key_slow_dec(&opal_tracepoint_key);
|
|
}
|
|
#else
|
|
/*
|
|
* We optimise OPAL calls by placing opal_tracepoint_refcount
|
|
* directly in the TOC so we can check if the opal tracepoints are
|
|
* enabled via a single load.
|
|
*/
|
|
|
|
/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
|
|
extern long opal_tracepoint_refcount;
|
|
|
|
int opal_tracepoint_regfunc(void)
|
|
{
|
|
opal_tracepoint_refcount++;
|
|
return 0;
|
|
}
|
|
|
|
void opal_tracepoint_unregfunc(void)
|
|
{
|
|
opal_tracepoint_refcount--;
|
|
}
|
|
#endif
|
|
|
|
/*
|
|
* Since the tracing code might execute OPAL calls we need to guard against
|
|
* recursion.
|
|
*/
|
|
static DEFINE_PER_CPU(unsigned int, opal_trace_depth);
|
|
|
|
void __trace_opal_entry(unsigned long opcode, unsigned long *args)
|
|
{
|
|
unsigned long flags;
|
|
unsigned int *depth;
|
|
|
|
local_irq_save(flags);
|
|
|
|
depth = this_cpu_ptr(&opal_trace_depth);
|
|
|
|
if (*depth)
|
|
goto out;
|
|
|
|
(*depth)++;
|
|
preempt_disable();
|
|
trace_opal_entry(opcode, args);
|
|
(*depth)--;
|
|
|
|
out:
|
|
local_irq_restore(flags);
|
|
}
|
|
|
|
void __trace_opal_exit(long opcode, unsigned long retval)
|
|
{
|
|
unsigned long flags;
|
|
unsigned int *depth;
|
|
|
|
local_irq_save(flags);
|
|
|
|
depth = this_cpu_ptr(&opal_trace_depth);
|
|
|
|
if (*depth)
|
|
goto out;
|
|
|
|
(*depth)++;
|
|
trace_opal_exit(opcode, retval);
|
|
preempt_enable();
|
|
(*depth)--;
|
|
|
|
out:
|
|
local_irq_restore(flags);
|
|
}
|