diff options
author | Alexander Shishkin <alexander.shishkin@linux.intel.com> | 2013-03-30 06:53:50 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-03-30 11:08:39 -0400 |
commit | 69b7e8d34f12a5770d57ccd38926d373e4599561 (patch) | |
tree | e3b433ed47d5acec390816adc80da2e442947802 /drivers/usb/chipidea/debug.c | |
parent | 571bb7abac4ed02cf7d5094b4a04a8bdca3783ed (diff) |
usb: chipidea: remove home-grown tracing facility
As part of the legacy from the original driver design, we retain home-grown
tracing infrastructure, complete with own ring buffer and timestamps,
which among other things has a performance penalty. This patch removes it.
Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/chipidea/debug.c')
-rw-r--r-- | drivers/usb/chipidea/debug.c | 360 |
1 files changed, 1 insertions, 359 deletions
diff --git a/drivers/usb/chipidea/debug.c b/drivers/usb/chipidea/debug.c index e6cc45ebb33d..898aca591915 100644 --- a/drivers/usb/chipidea/debug.c +++ b/drivers/usb/chipidea/debug.c | |||
@@ -10,46 +10,6 @@ | |||
10 | #include "bits.h" | 10 | #include "bits.h" |
11 | #include "debug.h" | 11 | #include "debug.h" |
12 | 12 | ||
13 | /* Interrupt statistics */ | ||
14 | #define ISR_MASK 0x1F | ||
15 | static struct isr_statistics { | ||
16 | u32 test; | ||
17 | u32 ui; | ||
18 | u32 uei; | ||
19 | u32 pci; | ||
20 | u32 uri; | ||
21 | u32 sli; | ||
22 | u32 none; | ||
23 | struct { | ||
24 | u32 cnt; | ||
25 | u32 buf[ISR_MASK+1]; | ||
26 | u32 idx; | ||
27 | } hndl; | ||
28 | } isr_statistics; | ||
29 | |||
30 | void dbg_interrupt(u32 intmask) | ||
31 | { | ||
32 | if (!intmask) { | ||
33 | isr_statistics.none++; | ||
34 | return; | ||
35 | } | ||
36 | |||
37 | isr_statistics.hndl.buf[isr_statistics.hndl.idx++] = intmask; | ||
38 | isr_statistics.hndl.idx &= ISR_MASK; | ||
39 | isr_statistics.hndl.cnt++; | ||
40 | |||
41 | if (USBi_URI & intmask) | ||
42 | isr_statistics.uri++; | ||
43 | if (USBi_PCI & intmask) | ||
44 | isr_statistics.pci++; | ||
45 | if (USBi_UEI & intmask) | ||
46 | isr_statistics.uei++; | ||
47 | if (USBi_UI & intmask) | ||
48 | isr_statistics.ui++; | ||
49 | if (USBi_SLI & intmask) | ||
50 | isr_statistics.sli++; | ||
51 | } | ||
52 | |||
53 | /** | 13 | /** |
54 | * hw_register_read: reads all device registers (execute without interruption) | 14 | * hw_register_read: reads all device registers (execute without interruption) |
55 | * @buf: destination buffer | 15 | * @buf: destination buffer |
@@ -196,312 +156,6 @@ static ssize_t show_driver(struct device *dev, struct device_attribute *attr, | |||
196 | } | 156 | } |
197 | static DEVICE_ATTR(driver, S_IRUSR, show_driver, NULL); | 157 | static DEVICE_ATTR(driver, S_IRUSR, show_driver, NULL); |
198 | 158 | ||
199 | /* Maximum event message length */ | ||
200 | #define DBG_DATA_MSG 64UL | ||
201 | |||
202 | /* Maximum event messages */ | ||
203 | #define DBG_DATA_MAX 128UL | ||
204 | |||
205 | /* Event buffer descriptor */ | ||
206 | static struct { | ||
207 | char (buf[DBG_DATA_MAX])[DBG_DATA_MSG]; /* buffer */ | ||
208 | unsigned idx; /* index */ | ||
209 | unsigned tty; /* print to console? */ | ||
210 | rwlock_t lck; /* lock */ | ||
211 | } dbg_data = { | ||
212 | .idx = 0, | ||
213 | .tty = 0, | ||
214 | .lck = __RW_LOCK_UNLOCKED(dbg_data.lck) | ||
215 | }; | ||
216 | |||
217 | /** | ||
218 | * dbg_dec: decrements debug event index | ||
219 | * @idx: buffer index | ||
220 | */ | ||
221 | static void dbg_dec(unsigned *idx) | ||
222 | { | ||
223 | *idx = (*idx - 1) & (DBG_DATA_MAX-1); | ||
224 | } | ||
225 | |||
226 | /** | ||
227 | * dbg_inc: increments debug event index | ||
228 | * @idx: buffer index | ||
229 | */ | ||
230 | static void dbg_inc(unsigned *idx) | ||
231 | { | ||
232 | *idx = (*idx + 1) & (DBG_DATA_MAX-1); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * dbg_print: prints the common part of the event | ||
237 | * @addr: endpoint address | ||
238 | * @name: event name | ||
239 | * @status: status | ||
240 | * @extra: extra information | ||
241 | */ | ||
242 | static void dbg_print(u8 addr, const char *name, int status, const char *extra) | ||
243 | { | ||
244 | struct timeval tval; | ||
245 | unsigned int stamp; | ||
246 | unsigned long flags; | ||
247 | |||
248 | write_lock_irqsave(&dbg_data.lck, flags); | ||
249 | |||
250 | do_gettimeofday(&tval); | ||
251 | stamp = tval.tv_sec & 0xFFFF; /* 2^32 = 4294967296. Limit to 4096s */ | ||
252 | stamp = stamp * 1000000 + tval.tv_usec; | ||
253 | |||
254 | scnprintf(dbg_data.buf[dbg_data.idx], DBG_DATA_MSG, | ||
255 | "%04X\t? %02X %-7.7s %4i ?\t%s\n", | ||
256 | stamp, addr, name, status, extra); | ||
257 | |||
258 | dbg_inc(&dbg_data.idx); | ||
259 | |||
260 | write_unlock_irqrestore(&dbg_data.lck, flags); | ||
261 | |||
262 | if (dbg_data.tty != 0) | ||
263 | pr_notice("%04X\t? %02X %-7.7s %4i ?\t%s\n", | ||
264 | stamp, addr, name, status, extra); | ||
265 | } | ||
266 | |||
267 | /** | ||
268 | * dbg_done: prints a DONE event | ||
269 | * @addr: endpoint address | ||
270 | * @td: transfer descriptor | ||
271 | * @status: status | ||
272 | */ | ||
273 | void dbg_done(u8 addr, const u32 token, int status) | ||
274 | { | ||
275 | char msg[DBG_DATA_MSG]; | ||
276 | |||
277 | scnprintf(msg, sizeof(msg), "%d %02X", | ||
278 | (int)(token & TD_TOTAL_BYTES) >> ffs_nr(TD_TOTAL_BYTES), | ||
279 | (int)(token & TD_STATUS) >> ffs_nr(TD_STATUS)); | ||
280 | dbg_print(addr, "DONE", status, msg); | ||
281 | } | ||
282 | |||
283 | /** | ||
284 | * dbg_event: prints a generic event | ||
285 | * @addr: endpoint address | ||
286 | * @name: event name | ||
287 | * @status: status | ||
288 | */ | ||
289 | void dbg_event(u8 addr, const char *name, int status) | ||
290 | { | ||
291 | if (name != NULL) | ||
292 | dbg_print(addr, name, status, ""); | ||
293 | } | ||
294 | |||
295 | /* | ||
296 | * dbg_queue: prints a QUEUE event | ||
297 | * @addr: endpoint address | ||
298 | * @req: USB request | ||
299 | * @status: status | ||
300 | */ | ||
301 | void dbg_queue(u8 addr, const struct usb_request *req, int status) | ||
302 | { | ||
303 | char msg[DBG_DATA_MSG]; | ||
304 | |||
305 | if (req != NULL) { | ||
306 | scnprintf(msg, sizeof(msg), | ||
307 | "%d %d", !req->no_interrupt, req->length); | ||
308 | dbg_print(addr, "QUEUE", status, msg); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * dbg_setup: prints a SETUP event | ||
314 | * @addr: endpoint address | ||
315 | * @req: setup request | ||
316 | */ | ||
317 | void dbg_setup(u8 addr, const struct usb_ctrlrequest *req) | ||
318 | { | ||
319 | char msg[DBG_DATA_MSG]; | ||
320 | |||
321 | if (req != NULL) { | ||
322 | scnprintf(msg, sizeof(msg), | ||
323 | "%02X %02X %04X %04X %d", req->bRequestType, | ||
324 | req->bRequest, le16_to_cpu(req->wValue), | ||
325 | le16_to_cpu(req->wIndex), le16_to_cpu(req->wLength)); | ||
326 | dbg_print(addr, "SETUP", 0, msg); | ||
327 | } | ||
328 | } | ||
329 | |||
330 | /** | ||
331 | * show_events: displays the event buffer | ||
332 | * | ||
333 | * Check "device.h" for details | ||
334 | */ | ||
335 | static ssize_t show_events(struct device *dev, struct device_attribute *attr, | ||
336 | char *buf) | ||
337 | { | ||
338 | unsigned long flags; | ||
339 | unsigned i, j, n = 0; | ||
340 | |||
341 | if (attr == NULL || buf == NULL) { | ||
342 | dev_err(dev->parent, "[%s] EINVAL\n", __func__); | ||
343 | return 0; | ||
344 | } | ||
345 | |||
346 | read_lock_irqsave(&dbg_data.lck, flags); | ||
347 | |||
348 | i = dbg_data.idx; | ||
349 | for (dbg_dec(&i); i != dbg_data.idx; dbg_dec(&i)) { | ||
350 | n += strlen(dbg_data.buf[i]); | ||
351 | if (n >= PAGE_SIZE) { | ||
352 | n -= strlen(dbg_data.buf[i]); | ||
353 | break; | ||
354 | } | ||
355 | } | ||
356 | for (j = 0, dbg_inc(&i); j < n; dbg_inc(&i)) | ||
357 | j += scnprintf(buf + j, PAGE_SIZE - j, | ||
358 | "%s", dbg_data.buf[i]); | ||
359 | |||
360 | read_unlock_irqrestore(&dbg_data.lck, flags); | ||
361 | |||
362 | return n; | ||
363 | } | ||
364 | |||
365 | /** | ||
366 | * store_events: configure if events are going to be also printed to console | ||
367 | * | ||
368 | * Check "device.h" for details | ||
369 | */ | ||
370 | static ssize_t store_events(struct device *dev, struct device_attribute *attr, | ||
371 | const char *buf, size_t count) | ||
372 | { | ||
373 | unsigned tty; | ||
374 | |||
375 | if (attr == NULL || buf == NULL) { | ||
376 | dev_err(dev, "[%s] EINVAL\n", __func__); | ||
377 | goto done; | ||
378 | } | ||
379 | |||
380 | if (sscanf(buf, "%u", &tty) != 1 || tty > 1) { | ||
381 | dev_err(dev, "<1|0>: enable|disable console log\n"); | ||
382 | goto done; | ||
383 | } | ||
384 | |||
385 | dbg_data.tty = tty; | ||
386 | dev_info(dev, "tty = %u", dbg_data.tty); | ||
387 | |||
388 | done: | ||
389 | return count; | ||
390 | } | ||
391 | static DEVICE_ATTR(events, S_IRUSR | S_IWUSR, show_events, store_events); | ||
392 | |||
393 | /** | ||
394 | * show_inters: interrupt status, enable status and historic | ||
395 | * | ||
396 | * Check "device.h" for details | ||
397 | */ | ||
398 | static ssize_t show_inters(struct device *dev, struct device_attribute *attr, | ||
399 | char *buf) | ||
400 | { | ||
401 | struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev); | ||
402 | unsigned long flags; | ||
403 | u32 intr; | ||
404 | unsigned i, j, n = 0; | ||
405 | |||
406 | if (attr == NULL || buf == NULL) { | ||
407 | dev_err(ci->dev, "[%s] EINVAL\n", __func__); | ||
408 | return 0; | ||
409 | } | ||
410 | |||
411 | spin_lock_irqsave(&ci->lock, flags); | ||
412 | |||
413 | /*n += scnprintf(buf + n, PAGE_SIZE - n, | ||
414 | "status = %08x\n", hw_read_intr_status(ci)); | ||
415 | n += scnprintf(buf + n, PAGE_SIZE - n, | ||
416 | "enable = %08x\n", hw_read_intr_enable(ci));*/ | ||
417 | |||
418 | n += scnprintf(buf + n, PAGE_SIZE - n, "*test = %d\n", | ||
419 | isr_statistics.test); | ||
420 | n += scnprintf(buf + n, PAGE_SIZE - n, "? ui = %d\n", | ||
421 | isr_statistics.ui); | ||
422 | n += scnprintf(buf + n, PAGE_SIZE - n, "? uei = %d\n", | ||
423 | isr_statistics.uei); | ||
424 | n += scnprintf(buf + n, PAGE_SIZE - n, "? pci = %d\n", | ||
425 | isr_statistics.pci); | ||
426 | n += scnprintf(buf + n, PAGE_SIZE - n, "? uri = %d\n", | ||
427 | isr_statistics.uri); | ||
428 | n += scnprintf(buf + n, PAGE_SIZE - n, "? sli = %d\n", | ||
429 | isr_statistics.sli); | ||
430 | n += scnprintf(buf + n, PAGE_SIZE - n, "*none = %d\n", | ||
431 | isr_statistics.none); | ||
432 | n += scnprintf(buf + n, PAGE_SIZE - n, "*hndl = %d\n", | ||
433 | isr_statistics.hndl.cnt); | ||
434 | |||
435 | for (i = isr_statistics.hndl.idx, j = 0; j <= ISR_MASK; j++, i++) { | ||
436 | i &= ISR_MASK; | ||
437 | intr = isr_statistics.hndl.buf[i]; | ||
438 | |||
439 | if (USBi_UI & intr) | ||
440 | n += scnprintf(buf + n, PAGE_SIZE - n, "ui "); | ||
441 | intr &= ~USBi_UI; | ||
442 | if (USBi_UEI & intr) | ||
443 | n += scnprintf(buf + n, PAGE_SIZE - n, "uei "); | ||
444 | intr &= ~USBi_UEI; | ||
445 | if (USBi_PCI & intr) | ||
446 | n += scnprintf(buf + n, PAGE_SIZE - n, "pci "); | ||
447 | intr &= ~USBi_PCI; | ||
448 | if (USBi_URI & intr) | ||
449 | n += scnprintf(buf + n, PAGE_SIZE - n, "uri "); | ||
450 | intr &= ~USBi_URI; | ||
451 | if (USBi_SLI & intr) | ||
452 | n += scnprintf(buf + n, PAGE_SIZE - n, "sli "); | ||
453 | intr &= ~USBi_SLI; | ||
454 | if (intr) | ||
455 | n += scnprintf(buf + n, PAGE_SIZE - n, "??? "); | ||
456 | if (isr_statistics.hndl.buf[i]) | ||
457 | n += scnprintf(buf + n, PAGE_SIZE - n, "\n"); | ||
458 | } | ||
459 | |||
460 | spin_unlock_irqrestore(&ci->lock, flags); | ||
461 | |||
462 | return n; | ||
463 | } | ||
464 | |||
465 | /** | ||
466 | * store_inters: enable & force or disable an individual interrutps | ||
467 | * (to be used for test purposes only) | ||
468 | * | ||
469 | * Check "device.h" for details | ||
470 | */ | ||
471 | static ssize_t store_inters(struct device *dev, struct device_attribute *attr, | ||
472 | const char *buf, size_t count) | ||
473 | { | ||
474 | struct ci13xxx *ci = container_of(dev, struct ci13xxx, gadget.dev); | ||
475 | unsigned long flags; | ||
476 | unsigned en, bit; | ||
477 | |||
478 | if (attr == NULL || buf == NULL) { | ||
479 | dev_err(ci->dev, "EINVAL\n"); | ||
480 | goto done; | ||
481 | } | ||
482 | |||
483 | if (sscanf(buf, "%u %u", &en, &bit) != 2 || en > 1) { | ||
484 | dev_err(ci->dev, "<1|0> <bit>: enable|disable interrupt\n"); | ||
485 | goto done; | ||
486 | } | ||
487 | |||
488 | spin_lock_irqsave(&ci->lock, flags); | ||
489 | if (en) { | ||
490 | if (hw_intr_force(ci, bit)) | ||
491 | dev_err(dev, "invalid bit number\n"); | ||
492 | else | ||
493 | isr_statistics.test++; | ||
494 | } else { | ||
495 | if (hw_intr_clear(ci, bit)) | ||
496 | dev_err(dev, "invalid bit number\n"); | ||
497 | } | ||
498 | spin_unlock_irqrestore(&ci->lock, flags); | ||
499 | |||
500 | done: | ||
501 | return count; | ||
502 | } | ||
503 | static DEVICE_ATTR(inters, S_IRUSR | S_IWUSR, show_inters, store_inters); | ||
504 | |||
505 | /** | 159 | /** |
506 | * show_port_test: reads port test mode | 160 | * show_port_test: reads port test mode |
507 | * | 161 | * |
@@ -730,15 +384,9 @@ int dbg_create_files(struct device *dev) | |||
730 | retval = device_create_file(dev, &dev_attr_driver); | 384 | retval = device_create_file(dev, &dev_attr_driver); |
731 | if (retval) | 385 | if (retval) |
732 | goto rm_device; | 386 | goto rm_device; |
733 | retval = device_create_file(dev, &dev_attr_events); | ||
734 | if (retval) | ||
735 | goto rm_driver; | ||
736 | retval = device_create_file(dev, &dev_attr_inters); | ||
737 | if (retval) | ||
738 | goto rm_events; | ||
739 | retval = device_create_file(dev, &dev_attr_port_test); | 387 | retval = device_create_file(dev, &dev_attr_port_test); |
740 | if (retval) | 388 | if (retval) |
741 | goto rm_inters; | 389 | goto rm_driver; |
742 | retval = device_create_file(dev, &dev_attr_qheads); | 390 | retval = device_create_file(dev, &dev_attr_qheads); |
743 | if (retval) | 391 | if (retval) |
744 | goto rm_port_test; | 392 | goto rm_port_test; |
@@ -756,10 +404,6 @@ int dbg_create_files(struct device *dev) | |||
756 | device_remove_file(dev, &dev_attr_qheads); | 404 | device_remove_file(dev, &dev_attr_qheads); |
757 | rm_port_test: | 405 | rm_port_test: |
758 | device_remove_file(dev, &dev_attr_port_test); | 406 | device_remove_file(dev, &dev_attr_port_test); |
759 | rm_inters: | ||
760 | device_remove_file(dev, &dev_attr_inters); | ||
761 | rm_events: | ||
762 | device_remove_file(dev, &dev_attr_events); | ||
763 | rm_driver: | 407 | rm_driver: |
764 | device_remove_file(dev, &dev_attr_driver); | 408 | device_remove_file(dev, &dev_attr_driver); |
765 | rm_device: | 409 | rm_device: |
@@ -782,8 +426,6 @@ int dbg_remove_files(struct device *dev) | |||
782 | device_remove_file(dev, &dev_attr_registers); | 426 | device_remove_file(dev, &dev_attr_registers); |
783 | device_remove_file(dev, &dev_attr_qheads); | 427 | device_remove_file(dev, &dev_attr_qheads); |
784 | device_remove_file(dev, &dev_attr_port_test); | 428 | device_remove_file(dev, &dev_attr_port_test); |
785 | device_remove_file(dev, &dev_attr_inters); | ||
786 | device_remove_file(dev, &dev_attr_events); | ||
787 | device_remove_file(dev, &dev_attr_driver); | 429 | device_remove_file(dev, &dev_attr_driver); |
788 | device_remove_file(dev, &dev_attr_device); | 430 | device_remove_file(dev, &dev_attr_device); |
789 | return 0; | 431 | return 0; |