mirror of
https://github.com/adulau/aha.git
synced 2025-01-02 14:13:18 +00:00
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 <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
1720058343
commit
4d6cd48380
3 changed files with 9 additions and 6 deletions
|
@ -301,6 +301,7 @@ static void mon_bus_init(struct dentry *mondir, struct usb_bus *ubus)
|
||||||
*/
|
*/
|
||||||
mbus->u_bus = ubus;
|
mbus->u_bus = ubus;
|
||||||
ubus->mon_bus = mbus;
|
ubus->mon_bus = mbus;
|
||||||
|
mbus->uses_dma = ubus->uses_dma;
|
||||||
|
|
||||||
rc = snprintf(name, NAMESZ, "%dt", ubus->busnum);
|
rc = snprintf(name, NAMESZ, "%dt", ubus->busnum);
|
||||||
if (rc <= 0 || rc >= NAMESZ)
|
if (rc <= 0 || rc >= NAMESZ)
|
||||||
|
|
|
@ -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,
|
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')
|
if (!usb_pipecontrol(urb->pipe) || ev_type != 'S')
|
||||||
return '-';
|
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);
|
return mon_dmapeek(ep->setup, urb->setup_dma, SETUP_MAX);
|
||||||
if (urb->setup_packet == NULL)
|
if (urb->setup_packet == NULL)
|
||||||
return 'Z'; /* '0' would be not as pretty. */
|
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,
|
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;
|
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
|
* contain non-NULL garbage in case the upper level promised to
|
||||||
* set DMA for the HCD.
|
* 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);
|
return mon_dmapeek(ep->data, urb->transfer_dma, len);
|
||||||
|
|
||||||
if (urb->transfer_buffer == NULL)
|
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 */
|
/* Collecting status makes debugging sense for submits, too */
|
||||||
ep->status = urb->status;
|
ep->status = urb->status;
|
||||||
|
|
||||||
ep->setup_flag = mon_text_get_setup(ep, urb, 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);
|
ep->data_flag = mon_text_get_data(ep, urb, ep->length, ev_type,
|
||||||
|
rp->r.m_bus);
|
||||||
|
|
||||||
rp->nevents++;
|
rp->nevents++;
|
||||||
list_add_tail(&ep->e_link, &rp->e_list);
|
list_add_tail(&ep->e_link, &rp->e_list);
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct mon_bus {
|
||||||
struct dentry *dent_s; /* Debugging file */
|
struct dentry *dent_s; /* Debugging file */
|
||||||
struct dentry *dent_t; /* Text interface file */
|
struct dentry *dent_t; /* Text interface file */
|
||||||
struct usb_bus *u_bus;
|
struct usb_bus *u_bus;
|
||||||
|
int uses_dma;
|
||||||
|
|
||||||
/* Ref */
|
/* Ref */
|
||||||
int nreaders; /* Under mon_lock AND mbus->lock */
|
int nreaders; /* Under mon_lock AND mbus->lock */
|
||||||
|
|
Loading…
Reference in a new issue