brcm2708: update against latest rpi-3.10.y branch
[openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0148-bcm2708_fb-report-number-of-dma-copies.patch
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
5
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.
10
11 Signed-off-by: Luke Diamand <luked@broadcom.com>
12 ---
13  drivers/video/bcm2708_fb.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++
14  1 file changed, 55 insertions(+)
15
16 --- a/drivers/video/bcm2708_fb.c
17 +++ b/drivers/video/bcm2708_fb.c
18 @@ -27,6 +27,7 @@
19  #include <linux/clk.h>
20  #include <linux/printk.h>
21  #include <linux/console.h>
22 +#include <linux/debugfs.h>
23  
24  #include <mach/dma.h>
25  #include <mach/platform.h>
26 @@ -58,6 +59,12 @@ struct fbinfo_s {
27         u16 cmap[256];
28  };
29  
30 +struct bcm2708_fb_stats {
31 +       struct debugfs_regset32 regset;
32 +       u32 dma_copies;
33 +       u32 dma_irqs;
34 +};
35 +
36  struct bcm2708_fb {
37         struct fb_info fb;
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 */
42         dma_addr_t cb_handle;
43 +       struct dentry *debugfs_dir;
44 +       struct bcm2708_fb_stats stats;
45  };
46  
47  #define to_bcm2708(info)       container_of(info, struct bcm2708_fb, fb)
48  
49 +static void bcm2708_fb_debugfs_deinit(struct bcm2708_fb *fb)
50 +{
51 +       debugfs_remove_recursive(fb->debugfs_dir);
52 +       fb->debugfs_dir = NULL;
53 +}
54 +
55 +static int bcm2708_fb_debugfs_init(struct bcm2708_fb *fb)
56 +{
57 +       static struct debugfs_reg32 stats_registers[] = {
58 +               {
59 +                       "dma_copies",
60 +                       offsetof(struct bcm2708_fb_stats, dma_copies)
61 +               },
62 +       };
63 +
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",
67 +                       __func__);
68 +               return -EFAULT;
69 +       }
70 +
71 +       fb->stats.regset.regs = stats_registers;
72 +       fb->stats.regset.nregs = ARRAY_SIZE(stats_registers);
73 +       fb->stats.regset.base = &fb->stats;
74 +
75 +       if (!debugfs_create_regset32(
76 +               "stats", 0444, fb->debugfs_dir, &fb->stats.regset)) {
77 +               pr_warn("%s: could not create statistics registers\n",
78 +                       __func__);
79 +               goto fail;
80 +       }
81 +       return 0;
82 +
83 +fail:
84 +       bcm2708_fb_debugfs_deinit(fb);
85 +       return -EFAULT;
86 +}
87 +
88  static int bcm2708_fb_set_bitfields(struct fb_var_screeninfo *var)
89  {
90         int ret = 0;
91 @@ -443,8 +491,10 @@ static void bcm2708_fb_copyarea(struct f
92         /* end of dma control blocks chain */
93         cb->next = 0;
94  
95 +
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++;
99  }
100  
101  static void bcm2708_fb_imageblit(struct fb_info *info,
102 @@ -552,6 +602,9 @@ static int bcm2708_fb_probe(struct platf
103         }
104         memset(fb, 0, sizeof(struct bcm2708_fb));
105  
106 +
107 +       bcm2708_fb_debugfs_init(fb);
108 +
109         fb->cb_base = dma_alloc_writecombine(&dev->dev, SZ_64K,
110                                              &fb->cb_handle, GFP_KERNEL);
111         if (!fb->cb_base) {
112 @@ -607,6 +660,8 @@ static int bcm2708_fb_remove(struct plat
113  
114         dma_free_coherent(NULL, PAGE_ALIGN(sizeof(*fb->info)), (void *)fb->info,
115                           fb->dma);
116 +       bcm2708_fb_debugfs_deinit(fb);
117 +
118         kfree(fb);
119  
120         return 0;