aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@redhat.com>2006-06-09 23:10:10 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2006-06-21 18:04:17 -0400
commit5b1c674d223eef6c6494be8be91e9e3a3054817e (patch)
tree4f7cbbc36d90ec00cd9f958b62cbfc87f550f34f /drivers/usb
parent4bc203d997c0dc1eada4cc9681372c2f7a456c46 (diff)
[PATCH] USB: update usbmon, fix glued lines
This update contains one bug fix: some lines can come out truncated, because of the safety cutoff. This happened because I forgot to update the size when status packets began to be printed. The rest is: - Comments updates - Allow snooping with pkmap on x86_64, which is cache-coherent - Enlarge event buffers (certainly we can have a couple of pages) - Add event counter First touch upon usbmon for 2.6.18. Signed-off-by: Pete Zaitcev <zaitcev@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/mon/mon_dma.c5
-rw-r--r--drivers/usb/mon/mon_main.c3
-rw-r--r--drivers/usb/mon/mon_stat.c4
-rw-r--r--drivers/usb/mon/mon_text.c9
-rw-r--r--drivers/usb/mon/usb_mon.h1
5 files changed, 15 insertions, 7 deletions
diff --git a/drivers/usb/mon/mon_dma.c b/drivers/usb/mon/mon_dma.c
index 0a1367b760a0..ddcfc01e77a0 100644
--- a/drivers/usb/mon/mon_dma.c
+++ b/drivers/usb/mon/mon_dma.c
@@ -13,7 +13,10 @@
13#include <linux/usb.h> /* Only needed for declarations in usb_mon.h */ 13#include <linux/usb.h> /* Only needed for declarations in usb_mon.h */
14#include "usb_mon.h" 14#include "usb_mon.h"
15 15
16#ifdef __i386__ /* CONFIG_ARCH_I386 does not exit */ 16/*
17 * PC-compatibles, are, fortunately, sufficiently cache-coherent for this.
18 */
19#if defined(__i386__) || defined(__x86_64__) /* CONFIG_ARCH_I386 doesn't exit */
17#define MON_HAS_UNMAP 1 20#define MON_HAS_UNMAP 1
18 21
19#define phys_to_page(phys) pfn_to_page((phys) >> PAGE_SHIFT) 22#define phys_to_page(phys) pfn_to_page((phys) >> PAGE_SHIFT)
diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c
index 6ecc27302211..86db92b4915b 100644
--- a/drivers/usb/mon/mon_main.c
+++ b/drivers/usb/mon/mon_main.c
@@ -97,6 +97,7 @@ static void mon_submit(struct usb_bus *ubus, struct urb *urb)
97 if (mbus->nreaders == 0) 97 if (mbus->nreaders == 0)
98 goto out_locked; 98 goto out_locked;
99 99
100 mbus->cnt_events++;
100 list_for_each (pos, &mbus->r_list) { 101 list_for_each (pos, &mbus->r_list) {
101 r = list_entry(pos, struct mon_reader, r_link); 102 r = list_entry(pos, struct mon_reader, r_link);
102 r->rnf_submit(r->r_data, urb); 103 r->rnf_submit(r->r_data, urb);
@@ -152,6 +153,7 @@ static void mon_complete(struct usb_bus *ubus, struct urb *urb)
152 } 153 }
153 154
154 spin_lock_irqsave(&mbus->lock, flags); 155 spin_lock_irqsave(&mbus->lock, flags);
156 mbus->cnt_events++;
155 list_for_each (pos, &mbus->r_list) { 157 list_for_each (pos, &mbus->r_list) {
156 r = list_entry(pos, struct mon_reader, r_link); 158 r = list_entry(pos, struct mon_reader, r_link);
157 r->rnf_complete(r->r_data, urb); 159 r->rnf_complete(r->r_data, urb);
@@ -163,7 +165,6 @@ static void mon_complete(struct usb_bus *ubus, struct urb *urb)
163 165
164/* 166/*
165 * Stop monitoring. 167 * Stop monitoring.
166 * Obviously this must be well locked, so no need to play with mb's.
167 */ 168 */
168static void mon_stop(struct mon_bus *mbus) 169static void mon_stop(struct mon_bus *mbus)
169{ 170{
diff --git a/drivers/usb/mon/mon_stat.c b/drivers/usb/mon/mon_stat.c
index 6e4b165d070a..1fe01d994a79 100644
--- a/drivers/usb/mon/mon_stat.c
+++ b/drivers/usb/mon/mon_stat.c
@@ -31,8 +31,8 @@ static int mon_stat_open(struct inode *inode, struct file *file)
31 mbus = inode->u.generic_ip; 31 mbus = inode->u.generic_ip;
32 32
33 sp->slen = snprintf(sp->str, STAT_BUF_SIZE, 33 sp->slen = snprintf(sp->str, STAT_BUF_SIZE,
34 "nreaders %d text_lost %u\n", 34 "nreaders %d events %u text_lost %u\n",
35 mbus->nreaders, mbus->cnt_text_lost); 35 mbus->nreaders, mbus->cnt_events, mbus->cnt_text_lost);
36 36
37 file->private_data = sp; 37 file->private_data = sp;
38 return 0; 38 return 0;
diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c
index ac043ec2b8dc..9f9236bf62d2 100644
--- a/drivers/usb/mon/mon_text.c
+++ b/drivers/usb/mon/mon_text.c
@@ -26,10 +26,13 @@
26 26
27/* 27/*
28 * This limit exists to prevent OOMs when the user process stops reading. 28 * This limit exists to prevent OOMs when the user process stops reading.
29 * If usbmon were available to unprivileged processes, it might be open
30 * to a local DoS. But we have to keep to root in order to prevent
31 * password sniffing from HID devices.
29 */ 32 */
30#define EVENT_MAX 25 33#define EVENT_MAX (2*PAGE_SIZE / sizeof(struct mon_event_text))
31 34
32#define PRINTF_DFL 130 35#define PRINTF_DFL 160
33 36
34struct mon_event_text { 37struct mon_event_text {
35 struct list_head e_link; 38 struct list_head e_link;
@@ -111,7 +114,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
111 * number of corner cases, but it seems that the following is 114 * number of corner cases, but it seems that the following is
112 * more or less safe. 115 * more or less safe.
113 * 116 *
114 * We do not even try to look transfer_buffer, because it can 117 * We do not even try to look at transfer_buffer, because it can
115 * contain non-NULL garbage in case the upper level promised to 118 * contain non-NULL garbage in case the upper level promised to
116 * set DMA for the HCD. 119 * set DMA for the HCD.
117 */ 120 */
diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h
index 8e0613c350cc..92702835b1e5 100644
--- a/drivers/usb/mon/usb_mon.h
+++ b/drivers/usb/mon/usb_mon.h
@@ -27,6 +27,7 @@ struct mon_bus {
27 struct kref ref; /* Under mon_lock */ 27 struct kref ref; /* Under mon_lock */
28 28
29 /* Stats */ 29 /* Stats */
30 unsigned int cnt_events;
30 unsigned int cnt_text_lost; 31 unsigned int cnt_text_lost;
31}; 32};
32 33