Skip to contentSkip to conversation

drm/i915: shorten i915_next_seqno debugfs output

PATCH In review Mika Kuoppala 3 participants 9 messages Apr 11, 2013 – Apr 16, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: shorten i915_next_seqno debugfs output

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes. Fix this by returning only the value and nothing else.

---
 drivers/gpu/drm/i915/i915_debugfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -1
index be88532..afe9421 100644
@@ -901,7 +901,7 @@ i915_next_seqno_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
 			i915_next_seqno_get, i915_next_seqno_set,
-			"next_seqno :  0x%llx\n");
+			"0x%llx\n");
 
 static int i915_rstdby_delays(struct seq_file *m, void *unused)
 {
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 6 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

Quoted 7 lines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes. Fix this by returning only the value and nothing else.

Oh! Thanks for catching that. What a weird limitation.

What about max freq, min freq, and wedged? Do those run the risk of truncation too?

-Kees

Quoted 18 lines
---
 drivers/gpu/drm/i915/i915_debugfs.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +1 -2
index be88532..afe9421 100644
@@ -901,7 +901,7 @@ i915_next_seqno_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
                        i915_next_seqno_get, i915_next_seqno_set,
-                       "next_seqno :  0x%llx\n");
+                       "0x%llx\n");
 
 static int i915_rstdby_delays(struct seq_file *m, void *unused)
 {
--
Quoted 2 lines

1.7.9.5

--
Kees Cook
Chrome OS Security

#2 lore raw
Quoted 13 lines · Kees Cook
Quoted 11 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes. Fix this by returning only the value and nothing else.

Quoted 7 lines
Quoted 2 lines

Oh! Thanks for catching that. What a weird limitation.

What about max freq, min freq, and wedged? Do those run the risk of truncation too?

max and min freq should be safe, and wedged too on 32bit platforms. But if gpu is declared wedged on host with 64bit atomic_t, it will crop the output.

-Mika

#3 lore raw
Quoted 18 lines · Mika Kuoppala
Quoted 16 lines · Kees Cook
Quoted 13 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes. Fix this by returning only the value and nothing else.

Quoted 8 lines
Quoted 4 lines

Oh! Thanks for catching that. What a weird limitation.

What about max freq, min freq, and wedged? Do those run the risk of truncation too?

max and min freq should be safe, and wedged too on 32bit platforms. But if gpu is declared wedged on host with 64bit atomic_t, it will crop the output.

Should we consider proposing an increase in the size of the simple attr buffer? It seems silly to provide an arbitrary format string but leave the buffer so small.

-Kees

--
Kees Cook
Chrome OS Security

#4 lore raw
Quoted 25 lines · Kees Cook
Quoted 23 lines · Mika Kuoppala
Quoted 20 lines · Kees Cook
Quoted 6 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

Quoted 7 lines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes. Fix this by returning only the value and nothing else.

Oh! Thanks for catching that. What a weird limitation.

What about max freq, min freq, and wedged? Do those run the risk of truncation too?

Quoted 7 lines
Quoted 3 lines

max and min freq should be safe, and wedged too on 32bit platforms. But if gpu is declared wedged on host with 64bit atomic_t, it will crop the output.

Should we consider proposing an increase in the size of the simple attr buffer? It seems silly to provide an arbitrary format string but leave the buffer so small.

That or dynamic allocation to attr->get_buf. But that would need extra pass with snprintf and I don't know if that qualifies as 'simple' anymore.

I have posted a patch which fixes all i915 debugfs simple attributes to fit into the simple_attr by removing everything except the fmt to value. I didn't find any testcases which would rely on preample being there.

--Mika

Acked-by
#5 lore raw
Quoted 35 lines · Mika Kuoppala
Quoted 25 lines · Kees Cook
Quoted 23 lines · Mika Kuoppala
Quoted 20 lines · Kees Cook
Quoted 6 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

Quoted 7 lines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes. Fix this by returning only the value and nothing else.

Oh! Thanks for catching that. What a weird limitation.

What about max freq, min freq, and wedged? Do those run the risk of truncation too?

Quoted 7 lines
Quoted 3 lines

max and min freq should be safe, and wedged too on 32bit platforms. But if gpu is declared wedged on host with 64bit atomic_t, it will crop the output.

Should we consider proposing an increase in the size of the simple attr buffer? It seems silly to provide an arbitrary format string but leave the buffer so small.

Quoted 8 lines

That or dynamic allocation to attr->get_buf. But that would need extra pass with snprintf and I don't know if that qualifies as 'simple' anymore.

I have posted a patch which fixes all i915 debugfs simple attributes to fit into the simple_attr by removing everything except the fmt to value. I didn't find any testcases which would rely on preample being there.

That works too. :) If you want, consider them:

:)

Thanks!

-Kees

--
Kees Cook
Chrome OS Security

#6 lore raw

PATCH 1/1 drm/i915: shorten debugfs output simple attributes

In reply to Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes.

Fix is to strip out preamples on all simple attributes that have one.

v2: Fix all simple attributes (Daniel Vetter)

---
 drivers/gpu/drm/i915/i915_debugfs.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
index be88532..7e60bb5 100644
@@ -901,7 +901,7 @@ i915_next_seqno_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_next_seqno_fops,
 			i915_next_seqno_get, i915_next_seqno_set,
-			"next_seqno :  0x%llx\n");
+			"0x%llx\n");
 
 static int i915_rstdby_delays(struct seq_file *m, void *unused)
 {
@@ -1687,7 +1687,7 @@ i915_wedged_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_wedged_fops,
 			i915_wedged_get, i915_wedged_set,
-			"wedged :  %llu\n");
+			"%llu\n");
 
 static int
 i915_ring_stop_get(void *data, u64 *val)
@@ -1841,7 +1841,7 @@ i915_max_freq_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_max_freq_fops,
 			i915_max_freq_get, i915_max_freq_set,
-			"max freq: %llu\n");
+			"%llu\n");
 
 static int
 i915_min_freq_get(void *data, u64 *val)
@@ -1892,7 +1892,7 @@ i915_min_freq_set(void *data, u64 val)
 
 DEFINE_SIMPLE_ATTRIBUTE(i915_min_freq_fops,
 			i915_min_freq_get, i915_min_freq_set,
-			"min freq: %llu\n");
+			"%llu\n");
 
 static int
 i915_cache_sharing_get(void *data, u64 *val)
Signature · 1 line
1.7.9.5
Acked-by on v1 1/1
#7 lore raw

Re: [PATCH] drm/i915: shorten debugfs output simple attributes

Quoted 10 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes.

Quoted 7 lines

Fix is to strip out preamples on all simple attributes that have one.

v2: Fix all simple attributes (Daniel Vetter)

Signature · 2 lines
Kees Cook
Chrome OS Security
#8 lore raw

Re: [PATCH] drm/i915: shorten debugfs output simple attributes

Quoted 15 lines · Kees Cook
Quoted 13 lines · Mika Kuoppala

commit 647416f9eefe7699754b01b9fc82758fde83248c

Author: Kees Cook <[email protected]>
Date:   Sun Mar 10 14:10:06 2013 -0700

drm/i915: use simple attribute in debugfs routines

made i915_next_seqno debugfs entry to crop it's output if returned value was large enough. Using simple_attr will limit the output to 24 bytes.

Fix is to strip out preamples on all simple attributes that have one.

Quoted 6 lines
Quoted 4 lines

v2: Fix all simple attributes (Daniel Vetter)

Queued for -next, thanks for the patch.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch