Skip to content

Commit

Permalink
[ARM] Convert dmabounce statistics to use a device attribute
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Russell King authored and Russell King committed Feb 12, 2007
1 parent ab2c215 commit 017cc02
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions arch/arm/common/dmabounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@

#include <asm/cacheflush.h>

#undef DEBUG
#undef STATS

#ifdef STATS
Expand Down Expand Up @@ -72,6 +71,7 @@ struct dmabounce_device_info {
unsigned long total_allocs;
unsigned long map_op_count;
unsigned long bounce_count;
int attr_res;
#endif
struct dmabounce_pool small;
struct dmabounce_pool large;
Expand All @@ -80,16 +80,21 @@ struct dmabounce_device_info {
};

#ifdef STATS
static void print_alloc_stats(struct dmabounce_device_info *device_info)
static ssize_t dmabounce_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
printk(KERN_INFO
"%s: dmabounce: sbp: %lu, lbp: %lu, other: %lu, total: %lu\n",
device_info->dev->bus_id,
device_info->small.allocs, device_info->large.allocs,
struct dmabounce_device_info *device_info = dev->archdata.dmabounce;
return sprintf(buf, "%lu %lu %lu %lu %lu %lu\n",
device_info->small.allocs,
device_info->large.allocs,
device_info->total_allocs - device_info->small.allocs -
device_info->large.allocs,
device_info->total_allocs);
device_info->total_allocs,
device_info->map_op_count,
device_info->bounce_count);
}

static DEVICE_ATTR(dmabounce_stats, 0400, dmabounce_show, NULL);
#endif


Expand Down Expand Up @@ -145,8 +150,6 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info, void *ptr,
if (pool)
pool->allocs++;
device_info->total_allocs++;
if (device_info->total_allocs % 1000 == 0)
print_alloc_stats(device_info);
#endif

write_lock_irqsave(&device_info->lock, flags);
Expand Down Expand Up @@ -201,15 +204,6 @@ free_safe_buffer(struct dmabounce_device_info *device_info, struct safe_buffer *

/* ************************************************** */

#ifdef STATS
static void print_map_stats(struct dmabounce_device_info *device_info)
{
dev_info(device_info->dev,
"dmabounce: map_op_count=%lu, bounce_count=%lu\n",
device_info->map_op_count, device_info->bounce_count);
}
#endif

static inline dma_addr_t
map_single(struct device *dev, void *ptr, size_t size,
enum dma_data_direction dir)
Expand Down Expand Up @@ -587,6 +581,7 @@ dmabounce_register_dev(struct device *dev, unsigned long small_buffer_size,
device_info->total_allocs = 0;
device_info->map_op_count = 0;
device_info->bounce_count = 0;
device_info->attr_res = device_create_file(dev, &dev_attr_dmabounce_stats);
#endif

dev->archdata.dmabounce = device_info;
Expand Down Expand Up @@ -630,8 +625,8 @@ dmabounce_unregister_dev(struct device *dev)
dma_pool_destroy(device_info->large.pool);

#ifdef STATS
print_alloc_stats(device_info);
print_map_stats(device_info);
if (device_info->attr_res == 0)
device_remove_file(dev, &dev_attr_dmabounce_stats);
#endif

kfree(device_info);
Expand Down

0 comments on commit 017cc02

Please sign in to comment.