1 From 2807aef659483de0d569b2c01e2b68be046496d3 Mon Sep 17 00:00:00 2001
2 From: Luke Diamand <luked@broadcom.com>
3 Date: Tue, 31 Dec 2013 23:07:36 +0000
4 Subject: [PATCH 148/174] bcm2708_fb: report number of dma copies
6 Add a counter (exported via debugfs) reporting the
7 number of dma copies that the framebuffer driver
8 has done, in order to help evaluate different
9 optimization strategies.
11 Signed-off-by: Luke Diamand <luked@broadcom.com>
13 drivers/video/bcm2708_fb.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 55 insertions(+)
16 --- a/drivers/video/bcm2708_fb.c
17 +++ b/drivers/video/bcm2708_fb.c
19 #include <linux/clk.h>
20 #include <linux/printk.h>
21 #include <linux/console.h>
22 +#include <linux/debugfs.h>
25 #include <mach/platform.h>
26 @@ -58,6 +59,12 @@ struct fbinfo_s {
30 +struct bcm2708_fb_stats {
31 + struct debugfs_regset32 regset;
38 struct platform_device *dev;
39 @@ -69,10 +76,51 @@ struct bcm2708_fb {
40 void __iomem *dma_chan_base;
41 void *cb_base; /* DMA control blocks */
43 + struct dentry *debugfs_dir;
44 + struct bcm2708_fb_stats stats;
47 #define to_bcm2708(info) container_of(info, struct bcm2708_fb, fb)
49 +static void bcm2708_fb_debugfs_deinit(struct bcm2708_fb *fb)
51 + debugfs_remove_recursive(fb->debugfs_dir);
52 + fb->debugfs_dir = NULL;
55 +static int bcm2708_fb_debugfs_init(struct bcm2708_fb *fb)
57 + static struct debugfs_reg32 stats_registers[] = {
60 + offsetof(struct bcm2708_fb_stats, dma_copies)
64 + fb->debugfs_dir = debugfs_create_dir(DRIVER_NAME, NULL);
65 + if (!fb->debugfs_dir) {
66 + pr_warn("%s: could not create debugfs entry\n",
71 + fb->stats.regset.regs = stats_registers;
72 + fb->stats.regset.nregs = ARRAY_SIZE(stats_registers);
73 + fb->stats.regset.base = &fb->stats;
75 + if (!debugfs_create_regset32(
76 + "stats", 0444, fb->debugfs_dir, &fb->stats.regset)) {
77 + pr_warn("%s: could not create statistics registers\n",
84 + bcm2708_fb_debugfs_deinit(fb);
88 static int bcm2708_fb_set_bitfields(struct fb_var_screeninfo *var)
91 @@ -443,8 +491,10 @@ static void bcm2708_fb_copyarea(struct f
92 /* end of dma control blocks chain */
96 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
97 bcm_dma_wait_idle(fb->dma_chan_base);
98 + fb->stats.dma_copies++;
101 static void bcm2708_fb_imageblit(struct fb_info *info,
102 @@ -552,6 +602,9 @@ static int bcm2708_fb_probe(struct platf
104 memset(fb, 0, sizeof(struct bcm2708_fb));
107 + bcm2708_fb_debugfs_init(fb);
109 fb->cb_base = dma_alloc_writecombine(&dev->dev, SZ_64K,
110 &fb->cb_handle, GFP_KERNEL);
112 @@ -607,6 +660,8 @@ static int bcm2708_fb_remove(struct plat
114 dma_free_coherent(NULL, PAGE_ALIGN(sizeof(*fb->info)), (void *)fb->info,
116 + bcm2708_fb_debugfs_deinit(fb);