aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoerg Roedel <joerg.roedel@amd.com>2009-01-09 07:13:27 -0500
committerJoerg Roedel <joerg.roedel@amd.com>2009-03-05 14:35:16 -0500
commit788dcfa6f17424695823152890d30da09f62f9c3 (patch)
treed4f688954efcd23e95c9954408dd6a39959df247 /lib
parent59d3daafa17265f01149df8eab3fb69b9b42cb2e (diff)
dma-debug: add debugfs interface
Impact: add debugfs interface for configuring DMA-API debugging Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/dma-debug.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c
index 2ede46308024..20d6cdbcacdc 100644
--- a/lib/dma-debug.c
+++ b/lib/dma-debug.c
@@ -19,6 +19,7 @@
19 19
20#include <linux/dma-debug.h> 20#include <linux/dma-debug.h>
21#include <linux/spinlock.h> 21#include <linux/spinlock.h>
22#include <linux/debugfs.h>
22#include <linux/types.h> 23#include <linux/types.h>
23#include <linux/list.h> 24#include <linux/list.h>
24#include <linux/slab.h> 25#include <linux/slab.h>
@@ -61,12 +62,29 @@ static DEFINE_SPINLOCK(free_entries_lock);
61/* Global disable flag - will be set in case of an error */ 62/* Global disable flag - will be set in case of an error */
62static bool global_disable __read_mostly; 63static bool global_disable __read_mostly;
63 64
65/* Global error count */
66static u32 error_count;
67
68/* Global error show enable*/
69static u32 show_all_errors __read_mostly;
70/* Number of errors to show */
71static u32 show_num_errors = 1;
72
64static u32 num_free_entries; 73static u32 num_free_entries;
65static u32 min_free_entries; 74static u32 min_free_entries;
66 75
67/* number of preallocated entries requested by kernel cmdline */ 76/* number of preallocated entries requested by kernel cmdline */
68static u32 req_entries; 77static u32 req_entries;
69 78
79/* debugfs dentry's for the stuff above */
80static struct dentry *dma_debug_dent __read_mostly;
81static struct dentry *global_disable_dent __read_mostly;
82static struct dentry *error_count_dent __read_mostly;
83static struct dentry *show_all_errors_dent __read_mostly;
84static struct dentry *show_num_errors_dent __read_mostly;
85static struct dentry *num_free_entries_dent __read_mostly;
86static struct dentry *min_free_entries_dent __read_mostly;
87
70/* 88/*
71 * Hash related functions 89 * Hash related functions
72 * 90 *
@@ -241,6 +259,58 @@ out_err:
241 return -ENOMEM; 259 return -ENOMEM;
242} 260}
243 261
262static int dma_debug_fs_init(void)
263{
264 dma_debug_dent = debugfs_create_dir("dma-api", NULL);
265 if (!dma_debug_dent) {
266 printk(KERN_ERR "DMA-API: can not create debugfs directory\n");
267 return -ENOMEM;
268 }
269
270 global_disable_dent = debugfs_create_bool("disabled", 0444,
271 dma_debug_dent,
272 (u32 *)&global_disable);
273 if (!global_disable_dent)
274 goto out_err;
275
276 error_count_dent = debugfs_create_u32("error_count", 0444,
277 dma_debug_dent, &error_count);
278 if (!error_count_dent)
279 goto out_err;
280
281 show_all_errors_dent = debugfs_create_u32("all_errors", 0644,
282 dma_debug_dent,
283 &show_all_errors);
284 if (!show_all_errors_dent)
285 goto out_err;
286
287 show_num_errors_dent = debugfs_create_u32("num_errors", 0644,
288 dma_debug_dent,
289 &show_num_errors);
290 if (!show_num_errors_dent)
291 goto out_err;
292
293 num_free_entries_dent = debugfs_create_u32("num_free_entries", 0444,
294 dma_debug_dent,
295 &num_free_entries);
296 if (!num_free_entries_dent)
297 goto out_err;
298
299 min_free_entries_dent = debugfs_create_u32("min_free_entries", 0444,
300 dma_debug_dent,
301 &min_free_entries);
302 if (!min_free_entries_dent)
303 goto out_err;
304
305 return 0;
306
307out_err:
308 debugfs_remove_recursive(dma_debug_dent);
309
310 return -ENOMEM;
311}
312
313
244/* 314/*
245 * Let the architectures decide how many entries should be preallocated. 315 * Let the architectures decide how many entries should be preallocated.
246 */ 316 */
@@ -256,6 +326,14 @@ void dma_debug_init(u32 num_entries)
256 dma_entry_hash[i].lock = SPIN_LOCK_UNLOCKED; 326 dma_entry_hash[i].lock = SPIN_LOCK_UNLOCKED;
257 } 327 }
258 328
329 if (dma_debug_fs_init() != 0) {
330 printk(KERN_ERR "DMA-API: error creating debugfs entries "
331 "- disabling\n");
332 global_disable = true;
333
334 return;
335 }
336
259 if (req_entries) 337 if (req_entries)
260 num_entries = req_entries; 338 num_entries = req_entries;
261 339