Skip to content

Commit

Permalink
usbmon: don't call mon_dmapeek if DMA isn't being used
Browse files Browse the repository at this point in the history
This patch (as755b) fixes a bug in usbmon.  Rather than assuming all
USB host controllers use DMA, the code will check the usb_bus data
structure.  If DMA isn't used, we don't want to try peeking into a
non-existent DMA buffer!

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Sep 27, 2006
1 parent 1720058 commit 4d6cd48
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions drivers/usb/mon/mon_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus)
*/
mbus->u_bus = ubus;
ubus->mon_bus = mbus;
mbus->uses_dma = ubus->uses_dma;

rc = snprintf(name, NAMESZ, "%dt", ubus->busnum);
if (rc <= 0 || rc >= NAMESZ)
Expand Down
13 changes: 7 additions & 6 deletions drivers/usb/mon/mon_text.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ static void mon_text_ctor(void *, kmem_cache_t *, unsigned long);
*/

static inline char mon_text_get_setup(struct mon_event_text *ep,
struct urb *urb, char ev_type)
struct urb *urb, char ev_type, struct mon_bus *mbus)
{

if (!usb_pipecontrol(urb->pipe) || ev_type != 'S')
return '-';

if (urb->transfer_flags & URB_NO_SETUP_DMA_MAP)
if (mbus->uses_dma && (urb->transfer_flags & URB_NO_SETUP_DMA_MAP))
return mon_dmapeek(ep->setup, urb->setup_dma, SETUP_MAX);
if (urb->setup_packet == NULL)
return 'Z'; /* '0' would be not as pretty. */
Expand All @@ -91,7 +91,7 @@ static inline char mon_text_get_setup(struct mon_event_text *ep,
}

static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
int len, char ev_type)
int len, char ev_type, struct mon_bus *mbus)
{
int pipe = urb->pipe;

Expand All @@ -117,7 +117,7 @@ static inline char mon_text_get_data(struct mon_event_text *ep, struct urb *urb,
* contain non-NULL garbage in case the upper level promised to
* set DMA for the HCD.
*/
if (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)
if (mbus->uses_dma && (urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP))
return mon_dmapeek(ep->data, urb->transfer_dma, len);

if (urb->transfer_buffer == NULL)
Expand Down Expand Up @@ -161,8 +161,9 @@ static void mon_text_event(struct mon_reader_text *rp, struct urb *urb,
/* Collecting status makes debugging sense for submits, too */
ep->status = urb->status;

ep->setup_flag = mon_text_get_setup(ep, urb, ev_type);
ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type);
ep->setup_flag = mon_text_get_setup(ep, urb, ev_type, rp->r.m_bus);
ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type,
rp->r.m_bus);

rp->nevents++;
list_add_tail(&ep->e_link, &rp->e_list);
Expand Down
1 change: 1 addition & 0 deletions drivers/usb/mon/usb_mon.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct mon_bus {
struct dentry *dent_s; /* Debugging file */
struct dentry *dent_t; /* Text interface file */
struct usb_bus *u_bus;
int uses_dma;

/* Ref */
int nreaders; /* Under mon_lock AND mbus->lock */
Expand Down

0 comments on commit 4d6cd48

Please sign in to comment.