| From ff8518f0bab439ff1fb282d5efa3f1bc47d09ded Mon Sep 17 00:00:00 2001 |
| From: Sean Paul <seanpaul@chromium.org> |
| Date: Tue, 18 Aug 2020 17:05:06 -0400 |
| Subject: [PATCH] CHROMIUM: drm/print: Add drm_debug_category_printer |
| |
| This patch adds a new printer which will select the appropriate output |
| for a given debug category. Currently there is only one output target, |
| which is syslog. However in the future we'll have tracefs and it will be |
| useful to print to syslog, tracefs, or both. Drivers just need to create |
| the printer for the appropriate category and the printer will decide |
| where to send the output. |
| |
| Signed-off-by: Sean Paul <seanpaul@chromium.org> |
| Link: https://patchwork.freedesktop.org/patch/msgid/20200608210505.48519-11-sean@poorly.run #v5 |
| |
| Changes in v5: |
| -Added to the set |
| Changes in v6: |
| -None |
| (am from https://patchwork.freedesktop.org/patch/386275/) |
| (also found at https://lore.kernel.org/r/20200818210510.49730-11-sean@poorly.run) |
| |
| Downstream reason: |
| -Patchset needs more work to resolve dynamic debug conflicts and |
| adoption upstream |
| |
| BUG=b:193917467 |
| TEST=Tested on volteer/zork/trogdor. Build tested on others |
| |
| Change-Id: I989519a871c52c018859a1447d2fffcdc87eadd5 |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3260467 |
| Reviewed-by: Drew Davenport <ddavenport@chromium.org> |
| Tested-by: Sean Paul <seanpaul@chromium.org> |
| Commit-Queue: Sean Paul <seanpaul@chromium.org> |
| --- |
| drivers/gpu/drm/drm_print.c | 5 +++++ |
| include/drm/drm_print.h | 28 ++++++++++++++++++++++++++++ |
| 2 files changed, 33 insertions(+) |
| |
| diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c |
| index d0133fb3b6172f5c5b50ce93fb97beb3c6709c36..f2da392059e892524972e3e5146b8a287c5c9519 100644 |
| --- a/drivers/gpu/drm/drm_print.c |
| +++ b/drivers/gpu/drm/drm_print.c |
| @@ -214,6 +214,11 @@ void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf) |
| } |
| EXPORT_SYMBOL(__drm_printfn_err); |
| |
| +void __drm_printfn_noop(struct drm_printer *p, struct va_format *vaf) |
| +{ |
| +} |
| +EXPORT_SYMBOL(__drm_printfn_noop); |
| + |
| /** |
| * drm_puts - print a const string to a &drm_printer stream |
| * @p: the &drm printer |
| diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h |
| index 0cf4f619afd908b081766c158447c93a49dfa343..45e2ddab14c9aabde3aab58574af54032218442e 100644 |
| --- a/include/drm/drm_print.h |
| +++ b/include/drm/drm_print.h |
| @@ -191,6 +191,7 @@ void __drm_puts_seq_file(struct drm_printer *p, const char *str); |
| void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf); |
| void __drm_printfn_debug_syslog(struct drm_printer *p, struct va_format *vaf); |
| void __drm_printfn_err(struct drm_printer *p, struct va_format *vaf); |
| +void __drm_printfn_noop(struct drm_printer *p, struct va_format *vaf); |
| |
| __printf(2, 3) |
| void drm_printf(struct drm_printer *p, const char *f, ...); |
| @@ -362,6 +363,33 @@ static inline struct drm_printer drm_err_printer(struct drm_device *drm, |
| return p; |
| } |
| |
| +/** |
| + * drm_debug_category_printer - construct a &drm_printer that outputs to |
| + * pr_debug() if enabled for the given category. |
| + * @category: the DRM_UT_* message category this message belongs to |
| + * @prefix: trace output prefix |
| + * |
| + * RETURNS: |
| + * The &drm_printer object |
| + */ |
| +static inline struct drm_printer |
| +drm_debug_category_printer(enum drm_debug_category category, |
| + const char *prefix) |
| +{ |
| + struct drm_printer p = { |
| + .prefix = prefix |
| + }; |
| + |
| + if (drm_debug_syslog_enabled(category)) { |
| + p.printfn = __drm_printfn_debug_syslog; |
| + } else { |
| + WARN(1, "Debug category %d is inactive.", category); |
| + p.printfn = __drm_printfn_noop; |
| + } |
| + |
| + return p; |
| +} |
| + |
| /* |
| * struct device based logging |
| * |
| -- |
| 2.44.0.478.gd926399ef9-goog |
| |