Skip to contentSkip to conversation

printk: Add dummy routine for when CONFIG_PRINTK=n

PATCH Superseded Pranith Kumar 4 participants 6 messages Jan 20, 2015 – Jan 22, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 printk: Add dummy routine for when CONFIG_PRINTK=n

There are missing dummy routines for log_buf_addr_get() and log_buf_len_get() for when CONFIG_PRINTK is not set causing build failures.

This patch adds these dummy routines at the appropriate location.

CC Michael Ellerman <[email protected]>
---
 include/linux/printk.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
include/linux/printk.h +12 -3
index aeb9d7f..f52f02b 100644
@@ -10,9 +10,6 @@
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
-extern char *log_buf_addr_get(void);
-extern u32 log_buf_len_get(void);
-
 static inline int printk_get_level(const char *buffer)
 {
 	if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
@@ -168,6 +165,8 @@ void __init setup_log_buf(int early);
 void dump_stack_set_arch_desc(const char *fmt, ...);
 void dump_stack_print_info(const char *log_lvl);
 void show_regs_print_info(const char *log_lvl);
+char *log_buf_addr_get(void);
+u32 log_buf_len_get(void);
 #else
 static inline __printf(1, 0)
 int vprintk(const char *s, va_list args)
@@ -217,6 +216,16 @@ static inline void dump_stack_print_info(const char *log_lvl)
 static inline void show_regs_print_info(const char *log_lvl)
 {
 }
+
+static inline char *log_buf_addr_get(void)
+{
+	return NULL;
+}
+
+static linline u32 log_buf_len_get(void)
+{
+	return 0;
+}
 #endif
 
 extern asmlinkage void dump_stack(void) __cold;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 2/2 powerpc/powernv: Skip registering log region when CONFIG_PRINTK=n

When CONFIG_PRINTK=n, log_buf_addr_get() returns NULL and log_buf_len_get() return 0. Check for these return values and skip registering the dump buffer.

CC Michael Ellerman <[email protected]>
---
 arch/powerpc/platforms/powernv/opal.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/powerpc/platforms/powernv/opal.c +6 -0
index f10b9ec..1db119f0 100644
@@ -667,7 +667,13 @@ static void __init opal_dump_region_init(void)
 
 	/* Register kernel log buffer */
 	addr = log_buf_addr_get();
+	if (addr == NULL)
+		return;
+
 	size = log_buf_len_get();
+	if (size == 0)
+		return;
+
 	rc = opal_register_dump_region(OPAL_DUMP_REGION_LOG_BUF,
 				       __pa(addr), size);
 	/* Don't warn if this is just an older OPAL that doesn't
Signature · 1 line
1.9.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] powerpc/powernv: Skip registering log region when CONFIG_PRINTK=n

Quoted 5 lines · Pranith Kumar

When CONFIG_PRINTK=n, log_buf_addr_get() returns NULL and log_buf_len_get() return 0. Check for these return values and skip registering the dump buffer.

CC Michael Ellerman <[email protected]>

(investigating what would occur on systems with current firmware..)

Looking at hw/fsp/fsp-mdst-table.c in skiboot it appears that we'd end up logging an error log about being passed the size 0 and return OPAL_PARAMETER back to Linux.

While harmless, this is, naturally, not awesome to log an error about being unable to grab kernel log on crash every time you boot.

Quoted 29 lines
---
 arch/powerpc/platforms/powernv/opal.c | 6 ++++++
 1 file changed, 6 insertions(+)
arch/powerpc/platforms/powernv/opal.c +6 -0
index f10b9ec..1db119f0 100644
@@ -667,7 +667,13 @@ static void __init opal_dump_region_init(void)
 
 	/* Register kernel log buffer */
 	addr = log_buf_addr_get();
+	if (addr == NULL)
+		return;
+
 	size = log_buf_len_get();
+	if (size == 0)
+		return;
+
 	rc = opal_register_dump_region(OPAL_DUMP_REGION_LOG_BUF,
 				       __pa(addr), size);
 	/* Don't warn if this is just an older OPAL that doesn't
Signature · 6 lines
1.9.1

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev
#3 lore raw
In reply to Pranith Kumar
Quoted 7 lines · Pranith Kumar

There are missing dummy routines for log_buf_addr_get() and log_buf_len_get() for when CONFIG_PRINTK is not set causing build failures.

This patch adds these dummy routines at the appropriate location.

CC Michael Ellerman <[email protected]>

Are folks on CC happy if we take this via the powerpc tree?

Apologies for not getting it right the first time.

cheers

#4 lore raw
In reply to Pranith Kumar
Quoted 35 lines · Pranith Kumar

There are missing dummy routines for log_buf_addr_get() and log_buf_len_get() for when CONFIG_PRINTK is not set causing build failures.

This patch adds these dummy routines at the appropriate location.

CC Michael Ellerman <[email protected]>
---
 include/linux/printk.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
include/linux/printk.h +2 -3
index aeb9d7f..f52f02b 100644
@@ -10,9 +10,6 @@
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
-extern char *log_buf_addr_get(void);
-extern u32 log_buf_len_get(void);
-
 static inline int printk_get_level(const char *buffer)
 {
 	if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
@@ -168,6 +165,8 @@ void __init setup_log_buf(int early);
 void dump_stack_set_arch_desc(const char *fmt, ...);
 void dump_stack_print_info(const char *log_lvl);
 void show_regs_print_info(const char *log_lvl);
+char *log_buf_addr_get(void);
+u32 log_buf_len_get(void);
 #else
 static inline __printf(1, 0)
 int vprintk(const char *s, va_list args)

include/linux/printk.h static inline void dump_stack_print_info(const char *log_lvl) · line 225

Quoted 10 lines
include/linux/printk.h +7 -0
@@ -217,6 +216,16 @@ static inline void dump_stack_print_info(const char *log_lvl)
 static inline void show_regs_print_info(const char *log_lvl)
 {
 }
+
+static inline char *log_buf_addr_get(void)
+{
+	return NULL;
+}
+
+static linline u32 log_buf_len_get(void)
          ^
	  typo: linline -> inline

Otherwise, it looks fine to me.

Well, If you send v2, I would move this above log_buf_kexec_setup() in both #ifdef branches. So that all four log_buf()-related functions declared/defined together.

Best Regards,
Petr

Quoted 9 lines
include/linux/printk.h +3 -0
+{
+	return 0;
+}
 #endif
 
 extern asmlinkage void dump_stack(void) __cold;
Signature · 1 line
1.9.1
#5 lore raw
Quoted 40 lines · Petr Mladek
Quoted 39 lines · Pranith Kumar

There are missing dummy routines for log_buf_addr_get() and log_buf_len_get() for when CONFIG_PRINTK is not set causing build failures.

This patch adds these dummy routines at the appropriate location.

CC Michael Ellerman <[email protected]>
---
 include/linux/printk.h | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
include/linux/printk.h +3 -3
index aeb9d7f..f52f02b 100644
@@ -10,9 +10,6 @@
 extern const char linux_banner[];
 extern const char linux_proc_banner[];
 
-extern char *log_buf_addr_get(void);
-extern u32 log_buf_len_get(void);
-
 static inline int printk_get_level(const char *buffer)
 {
      if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
@@ -168,6 +165,8 @@ void __init setup_log_buf(int early);
 void dump_stack_set_arch_desc(const char *fmt, ...);
 void dump_stack_print_info(const char *log_lvl);
 void show_regs_print_info(const char *log_lvl);
+char *log_buf_addr_get(void);
+u32 log_buf_len_get(void);
 #else
 static inline __printf(1, 0)
 int vprintk(const char *s, va_list args)
@@ -217,6 +216,16 @@ static inline void dump_stack_print_info(const char *log_lvl)
 static inline void show_regs_print_info(const char *log_lvl)
 {
 }
+
Quoted 8 lines

include/linux/printk.h static inline void dump_stack_print_info(const char *log_lvl) · line 225

Quoted 6 lines
include/linux/printk.h +6 -0
+static inline char *log_buf_addr_get(void)
+{
+     return NULL;
+}
+
+static linline u32 log_buf_len_get(void)
          ^
          typo: linline -> inline

Argh, shows why we should always atleast build test before sending a patch, no matter how trivial it is.

Quoted 6 lines

Otherwise, it looks fine to me.

Well, If you send v2, I would move this above log_buf_kexec_setup() in both #ifdef branches. So that all four log_buf()-related functions declared/defined together.

I will update as you said in v2.

Thanks!

Signature · 1 line
Pranith