From 4d6cd48380c4d361cc8ec34359df22377d85d202 Mon Sep 17 00:00:00 2001 From: Alan Stern Date: Wed, 30 Aug 2006 11:35:21 -0400 Subject: [PATCH] usbmon: don't call mon_dmapeek if DMA isn't being used 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 Signed-off-by: Greg Kroah-Hartman --- drivers/usb/mon/mon_main.c | 1 + drivers/usb/mon/mon_text.c | 13 +++++++------ drivers/usb/mon/usb_mon.h | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/usb/mon/mon_main.c b/drivers/usb/mon/mon_main.c index e0ed36cdfd..394bbf2f68 100644 --- a/drivers/usb/mon/mon_main.c +++ b/drivers/usb/mon/mon_main.c @@ -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) diff --git a/drivers/usb/mon/mon_text.c b/drivers/usb/mon/mon_text.c index 775e374a96..7a2346c532 100644 --- a/drivers/usb/mon/mon_text.c +++ b/drivers/usb/mon/mon_text.c @@ -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. */ @@ -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; @@ -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) @@ -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); diff --git a/drivers/usb/mon/usb_mon.h b/drivers/usb/mon/usb_mon.h index 50efc8ee7c..ab9d02d5df 100644 --- a/drivers/usb/mon/usb_mon.h +++ b/drivers/usb/mon/usb_mon.h @@ -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 */ -- 2.39.5