diff options
author | Joerg Roedel <joerg.roedel@amd.com> | 2009-05-22 12:24:20 -0400 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2009-06-02 08:54:55 -0400 |
commit | 2e507d849f1834d3fe9aae71b7aabf4c2a3827b8 (patch) | |
tree | 7cc7623379821ef36423d4c3fe19f17c7e5c019f /lib | |
parent | 41fb454ebe6024f5c1e3b3cbc0abc0da762e7b51 (diff) |
dma-debug: add variables and checks for driver filter
This patch adds the state variables for the driver filter and a function
to check if the filter is enabled and matches to the current device. The
check is built into the err_printk function.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/dma-debug.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/lib/dma-debug.c b/lib/dma-debug.c index cdd205d6bf7..c01f64780ca 100644 --- a/lib/dma-debug.c +++ b/lib/dma-debug.c | |||
@@ -99,6 +99,15 @@ static struct dentry *show_num_errors_dent __read_mostly; | |||
99 | static struct dentry *num_free_entries_dent __read_mostly; | 99 | static struct dentry *num_free_entries_dent __read_mostly; |
100 | static struct dentry *min_free_entries_dent __read_mostly; | 100 | static struct dentry *min_free_entries_dent __read_mostly; |
101 | 101 | ||
102 | /* per-driver filter related state */ | ||
103 | |||
104 | #define NAME_MAX_LEN 64 | ||
105 | |||
106 | static char current_driver_name[NAME_MAX_LEN] __read_mostly; | ||
107 | static struct device_driver *current_driver __read_mostly; | ||
108 | |||
109 | static DEFINE_RWLOCK(driver_name_lock); | ||
110 | |||
102 | static const char *type2name[4] = { "single", "page", | 111 | static const char *type2name[4] = { "single", "page", |
103 | "scather-gather", "coherent" }; | 112 | "scather-gather", "coherent" }; |
104 | 113 | ||
@@ -128,9 +137,47 @@ static inline void dump_entry_trace(struct dma_debug_entry *entry) | |||
128 | #endif | 137 | #endif |
129 | } | 138 | } |
130 | 139 | ||
140 | static bool driver_filter(struct device *dev) | ||
141 | { | ||
142 | /* driver filter off */ | ||
143 | if (likely(!current_driver_name[0])) | ||
144 | return true; | ||
145 | |||
146 | /* driver filter on and initialized */ | ||
147 | if (current_driver && dev->driver == current_driver) | ||
148 | return true; | ||
149 | |||
150 | /* driver filter on but not yet initialized */ | ||
151 | if (!current_driver && current_driver_name[0]) { | ||
152 | struct device_driver *drv = get_driver(dev->driver); | ||
153 | unsigned long flags; | ||
154 | bool ret = false; | ||
155 | |||
156 | if (!drv) | ||
157 | return false; | ||
158 | |||
159 | /* lock to protect against change of current_driver_name */ | ||
160 | read_lock_irqsave(&driver_name_lock, flags); | ||
161 | |||
162 | if (drv->name && | ||
163 | strncmp(current_driver_name, drv->name, 63) == 0) { | ||
164 | current_driver = drv; | ||
165 | ret = true; | ||
166 | } | ||
167 | |||
168 | read_unlock_irqrestore(&driver_name_lock, flags); | ||
169 | put_driver(drv); | ||
170 | |||
171 | return ret; | ||
172 | } | ||
173 | |||
174 | return false; | ||
175 | } | ||
176 | |||
131 | #define err_printk(dev, entry, format, arg...) do { \ | 177 | #define err_printk(dev, entry, format, arg...) do { \ |
132 | error_count += 1; \ | 178 | error_count += 1; \ |
133 | if (show_all_errors || show_num_errors > 0) { \ | 179 | if (driver_filter(dev) && \ |
180 | (show_all_errors || show_num_errors > 0)) { \ | ||
134 | WARN(1, "%s %s: " format, \ | 181 | WARN(1, "%s %s: " format, \ |
135 | dev_driver_string(dev), \ | 182 | dev_driver_string(dev), \ |
136 | dev_name(dev) , ## arg); \ | 183 | dev_name(dev) , ## arg); \ |