* [PATCH master 1/3] include: linux/printk: implement pr_*_once macros
@ 2023-02-02 12:57 Ahmad Fatoum
2023-02-02 12:57 ` [PATCH master 2/3] fs: tftp: print message when NIC can't keep us with TFTP windowsize Ahmad Fatoum
2023-02-02 12:57 ` [PATCH 3/3] include: printk: retire printk_once for pr_debug_once Ahmad Fatoum
0 siblings, 2 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-02-02 12:57 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
These are useful as a less verbose alternative to WARN_ONCE, which also
prints a stack trace if possible.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/linux/printk.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/include/linux/printk.h b/include/linux/printk.h
index 2fd6551e0ccb..a9d1b05f6f0f 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -94,6 +94,15 @@ static inline int dev_err_probe(struct device *dev, int err, const char *fmt,
(level) <= LOGLEVEL ? pr_print((level), (format), ##args) : 0; \
})
+#define __pr_printk_once(level, format, args...) do { \
+ static bool __print_once; \
+ \
+ if (!__print_once && (level) <= LOGLEVEL) { \
+ __print_once = true; \
+ pr_print((level), (format), ##args); \
+ } \
+} while (0)
+
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif
@@ -110,7 +119,18 @@ static inline int dev_err_probe(struct device *dev, int err, const char *fmt,
#define pr_vdebug(fmt, arg...) __pr_printk(8, pr_fmt(fmt), ##arg)
#define pr_cont(fmt, arg...) __pr_printk(-1, fmt, ##arg)
+#define pr_emerg_once(fmt, arg...) __pr_printk_once(0, pr_fmt(fmt), ##arg)
+#define pr_alert_once(fmt, arg...) __pr_printk_once(1, pr_fmt(fmt), ##arg)
+#define pr_crit_once(fmt, arg...) __pr_printk_once(2, pr_fmt(fmt), ##arg)
+#define pr_err_once(fmt, arg...) __pr_printk_once(3, pr_fmt(fmt), ##arg)
+#define pr_warning_once(fmt, arg...) __pr_printk_once(4, pr_fmt(fmt), ##arg)
+#define pr_notice_once(fmt, arg...) __pr_printk_once(5, pr_fmt(fmt), ##arg)
+#define pr_info_once(fmt, arg...) __pr_printk_once(6, pr_fmt(fmt), ##arg)
+#define pr_debug_once(fmt, arg...) __pr_printk_once(7, pr_fmt(fmt), ##arg)
+#define pr_vdebug_once(fmt, arg...) __pr_printk_once(8, pr_fmt(fmt), ##arg)
+
#define pr_warn pr_warning
+#define pr_warn_once pr_warning_once
int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size,
int swab);
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH master 2/3] fs: tftp: print message when NIC can't keep us with TFTP windowsize
2023-02-02 12:57 [PATCH master 1/3] include: linux/printk: implement pr_*_once macros Ahmad Fatoum
@ 2023-02-02 12:57 ` Ahmad Fatoum
2023-02-02 12:57 ` [PATCH 3/3] include: printk: retire printk_once for pr_debug_once Ahmad Fatoum
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-02-02 12:57 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
When the NIC driver doesn't configure enough buffers to keep up
with a big TFTP windowsize, error reporting is less than optimal,
e.g. on Layerscape FMan:
T BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBT T BBBBBBBBBBBBT
BBBBBBBBBBBBBBBBBBBBBBBBBT
or on older DWMAC1000 (non-EQOS):
WARNING: eth0: Rx error status (8800)
T BBBBBBWARNING: eth0: Rx error status (8800)
While we probably want to increase ring buffer depth in the drivers of
these NICs, for now, at least print a helpful warning.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
fs/tftp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/tftp.c b/fs/tftp.c
index 0b0b86a1a07e..0f7a40e26abd 100644
--- a/fs/tftp.c
+++ b/fs/tftp.c
@@ -477,6 +477,8 @@ static void tftp_handle_data(struct file_priv *priv, uint16_t block,
/* completely unexpected and unrelated to actual window;
ignore the packet. */
printf("B");
+ if (g_tftp_window_size > 1)
+ pr_warn_once("Unexpected packet. global.tftp.windowsize too high for NIC?\n");
} else {
/* The 'rc < 0' below happens e.g. when datagrams in the first
part of the transfer window are dropped.
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] include: printk: retire printk_once for pr_debug_once
2023-02-02 12:57 [PATCH master 1/3] include: linux/printk: implement pr_*_once macros Ahmad Fatoum
2023-02-02 12:57 ` [PATCH master 2/3] fs: tftp: print message when NIC can't keep us with TFTP windowsize Ahmad Fatoum
@ 2023-02-02 12:57 ` Ahmad Fatoum
1 sibling, 0 replies; 3+ messages in thread
From: Ahmad Fatoum @ 2023-02-02 12:57 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
printk is just printf and KERN_DEBUG is just "", so printk_once(KERN_DEBUG
doesn't do what's promised. Replace instead with pr_debug_once, which
does what one would expect.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
include/printk.h | 10 ----------
lib/list_sort.c | 5 ++---
scripts/bareboxenv.c | 2 +-
3 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/include/printk.h b/include/printk.h
index 90c45afd9fc7..6f8635fae2c0 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -31,16 +31,6 @@ void __attribute__((noreturn)) panic(const char *fmt, ...);
#define printk printf
-#define printk_once(fmt, ...) \
-({ \
- static bool __print_once ; \
- \
- if (!__print_once) { \
- __print_once = true; \
- printk(fmt, ##__VA_ARGS__); \
- } \
-})
-
enum {
DUMP_PREFIX_NONE,
DUMP_PREFIX_ADDRESS,
diff --git a/lib/list_sort.c b/lib/list_sort.c
index 77ddadb3d6ac..eea87f834ca4 100644
--- a/lib/list_sort.c
+++ b/lib/list_sort.c
@@ -4,6 +4,7 @@
#include <linux/kernel.h>
#define EXPORT_SYMBOL(x)
#else
+#define pr_fmt(fmt) "list_sort: " fmt
#include <common.h>
#include <malloc.h>
#endif
@@ -129,9 +130,7 @@ void list_sort(void *priv, struct list_head *head,
}
if (lev > max_lev) {
if (unlikely(lev >= ARRAY_SIZE(part)-1)) {
- printk_once(KERN_DEBUG "list passed to"
- " list_sort() too long for"
- " efficiency\n");
+ pr_debug_once("list passed to too long for efficient sorting\n");
lev--;
}
max_lev = lev;
diff --git a/scripts/bareboxenv.c b/scripts/bareboxenv.c
index f1706a5e175b..e954447015c5 100644
--- a/scripts/bareboxenv.c
+++ b/scripts/bareboxenv.c
@@ -20,7 +20,7 @@
#include "compiler.h"
#define debug(...)
-#define printk_once(...)
+#define pr_debug_once(...)
/* Find out if the last character of a string matches the one given.
* Don't underrun the buffer if the string length is 0.
--
2.30.2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-02 12:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-02 12:57 [PATCH master 1/3] include: linux/printk: implement pr_*_once macros Ahmad Fatoum
2023-02-02 12:57 ` [PATCH master 2/3] fs: tftp: print message when NIC can't keep us with TFTP windowsize Ahmad Fatoum
2023-02-02 12:57 ` [PATCH 3/3] include: printk: retire printk_once for pr_debug_once Ahmad Fatoum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox