aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host/ehci-dbg.c
diff options
context:
space:
mode:
authorMing Lei <tom.leiming@gmail.com>2008-09-18 11:06:21 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-10-17 17:40:57 -0400
commit3c04e20ea95f9a8555456000e0ff340bdc46dea8 (patch)
tree6159c4095f2ede77a560b04e886814f0d40ba141 /drivers/usb/host/ehci-dbg.c
parent549c41e0ac0a3eb68cfdaeb43c1a314e2a6c289a (diff)
USB: ehci-dbg: increase debug buffer size for periodic file
This patch is based on the following ideas: 1. Some usb devices (such as usb video class) have endpoints of high interval attribute, so reading "periodic" file need more debug buffer to accommodate the qh or itd schedule information. For example, 4KB buffer is not enough for a single interrupt qh of 2ms period. 2. print a %p need 16 byte buffer on 64-bits arch, but 8 byte on 32-bits arch. Add a extra bonus for 64-bits arch. Signed-off-by: Ming Lei <tom.leiming@gmail.com> Acked-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host/ehci-dbg.c')
-rw-r--r--drivers/usb/host/ehci-dbg.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/drivers/usb/host/ehci-dbg.c b/drivers/usb/host/ehci-dbg.c
index b0f8ed5a7fb9..9534ff3f5e7b 100644
--- a/drivers/usb/host/ehci-dbg.c
+++ b/drivers/usb/host/ehci-dbg.c
@@ -358,7 +358,8 @@ struct debug_buffer {
358 struct usb_bus *bus; 358 struct usb_bus *bus;
359 struct mutex mutex; /* protect filling of buffer */ 359 struct mutex mutex; /* protect filling of buffer */
360 size_t count; /* number of characters filled into buffer */ 360 size_t count; /* number of characters filled into buffer */
361 char *page; 361 char *output_buf;
362 size_t alloc_size;
362}; 363};
363 364
364#define speed_char(info1) ({ char tmp; \ 365#define speed_char(info1) ({ char tmp; \
@@ -488,8 +489,8 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
488 489
489 hcd = bus_to_hcd(buf->bus); 490 hcd = bus_to_hcd(buf->bus);
490 ehci = hcd_to_ehci (hcd); 491 ehci = hcd_to_ehci (hcd);
491 next = buf->page; 492 next = buf->output_buf;
492 size = PAGE_SIZE; 493 size = buf->alloc_size;
493 494
494 *next = 0; 495 *next = 0;
495 496
@@ -510,7 +511,7 @@ static ssize_t fill_async_buffer(struct debug_buffer *buf)
510 } 511 }
511 spin_unlock_irqrestore (&ehci->lock, flags); 512 spin_unlock_irqrestore (&ehci->lock, flags);
512 513
513 return strlen(buf->page); 514 return strlen(buf->output_buf);
514} 515}
515 516
516#define DBG_SCHED_LIMIT 64 517#define DBG_SCHED_LIMIT 64
@@ -531,8 +532,8 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
531 532
532 hcd = bus_to_hcd(buf->bus); 533 hcd = bus_to_hcd(buf->bus);
533 ehci = hcd_to_ehci (hcd); 534 ehci = hcd_to_ehci (hcd);
534 next = buf->page; 535 next = buf->output_buf;
535 size = PAGE_SIZE; 536 size = buf->alloc_size;
536 537
537 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size); 538 temp = scnprintf (next, size, "size = %d\n", ehci->periodic_size);
538 size -= temp; 539 size -= temp;
@@ -649,7 +650,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
649 spin_unlock_irqrestore (&ehci->lock, flags); 650 spin_unlock_irqrestore (&ehci->lock, flags);
650 kfree (seen); 651 kfree (seen);
651 652
652 return PAGE_SIZE - size; 653 return buf->alloc_size - size;
653} 654}
654#undef DBG_SCHED_LIMIT 655#undef DBG_SCHED_LIMIT
655 656
@@ -665,8 +666,8 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
665 666
666 hcd = bus_to_hcd(buf->bus); 667 hcd = bus_to_hcd(buf->bus);
667 ehci = hcd_to_ehci (hcd); 668 ehci = hcd_to_ehci (hcd);
668 next = buf->page; 669 next = buf->output_buf;
669 size = PAGE_SIZE; 670 size = buf->alloc_size;
670 671
671 spin_lock_irqsave (&ehci->lock, flags); 672 spin_lock_irqsave (&ehci->lock, flags);
672 673
@@ -808,7 +809,7 @@ static ssize_t fill_registers_buffer(struct debug_buffer *buf)
808done: 809done:
809 spin_unlock_irqrestore (&ehci->lock, flags); 810 spin_unlock_irqrestore (&ehci->lock, flags);
810 811
811 return PAGE_SIZE - size; 812 return buf->alloc_size - size;
812} 813}
813 814
814static struct debug_buffer *alloc_buffer(struct usb_bus *bus, 815static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
@@ -822,6 +823,7 @@ static struct debug_buffer *alloc_buffer(struct usb_bus *bus,
822 buf->bus = bus; 823 buf->bus = bus;
823 buf->fill_func = fill_func; 824 buf->fill_func = fill_func;
824 mutex_init(&buf->mutex); 825 mutex_init(&buf->mutex);
826 buf->alloc_size = PAGE_SIZE;
825 } 827 }
826 828
827 return buf; 829 return buf;
@@ -831,10 +833,10 @@ static int fill_buffer(struct debug_buffer *buf)
831{ 833{
832 int ret = 0; 834 int ret = 0;
833 835
834 if (!buf->page) 836 if (!buf->output_buf)
835 buf->page = (char *)get_zeroed_page(GFP_KERNEL); 837 buf->output_buf = (char *)vmalloc(buf->alloc_size);
836 838
837 if (!buf->page) { 839 if (!buf->output_buf) {
838 ret = -ENOMEM; 840 ret = -ENOMEM;
839 goto out; 841 goto out;
840 } 842 }
@@ -867,7 +869,7 @@ static ssize_t debug_output(struct file *file, char __user *user_buf,
867 mutex_unlock(&buf->mutex); 869 mutex_unlock(&buf->mutex);
868 870
869 ret = simple_read_from_buffer(user_buf, len, offset, 871 ret = simple_read_from_buffer(user_buf, len, offset,
870 buf->page, buf->count); 872 buf->output_buf, buf->count);
871 873
872out: 874out:
873 return ret; 875 return ret;
@@ -879,8 +881,8 @@ static int debug_close(struct inode *inode, struct file *file)
879 struct debug_buffer *buf = file->private_data; 881 struct debug_buffer *buf = file->private_data;
880 882
881 if (buf) { 883 if (buf) {
882 if (buf->page) 884 if (buf->output_buf)
883 free_page((unsigned long)buf->page); 885 vfree(buf->output_buf);
884 kfree(buf); 886 kfree(buf);
885 } 887 }
886 888
@@ -895,10 +897,14 @@ static int debug_async_open(struct inode *inode, struct file *file)
895 897
896static int debug_periodic_open(struct inode *inode, struct file *file) 898static int debug_periodic_open(struct inode *inode, struct file *file)
897{ 899{
898 file->private_data = alloc_buffer(inode->i_private, 900 struct debug_buffer *buf;
899 fill_periodic_buffer); 901 buf = alloc_buffer(inode->i_private, fill_periodic_buffer);
902 if (!buf)
903 return -ENOMEM;
900 904
901 return file->private_data ? 0 : -ENOMEM; 905 buf->alloc_size = (sizeof(void *) == 4 ? 6 : 8)*PAGE_SIZE;
906 file->private_data = buf;
907 return 0;
902} 908}
903 909
904static int debug_registers_open(struct inode *inode, struct file *file) 910static int debug_registers_open(struct inode *inode, struct file *file)