Re: [PATCH v3 3/6] gpu: host1x: Improve debug disassembly formatting

2017-09-28 Thread Joe Perches
On Thu, 2017-09-28 at 15:50 +0300, Mikko Perttunen wrote:
> The host1x driver prints out "disassembly" dumps of the command FIFO
> and gather contents on submission timeouts. However, the output has
> been quite difficult to read with unnecessary newlines and occasional
> missing parentheses.

I think it would be cleaner/simpler to change
this by adding a line initiator with just a
KERN_ at the few places that actually
start a newline.

Then change the write_to_seqfile to skip any
output that starts with KERN_

> diff --git a/drivers/gpu/host1x/hw/debug_hw_1x01.c 
> b/drivers/gpu/host1x/hw/debug_hw_1x01.c
[]
> @@ -111,11 +111,11 @@ static void host1x_debug_show_channel_fifo(struct 
> host1x *host,
>   val = host1x_sync_readl(host, HOST1X_SYNC_CFPEEK_READ);
>  
>   if (!data_count) {
> - host1x_debug_output(o, "%08x:", val);
> + host1x_debug_output(o, "%08x: ", val);

ie: change this and the other start of lines to prepend KERN_INFO

host_x_debug_putput(o, KERN_INFO "%08x ", val);

>   data_count = show_channel_command(o, val);
>   } else {
> - host1x_debug_output(o, "%08x%s", val,
> - data_count > 0 ? ", " : "])\n");

And don't change all the other continuation lines

And change the write_to_ functions to

static inline void write_to_seqfile(void *ctx, const char *str, size_t len)
{
const char *output = printk_skip_level(str);

seq_write(ctx, output, len - (str - output)); 
}

static inline void write_to_printk(void *ctx, const char *str, size_t len)
{
const char *output = printk_skip_level(str);

if (output == str)
pr_cont("%s", str);
else
printk("s", str);
}



[PATCH v3 3/6] gpu: host1x: Improve debug disassembly formatting

2017-09-28 Thread Mikko Perttunen
The host1x driver prints out "disassembly" dumps of the command FIFO
and gather contents on submission timeouts. However, the output has
been quite difficult to read with unnecessary newlines and occasional
missing parentheses.

Fix these problems by using pr_cont to remove unnecessary newlines
and by fixing other small issues.

Signed-off-by: Mikko Perttunen 
Reviewed-by: Dmitry Osipenko 
Tested-by: Dmitry Osipenko 
---
 drivers/gpu/host1x/debug.c| 14 ++-
 drivers/gpu/host1x/debug.h| 14 ---
 drivers/gpu/host1x/hw/debug_hw.c  | 46 ++-
 drivers/gpu/host1x/hw/debug_hw_1x01.c |  8 +++---
 drivers/gpu/host1x/hw/debug_hw_1x06.c |  9 ---
 5 files changed, 61 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c
index 2aae0e63214c..dc77ec452ffc 100644
--- a/drivers/gpu/host1x/debug.c
+++ b/drivers/gpu/host1x/debug.c
@@ -40,7 +40,19 @@ void host1x_debug_output(struct output *o, const char *fmt, 
...)
len = vsnprintf(o->buf, sizeof(o->buf), fmt, args);
va_end(args);
 
-   o->fn(o->ctx, o->buf, len);
+   o->fn(o->ctx, o->buf, len, false);
+}
+
+void host1x_debug_cont(struct output *o, const char *fmt, ...)
+{
+   va_list args;
+   int len;
+
+   va_start(args, fmt);
+   len = vsnprintf(o->buf, sizeof(o->buf), fmt, args);
+   va_end(args);
+
+   o->fn(o->ctx, o->buf, len, true);
 }
 
 static int show_channel(struct host1x_channel *ch, void *data, bool show_fifo)
diff --git a/drivers/gpu/host1x/debug.h b/drivers/gpu/host1x/debug.h
index 4595b2e0799f..990cce47e737 100644
--- a/drivers/gpu/host1x/debug.h
+++ b/drivers/gpu/host1x/debug.h
@@ -24,22 +24,28 @@
 struct host1x;
 
 struct output {
-   void (*fn)(void *ctx, const char *str, size_t len);
+   void (*fn)(void *ctx, const char *str, size_t len, bool cont);
void *ctx;
char buf[256];
 };
 
-static inline void write_to_seqfile(void *ctx, const char *str, size_t len)
+static inline void write_to_seqfile(void *ctx, const char *str, size_t len,
+   bool cont)
 {
seq_write((struct seq_file *)ctx, str, len);
 }
 
-static inline void write_to_printk(void *ctx, const char *str, size_t len)
+static inline void write_to_printk(void *ctx, const char *str, size_t len,
+  bool cont)
 {
-   pr_info("%s", str);
+   if (cont)
+   pr_cont("%s", str);
+   else
+   pr_info("%s", str);
 }
 
 void __printf(2, 3) host1x_debug_output(struct output *o, const char *fmt, 
...);
+void __printf(2, 3) host1x_debug_cont(struct output *o, const char *fmt, ...);
 
 extern unsigned int host1x_debug_trace_cmdbuf;
 
diff --git a/drivers/gpu/host1x/hw/debug_hw.c b/drivers/gpu/host1x/hw/debug_hw.c
index 770d92e62d69..1e67667e308c 100644
--- a/drivers/gpu/host1x/hw/debug_hw.c
+++ b/drivers/gpu/host1x/hw/debug_hw.c
@@ -40,48 +40,59 @@ enum {
 
 static unsigned int show_channel_command(struct output *o, u32 val)
 {
-   unsigned int mask, subop;
+   unsigned int mask, subop, num;
 
switch (val >> 28) {
case HOST1X_OPCODE_SETCLASS:
mask = val & 0x3f;
if (mask) {
-   host1x_debug_output(o, "SETCL(class=%03x, offset=%03x, 
mask=%02x, [",
+   host1x_debug_cont(o, "SETCL(class=%03x, offset=%03x, 
mask=%02x, [",
val >> 6 & 0x3ff,
val >> 16 & 0xfff, mask);
return hweight8(mask);
}
 
-   host1x_debug_output(o, "SETCL(class=%03x)\n", val >> 6 & 0x3ff);
+   host1x_debug_cont(o, "SETCL(class=%03x)\n", val >> 6 & 0x3ff);
return 0;
 
case HOST1X_OPCODE_INCR:
-   host1x_debug_output(o, "INCR(offset=%03x, [",
+   num = val & 0x;
+   host1x_debug_cont(o, "INCR(offset=%03x, [",
val >> 16 & 0xfff);
-   return val & 0x;
+   if (!num)
+   host1x_debug_cont(o, "])\n");
+
+   return num;
 
case HOST1X_OPCODE_NONINCR:
-   host1x_debug_output(o, "NONINCR(offset=%03x, [",
+   num = val & 0x;
+   host1x_debug_cont(o, "NONINCR(offset=%03x, [",
val >> 16 & 0xfff);
-   return val & 0x;
+   if (!num)
+   host1x_debug_cont(o, "])\n");
+
+   return num;
 
case HOST1X_OPCODE_MASK:
mask = val & 0x;
-   host1x_debug_output(o, "MASK(offset=%03x, mask=%03x, [",
+   host1x_debug_cont(o, "MASK(offset=%03x, mask=%03x, [",
val >> 16 & 0xfff, mask);
+   if (!mask)
+   host1x_debug_cont(o,