aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2007-02-12 05:53:50 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2007-02-12 05:53:50 -0500
commit017cc022b6f0a0619cc3b0bba43e1c3247b06779 (patch)
treead89a72c1d764aa4f099a0e12d397e1649e1f756
parentab2c21529df6ee0f06787773882a1abc6bc2d665 (diff)
[ARM] Convert dmabounce statistics to use a device attribute
Rather than printk'ing the dmabounce statistics occasionally to the kernel log, provide a sysfs file to allow this information to be periodically read. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/common/dmabounce.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/arch/arm/common/dmabounce.c b/arch/arm/common/dmabounce.c
index 490e1fe286d5..4d5b031ac745 100644
--- a/arch/arm/common/dmabounce.c
+++ b/arch/arm/common/dmabounce.c
@@ -32,7 +32,6 @@
32 32
33#include <asm/cacheflush.h> 33#include <asm/cacheflush.h>
34 34
35#undef DEBUG
36#undef STATS 35#undef STATS
37 36
38#ifdef STATS 37#ifdef STATS
@@ -72,6 +71,7 @@ struct dmabounce_device_info {
72 unsigned long total_allocs; 71 unsigned long total_allocs;
73 unsigned long map_op_count; 72 unsigned long map_op_count;
74 unsigned long bounce_count; 73 unsigned long bounce_count;
74 int attr_res;
75#endif 75#endif
76 struct dmabounce_pool small; 76 struct dmabounce_pool small;
77 struct dmabounce_pool large; 77 struct dmabounce_pool large;
@@ -80,16 +80,21 @@ struct dmabounce_device_info {
80}; 80};
81 81
82#ifdef STATS 82#ifdef STATS
83static void print_alloc_stats(struct dmabounce_device_info *device_info) 83static ssize_t dmabounce_show(struct device *dev, struct device_attribute *attr,
84 char *buf)
84{ 85{
85 printk(KERN_INFO 86 struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
86 "%s: dmabounce: sbp: %lu, lbp: %lu, other: %lu, total: %lu\n", 87 return sprintf(buf, "%lu %lu %lu %lu %lu %lu\n",
87 device_info->dev->bus_id, 88 device_info->small.allocs,
88 device_info->small.allocs, device_info->large.allocs, 89 device_info->large.allocs,
89 device_info->total_allocs - device_info->small.allocs - 90 device_info->total_allocs - device_info->small.allocs -
90 device_info->large.allocs, 91 device_info->large.allocs,
91 device_info->total_allocs); 92 device_info->total_allocs,
93 device_info->map_op_count,
94 device_info->bounce_count);
92} 95}
96
97static DEVICE_ATTR(dmabounce_stats, 0400, dmabounce_show, NULL);
93#endif 98#endif
94 99
95 100
@@ -145,8 +150,6 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info, void *ptr,
145 if (pool) 150 if (pool)
146 pool->allocs++; 151 pool->allocs++;
147 device_info->total_allocs++; 152 device_info->total_allocs++;
148 if (device_info->total_allocs % 1000 == 0)
149 print_alloc_stats(device_info);
150#endif 153#endif
151 154
152 write_lock_irqsave(&device_info->lock, flags); 155 write_lock_irqsave(&device_info->lock, flags);
@@ -201,15 +204,6 @@ free_safe_buffer(struct dmabounce_device_info *device_info, struct safe_buffer *
201 204
202/* ************************************************** */ 205/* ************************************************** */
203 206
204#ifdef STATS
205static void print_map_stats(struct dmabounce_device_info *device_info)
206{
207 dev_info(device_info->dev,
208 "dmabounce: map_op_count=%lu, bounce_count=%lu\n",
209 device_info->map_op_count, device_info->bounce_count);
210}
211#endif
212
213static inline dma_addr_t 207static inline dma_addr_t
214map_single(struct device *dev, void *ptr, size_t size, 208map_single(struct device *dev, void *ptr, size_t size,
215 enum dma_data_direction dir) 209 enum dma_data_direction dir)
@@ -587,6 +581,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
587 device_info->total_allocs = 0; 581 device_info->total_allocs = 0;
588 device_info->map_op_count = 0; 582 device_info->map_op_count = 0;
589 device_info->bounce_count = 0; 583 device_info->bounce_count = 0;
584 device_info->attr_res = device_create_file(dev, &dev_attr_dmabounce_stats);
590#endif 585#endif
591 586
592 dev->archdata.dmabounce = device_info; 587 dev->archdata.dmabounce = device_info;
@@ -630,8 +625,8 @@ dmabounce_unregister_dev(struct device *dev)
630 dma_pool_destroy(device_info->large.pool); 625 dma_pool_destroy(device_info->large.pool);
631 626
632#ifdef STATS 627#ifdef STATS
633 print_alloc_stats(device_info); 628 if (device_info->attr_res == 0)
634 print_map_stats(device_info); 629 device_remove_file(dev, &dev_attr_dmabounce_stats);
635#endif 630#endif
636 631
637 kfree(device_info); 632 kfree(device_info);