Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 145943
b: refs/heads/master
c: 92db1e6
h: refs/heads/master
i:
  145941: 5541ba7
  145939: ebcd589
  145935: 12b65c5
v: v3
  • Loading branch information
Ingo Molnar committed Jun 9, 2009
1 parent d0e581d commit f79c550
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 57 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e9a22a13c71986851e931bdfa054f68839ff8576
refs/heads/master: 92db1e6af747faa129e236d68386af26a0efc12b
112 changes: 56 additions & 56 deletions trunk/lib/dma-debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,18 @@ static inline void dump_entry_trace(struct dma_debug_entry *entry)
{
#ifdef CONFIG_STACKTRACE
if (entry) {
printk(KERN_WARNING "Mapped at:\n");
pr_warning("Mapped at:\n");
print_stack_trace(&entry->stacktrace, 0);
}
#endif
}

static bool driver_filter(struct device *dev)
{
struct device_driver *drv;
unsigned long flags;
bool ret;

/* driver filter off */
if (likely(!current_driver_name[0]))
return true;
Expand All @@ -155,32 +159,28 @@ static bool driver_filter(struct device *dev)
if (current_driver && dev->driver == current_driver)
return true;

/* driver filter on but not yet initialized */
if (!current_driver && current_driver_name[0]) {
struct device_driver *drv = get_driver(dev->driver);
unsigned long flags;
bool ret = false;

if (!drv)
return false;

/* lock to protect against change of current_driver_name */
read_lock_irqsave(&driver_name_lock, flags);
if (current_driver || !current_driver_name[0])
return false;

if (drv->name &&
strncmp(current_driver_name, drv->name,
NAME_MAX_LEN-1) == 0) {
current_driver = drv;
ret = true;
}
/* driver filter on but not yet initialized */
drv = get_driver(dev->driver);
if (!drv)
return false;

read_unlock_irqrestore(&driver_name_lock, flags);
put_driver(drv);
/* lock to protect against change of current_driver_name */
read_lock_irqsave(&driver_name_lock, flags);

return ret;
ret = false;
if (drv->name &&
strncmp(current_driver_name, drv->name, NAME_MAX_LEN - 1) == 0) {
current_driver = drv;
ret = true;
}

return false;
read_unlock_irqrestore(&driver_name_lock, flags);
put_driver(drv);

return ret;
}

#define err_printk(dev, entry, format, arg...) do { \
Expand Down Expand Up @@ -377,8 +377,7 @@ static struct dma_debug_entry *dma_entry_alloc(void)
spin_lock_irqsave(&free_entries_lock, flags);

if (list_empty(&free_entries)) {
printk(KERN_ERR "DMA-API: debugging out of memory "
"- disabling\n");
pr_err("DMA-API: debugging out of memory - disabling\n");
global_disable = true;
goto out;
}
Expand Down Expand Up @@ -483,8 +482,7 @@ static int prealloc_memory(u32 num_entries)
num_free_entries = num_entries;
min_free_entries = num_entries;

printk(KERN_INFO "DMA-API: preallocated %d debug entries\n",
num_entries);
pr_info("DMA-API: preallocated %d debug entries\n", num_entries);

return 0;

Expand All @@ -501,8 +499,8 @@ static int prealloc_memory(u32 num_entries)
static ssize_t filter_read(struct file *file, char __user *user_buf,
size_t count, loff_t *ppos)
{
unsigned long flags;
char buf[NAME_MAX_LEN + 1];
unsigned long flags;
int len;

if (!current_driver_name[0])
Expand All @@ -523,9 +521,9 @@ static ssize_t filter_read(struct file *file, char __user *user_buf,
static ssize_t filter_write(struct file *file, const char __user *userbuf,
size_t count, loff_t *ppos)
{
unsigned long flags;
char buf[NAME_MAX_LEN];
size_t len = NAME_MAX_LEN - 1;
unsigned long flags;
size_t len;
int i;

/*
Expand All @@ -534,15 +532,16 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
* disabled. Since copy_from_user can fault and may sleep we
* need to copy to temporary buffer first
*/
len = min(count, len);
len = min(count, (size_t)(NAME_MAX_LEN - 1));
if (copy_from_user(buf, userbuf, len))
return -EFAULT;

buf[len] = 0;

write_lock_irqsave(&driver_name_lock, flags);

/* Now handle the string we got from userspace very carefully.
/*
* Now handle the string we got from userspace very carefully.
* The rules are:
* - only use the first token we got
* - token delimiter is everything looking like a space
Expand All @@ -551,13 +550,12 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
*/
if (!isalnum(buf[0])) {
/*
If the first character userspace gave us is not
* If the first character userspace gave us is not
* alphanumerical then assume the filter should be
* switched off.
*/
if (current_driver_name[0])
printk(KERN_INFO "DMA-API: switching off dma-debug "
"driver filter\n");
pr_info("DMA-API: switching off dma-debug driver filter\n");
current_driver_name[0] = 0;
current_driver = NULL;
goto out_unlock;
Expand All @@ -575,8 +573,8 @@ static ssize_t filter_write(struct file *file, const char __user *userbuf,
current_driver_name[i] = 0;
current_driver = NULL;

printk(KERN_INFO "DMA-API: enable driver filter for driver [%s]\n",
current_driver_name);
pr_info("DMA-API: enable driver filter for driver [%s]\n",
current_driver_name);

out_unlock:
write_unlock_irqrestore(&driver_name_lock, flags);
Expand All @@ -593,7 +591,7 @@ static int dma_debug_fs_init(void)
{
dma_debug_dent = debugfs_create_dir("dma-api", NULL);
if (!dma_debug_dent) {
printk(KERN_ERR "DMA-API: can not create debugfs directory\n");
pr_err("DMA-API: can not create debugfs directory\n");
return -ENOMEM;
}

Expand Down Expand Up @@ -651,15 +649,19 @@ static int device_dma_allocations(struct device *dev)
unsigned long flags;
int count = 0, i;

local_irq_save(flags);

for (i = 0; i < HASH_SIZE; ++i) {
spin_lock_irqsave(&dma_entry_hash[i].lock, flags);
spin_lock(&dma_entry_hash[i].lock);
list_for_each_entry(entry, &dma_entry_hash[i].list, list) {
if (entry->dev == dev)
count += 1;
}
spin_unlock_irqrestore(&dma_entry_hash[i].lock, flags);
spin_unlock(&dma_entry_hash[i].lock);
}

local_irq_restore(flags);

return count;
}

Expand Down Expand Up @@ -692,7 +694,7 @@ void dma_debug_add_bus(struct bus_type *bus)

nb = kzalloc(sizeof(struct notifier_block), GFP_KERNEL);
if (nb == NULL) {
printk(KERN_ERR "dma_debug_add_bus: out of memory\n");
pr_err("dma_debug_add_bus: out of memory\n");
return;
}

Expand All @@ -717,8 +719,7 @@ void dma_debug_init(u32 num_entries)
}

if (dma_debug_fs_init() != 0) {
printk(KERN_ERR "DMA-API: error creating debugfs entries "
"- disabling\n");
pr_err("DMA-API: error creating debugfs entries - disabling\n");
global_disable = true;

return;
Expand All @@ -728,16 +729,15 @@ void dma_debug_init(u32 num_entries)
num_entries = req_entries;

if (prealloc_memory(num_entries) != 0) {
printk(KERN_ERR "DMA-API: debugging out of memory error "
"- disabled\n");
pr_err("DMA-API: debugging out of memory error - disabled\n");
global_disable = true;

return;
}

nr_total_entries = num_free_entries;

printk(KERN_INFO "DMA-API: debugging enabled by kernel config\n");
pr_info("DMA-API: debugging enabled by kernel config\n");
}

static __init int dma_debug_cmdline(char *str)
Expand All @@ -746,8 +746,7 @@ static __init int dma_debug_cmdline(char *str)
return -EINVAL;

if (strncmp(str, "off", 3) == 0) {
printk(KERN_INFO "DMA-API: debugging disabled on kernel "
"command line\n");
pr_info("DMA-API: debugging disabled on kernel command line\n");
global_disable = true;
}

Expand Down Expand Up @@ -1039,18 +1038,19 @@ EXPORT_SYMBOL(debug_dma_map_sg);

static int get_nr_mapped_entries(struct device *dev, struct scatterlist *s)
{
struct dma_debug_entry *entry;
struct dma_debug_entry *entry, ref;
struct hash_bucket *bucket;
unsigned long flags;
int mapped_ents = 0;
struct dma_debug_entry ref;
int mapped_ents;

ref.dev = dev;
ref.dev = dev;
ref.dev_addr = sg_dma_address(s);
ref.size = sg_dma_len(s),
ref.size = sg_dma_len(s),

bucket = get_hash_bucket(&ref, &flags);
entry = hash_bucket_find(bucket, &ref);
mapped_ents = 0;

bucket = get_hash_bucket(&ref, &flags);
entry = hash_bucket_find(bucket, &ref);
if (entry)
mapped_ents = entry->sg_mapped_ents;
put_hash_bucket(bucket, &flags);
Expand Down Expand Up @@ -1237,8 +1237,8 @@ static int __init dma_debug_driver_setup(char *str)
}

if (current_driver_name[0])
printk(KERN_INFO "DMA-API: enable driver filter for "
"driver [%s]\n", current_driver_name);
pr_info("DMA-API: enable driver filter for driver [%s]\n",
current_driver_name);


return 1;
Expand Down

0 comments on commit f79c550

Please sign in to comment.