brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0148-bcm2708_fb-report-number-of-dma-copies.patch
1 From ceb70800efa2f4c92f0c89bf472005decd577d65 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/196] 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 diff --git a/drivers/video/bcm2708_fb.c b/drivers/video/bcm2708_fb.c
17 index c10c5ee..4d7d963 100644
18 --- a/drivers/video/bcm2708_fb.c
19 +++ b/drivers/video/bcm2708_fb.c
20 @@ -27,6 +27,7 @@
21 #include <linux/clk.h>
22 #include <linux/printk.h>
23 #include <linux/console.h>
24 +#include <linux/debugfs.h>
25
26 #include <mach/dma.h>
27 #include <mach/platform.h>
28 @@ -58,6 +59,12 @@ struct fbinfo_s {
29 u16 cmap[256];
30 };
31
32 +struct bcm2708_fb_stats {
33 + struct debugfs_regset32 regset;
34 + u32 dma_copies;
35 + u32 dma_irqs;
36 +};
37 +
38 struct bcm2708_fb {
39 struct fb_info fb;
40 struct platform_device *dev;
41 @@ -69,10 +76,51 @@ struct bcm2708_fb {
42 void __iomem *dma_chan_base;
43 void *cb_base; /* DMA control blocks */
44 dma_addr_t cb_handle;
45 + struct dentry *debugfs_dir;
46 + struct bcm2708_fb_stats stats;
47 };
48
49 #define to_bcm2708(info) container_of(info, struct bcm2708_fb, fb)
50
51 +static void bcm2708_fb_debugfs_deinit(struct bcm2708_fb *fb)
52 +{
53 + debugfs_remove_recursive(fb->debugfs_dir);
54 + fb->debugfs_dir = NULL;
55 +}
56 +
57 +static int bcm2708_fb_debugfs_init(struct bcm2708_fb *fb)
58 +{
59 + static struct debugfs_reg32 stats_registers[] = {
60 + {
61 + "dma_copies",
62 + offsetof(struct bcm2708_fb_stats, dma_copies)
63 + },
64 + };
65 +
66 + fb->debugfs_dir = debugfs_create_dir(DRIVER_NAME, NULL);
67 + if (!fb->debugfs_dir) {
68 + pr_warn("%s: could not create debugfs entry\n",
69 + __func__);
70 + return -EFAULT;
71 + }
72 +
73 + fb->stats.regset.regs = stats_registers;
74 + fb->stats.regset.nregs = ARRAY_SIZE(stats_registers);
75 + fb->stats.regset.base = &fb->stats;
76 +
77 + if (!debugfs_create_regset32(
78 + "stats", 0444, fb->debugfs_dir, &fb->stats.regset)) {
79 + pr_warn("%s: could not create statistics registers\n",
80 + __func__);
81 + goto fail;
82 + }
83 + return 0;
84 +
85 +fail:
86 + bcm2708_fb_debugfs_deinit(fb);
87 + return -EFAULT;
88 +}
89 +
90 static int bcm2708_fb_set_bitfields(struct fb_var_screeninfo *var)
91 {
92 int ret = 0;
93 @@ -443,8 +491,10 @@ static void bcm2708_fb_copyarea(struct fb_info *info,
94 /* end of dma control blocks chain */
95 cb->next = 0;
96
97 +
98 bcm_dma_start(fb->dma_chan_base, fb->cb_handle);
99 bcm_dma_wait_idle(fb->dma_chan_base);
100 + fb->stats.dma_copies++;
101 }
102
103 static void bcm2708_fb_imageblit(struct fb_info *info,
104 @@ -552,6 +602,9 @@ static int bcm2708_fb_probe(struct platform_device *dev)
105 }
106 memset(fb, 0, sizeof(struct bcm2708_fb));
107
108 +
109 + bcm2708_fb_debugfs_init(fb);
110 +
111 fb->cb_base = dma_alloc_writecombine(&dev->dev, SZ_64K,
112 &fb->cb_handle, GFP_KERNEL);
113 if (!fb->cb_base) {
114 @@ -607,6 +660,8 @@ static int bcm2708_fb_remove(struct platform_device *dev)
115
116 dma_free_coherent(NULL, PAGE_ALIGN(sizeof(*fb->info)), (void *)fb->info,
117 fb->dma);
118 + bcm2708_fb_debugfs_deinit(fb);
119 +
120 kfree(fb);
121
122 return 0;
123 --
124 1.9.1
125