All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/ftrace: add ftrace.h, fix sparse warning
@ 2017-03-06  8:49 Tobin C. Harding
  2017-03-08 11:24 ` Michael Ellerman
  2017-03-21 11:36 ` Michael Ellerman
  0 siblings, 2 replies; 3+ messages in thread
From: Tobin C. Harding @ 2017-03-06  8:49 UTC (permalink / raw)
  To: Ingo Molnar, Steven Rostedt
  Cc: Michael Ellerman, linuxppc-dev, Tobin C. Harding

Sparse emits warning: symbol 'prepare_ftrace_return' was not
declared. Should it be static? prepare_ftrace_return() is called
from assembler and should not be static. Adding a header file
declaring the function will fix the sparse warning while adding
documentation to the call.

Add header file ftrace.h with single function declaration. Protect
declaration with preprocessor guard so it may be included in
assembly. Include new header in all files that call
prepare_ftrace_return() and in ftrace.c where function is defined.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---

Github issue: #37 Fix sparse warnings

Tested by building on Power8.

There are a bunch of these in arch/powerpc/kernel/. Do we want to add
a header for each one, cluttering up the directory to fix the sparse
warnings? 

 arch/powerpc/kernel/entry_32.S | 2 ++
 arch/powerpc/kernel/entry_64.S | 2 ++
 arch/powerpc/kernel/ftrace.c   | 1 +
 arch/powerpc/kernel/ftrace.h   | 9 +++++++++
 4 files changed, 14 insertions(+)
 create mode 100644 arch/powerpc/kernel/ftrace.h

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 3841d74..bb7284c 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -35,6 +35,8 @@
 #include <asm/ptrace.h>
 #include <asm/export.h>
 
+#include "ftrace.h"
+
 /*
  * MSR_KERNEL is > 0x10000 on 4xx/Book-E since it include MSR_CE.
  */
diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S
index 6432d4b..8591026 100644
--- a/arch/powerpc/kernel/entry_64.S
+++ b/arch/powerpc/kernel/entry_64.S
@@ -40,6 +40,8 @@
 #include <asm/ppc-opcode.h>
 #include <asm/export.h>
 
+#include "ftrace.h"
+
 /*
  * System calls.
  */
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 5c9f50c..d4d3bb1 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -26,6 +26,7 @@
 #include <asm/ftrace.h>
 #include <asm/syscall.h>
 
+#include "ftrace.h"
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 static unsigned int
diff --git a/arch/powerpc/kernel/ftrace.h b/arch/powerpc/kernel/ftrace.h
new file mode 100644
index 0000000..dc27dd7
--- /dev/null
+++ b/arch/powerpc/kernel/ftrace.h
@@ -0,0 +1,9 @@
+#ifndef _FTRACE_H
+#define _FTRACE_H
+
+#ifndef __ASSEMBLER__
+
+unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip);
+
+#endif	/* __ASSEMBLER__ */
+#endif	/* _FTRACE_H */
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc/ftrace: add ftrace.h, fix sparse warning
  2017-03-06  8:49 [PATCH] powerpc/ftrace: add ftrace.h, fix sparse warning Tobin C. Harding
@ 2017-03-08 11:24 ` Michael Ellerman
  2017-03-21 11:36 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-03-08 11:24 UTC (permalink / raw)
  To: Tobin C. Harding, Ingo Molnar, Steven Rostedt
  Cc: linuxppc-dev, Tobin C. Harding

"Tobin C. Harding" <me@tobin.cc> writes:

> Sparse emits warning: symbol 'prepare_ftrace_return' was not
> declared. Should it be static? prepare_ftrace_return() is called
> from assembler and should not be static. Adding a header file
> declaring the function will fix the sparse warning while adding
> documentation to the call.
>
> Add header file ftrace.h with single function declaration. Protect
> declaration with preprocessor guard so it may be included in
> assembly. Include new header in all files that call
> prepare_ftrace_return() and in ftrace.c where function is defined.
>
> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
>
> Github issue: #37 Fix sparse warnings
>
> Tested by building on Power8.
>
> There are a bunch of these in arch/powerpc/kernel/. Do we want to add
> a header for each one, cluttering up the directory to fix the sparse
> warnings? 

No we don't.

In fact we already have a header for this, ie. functions defined in asm
but called from C, it's arch/powerpc/include/asm/asm-prototypes.h.

So I've reworked it to:

diff --git a/arch/powerpc/include/asm/asm-prototypes.h b/arch/powerpc/include/asm/asm-prototypes.h
index f6c5264287e5..e02db66a77e3 100644
--- a/arch/powerpc/include/asm/asm-prototypes.h
+++ b/arch/powerpc/include/asm/asm-prototypes.h
@@ -120,6 +120,8 @@ extern s64 __ashrdi3(s64, int);
 extern int __cmpdi2(s64, s64);
 extern int __ucmpdi2(u64, u64);
 
+/* tracing */
 void _mcount(void);
+unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip);
 
 #endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */
diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c
index 5c9f50c1aa99..32509de6ce4c 100644
--- a/arch/powerpc/kernel/ftrace.c
+++ b/arch/powerpc/kernel/ftrace.c
@@ -21,6 +21,7 @@
 #include <linux/init.h>
 #include <linux/list.h>
 
+#include <asm/asm-prototypes.h>
 #include <asm/cacheflush.h>
 #include <asm/code-patching.h>
 #include <asm/ftrace.h>



cheers

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: powerpc/ftrace: add ftrace.h, fix sparse warning
  2017-03-06  8:49 [PATCH] powerpc/ftrace: add ftrace.h, fix sparse warning Tobin C. Harding
  2017-03-08 11:24 ` Michael Ellerman
@ 2017-03-21 11:36 ` Michael Ellerman
  1 sibling, 0 replies; 3+ messages in thread
From: Michael Ellerman @ 2017-03-21 11:36 UTC (permalink / raw)
  To: Tobin C. Harding, Ingo Molnar, Steven Rostedt
  Cc: linuxppc-dev, Tobin C. Harding

On Mon, 2017-03-06 at 08:49:46 UTC, "Tobin C. Harding" wrote:
> Sparse emits warning: symbol 'prepare_ftrace_return' was not
> declared. Should it be static? prepare_ftrace_return() is called
> from assembler and should not be static. Adding a header file
> declaring the function will fix the sparse warning while adding
> documentation to the call.
> 
> Add header file ftrace.h with single function declaration. Protect
> declaration with preprocessor guard so it may be included in
> assembly. Include new header in all files that call
> prepare_ftrace_return() and in ftrace.c where function is defined.
> 
> Signed-off-by: Tobin C. Harding <me@tobin.cc>

Applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/b3a7864c6feb0fb30bc2cd37265707

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-21 11:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-06  8:49 [PATCH] powerpc/ftrace: add ftrace.h, fix sparse warning Tobin C. Harding
2017-03-08 11:24 ` Michael Ellerman
2017-03-21 11:36 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.