[Intel-gfx] [PATCH 1/2] drm/printer: add debug printer
Daniel Vetter
daniel at ffwll.ch
Fri Dec 30 10:42:32 UTC 2016
On Thu, Dec 29, 2016 at 12:47:52PM +0000, Chris Wilson wrote:
> On Wed, Dec 28, 2016 at 05:42:09PM +0100, Daniel Vetter wrote:
> > Useful for dumping lots of data into dmesg, e.g. drm_mm.
> >
> > Cc: Rob Clark <robdclark at gmail.com>
> > Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
> > ---
> > drivers/gpu/drm/drm_print.c | 6 ++++++
> > include/drm/drm_print.h | 20 ++++++++++++++++++--
> > 2 files changed, 24 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c
> > index ad3caaa1f48b..a8300cd2d3b3 100644
> > --- a/drivers/gpu/drm/drm_print.c
> > +++ b/drivers/gpu/drm/drm_print.c
> > @@ -40,6 +40,12 @@ void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf)
> > }
> > EXPORT_SYMBOL(__drm_printfn_info);
> >
> > +void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf)
> > +{
> > + pr_debug("%s %pV", p->prefix, vaf);
> > +}
> > +EXPORT_SYMBOL(__drm_printfn_info);
>
> Ahem.
Oops, I spotted it, but misplaced the fixup hunk into the 2nd patch. Will
fix.
> > +
> > /**
> > * drm_printf - print to a &drm_printer stream
> > * @p: the &drm_printer
> > diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h
> > index 1adf84aea622..e9d0ba20089c 100644
> > --- a/include/drm/drm_print.h
> > +++ b/include/drm/drm_print.h
> > @@ -60,19 +60,20 @@
> >
> > /**
> > * struct drm_printer - drm output "stream"
> > - * @printfn: actual output fxn
> > - * @arg: output fxn specific data
> > *
> > * Do not use struct members directly. Use drm_printer_seq_file(),
> > * drm_printer_info(), etc to initialize. And drm_printf() for output.
> > */
> > struct drm_printer {
> > + /* private: */
> > void (*printfn)(struct drm_printer *p, struct va_format *vaf);
> > void *arg;
> > + const char *prefix;
> > };
> >
> > void __drm_printfn_seq_file(struct drm_printer *p, struct va_format *vaf);
> > void __drm_printfn_info(struct drm_printer *p, struct va_format *vaf);
> > +void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf);
> >
> > void drm_printf(struct drm_printer *p, const char *f, ...);
> >
> > @@ -109,4 +110,19 @@ static inline struct drm_printer drm_info_printer(struct device *dev)
> > return p;
> > }
> >
> > +/**
> > + * drm_debug_printer - construct a &drm_printer that outputs to pr_debug()
> > + * @prefix: debug output prefix
> > + *
> > + * RETURNS:
> > + * The &drm_printer object
> > + */
> > +static inline struct drm_printer drm_debug_printer(const char *prefix)
> > +{
> > + struct drm_printer p = {
> > + .printfn = __drm_printfn_debug,
> > + .prefix = prefix
> > + };
> > + return p;
> > +}
>
> \n
>
> > #endif /* DRM_PRINT_H_ */
>
> I was looking at a single __drm_printfn callback with a
> drm_printer.level, but we lose the dynamic debug goodness.
>
> With the EXPORT_SYMBOL fixed,
> Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Thanks for the review, both applied to -misc.
-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the Intel-gfx
mailing list