* [PATCH 1/6] drm: helper macros to print composite types
[not found] ` <1476489353-16261-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-10-14 23:55 ` Rob Clark
2016-10-17 17:00 ` Sean Paul
2016-10-14 23:55 ` [PATCH 2/6] drm: add helper for printing to log or seq_file Rob Clark
` (3 subsequent siblings)
4 siblings, 1 reply; 20+ messages in thread
From: Rob Clark @ 2016-10-14 23:55 UTC (permalink / raw)
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Archit Taneja, Rob Clark, Sean Paul, Daniel Vetter,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
Ville Syrjälä
I'll want to print things in a similar way in a later patch. This will
make it easier.
TODO drm_rect_debug_print() doesn't have many call sites, and is kind of
unnecessary now. Should we just drop it?
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
drivers/gpu/drm/drm_modes.c | 8 +-------
drivers/gpu/drm/drm_rect.c | 11 ++---------
include/drm/drmP.h | 21 +++++++++++++++++++++
3 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index fc5040a..77b0301 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -49,13 +49,7 @@
*/
void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
{
- DRM_DEBUG_KMS("Modeline %d:\"%s\" %d %d %d %d %d %d %d %d %d %d "
- "0x%x 0x%x\n",
- mode->base.id, mode->name, mode->vrefresh, mode->clock,
- mode->hdisplay, mode->hsync_start,
- mode->hsync_end, mode->htotal,
- mode->vdisplay, mode->vsync_start,
- mode->vsync_end, mode->vtotal, mode->type, mode->flags);
+ DRM_DEBUG_KMS("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
}
EXPORT_SYMBOL(drm_mode_debug_printmodeline);
diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c
index a8e2c86..d451112 100644
--- a/drivers/gpu/drm/drm_rect.c
+++ b/drivers/gpu/drm/drm_rect.c
@@ -281,17 +281,10 @@ EXPORT_SYMBOL(drm_rect_calc_vscale_relaxed);
*/
void drm_rect_debug_print(const char *prefix, const struct drm_rect *r, bool fixed_point)
{
- int w = drm_rect_width(r);
- int h = drm_rect_height(r);
-
if (fixed_point)
- DRM_DEBUG_KMS("%s%d.%06ux%d.%06u%+d.%06u%+d.%06u\n", prefix,
- w >> 16, ((w & 0xffff) * 15625) >> 10,
- h >> 16, ((h & 0xffff) * 15625) >> 10,
- r->x1 >> 16, ((r->x1 & 0xffff) * 15625) >> 10,
- r->y1 >> 16, ((r->y1 & 0xffff) * 15625) >> 10);
+ DRM_DEBUG_KMS("%s" DRM_RECT_FP_FMT "\n", prefix, DRM_RECT_FP_ARG(r));
else
- DRM_DEBUG_KMS("%s%dx%d%+d%+d\n", prefix, w, h, r->x1, r->y1);
+ DRM_DEBUG_KMS("%s" DRM_RECT_FMT "\n", prefix, DRM_RECT_ARG(r));
}
EXPORT_SYMBOL(drm_rect_debug_print);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 28d341a..7ffaa35 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -231,6 +231,27 @@ void drm_err(const char *format, ...);
drm_ut_debug_printk(__func__, fmt, ##args); \
} while (0)
+/* Format strings and argument splitters to simplify printing
+ * various "complex" objects
+ */
+#define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
+#define DRM_MODE_ARG(m) \
+ (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \
+ (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
+ (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
+ (m)->type, (m)->flags
+
+#define DRM_RECT_FMT "%dx%d%+d%+d"
+#define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1
+
+/* for rect's in fixed-point format: */
+#define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u"
+#define DRM_RECT_FP_ARG(r) \
+ drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \
+ drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \
+ (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
+ (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
+
/*@}*/
/***********************************************************************/
--
2.7.4
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 1/6] drm: helper macros to print composite types
2016-10-14 23:55 ` [PATCH 1/6] drm: helper macros to print composite types Rob Clark
@ 2016-10-17 17:00 ` Sean Paul
0 siblings, 0 replies; 20+ messages in thread
From: Sean Paul @ 2016-10-17 17:00 UTC (permalink / raw)
To: Rob Clark; +Cc: freedreno, dri-devel
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark@gmail.com> wrote:
> I'll want to print things in a similar way in a later patch. This will
> make it easier.
>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
> TODO drm_rect_debug_print() doesn't have many call sites, and is kind of
> unnecessary now. Should we just drop it?
>
yeah, seems like you could get the same info from the state dumps.
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> drivers/gpu/drm/drm_modes.c | 8 +-------
> drivers/gpu/drm/drm_rect.c | 11 ++---------
> include/drm/drmP.h | 21 +++++++++++++++++++++
> 3 files changed, 24 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index fc5040a..77b0301 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -49,13 +49,7 @@
> */
> void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
> {
> - DRM_DEBUG_KMS("Modeline %d:\"%s\" %d %d %d %d %d %d %d %d %d %d "
> - "0x%x 0x%x\n",
> - mode->base.id, mode->name, mode->vrefresh, mode->clock,
> - mode->hdisplay, mode->hsync_start,
> - mode->hsync_end, mode->htotal,
> - mode->vdisplay, mode->vsync_start,
> - mode->vsync_end, mode->vtotal, mode->type, mode->flags);
> + DRM_DEBUG_KMS("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
> }
> EXPORT_SYMBOL(drm_mode_debug_printmodeline);
>
> diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c
> index a8e2c86..d451112 100644
> --- a/drivers/gpu/drm/drm_rect.c
> +++ b/drivers/gpu/drm/drm_rect.c
> @@ -281,17 +281,10 @@ EXPORT_SYMBOL(drm_rect_calc_vscale_relaxed);
> */
> void drm_rect_debug_print(const char *prefix, const struct drm_rect *r, bool fixed_point)
> {
> - int w = drm_rect_width(r);
> - int h = drm_rect_height(r);
> -
> if (fixed_point)
> - DRM_DEBUG_KMS("%s%d.%06ux%d.%06u%+d.%06u%+d.%06u\n", prefix,
> - w >> 16, ((w & 0xffff) * 15625) >> 10,
> - h >> 16, ((h & 0xffff) * 15625) >> 10,
> - r->x1 >> 16, ((r->x1 & 0xffff) * 15625) >> 10,
> - r->y1 >> 16, ((r->y1 & 0xffff) * 15625) >> 10);
> + DRM_DEBUG_KMS("%s" DRM_RECT_FP_FMT "\n", prefix, DRM_RECT_FP_ARG(r));
> else
> - DRM_DEBUG_KMS("%s%dx%d%+d%+d\n", prefix, w, h, r->x1, r->y1);
> + DRM_DEBUG_KMS("%s" DRM_RECT_FMT "\n", prefix, DRM_RECT_ARG(r));
> }
> EXPORT_SYMBOL(drm_rect_debug_print);
>
> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index 28d341a..7ffaa35 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -231,6 +231,27 @@ void drm_err(const char *format, ...);
> drm_ut_debug_printk(__func__, fmt, ##args); \
> } while (0)
>
> +/* Format strings and argument splitters to simplify printing
> + * various "complex" objects
> + */
> +#define DRM_MODE_FMT "%d:\"%s\" %d %d %d %d %d %d %d %d %d %d 0x%x 0x%x"
> +#define DRM_MODE_ARG(m) \
> + (m)->base.id, (m)->name, (m)->vrefresh, (m)->clock, \
> + (m)->hdisplay, (m)->hsync_start, (m)->hsync_end, (m)->htotal, \
> + (m)->vdisplay, (m)->vsync_start, (m)->vsync_end, (m)->vtotal, \
> + (m)->type, (m)->flags
> +
> +#define DRM_RECT_FMT "%dx%d%+d%+d"
> +#define DRM_RECT_ARG(r) drm_rect_width(r), drm_rect_height(r), (r)->x1, (r)->y1
> +
> +/* for rect's in fixed-point format: */
> +#define DRM_RECT_FP_FMT "%d.%06ux%d.%06u%+d.%06u%+d.%06u"
> +#define DRM_RECT_FP_ARG(r) \
> + drm_rect_width(r) >> 16, ((drm_rect_width(r) & 0xffff) * 15625) >> 10, \
> + drm_rect_height(r) >> 16, ((drm_rect_height(r) & 0xffff) * 15625) >> 10, \
> + (r)->x1 >> 16, (((r)->x1 & 0xffff) * 15625) >> 10, \
> + (r)->y1 >> 16, (((r)->y1 & 0xffff) * 15625) >> 10
> +
> /*@}*/
>
> /***********************************************************************/
> --
> 2.7.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 2/6] drm: add helper for printing to log or seq_file
[not found] ` <1476489353-16261-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-14 23:55 ` [PATCH 1/6] drm: helper macros to print composite types Rob Clark
@ 2016-10-14 23:55 ` Rob Clark
2016-10-17 6:38 ` Daniel Vetter
[not found] ` <1476489353-16261-3-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-14 23:55 ` [PATCH 3/6] drm: add helpers to go from plane state to drm_rect Rob Clark
` (2 subsequent siblings)
4 siblings, 2 replies; 20+ messages in thread
From: Rob Clark @ 2016-10-14 23:55 UTC (permalink / raw)
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Archit Taneja, Rob Clark, Sean Paul, Daniel Vetter,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
Ville Syrjälä
Sometimes it is nice not to duplicate equivalent printk() and
seq_printf() code.
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
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 0000000..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 <robdclark@gmail.com>
+ */
+
+#include <linux/seq_file.h>
+#include <drm/drmP.h>
+#include <drm/drm_print.h>
+
+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 0000000..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 <robdclark@gmail.com>
+ */
+
+#ifndef DRM_PRINT_H_
+#define DRM_PRINT_H_
+
+#include <stdarg.h>
+#include <linux/seq_file.h>
+
+/* A simple wrapper to abstract seq_file vs printk, so same logging code
+ * does not have to be duplicated.
+ */
+struct drm_print {
+ void (*printfn)(struct drm_print *p, const char *f, va_list args);
+ void *arg;
+};
+
+void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
+void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
+
+void drm_printf(struct drm_print *p, const char *f, ...);
+
+static inline struct drm_print drm_print_seq_file(struct seq_file *f)
+{
+ struct drm_print p = {
+ .printfn = __drm_printfn_seq_file,
+ .arg = f,
+ };
+ return p;
+}
+
+static inline struct drm_print drm_print_info(void)
+{
+ struct drm_print p = {
+ .printfn = __drm_printfn_info,
+ };
+ return p;
+}
+
+#endif /* DRM_PRINT_H_ */
--
2.7.4
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 2/6] drm: add helper for printing to log or seq_file
2016-10-14 23:55 ` [PATCH 2/6] drm: add helper for printing to log or seq_file Rob Clark
@ 2016-10-17 6:38 ` Daniel Vetter
2016-10-17 11:59 ` Rob Clark
[not found] ` <1476489353-16261-3-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
1 sibling, 1 reply; 20+ messages in thread
From: Daniel Vetter @ 2016-10-17 6:38 UTC (permalink / raw)
To: Rob Clark; +Cc: dri-devel, freedreno
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 <robdclark@gmail.com>
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 0000000..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 <robdclark@gmail.com>
> + */
> +
> +#include <linux/seq_file.h>
> +#include <drm/drmP.h>
> +#include <drm/drm_print.h>
> +
> +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 0000000..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 <robdclark@gmail.com>
> + */
> +
> +#ifndef DRM_PRINT_H_
> +#define DRM_PRINT_H_
> +
> +#include <stdarg.h>
> +#include <linux/seq_file.h>
> +
> +/* A simple wrapper to abstract seq_file vs printk, so same logging code
> + * does not have to be duplicated.
> + */
> +struct drm_print {
> + void (*printfn)(struct drm_print *p, const char *f, va_list args);
> + void *arg;
> +};
> +
> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
> +
> +void drm_printf(struct drm_print *p, const char *f, ...);
> +
> +static inline struct drm_print drm_print_seq_file(struct seq_file *f)
> +{
> + struct drm_print p = {
> + .printfn = __drm_printfn_seq_file,
> + .arg = f,
> + };
> + return p;
> +}
> +
> +static inline struct drm_print drm_print_info(void)
> +{
> + struct drm_print p = {
> + .printfn = __drm_printfn_info,
> + };
> + return p;
> +}
> +
> +#endif /* DRM_PRINT_H_ */
> --
> 2.7.4
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 2/6] drm: add helper for printing to log or seq_file
2016-10-17 6:38 ` Daniel Vetter
@ 2016-10-17 11:59 ` Rob Clark
2016-10-17 12:30 ` Daniel Vetter
0 siblings, 1 reply; 20+ messages in thread
From: Rob Clark @ 2016-10-17 11:59 UTC (permalink / raw)
To: Daniel Vetter; +Cc: freedreno, dri-devel@lists.freedesktop.org
On Mon, Oct 17, 2016 at 2:38 AM, Daniel Vetter <daniel@ffwll.ch> 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 <robdclark@gmail.com>
>
> 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 0000000..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 <robdclark@gmail.com>
>> + */
>> +
>> +#include <linux/seq_file.h>
>> +#include <drm/drmP.h>
>> +#include <drm/drm_print.h>
>> +
>> +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 0000000..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 <robdclark@gmail.com>
>> + */
>> +
>> +#ifndef DRM_PRINT_H_
>> +#define DRM_PRINT_H_
>> +
>> +#include <stdarg.h>
>> +#include <linux/seq_file.h>
>> +
>> +/* A simple wrapper to abstract seq_file vs printk, so same logging code
>> + * does not have to be duplicated.
>> + */
>> +struct drm_print {
>> + void (*printfn)(struct drm_print *p, const char *f, va_list args);
>> + void *arg;
>> +};
>> +
>> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
>> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
>> +
>> +void drm_printf(struct drm_print *p, const char *f, ...);
>> +
>> +static inline struct drm_print drm_print_seq_file(struct seq_file *f)
>> +{
>> + struct drm_print p = {
>> + .printfn = __drm_printfn_seq_file,
>> + .arg = f,
>> + };
>> + return p;
>> +}
>> +
>> +static inline struct drm_print drm_print_info(void)
>> +{
>> + struct drm_print p = {
>> + .printfn = __drm_printfn_info,
>> + };
>> + return p;
>> +}
>> +
>> +#endif /* DRM_PRINT_H_ */
>> --
>> 2.7.4
>>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 2/6] drm: add helper for printing to log or seq_file
2016-10-17 11:59 ` Rob Clark
@ 2016-10-17 12:30 ` Daniel Vetter
2016-10-17 12:35 ` Rob Clark
0 siblings, 1 reply; 20+ messages in thread
From: Daniel Vetter @ 2016-10-17 12:30 UTC (permalink / raw)
To: Rob Clark; +Cc: dri-devel@lists.freedesktop.org, freedreno
On Mon, Oct 17, 2016 at 07:59:51AM -0400, Rob Clark wrote:
> On Mon, Oct 17, 2016 at 2:38 AM, Daniel Vetter <daniel@ffwll.ch> 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 <robdclark@gmail.com>
> >
> > 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 0000000..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 <robdclark@gmail.com>
> >> + */
> >> +
> >> +#include <linux/seq_file.h>
> >> +#include <drm/drmP.h>
> >> +#include <drm/drm_print.h>
> >> +
> >> +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 0000000..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 <robdclark@gmail.com>
> >> + */
> >> +
> >> +#ifndef DRM_PRINT_H_
> >> +#define DRM_PRINT_H_
> >> +
> >> +#include <stdarg.h>
> >> +#include <linux/seq_file.h>
> >> +
> >> +/* A simple wrapper to abstract seq_file vs printk, so same logging code
> >> + * does not have to be duplicated.
> >> + */
> >> +struct drm_print {
> >> + void (*printfn)(struct drm_print *p, const char *f, va_list args);
> >> + void *arg;
> >> +};
> >> +
> >> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
> >> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
> >> +
> >> +void drm_printf(struct drm_print *p, const char *f, ...);
> >> +
> >> +static inline struct drm_print drm_print_seq_file(struct seq_file *f)
> >> +{
> >> + struct drm_print p = {
> >> + .printfn = __drm_printfn_seq_file,
> >> + .arg = f,
> >> + };
> >> + return p;
> >> +}
> >> +
> >> +static inline struct drm_print drm_print_info(void)
> >> +{
> >> + struct drm_print p = {
> >> + .printfn = __drm_printfn_info,
> >> + };
> >> + return p;
> >> +}
> >> +
> >> +#endif /* DRM_PRINT_H_ */
> >> --
> >> 2.7.4
> >>
> >
> > --
> > Daniel Vetter
> > Software Engineer, Intel Corporation
> > http://blog.ffwll.ch
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 2/6] drm: add helper for printing to log or seq_file
2016-10-17 12:30 ` Daniel Vetter
@ 2016-10-17 12:35 ` Rob Clark
0 siblings, 0 replies; 20+ messages in thread
From: Rob Clark @ 2016-10-17 12:35 UTC (permalink / raw)
To: Daniel Vetter; +Cc: freedreno, dri-devel@lists.freedesktop.org
On Mon, Oct 17, 2016 at 8:30 AM, Daniel Vetter <daniel@ffwll.ch> 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 <daniel@ffwll.ch> 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 <robdclark@gmail.com>
>> >
>> > 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 0000000..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 <robdclark@gmail.com>
>> >> + */
>> >> +
>> >> +#include <linux/seq_file.h>
>> >> +#include <drm/drmP.h>
>> >> +#include <drm/drm_print.h>
>> >> +
>> >> +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 0000000..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 <robdclark@gmail.com>
>> >> + */
>> >> +
>> >> +#ifndef DRM_PRINT_H_
>> >> +#define DRM_PRINT_H_
>> >> +
>> >> +#include <stdarg.h>
>> >> +#include <linux/seq_file.h>
>> >> +
>> >> +/* A simple wrapper to abstract seq_file vs printk, so same logging code
>> >> + * does not have to be duplicated.
>> >> + */
>> >> +struct drm_print {
>> >> + void (*printfn)(struct drm_print *p, const char *f, va_list args);
>> >> + void *arg;
>> >> +};
>> >> +
>> >> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
>> >> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
>> >> +
>> >> +void drm_printf(struct drm_print *p, const char *f, ...);
>> >> +
>> >> +static inline struct drm_print drm_print_seq_file(struct seq_file *f)
>> >> +{
>> >> + struct drm_print p = {
>> >> + .printfn = __drm_printfn_seq_file,
>> >> + .arg = f,
>> >> + };
>> >> + return p;
>> >> +}
>> >> +
>> >> +static inline struct drm_print drm_print_info(void)
>> >> +{
>> >> + struct drm_print p = {
>> >> + .printfn = __drm_printfn_info,
>> >> + };
>> >> + return p;
>> >> +}
>> >> +
>> >> +#endif /* DRM_PRINT_H_ */
>> >> --
>> >> 2.7.4
>> >>
>> >
>> > --
>> > Daniel Vetter
>> > Software Engineer, Intel Corporation
>> > http://blog.ffwll.ch
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
[parent not found: <1476489353-16261-3-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: [PATCH 2/6] drm: add helper for printing to log or seq_file
[not found] ` <1476489353-16261-3-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2016-10-17 17:00 ` Sean Paul
2016-10-24 17:05 ` Rob Clark
0 siblings, 1 reply; 20+ messages in thread
From: Sean Paul @ 2016-10-17 17:00 UTC (permalink / raw)
To: Rob Clark
Cc: Daniel Vetter, Archit Taneja,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
Ville Syrjälä, dri-devel
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark@gmail.com> wrote:
> Sometimes it is nice not to duplicate equivalent printk() and
> seq_printf() code.
>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> 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 0000000..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 <robdclark@gmail.com>
> + */
> +
> +#include <linux/seq_file.h>
> +#include <drm/drmP.h>
> +#include <drm/drm_print.h>
> +
> +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 0000000..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 <robdclark@gmail.com>
> + */
> +
> +#ifndef DRM_PRINT_H_
> +#define DRM_PRINT_H_
> +
> +#include <stdarg.h>
> +#include <linux/seq_file.h>
> +
> +/* A simple wrapper to abstract seq_file vs printk, so same logging code
> + * does not have to be duplicated.
> + */
> +struct drm_print {
> + void (*printfn)(struct drm_print *p, const char *f, va_list args);
> + void *arg;
> +};
> +
> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
> +
> +void drm_printf(struct drm_print *p, const char *f, ...);
> +
Is it worthwhile making _dev_ variants now?
Sean
> +static inline struct drm_print drm_print_seq_file(struct seq_file *f)
> +{
> + struct drm_print p = {
> + .printfn = __drm_printfn_seq_file,
> + .arg = f,
> + };
> + return p;
> +}
> +
> +static inline struct drm_print drm_print_info(void)
> +{
> + struct drm_print p = {
> + .printfn = __drm_printfn_info,
> + };
> + return p;
> +}
> +
> +#endif /* DRM_PRINT_H_ */
> --
> 2.7.4
>
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH 2/6] drm: add helper for printing to log or seq_file
2016-10-17 17:00 ` Sean Paul
@ 2016-10-24 17:05 ` Rob Clark
0 siblings, 0 replies; 20+ messages in thread
From: Rob Clark @ 2016-10-24 17:05 UTC (permalink / raw)
To: Sean Paul; +Cc: freedreno, dri-devel
On Mon, Oct 17, 2016 at 1:00 PM, Sean Paul <seanpaul@chromium.org> wrote:
> On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark@gmail.com> wrote:
>> Sometimes it is nice not to duplicate equivalent printk() and
>> seq_printf() code.
>>
>> Signed-off-by: Rob Clark <robdclark@gmail.com>
>> ---
>> 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 0000000..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 <robdclark@gmail.com>
>> + */
>> +
>> +#include <linux/seq_file.h>
>> +#include <drm/drmP.h>
>> +#include <drm/drm_print.h>
>> +
>> +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 0000000..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 <robdclark@gmail.com>
>> + */
>> +
>> +#ifndef DRM_PRINT_H_
>> +#define DRM_PRINT_H_
>> +
>> +#include <stdarg.h>
>> +#include <linux/seq_file.h>
>> +
>> +/* A simple wrapper to abstract seq_file vs printk, so same logging code
>> + * does not have to be duplicated.
>> + */
>> +struct drm_print {
>> + void (*printfn)(struct drm_print *p, const char *f, va_list args);
>> + void *arg;
>> +};
>> +
>> +void __drm_printfn_seq_file(struct drm_print *p, const char *f, va_list args);
>> +void __drm_printfn_info(struct drm_print *p, const char *f, va_list args);
>> +
>> +void drm_printf(struct drm_print *p, const char *f, ...);
>> +
>
> Is it worthwhile making _dev_ variants now?
>
> Sean
>
>
>> +static inline struct drm_print drm_print_seq_file(struct seq_file *f)
>> +{
>> + struct drm_print p = {
>> + .printfn = __drm_printfn_seq_file,
>> + .arg = f,
>> + };
>> + return p;
>> +}
>> +
>> +static inline struct drm_print drm_print_info(void)
>> +{
>> + struct drm_print p = {
>> + .printfn = __drm_printfn_info,
>> + };
>> + return p;
>> +}
>> +
>> +#endif /* DRM_PRINT_H_ */
>> --
>> 2.7.4
>>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 3/6] drm: add helpers to go from plane state to drm_rect
[not found] ` <1476489353-16261-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-14 23:55 ` [PATCH 1/6] drm: helper macros to print composite types Rob Clark
2016-10-14 23:55 ` [PATCH 2/6] drm: add helper for printing to log or seq_file Rob Clark
@ 2016-10-14 23:55 ` Rob Clark
2016-10-17 17:00 ` Sean Paul
2016-10-14 23:55 ` [PATCH 5/6] drm/atomic: add debugfs file to dump out atomic state Rob Clark
2016-10-14 23:55 ` [PATCH 6/6] drm/msm/mdp5: add atomic_print_state support Rob Clark
4 siblings, 1 reply; 20+ messages in thread
From: Rob Clark @ 2016-10-14 23:55 UTC (permalink / raw)
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Archit Taneja, Rob Clark, Sean Paul, Daniel Vetter,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
Ville Syrjälä
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
drivers/gpu/drm/drm_simple_kms_helper.c | 14 ++------------
drivers/gpu/drm/i915/intel_atomic_plane.c | 10 ++--------
drivers/gpu/drm/mediatek/mtk_drm_plane.c | 15 ++-------------
drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 ++--------
include/drm/drm_crtc.h | 24 ++++++++++++++++++++++++
5 files changed, 32 insertions(+), 41 deletions(-)
diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
index 0db36d2..9834fc5 100644
--- a/drivers/gpu/drm/drm_simple_kms_helper.c
+++ b/drivers/gpu/drm/drm_simple_kms_helper.c
@@ -73,18 +73,8 @@ static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = {
static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
struct drm_plane_state *plane_state)
{
- struct drm_rect src = {
- .x1 = plane_state->src_x,
- .y1 = plane_state->src_y,
- .x2 = plane_state->src_x + plane_state->src_w,
- .y2 = plane_state->src_y + plane_state->src_h,
- };
- struct drm_rect dest = {
- .x1 = plane_state->crtc_x,
- .y1 = plane_state->crtc_y,
- .x2 = plane_state->crtc_x + plane_state->crtc_w,
- .y2 = plane_state->crtc_y + plane_state->crtc_h,
- };
+ struct drm_rect src = drm_plane_state_src(plane_state);
+ struct drm_rect dest = drm_plane_state_dest(plane_state);
struct drm_rect clip = { 0 };
struct drm_simple_display_pipe *pipe;
struct drm_crtc_state *crtc_state;
diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 7de7721..6682e9b 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -139,14 +139,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
* we want to keep another copy internal to our driver that we can
* clip/modify ourselves.
*/
- intel_state->src.x1 = state->src_x;
- intel_state->src.y1 = state->src_y;
- intel_state->src.x2 = state->src_x + state->src_w;
- intel_state->src.y2 = state->src_y + state->src_h;
- intel_state->dst.x1 = state->crtc_x;
- intel_state->dst.y1 = state->crtc_y;
- intel_state->dst.x2 = state->crtc_x + state->crtc_w;
- intel_state->dst.y2 = state->crtc_y + state->crtc_h;
+ intel_state->src = drm_plane_state_src(state);
+ intel_state->dst = drm_plane_state_dest(state);
/* Clip all planes to CRTC size, or 0x0 if CRTC is disabled */
intel_state->clip.x1 = 0;
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 3995765..2749e74 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -135,19 +135,8 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
struct drm_framebuffer *fb = state->fb;
struct drm_crtc_state *crtc_state;
bool visible;
- struct drm_rect dest = {
- .x1 = state->crtc_x,
- .y1 = state->crtc_y,
- .x2 = state->crtc_x + state->crtc_w,
- .y2 = state->crtc_y + state->crtc_h,
- };
- struct drm_rect src = {
- /* 16.16 fixed point */
- .x1 = state->src_x,
- .y1 = state->src_y,
- .x2 = state->src_x + state->src_w,
- .y2 = state->src_y + state->src_h,
- };
+ struct drm_rect dest = drm_plane_state_dest(state);
+ struct drm_rect src = drm_plane_state_src(state); /* 16.16 fixed point */
struct drm_rect clip = { 0, };
if (!fb)
diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 6255e5b..31384ca 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -610,14 +610,8 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
if (WARN_ON(!crtc_state))
return -EINVAL;
- src->x1 = state->src_x;
- src->y1 = state->src_y;
- src->x2 = state->src_x + state->src_w;
- src->y2 = state->src_y + state->src_h;
- dest->x1 = state->crtc_x;
- dest->y1 = state->crtc_y;
- dest->x2 = state->crtc_x + state->crtc_w;
- dest->y2 = state->crtc_y + state->crtc_h;
+ *src = drm_plane_state_src(state);
+ *dest = drm_plane_state_dest(state);
clip.x1 = 0;
clip.y1 = 0;
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index b7d67cc..856fdf8 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -36,6 +36,7 @@
#include <uapi/drm/drm_mode.h>
#include <uapi/drm/drm_fourcc.h>
#include <drm/drm_modeset_lock.h>
+#include <drm/drm_rect.h>
struct drm_device;
struct drm_mode_set;
@@ -1395,6 +1396,29 @@ struct drm_plane_state {
struct drm_atomic_state *state;
};
+static inline struct drm_rect
+drm_plane_state_src(const struct drm_plane_state *state)
+{
+ struct drm_rect src = {
+ .x1 = state->src_x,
+ .y1 = state->src_y,
+ .x2 = state->src_x + state->src_w,
+ .y2 = state->src_y + state->src_h,
+ };
+ return src;
+}
+
+static inline struct drm_rect
+drm_plane_state_dest(const struct drm_plane_state *state)
+{
+ struct drm_rect dest = {
+ .x1 = state->crtc_x,
+ .y1 = state->crtc_y,
+ .x2 = state->crtc_x + state->crtc_w,
+ .y2 = state->crtc_y + state->crtc_h,
+ };
+ return dest;
+}
/**
* struct drm_plane_funcs - driver plane control functions
--
2.7.4
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 3/6] drm: add helpers to go from plane state to drm_rect
2016-10-14 23:55 ` [PATCH 3/6] drm: add helpers to go from plane state to drm_rect Rob Clark
@ 2016-10-17 17:00 ` Sean Paul
0 siblings, 0 replies; 20+ messages in thread
From: Sean Paul @ 2016-10-17 17:00 UTC (permalink / raw)
To: Rob Clark; +Cc: freedreno, dri-devel
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark@gmail.com> wrote:
Reviewed-by: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> drivers/gpu/drm/drm_simple_kms_helper.c | 14 ++------------
> drivers/gpu/drm/i915/intel_atomic_plane.c | 10 ++--------
> drivers/gpu/drm/mediatek/mtk_drm_plane.c | 15 ++-------------
> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 ++--------
> include/drm/drm_crtc.h | 24 ++++++++++++++++++++++++
> 5 files changed, 32 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
> index 0db36d2..9834fc5 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -73,18 +73,8 @@ static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = {
> static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
> struct drm_plane_state *plane_state)
> {
> - struct drm_rect src = {
> - .x1 = plane_state->src_x,
> - .y1 = plane_state->src_y,
> - .x2 = plane_state->src_x + plane_state->src_w,
> - .y2 = plane_state->src_y + plane_state->src_h,
> - };
> - struct drm_rect dest = {
> - .x1 = plane_state->crtc_x,
> - .y1 = plane_state->crtc_y,
> - .x2 = plane_state->crtc_x + plane_state->crtc_w,
> - .y2 = plane_state->crtc_y + plane_state->crtc_h,
> - };
> + struct drm_rect src = drm_plane_state_src(plane_state);
> + struct drm_rect dest = drm_plane_state_dest(plane_state);
> struct drm_rect clip = { 0 };
> struct drm_simple_display_pipe *pipe;
> struct drm_crtc_state *crtc_state;
> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
> index 7de7721..6682e9b 100644
> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
> @@ -139,14 +139,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
> * we want to keep another copy internal to our driver that we can
> * clip/modify ourselves.
> */
> - intel_state->src.x1 = state->src_x;
> - intel_state->src.y1 = state->src_y;
> - intel_state->src.x2 = state->src_x + state->src_w;
> - intel_state->src.y2 = state->src_y + state->src_h;
> - intel_state->dst.x1 = state->crtc_x;
> - intel_state->dst.y1 = state->crtc_y;
> - intel_state->dst.x2 = state->crtc_x + state->crtc_w;
> - intel_state->dst.y2 = state->crtc_y + state->crtc_h;
> + intel_state->src = drm_plane_state_src(state);
> + intel_state->dst = drm_plane_state_dest(state);
>
> /* Clip all planes to CRTC size, or 0x0 if CRTC is disabled */
> intel_state->clip.x1 = 0;
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 3995765..2749e74 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -135,19 +135,8 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
> struct drm_framebuffer *fb = state->fb;
> struct drm_crtc_state *crtc_state;
> bool visible;
> - struct drm_rect dest = {
> - .x1 = state->crtc_x,
> - .y1 = state->crtc_y,
> - .x2 = state->crtc_x + state->crtc_w,
> - .y2 = state->crtc_y + state->crtc_h,
> - };
> - struct drm_rect src = {
> - /* 16.16 fixed point */
> - .x1 = state->src_x,
> - .y1 = state->src_y,
> - .x2 = state->src_x + state->src_w,
> - .y2 = state->src_y + state->src_h,
> - };
> + struct drm_rect dest = drm_plane_state_dest(state);
> + struct drm_rect src = drm_plane_state_src(state); /* 16.16 fixed point */
> struct drm_rect clip = { 0, };
>
> if (!fb)
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 6255e5b..31384ca 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -610,14 +610,8 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
> if (WARN_ON(!crtc_state))
> return -EINVAL;
>
> - src->x1 = state->src_x;
> - src->y1 = state->src_y;
> - src->x2 = state->src_x + state->src_w;
> - src->y2 = state->src_y + state->src_h;
> - dest->x1 = state->crtc_x;
> - dest->y1 = state->crtc_y;
> - dest->x2 = state->crtc_x + state->crtc_w;
> - dest->y2 = state->crtc_y + state->crtc_h;
> + *src = drm_plane_state_src(state);
> + *dest = drm_plane_state_dest(state);
>
> clip.x1 = 0;
> clip.y1 = 0;
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index b7d67cc..856fdf8 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -36,6 +36,7 @@
> #include <uapi/drm/drm_mode.h>
> #include <uapi/drm/drm_fourcc.h>
> #include <drm/drm_modeset_lock.h>
> +#include <drm/drm_rect.h>
>
> struct drm_device;
> struct drm_mode_set;
> @@ -1395,6 +1396,29 @@ struct drm_plane_state {
> struct drm_atomic_state *state;
> };
>
> +static inline struct drm_rect
> +drm_plane_state_src(const struct drm_plane_state *state)
> +{
> + struct drm_rect src = {
> + .x1 = state->src_x,
> + .y1 = state->src_y,
> + .x2 = state->src_x + state->src_w,
> + .y2 = state->src_y + state->src_h,
> + };
> + return src;
> +}
> +
> +static inline struct drm_rect
> +drm_plane_state_dest(const struct drm_plane_state *state)
> +{
> + struct drm_rect dest = {
> + .x1 = state->crtc_x,
> + .y1 = state->crtc_y,
> + .x2 = state->crtc_x + state->crtc_w,
> + .y2 = state->crtc_y + state->crtc_h,
> + };
> + return dest;
> +}
>
> /**
> * struct drm_plane_funcs - driver plane control functions
> --
> 2.7.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 5/6] drm/atomic: add debugfs file to dump out atomic state
[not found] ` <1476489353-16261-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (2 preceding siblings ...)
2016-10-14 23:55 ` [PATCH 3/6] drm: add helpers to go from plane state to drm_rect Rob Clark
@ 2016-10-14 23:55 ` Rob Clark
2016-10-17 17:00 ` Sean Paul
2016-10-14 23:55 ` [PATCH 6/6] drm/msm/mdp5: add atomic_print_state support Rob Clark
4 siblings, 1 reply; 20+ messages in thread
From: Rob Clark @ 2016-10-14 23:55 UTC (permalink / raw)
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Archit Taneja, Rob Clark, Sean Paul, Daniel Vetter,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
Ville Syrjälä
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
drivers/gpu/drm/drm_atomic.c | 40 ++++++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/drm_debugfs.c | 9 +++++++++
include/drm/drm_atomic.h | 4 ++++
3 files changed, 53 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 3cc3cb5..117d429 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1565,6 +1565,46 @@ static void drm_atomic_print_state(const struct drm_atomic_state *state)
drm_atomic_connector_print_state(&p, connector_state);
}
+#ifdef CONFIG_DEBUG_FS
+static int drm_state_info(struct seq_file *m, void *data)
+{
+ struct drm_info_node *node = (struct drm_info_node *) m->private;
+ struct drm_device *dev = node->minor->dev;
+ struct drm_mode_config *config = &dev->mode_config;
+ struct drm_plane *plane;
+ struct drm_crtc *crtc;
+ struct drm_connector *connector;
+ struct drm_print p = drm_print_seq_file(m);
+
+ drm_modeset_lock_all(dev);
+
+ list_for_each_entry(plane, &config->plane_list, head)
+ drm_atomic_plane_print_state(&p, plane->state);
+
+ list_for_each_entry(crtc, &config->crtc_list, head)
+ drm_atomic_crtc_print_state(&p, crtc->state);
+
+ list_for_each_entry(connector, &config->connector_list, head)
+ drm_atomic_connector_print_state(&p, connector->state);
+
+ drm_modeset_unlock_all(dev);
+
+ return 0;
+}
+
+/* any use in debugfs files to dump individual planes/crtc/etc? */
+static const struct drm_info_list drm_atomic_debugfs_list[] = {
+ {"state", drm_state_info, 0},
+};
+
+int drm_atomic_debugfs_init(struct drm_minor *minor)
+{
+ return drm_debugfs_create_files(drm_atomic_debugfs_list,
+ ARRAY_SIZE(drm_atomic_debugfs_list),
+ minor->debugfs_root, minor);
+}
+#endif
+
/*
* The big monstor ioctl
*/
diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
index fa10cef..d8945a9 100644
--- a/drivers/gpu/drm/drm_debugfs.c
+++ b/drivers/gpu/drm/drm_debugfs.c
@@ -36,6 +36,7 @@
#include <linux/export.h>
#include <drm/drmP.h>
#include <drm/drm_edid.h>
+#include <drm/drm_atomic.h>
#include "drm_internal.h"
#if defined(CONFIG_DEBUG_FS)
@@ -163,6 +164,14 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
return ret;
}
+ if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
+ ret = drm_atomic_debugfs_init(minor);
+ if (ret) {
+ DRM_ERROR("Failed to create atomic debugfs files\n");
+ return ret;
+ }
+ }
+
if (dev->driver->debugfs_init) {
ret = dev->driver->debugfs_init(minor);
if (ret) {
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 856a9c8..68422f6 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -181,6 +181,10 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
int __must_check drm_atomic_commit(struct drm_atomic_state *state);
int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
+#ifdef CONFIG_DEBUG_FS
+int drm_atomic_debugfs_init(struct drm_minor *minor);
+#endif
+
#define for_each_connector_in_state(__state, connector, connector_state, __i) \
for ((__i) = 0; \
(__i) < (__state)->num_connector && \
--
2.7.4
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH 5/6] drm/atomic: add debugfs file to dump out atomic state
2016-10-14 23:55 ` [PATCH 5/6] drm/atomic: add debugfs file to dump out atomic state Rob Clark
@ 2016-10-17 17:00 ` Sean Paul
0 siblings, 0 replies; 20+ messages in thread
From: Sean Paul @ 2016-10-17 17:00 UTC (permalink / raw)
To: Rob Clark; +Cc: freedreno, dri-devel
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark@gmail.com> wrote:
A short commit message detailing the change and info printed would
probably be helpful.
Aside from that,
Reviewed-by: Sean Paul <seanpaul@chromium.org>
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
> drivers/gpu/drm/drm_atomic.c | 40 ++++++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/drm_debugfs.c | 9 +++++++++
> include/drm/drm_atomic.h | 4 ++++
> 3 files changed, 53 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
> index 3cc3cb5..117d429 100644
> --- a/drivers/gpu/drm/drm_atomic.c
> +++ b/drivers/gpu/drm/drm_atomic.c
> @@ -1565,6 +1565,46 @@ static void drm_atomic_print_state(const struct drm_atomic_state *state)
> drm_atomic_connector_print_state(&p, connector_state);
> }
>
> +#ifdef CONFIG_DEBUG_FS
> +static int drm_state_info(struct seq_file *m, void *data)
> +{
> + struct drm_info_node *node = (struct drm_info_node *) m->private;
> + struct drm_device *dev = node->minor->dev;
> + struct drm_mode_config *config = &dev->mode_config;
> + struct drm_plane *plane;
> + struct drm_crtc *crtc;
> + struct drm_connector *connector;
> + struct drm_print p = drm_print_seq_file(m);
> +
> + drm_modeset_lock_all(dev);
> +
> + list_for_each_entry(plane, &config->plane_list, head)
> + drm_atomic_plane_print_state(&p, plane->state);
> +
> + list_for_each_entry(crtc, &config->crtc_list, head)
> + drm_atomic_crtc_print_state(&p, crtc->state);
> +
> + list_for_each_entry(connector, &config->connector_list, head)
> + drm_atomic_connector_print_state(&p, connector->state);
> +
> + drm_modeset_unlock_all(dev);
> +
> + return 0;
> +}
> +
> +/* any use in debugfs files to dump individual planes/crtc/etc? */
> +static const struct drm_info_list drm_atomic_debugfs_list[] = {
> + {"state", drm_state_info, 0},
> +};
> +
> +int drm_atomic_debugfs_init(struct drm_minor *minor)
> +{
> + return drm_debugfs_create_files(drm_atomic_debugfs_list,
> + ARRAY_SIZE(drm_atomic_debugfs_list),
> + minor->debugfs_root, minor);
> +}
> +#endif
> +
> /*
> * The big monstor ioctl
> */
> diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c
> index fa10cef..d8945a9 100644
> --- a/drivers/gpu/drm/drm_debugfs.c
> +++ b/drivers/gpu/drm/drm_debugfs.c
> @@ -36,6 +36,7 @@
> #include <linux/export.h>
> #include <drm/drmP.h>
> #include <drm/drm_edid.h>
> +#include <drm/drm_atomic.h>
> #include "drm_internal.h"
>
> #if defined(CONFIG_DEBUG_FS)
> @@ -163,6 +164,14 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id,
> return ret;
> }
>
> + if (drm_core_check_feature(dev, DRIVER_ATOMIC)) {
> + ret = drm_atomic_debugfs_init(minor);
> + if (ret) {
> + DRM_ERROR("Failed to create atomic debugfs files\n");
> + return ret;
> + }
> + }
> +
> if (dev->driver->debugfs_init) {
> ret = dev->driver->debugfs_init(minor);
> if (ret) {
> diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
> index 856a9c8..68422f6 100644
> --- a/include/drm/drm_atomic.h
> +++ b/include/drm/drm_atomic.h
> @@ -181,6 +181,10 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
> int __must_check drm_atomic_commit(struct drm_atomic_state *state);
> int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
>
> +#ifdef CONFIG_DEBUG_FS
> +int drm_atomic_debugfs_init(struct drm_minor *minor);
> +#endif
> +
> #define for_each_connector_in_state(__state, connector, connector_state, __i) \
> for ((__i) = 0; \
> (__i) < (__state)->num_connector && \
> --
> 2.7.4
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 6/6] drm/msm/mdp5: add atomic_print_state support
[not found] ` <1476489353-16261-1-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
` (3 preceding siblings ...)
2016-10-14 23:55 ` [PATCH 5/6] drm/atomic: add debugfs file to dump out atomic state Rob Clark
@ 2016-10-14 23:55 ` Rob Clark
[not found] ` <1476489353-16261-7-git-send-email-robdclark-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
4 siblings, 1 reply; 20+ messages in thread
From: Rob Clark @ 2016-10-14 23:55 UTC (permalink / raw)
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
Cc: Archit Taneja, Rob Clark, Sean Paul, Daniel Vetter,
freedreno-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
Ville Syrjälä
We subclass drm_plane_state, so add mdp5_plane_atomic_print_state() to
dump out our own driver specific plane state.
Signed-off-by: Rob Clark <robdclark@gmail.com>
---
drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h | 12 ++++++++++++
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 18 +++++++++++++++++-
2 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
index e4b3fb3..3502711 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_kms.h
@@ -120,6 +120,18 @@ static inline u32 mdp5_read(struct mdp5_kms *mdp5_kms, u32 reg)
return msm_readl(mdp5_kms->mmio + reg);
}
+static inline const char *stage2name(enum mdp_mixer_stage_id stage)
+{
+ static const char *names[] = {
+#define NAME(n) [n] = #n
+ NAME(STAGE_UNUSED), NAME(STAGE_BASE),
+ NAME(STAGE0), NAME(STAGE1), NAME(STAGE2),
+ NAME(STAGE3), NAME(STAGE4), NAME(STAGE6),
+#undef NAME
+ };
+ return names[stage];
+}
+
static inline const char *pipe2name(enum mdp5_pipe pipe)
{
static const char *names[] = {
diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index b6f1fc66..9f99b4d 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -16,6 +16,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <drm/drm_print.h>
#include "mdp5_kms.h"
struct mdp5_plane {
@@ -187,6 +188,20 @@ done:
#undef SET_PROPERTY
}
+static void
+mdp5_plane_atomic_print_state(struct drm_print *p,
+ const struct drm_plane_state *state)
+{
+ struct mdp5_plane_state *pstate = to_mdp5_plane_state(state);
+
+ drm_printf(p, "\tpremultiplied=%u\n", pstate->premultiplied);
+ drm_printf(p, "\tzpos=%u\n", pstate->zpos);
+ drm_printf(p, "\talpha=%u\n", pstate->alpha);
+ drm_printf(p, "\tstage=%s\n", stage2name(pstate->stage));
+ drm_printf(p, "\tmode_changed=%u\n", pstate->mode_changed);
+ drm_printf(p, "\tpending=%u\n", pstate->pending);
+}
+
static void mdp5_plane_reset(struct drm_plane *plane)
{
struct mdp5_plane_state *mdp5_state;
@@ -250,6 +265,7 @@ static const struct drm_plane_funcs mdp5_plane_funcs = {
.reset = mdp5_plane_reset,
.atomic_duplicate_state = mdp5_plane_duplicate_state,
.atomic_destroy_state = mdp5_plane_destroy_state,
+ .atomic_print_state = mdp5_plane_atomic_print_state,
};
static int mdp5_plane_prepare_fb(struct drm_plane *plane,
@@ -907,7 +923,7 @@ struct drm_plane *mdp5_plane_init(struct drm_device *dev,
type = private_plane ? DRM_PLANE_TYPE_PRIMARY : DRM_PLANE_TYPE_OVERLAY;
ret = drm_universal_plane_init(dev, plane, 0xff, &mdp5_plane_funcs,
mdp5_plane->formats, mdp5_plane->nformats,
- type, NULL);
+ type, "%s", mdp5_plane->name);
if (ret)
goto fail;
--
2.7.4
_______________________________________________
Freedreno mailing list
Freedreno@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/freedreno
^ permalink raw reply related [flat|nested] 20+ messages in thread