Re: [Freedreno] [PATCH 2/6] drm: add helper for printing to log or seq_file
On Mon, Oct 17, 2016 at 1:00 PM, Sean Paul wrote: > On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark wrote: >> Sometimes it is nice not to duplicate equivalent printk() and >> seq_printf() code. >> >> Signed-off-by: Rob Clark >> --- >> drivers/gpu/drm/Makefile| 3 ++- >> drivers/gpu/drm/drm_print.c | 54 +++ >> include/drm/drm_print.h | 62 >> + >> 3 files changed, 118 insertions(+), 1 deletion(-) >> create mode 100644 drivers/gpu/drm/drm_print.c >> create mode 100644 include/drm/drm_print.h >> >> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile >> index e3dba6f..4894ebb 100644 >> --- a/drivers/gpu/drm/Makefile >> +++ b/drivers/gpu/drm/Makefile >> @@ -12,7 +12,8 @@ drm-y :=drm_auth.o drm_bufs.o drm_cache.o \ >> drm_info.o drm_debugfs.o drm_encoder_slave.o \ >> drm_trace_points.o drm_global.o drm_prime.o \ >> drm_rect.o drm_vma_manager.o drm_flip_work.o \ >> - drm_modeset_lock.o drm_atomic.o drm_bridge.o >> + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ >> + drm_print.o >> >> drm-$(CONFIG_COMPAT) += drm_ioc32.o >> drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o >> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c >> new file mode 100644 >> index 000..ddcb437 >> --- /dev/null >> +++ b/drivers/gpu/drm/drm_print.c >> @@ -0,0 +1,54 @@ >> +/* >> + * Copyright (C) 2016 Red Hat >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> in >> + * all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR >> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >> + * OTHER DEALINGS IN THE SOFTWARE. >> + * >> + * Authors: >> + * Rob Clark >> + */ >> + >> +#include >> +#include >> +#include >> + >> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list >> args) >> +{ >> + seq_vprintf(p->arg, f, args); >> +} >> + >> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args) >> +{ > > I think you can re-use drm_printk here: > > drm_printk(KERN_INFO, DRM_UT_NONE, f, args) fwiw, I looked at drm_printk().. but kinda don't want the fxn name in the output. However the va_format trick is neat. I think I'll use that plus dev_printk(). BR, -R > >> + const char *hdr = KERN_INFO "[" DRM_NAME "] "; >> + char fmt[strlen(hdr) + strlen(f) + 1]; >> + >> + memcpy(fmt, hdr, strlen(hdr)); >> + memcpy(fmt + strlen(hdr), f, strlen(f)); >> + fmt[strlen(hdr) + strlen(f)] = 0; >> + >> + vprintk(fmt, args); >> +} >> + >> +void drm_printf(struct drm_print *p, const char *f, ...) >> +{ >> + va_list args; >> + >> + va_start(args, f); >> + p->printfn(p, f, args); >> + va_end(args); >> +} >> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h >> new file mode 100644 >> index 000..f294a9a >> --- /dev/null >> +++ b/include/drm/drm_print.h >> @@ -0,0 +1,62 @@ >> +/* >> + * Copyright (C) 2016 Red Hat >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> in >> + * all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR >> + * OTHE
Re: [Freedreno] [PATCH 2/6] drm: add helper for printing to log or seq_file
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark wrote: > Sometimes it is nice not to duplicate equivalent printk() and > seq_printf() code. > > Signed-off-by: Rob Clark > --- > drivers/gpu/drm/Makefile| 3 ++- > drivers/gpu/drm/drm_print.c | 54 +++ > include/drm/drm_print.h | 62 > + > 3 files changed, 118 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/drm_print.c > create mode 100644 include/drm/drm_print.h > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index e3dba6f..4894ebb 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -12,7 +12,8 @@ drm-y :=drm_auth.o drm_bufs.o drm_cache.o \ > drm_info.o drm_debugfs.o drm_encoder_slave.o \ > drm_trace_points.o drm_global.o drm_prime.o \ > drm_rect.o drm_vma_manager.o drm_flip_work.o \ > - drm_modeset_lock.o drm_atomic.o drm_bridge.o > + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ > + drm_print.o > > drm-$(CONFIG_COMPAT) += drm_ioc32.o > drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c > new file mode 100644 > index 000..ddcb437 > --- /dev/null > +++ b/drivers/gpu/drm/drm_print.c > @@ -0,0 +1,54 @@ > +/* > + * Copyright (C) 2016 Red Hat > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + * Authors: > + * Rob Clark > + */ > + > +#include > +#include > +#include > + > +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args) > +{ > + seq_vprintf(p->arg, f, args); > +} > + > +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args) > +{ I think you can re-use drm_printk here: drm_printk(KERN_INFO, DRM_UT_NONE, f, args) > + const char *hdr = KERN_INFO "[" DRM_NAME "] "; > + char fmt[strlen(hdr) + strlen(f) + 1]; > + > + memcpy(fmt, hdr, strlen(hdr)); > + memcpy(fmt + strlen(hdr), f, strlen(f)); > + fmt[strlen(hdr) + strlen(f)] = 0; > + > + vprintk(fmt, args); > +} > + > +void drm_printf(struct drm_print *p, const char *f, ...) > +{ > + va_list args; > + > + va_start(args, f); > + p->printfn(p, f, args); > + va_end(args); > +} > diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h > new file mode 100644 > index 000..f294a9a > --- /dev/null > +++ b/include/drm/drm_print.h > @@ -0,0 +1,62 @@ > +/* > + * Copyright (C) 2016 Red Hat > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + * Authors: > + * Rob Clark > + */ > + > +#ifndef DRM_PRINT_H_ > +#define DRM_PRINT_H_ > + > +#include > +#include > + > +/* A simple wrapper to abstract seq_file vs printk, so sa
Re: [Freedreno] [PATCH 2/6] drm: add helper for printing to log or seq_file
On Mon, Oct 17, 2016 at 8:30 AM, Daniel Vetter wrote: > On Mon, Oct 17, 2016 at 07:59:51AM -0400, Rob Clark wrote: >> On Mon, Oct 17, 2016 at 2:38 AM, Daniel Vetter wrote: >> > On Fri, Oct 14, 2016 at 07:55:49PM -0400, Rob Clark wrote: >> >> Sometimes it is nice not to duplicate equivalent printk() and >> >> seq_printf() code. >> >> >> >> Signed-off-by: Rob Clark >> > >> > Ok, maybe I should wait for coffee to kick in before commenting on patches >> > ;-) >> > >> > Two bits: >> > - kerneldoc for this pls, plus pulling into drm-internals.rst. >> > - Would be awesome to de-dupe the existing dumping code in drm_mm.c with >> > this. >> >> I have a couple things in drm/msm that I want to de-dup.. and I guess >> most drivers probably do as well.. >> >> I'm toying with the idea to convert drm_info_list::show over to take a >> drm_print ptr instead of seq_file, then we could just re-use the >> debugfs fxns directly without having extra wrappers fxns.. question is >> best way to do that in a non-flag-day way.. > > One idea I had in the other reply is to create a seq_file which can dump > to debugfs. Not sure how feasible that is ... that was my first approach.. but seq_file carries a lot of baggage.. BR, -R > -Daniel > >> >> BR, >> -R >> >> > -Daniel >> > >> >> --- >> >> drivers/gpu/drm/Makefile| 3 ++- >> >> drivers/gpu/drm/drm_print.c | 54 +++ >> >> include/drm/drm_print.h | 62 >> >> + >> >> 3 files changed, 118 insertions(+), 1 deletion(-) >> >> create mode 100644 drivers/gpu/drm/drm_print.c >> >> create mode 100644 include/drm/drm_print.h >> >> >> >> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile >> >> index e3dba6f..4894ebb 100644 >> >> --- a/drivers/gpu/drm/Makefile >> >> +++ b/drivers/gpu/drm/Makefile >> >> @@ -12,7 +12,8 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ >> >> drm_info.o drm_debugfs.o drm_encoder_slave.o \ >> >> drm_trace_points.o drm_global.o drm_prime.o \ >> >> drm_rect.o drm_vma_manager.o drm_flip_work.o \ >> >> - drm_modeset_lock.o drm_atomic.o drm_bridge.o >> >> + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ >> >> + drm_print.o >> >> >> >> drm-$(CONFIG_COMPAT) += drm_ioc32.o >> >> drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o >> >> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c >> >> new file mode 100644 >> >> index 000..ddcb437 >> >> --- /dev/null >> >> +++ b/drivers/gpu/drm/drm_print.c >> >> @@ -0,0 +1,54 @@ >> >> +/* >> >> + * Copyright (C) 2016 Red Hat >> >> + * >> >> + * Permission is hereby granted, free of charge, to any person obtaining >> >> a >> >> + * copy of this software and associated documentation files (the >> >> "Software"), >> >> + * to deal in the Software without restriction, including without >> >> limitation >> >> + * the rights to use, copy, modify, merge, publish, distribute, >> >> sublicense, >> >> + * and/or sell copies of the Software, and to permit persons to whom the >> >> + * Software is furnished to do so, subject to the following conditions: >> >> + * >> >> + * The above copyright notice and this permission notice shall be >> >> included in >> >> + * all copies or substantial portions of the Software. >> >> + * >> >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, >> >> EXPRESS OR >> >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> >> MERCHANTABILITY, >> >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT >> >> SHALL >> >> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES >> >> OR >> >> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >> >> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >> >> + * OTHER DEALINGS IN THE SOFTWARE. >> >> + * >> >> + * Authors: >> >> + * Rob Clark >> >> + */ >> >> + >> >> +#include >> >> +#include >> >> +#include >> >> + >> >> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list >> >> args) >> >> +{ >> >> + seq_vprintf(p->arg, f, args); >> >> +} >> >> + >> >> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args) >> >> +{ >> >> + const char *hdr = KERN_INFO "[" DRM_NAME "] "; >> >> + char fmt[strlen(hdr) + strlen(f) + 1]; >> >> + >> >> + memcpy(fmt, hdr, strlen(hdr)); >> >> + memcpy(fmt + strlen(hdr), f, strlen(f)); >> >> + fmt[strlen(hdr) + strlen(f)] = 0; >> >> + >> >> + vprintk(fmt, args); >> >> +} >> >> + >> >> +void drm_printf(struct drm_print *p, const char *f, ...) >> >> +{ >> >> + va_list args; >> >> + >> >> + va_start(args, f); >> >> + p->printfn(p, f, args); >> >> + va_end(args); >> >> +} >> >> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h >> >> new file mode 100644 >> >> index 000..f294a9a >> >> --- /dev/null >> >> +++
Re: [Freedreno] [PATCH 2/6] drm: add helper for printing to log or seq_file
On Mon, Oct 17, 2016 at 07:59:51AM -0400, Rob Clark wrote: > On Mon, Oct 17, 2016 at 2:38 AM, Daniel Vetter wrote: > > On Fri, Oct 14, 2016 at 07:55:49PM -0400, Rob Clark wrote: > >> Sometimes it is nice not to duplicate equivalent printk() and > >> seq_printf() code. > >> > >> Signed-off-by: Rob Clark > > > > Ok, maybe I should wait for coffee to kick in before commenting on patches > > ;-) > > > > Two bits: > > - kerneldoc for this pls, plus pulling into drm-internals.rst. > > - Would be awesome to de-dupe the existing dumping code in drm_mm.c with > > this. > > I have a couple things in drm/msm that I want to de-dup.. and I guess > most drivers probably do as well.. > > I'm toying with the idea to convert drm_info_list::show over to take a > drm_print ptr instead of seq_file, then we could just re-use the > debugfs fxns directly without having extra wrappers fxns.. question is > best way to do that in a non-flag-day way.. One idea I had in the other reply is to create a seq_file which can dump to debugfs. Not sure how feasible that is ... -Daniel > > BR, > -R > > > -Daniel > > > >> --- > >> drivers/gpu/drm/Makefile| 3 ++- > >> drivers/gpu/drm/drm_print.c | 54 +++ > >> include/drm/drm_print.h | 62 > >> + > >> 3 files changed, 118 insertions(+), 1 deletion(-) > >> create mode 100644 drivers/gpu/drm/drm_print.c > >> create mode 100644 include/drm/drm_print.h > >> > >> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > >> index e3dba6f..4894ebb 100644 > >> --- a/drivers/gpu/drm/Makefile > >> +++ b/drivers/gpu/drm/Makefile > >> @@ -12,7 +12,8 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ > >> drm_info.o drm_debugfs.o drm_encoder_slave.o \ > >> drm_trace_points.o drm_global.o drm_prime.o \ > >> drm_rect.o drm_vma_manager.o drm_flip_work.o \ > >> - drm_modeset_lock.o drm_atomic.o drm_bridge.o > >> + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ > >> + drm_print.o > >> > >> drm-$(CONFIG_COMPAT) += drm_ioc32.o > >> drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o > >> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c > >> new file mode 100644 > >> index 000..ddcb437 > >> --- /dev/null > >> +++ b/drivers/gpu/drm/drm_print.c > >> @@ -0,0 +1,54 @@ > >> +/* > >> + * Copyright (C) 2016 Red Hat > >> + * > >> + * Permission is hereby granted, free of charge, to any person obtaining a > >> + * copy of this software and associated documentation files (the > >> "Software"), > >> + * to deal in the Software without restriction, including without > >> limitation > >> + * the rights to use, copy, modify, merge, publish, distribute, > >> sublicense, > >> + * and/or sell copies of the Software, and to permit persons to whom the > >> + * Software is furnished to do so, subject to the following conditions: > >> + * > >> + * The above copyright notice and this permission notice shall be > >> included in > >> + * all copies or substantial portions of the Software. > >> + * > >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > >> EXPRESS OR > >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > >> MERCHANTABILITY, > >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT > >> SHALL > >> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES > >> OR > >> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > >> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > >> + * OTHER DEALINGS IN THE SOFTWARE. > >> + * > >> + * Authors: > >> + * Rob Clark > >> + */ > >> + > >> +#include > >> +#include > >> +#include > >> + > >> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list > >> args) > >> +{ > >> + seq_vprintf(p->arg, f, args); > >> +} > >> + > >> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args) > >> +{ > >> + const char *hdr = KERN_INFO "[" DRM_NAME "] "; > >> + char fmt[strlen(hdr) + strlen(f) + 1]; > >> + > >> + memcpy(fmt, hdr, strlen(hdr)); > >> + memcpy(fmt + strlen(hdr), f, strlen(f)); > >> + fmt[strlen(hdr) + strlen(f)] = 0; > >> + > >> + vprintk(fmt, args); > >> +} > >> + > >> +void drm_printf(struct drm_print *p, const char *f, ...) > >> +{ > >> + va_list args; > >> + > >> + va_start(args, f); > >> + p->printfn(p, f, args); > >> + va_end(args); > >> +} > >> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h > >> new file mode 100644 > >> index 000..f294a9a > >> --- /dev/null > >> +++ b/include/drm/drm_print.h > >> @@ -0,0 +1,62 @@ > >> +/* > >> + * Copyright (C) 2016 Red Hat > >> + * > >> + * Permission is hereby granted, free of charge, to any person obtaining a > >> + * copy of this software and associated documentation files (the > >> "Software"),
Re: [Freedreno] [PATCH 2/6] drm: add helper for printing to log or seq_file
On Mon, Oct 17, 2016 at 2:38 AM, Daniel Vetter wrote: > On Fri, Oct 14, 2016 at 07:55:49PM -0400, Rob Clark wrote: >> Sometimes it is nice not to duplicate equivalent printk() and >> seq_printf() code. >> >> Signed-off-by: Rob Clark > > Ok, maybe I should wait for coffee to kick in before commenting on patches > ;-) > > Two bits: > - kerneldoc for this pls, plus pulling into drm-internals.rst. > - Would be awesome to de-dupe the existing dumping code in drm_mm.c with > this. I have a couple things in drm/msm that I want to de-dup.. and I guess most drivers probably do as well.. I'm toying with the idea to convert drm_info_list::show over to take a drm_print ptr instead of seq_file, then we could just re-use the debugfs fxns directly without having extra wrappers fxns.. question is best way to do that in a non-flag-day way.. BR, -R > -Daniel > >> --- >> drivers/gpu/drm/Makefile| 3 ++- >> drivers/gpu/drm/drm_print.c | 54 +++ >> include/drm/drm_print.h | 62 >> + >> 3 files changed, 118 insertions(+), 1 deletion(-) >> create mode 100644 drivers/gpu/drm/drm_print.c >> create mode 100644 include/drm/drm_print.h >> >> diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile >> index e3dba6f..4894ebb 100644 >> --- a/drivers/gpu/drm/Makefile >> +++ b/drivers/gpu/drm/Makefile >> @@ -12,7 +12,8 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ >> drm_info.o drm_debugfs.o drm_encoder_slave.o \ >> drm_trace_points.o drm_global.o drm_prime.o \ >> drm_rect.o drm_vma_manager.o drm_flip_work.o \ >> - drm_modeset_lock.o drm_atomic.o drm_bridge.o >> + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ >> + drm_print.o >> >> drm-$(CONFIG_COMPAT) += drm_ioc32.o >> drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o >> diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c >> new file mode 100644 >> index 000..ddcb437 >> --- /dev/null >> +++ b/drivers/gpu/drm/drm_print.c >> @@ -0,0 +1,54 @@ >> +/* >> + * Copyright (C) 2016 Red Hat >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> in >> + * all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> OR >> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR >> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >> + * OTHER DEALINGS IN THE SOFTWARE. >> + * >> + * Authors: >> + * Rob Clark >> + */ >> + >> +#include >> +#include >> +#include >> + >> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list >> args) >> +{ >> + seq_vprintf(p->arg, f, args); >> +} >> + >> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args) >> +{ >> + const char *hdr = KERN_INFO "[" DRM_NAME "] "; >> + char fmt[strlen(hdr) + strlen(f) + 1]; >> + >> + memcpy(fmt, hdr, strlen(hdr)); >> + memcpy(fmt + strlen(hdr), f, strlen(f)); >> + fmt[strlen(hdr) + strlen(f)] = 0; >> + >> + vprintk(fmt, args); >> +} >> + >> +void drm_printf(struct drm_print *p, const char *f, ...) >> +{ >> + va_list args; >> + >> + va_start(args, f); >> + p->printfn(p, f, args); >> + va_end(args); >> +} >> diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h >> new file mode 100644 >> index 000..f294a9a >> --- /dev/null >> +++ b/include/drm/drm_print.h >> @@ -0,0 +1,62 @@ >> +/* >> + * Copyright (C) 2016 Red Hat >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> in >> + * all copies or substantial portions of the Software. >> + *
Re: [Freedreno] [PATCH 2/6] drm: add helper for printing to log or seq_file
On Fri, Oct 14, 2016 at 07:55:49PM -0400, Rob Clark wrote: > Sometimes it is nice not to duplicate equivalent printk() and > seq_printf() code. > > Signed-off-by: Rob Clark Ok, maybe I should wait for coffee to kick in before commenting on patches ;-) Two bits: - kerneldoc for this pls, plus pulling into drm-internals.rst. - Would be awesome to de-dupe the existing dumping code in drm_mm.c with this. -Daniel > --- > drivers/gpu/drm/Makefile| 3 ++- > drivers/gpu/drm/drm_print.c | 54 +++ > include/drm/drm_print.h | 62 > + > 3 files changed, 118 insertions(+), 1 deletion(-) > create mode 100644 drivers/gpu/drm/drm_print.c > create mode 100644 include/drm/drm_print.h > > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index e3dba6f..4894ebb 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -12,7 +12,8 @@ drm-y := drm_auth.o drm_bufs.o drm_cache.o \ > drm_info.o drm_debugfs.o drm_encoder_slave.o \ > drm_trace_points.o drm_global.o drm_prime.o \ > drm_rect.o drm_vma_manager.o drm_flip_work.o \ > - drm_modeset_lock.o drm_atomic.o drm_bridge.o > + drm_modeset_lock.o drm_atomic.o drm_bridge.o \ > + drm_print.o > > drm-$(CONFIG_COMPAT) += drm_ioc32.o > drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o > diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c > new file mode 100644 > index 000..ddcb437 > --- /dev/null > +++ b/drivers/gpu/drm/drm_print.c > @@ -0,0 +1,54 @@ > +/* > + * Copyright (C) 2016 Red Hat > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + * Authors: > + * Rob Clark > + */ > + > +#include > +#include > +#include > + > +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args) > +{ > + seq_vprintf(p->arg, f, args); > +} > + > +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args) > +{ > + const char *hdr = KERN_INFO "[" DRM_NAME "] "; > + char fmt[strlen(hdr) + strlen(f) + 1]; > + > + memcpy(fmt, hdr, strlen(hdr)); > + memcpy(fmt + strlen(hdr), f, strlen(f)); > + fmt[strlen(hdr) + strlen(f)] = 0; > + > + vprintk(fmt, args); > +} > + > +void drm_printf(struct drm_print *p, const char *f, ...) > +{ > + va_list args; > + > + va_start(args, f); > + p->printfn(p, f, args); > + va_end(args); > +} > diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h > new file mode 100644 > index 000..f294a9a > --- /dev/null > +++ b/include/drm/drm_print.h > @@ -0,0 +1,62 @@ > +/* > + * Copyright (C) 2016 Red Hat > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included in > + * all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR > + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + * Authors: > + * Rob Clark > + */ > + > +#ifnd