USB: remove uses of URB_NO_SETUP_DMA_MAP
This patch (as1350) removes all usages of coherent buffers for USB control-request setup-packet buffers. There's no good reason to reserve coherent memory for these things; control requests are hardly ever used in large quantity (the major exception is firmware transfers, and they aren't time-critical). Furthermore, only seven drivers used it. We might as well always use streaming DMA mappings for setup-packet buffers, and remove some extra complexity from usbcore. The DMA-mapping portion of hcd.c is currently in flux. A separate patch will be submitted to remove support for URB_NO_SETUP_DMA_MAP after everything else settles down. The removal should go smoothly, as by then nobody will be using it. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
Родитель
749da5f82f
Коммит
0ede76fcec
|
@ -787,8 +787,7 @@ static int hid_alloc_buffers(struct usb_device *dev, struct hid_device *hid)
|
||||||
&usbhid->inbuf_dma);
|
&usbhid->inbuf_dma);
|
||||||
usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
|
usbhid->outbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
|
||||||
&usbhid->outbuf_dma);
|
&usbhid->outbuf_dma);
|
||||||
usbhid->cr = usb_buffer_alloc(dev, sizeof(*usbhid->cr), GFP_KERNEL,
|
usbhid->cr = kmalloc(sizeof(*usbhid->cr), GFP_KERNEL);
|
||||||
&usbhid->cr_dma);
|
|
||||||
usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
|
usbhid->ctrlbuf = usb_buffer_alloc(dev, usbhid->bufsize, GFP_KERNEL,
|
||||||
&usbhid->ctrlbuf_dma);
|
&usbhid->ctrlbuf_dma);
|
||||||
if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr ||
|
if (!usbhid->inbuf || !usbhid->outbuf || !usbhid->cr ||
|
||||||
|
@ -846,7 +845,7 @@ static void hid_free_buffers(struct usb_device *dev, struct hid_device *hid)
|
||||||
|
|
||||||
usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma);
|
usb_buffer_free(dev, usbhid->bufsize, usbhid->inbuf, usbhid->inbuf_dma);
|
||||||
usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma);
|
usb_buffer_free(dev, usbhid->bufsize, usbhid->outbuf, usbhid->outbuf_dma);
|
||||||
usb_buffer_free(dev, sizeof(*(usbhid->cr)), usbhid->cr, usbhid->cr_dma);
|
kfree(usbhid->cr);
|
||||||
usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
|
usb_buffer_free(dev, usbhid->bufsize, usbhid->ctrlbuf, usbhid->ctrlbuf_dma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1007,9 +1006,8 @@ static int usbhid_start(struct hid_device *hid)
|
||||||
|
|
||||||
usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr,
|
usb_fill_control_urb(usbhid->urbctrl, dev, 0, (void *) usbhid->cr,
|
||||||
usbhid->ctrlbuf, 1, hid_ctrl, hid);
|
usbhid->ctrlbuf, 1, hid_ctrl, hid);
|
||||||
usbhid->urbctrl->setup_dma = usbhid->cr_dma;
|
|
||||||
usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
|
usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
|
||||||
usbhid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
|
usbhid->urbctrl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
|
|
||||||
if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS))
|
if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS))
|
||||||
usbhid_init_reports(hid);
|
usbhid_init_reports(hid);
|
||||||
|
|
|
@ -75,7 +75,6 @@ struct usbhid_device {
|
||||||
|
|
||||||
struct urb *urbctrl; /* Control URB */
|
struct urb *urbctrl; /* Control URB */
|
||||||
struct usb_ctrlrequest *cr; /* Control request struct */
|
struct usb_ctrlrequest *cr; /* Control request struct */
|
||||||
dma_addr_t cr_dma; /* Control request struct dma */
|
|
||||||
struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
|
struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
|
||||||
unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
|
unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
|
||||||
char *ctrlbuf; /* Control buffer */
|
char *ctrlbuf; /* Control buffer */
|
||||||
|
|
|
@ -74,7 +74,6 @@ struct usb_kbd {
|
||||||
unsigned char *new;
|
unsigned char *new;
|
||||||
struct usb_ctrlrequest *cr;
|
struct usb_ctrlrequest *cr;
|
||||||
unsigned char *leds;
|
unsigned char *leds;
|
||||||
dma_addr_t cr_dma;
|
|
||||||
dma_addr_t new_dma;
|
dma_addr_t new_dma;
|
||||||
dma_addr_t leds_dma;
|
dma_addr_t leds_dma;
|
||||||
};
|
};
|
||||||
|
@ -199,7 +198,7 @@ static int usb_kbd_alloc_mem(struct usb_device *dev, struct usb_kbd *kbd)
|
||||||
return -1;
|
return -1;
|
||||||
if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
|
if (!(kbd->new = usb_buffer_alloc(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
|
||||||
return -1;
|
return -1;
|
||||||
if (!(kbd->cr = usb_buffer_alloc(dev, sizeof(struct usb_ctrlrequest), GFP_ATOMIC, &kbd->cr_dma)))
|
if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL)))
|
||||||
return -1;
|
return -1;
|
||||||
if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
|
if (!(kbd->leds = usb_buffer_alloc(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -212,7 +211,7 @@ static void usb_kbd_free_mem(struct usb_device *dev, struct usb_kbd *kbd)
|
||||||
usb_free_urb(kbd->irq);
|
usb_free_urb(kbd->irq);
|
||||||
usb_free_urb(kbd->led);
|
usb_free_urb(kbd->led);
|
||||||
usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
|
usb_buffer_free(dev, 8, kbd->new, kbd->new_dma);
|
||||||
usb_buffer_free(dev, sizeof(struct usb_ctrlrequest), kbd->cr, kbd->cr_dma);
|
kfree(kbd->cr);
|
||||||
usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
|
usb_buffer_free(dev, 1, kbd->leds, kbd->leds_dma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,9 +303,8 @@ static int usb_kbd_probe(struct usb_interface *iface,
|
||||||
usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0),
|
usb_fill_control_urb(kbd->led, dev, usb_sndctrlpipe(dev, 0),
|
||||||
(void *) kbd->cr, kbd->leds, 1,
|
(void *) kbd->cr, kbd->leds, 1,
|
||||||
usb_kbd_led, kbd);
|
usb_kbd_led, kbd);
|
||||||
kbd->led->setup_dma = kbd->cr_dma;
|
|
||||||
kbd->led->transfer_dma = kbd->leds_dma;
|
kbd->led->transfer_dma = kbd->leds_dma;
|
||||||
kbd->led->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
|
kbd->led->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
|
|
||||||
error = input_register_device(kbd->dev);
|
error = input_register_device(kbd->dev);
|
||||||
if (error)
|
if (error)
|
||||||
|
|
|
@ -102,7 +102,6 @@ struct cm109_dev {
|
||||||
struct cm109_ctl_packet *ctl_data;
|
struct cm109_ctl_packet *ctl_data;
|
||||||
dma_addr_t ctl_dma;
|
dma_addr_t ctl_dma;
|
||||||
struct usb_ctrlrequest *ctl_req;
|
struct usb_ctrlrequest *ctl_req;
|
||||||
dma_addr_t ctl_req_dma;
|
|
||||||
struct urb *urb_ctl;
|
struct urb *urb_ctl;
|
||||||
/*
|
/*
|
||||||
* The 3 bitfields below are protected by ctl_submit_lock.
|
* The 3 bitfields below are protected by ctl_submit_lock.
|
||||||
|
@ -629,9 +628,7 @@ static const struct usb_device_id cm109_usb_table[] = {
|
||||||
|
|
||||||
static void cm109_usb_cleanup(struct cm109_dev *dev)
|
static void cm109_usb_cleanup(struct cm109_dev *dev)
|
||||||
{
|
{
|
||||||
if (dev->ctl_req)
|
kfree(dev->ctl_req);
|
||||||
usb_buffer_free(dev->udev, sizeof(*(dev->ctl_req)),
|
|
||||||
dev->ctl_req, dev->ctl_req_dma);
|
|
||||||
if (dev->ctl_data)
|
if (dev->ctl_data)
|
||||||
usb_buffer_free(dev->udev, USB_PKT_LEN,
|
usb_buffer_free(dev->udev, USB_PKT_LEN,
|
||||||
dev->ctl_data, dev->ctl_dma);
|
dev->ctl_data, dev->ctl_dma);
|
||||||
|
@ -696,8 +693,7 @@ static int cm109_usb_probe(struct usb_interface *intf,
|
||||||
if (!dev->ctl_data)
|
if (!dev->ctl_data)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
dev->ctl_req = usb_buffer_alloc(udev, sizeof(*(dev->ctl_req)),
|
dev->ctl_req = kmalloc(sizeof(*(dev->ctl_req)), GFP_KERNEL);
|
||||||
GFP_KERNEL, &dev->ctl_req_dma);
|
|
||||||
if (!dev->ctl_req)
|
if (!dev->ctl_req)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
|
|
||||||
|
@ -735,10 +731,8 @@ static int cm109_usb_probe(struct usb_interface *intf,
|
||||||
usb_fill_control_urb(dev->urb_ctl, udev, usb_sndctrlpipe(udev, 0),
|
usb_fill_control_urb(dev->urb_ctl, udev, usb_sndctrlpipe(udev, 0),
|
||||||
(void *)dev->ctl_req, dev->ctl_data, USB_PKT_LEN,
|
(void *)dev->ctl_req, dev->ctl_data, USB_PKT_LEN,
|
||||||
cm109_urb_ctl_callback, dev);
|
cm109_urb_ctl_callback, dev);
|
||||||
dev->urb_ctl->setup_dma = dev->ctl_req_dma;
|
|
||||||
dev->urb_ctl->transfer_dma = dev->ctl_dma;
|
dev->urb_ctl->transfer_dma = dev->ctl_dma;
|
||||||
dev->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP |
|
dev->urb_ctl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
URB_NO_TRANSFER_DMA_MAP;
|
|
||||||
dev->urb_ctl->dev = udev;
|
dev->urb_ctl->dev = udev;
|
||||||
|
|
||||||
/* find out the physical bus location */
|
/* find out the physical bus location */
|
||||||
|
|
|
@ -64,7 +64,6 @@ struct powermate_device {
|
||||||
dma_addr_t data_dma;
|
dma_addr_t data_dma;
|
||||||
struct urb *irq, *config;
|
struct urb *irq, *config;
|
||||||
struct usb_ctrlrequest *configcr;
|
struct usb_ctrlrequest *configcr;
|
||||||
dma_addr_t configcr_dma;
|
|
||||||
struct usb_device *udev;
|
struct usb_device *udev;
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
spinlock_t lock;
|
spinlock_t lock;
|
||||||
|
@ -182,8 +181,6 @@ static void powermate_sync_state(struct powermate_device *pm)
|
||||||
usb_fill_control_urb(pm->config, pm->udev, usb_sndctrlpipe(pm->udev, 0),
|
usb_fill_control_urb(pm->config, pm->udev, usb_sndctrlpipe(pm->udev, 0),
|
||||||
(void *) pm->configcr, NULL, 0,
|
(void *) pm->configcr, NULL, 0,
|
||||||
powermate_config_complete, pm);
|
powermate_config_complete, pm);
|
||||||
pm->config->setup_dma = pm->configcr_dma;
|
|
||||||
pm->config->transfer_flags |= URB_NO_SETUP_DMA_MAP;
|
|
||||||
|
|
||||||
if (usb_submit_urb(pm->config, GFP_ATOMIC))
|
if (usb_submit_urb(pm->config, GFP_ATOMIC))
|
||||||
printk(KERN_ERR "powermate: usb_submit_urb(config) failed");
|
printk(KERN_ERR "powermate: usb_submit_urb(config) failed");
|
||||||
|
@ -281,8 +278,7 @@ static int powermate_alloc_buffers(struct usb_device *udev, struct powermate_dev
|
||||||
if (!pm->data)
|
if (!pm->data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
pm->configcr = usb_buffer_alloc(udev, sizeof(*(pm->configcr)),
|
pm->configcr = kmalloc(sizeof(*(pm->configcr)), GFP_KERNEL);
|
||||||
GFP_ATOMIC, &pm->configcr_dma);
|
|
||||||
if (!pm->configcr)
|
if (!pm->configcr)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -293,8 +289,7 @@ static void powermate_free_buffers(struct usb_device *udev, struct powermate_dev
|
||||||
{
|
{
|
||||||
usb_buffer_free(udev, POWERMATE_PAYLOAD_SIZE_MAX,
|
usb_buffer_free(udev, POWERMATE_PAYLOAD_SIZE_MAX,
|
||||||
pm->data, pm->data_dma);
|
pm->data, pm->data_dma);
|
||||||
usb_buffer_free(udev, sizeof(*(pm->configcr)),
|
kfree(pm->configcr);
|
||||||
pm->configcr, pm->configcr_dma);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called whenever a USB device matching one in our supported devices table is connected */
|
/* Called whenever a USB device matching one in our supported devices table is connected */
|
||||||
|
|
|
@ -111,7 +111,6 @@ struct yealink_dev {
|
||||||
struct yld_ctl_packet *ctl_data;
|
struct yld_ctl_packet *ctl_data;
|
||||||
dma_addr_t ctl_dma;
|
dma_addr_t ctl_dma;
|
||||||
struct usb_ctrlrequest *ctl_req;
|
struct usb_ctrlrequest *ctl_req;
|
||||||
dma_addr_t ctl_req_dma;
|
|
||||||
struct urb *urb_ctl;
|
struct urb *urb_ctl;
|
||||||
|
|
||||||
char phys[64]; /* physical device path */
|
char phys[64]; /* physical device path */
|
||||||
|
@ -836,8 +835,7 @@ static int usb_cleanup(struct yealink_dev *yld, int err)
|
||||||
usb_free_urb(yld->urb_irq);
|
usb_free_urb(yld->urb_irq);
|
||||||
usb_free_urb(yld->urb_ctl);
|
usb_free_urb(yld->urb_ctl);
|
||||||
|
|
||||||
usb_buffer_free(yld->udev, sizeof(*(yld->ctl_req)),
|
kfree(yld->ctl_req);
|
||||||
yld->ctl_req, yld->ctl_req_dma);
|
|
||||||
usb_buffer_free(yld->udev, USB_PKT_LEN,
|
usb_buffer_free(yld->udev, USB_PKT_LEN,
|
||||||
yld->ctl_data, yld->ctl_dma);
|
yld->ctl_data, yld->ctl_dma);
|
||||||
usb_buffer_free(yld->udev, USB_PKT_LEN,
|
usb_buffer_free(yld->udev, USB_PKT_LEN,
|
||||||
|
@ -896,8 +894,7 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||||
if (!yld->ctl_data)
|
if (!yld->ctl_data)
|
||||||
return usb_cleanup(yld, -ENOMEM);
|
return usb_cleanup(yld, -ENOMEM);
|
||||||
|
|
||||||
yld->ctl_req = usb_buffer_alloc(udev, sizeof(*(yld->ctl_req)),
|
yld->ctl_req = kmalloc(sizeof(*(yld->ctl_req)), GFP_KERNEL);
|
||||||
GFP_ATOMIC, &yld->ctl_req_dma);
|
|
||||||
if (yld->ctl_req == NULL)
|
if (yld->ctl_req == NULL)
|
||||||
return usb_cleanup(yld, -ENOMEM);
|
return usb_cleanup(yld, -ENOMEM);
|
||||||
|
|
||||||
|
@ -936,10 +933,8 @@ static int usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
||||||
usb_fill_control_urb(yld->urb_ctl, udev, usb_sndctrlpipe(udev, 0),
|
usb_fill_control_urb(yld->urb_ctl, udev, usb_sndctrlpipe(udev, 0),
|
||||||
(void *)yld->ctl_req, yld->ctl_data, USB_PKT_LEN,
|
(void *)yld->ctl_req, yld->ctl_data, USB_PKT_LEN,
|
||||||
urb_ctl_callback, yld);
|
urb_ctl_callback, yld);
|
||||||
yld->urb_ctl->setup_dma = yld->ctl_req_dma;
|
|
||||||
yld->urb_ctl->transfer_dma = yld->ctl_dma;
|
yld->urb_ctl->transfer_dma = yld->ctl_dma;
|
||||||
yld->urb_ctl->transfer_flags |= URB_NO_SETUP_DMA_MAP |
|
yld->urb_ctl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
URB_NO_TRANSFER_DMA_MAP;
|
|
||||||
yld->urb_ctl->dev = udev;
|
yld->urb_ctl->dev = udev;
|
||||||
|
|
||||||
/* find out the physical bus location */
|
/* find out the physical bus location */
|
||||||
|
|
|
@ -396,8 +396,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags)
|
||||||
return -EPIPE; /* The most suitable error code :-) */
|
return -EPIPE; /* The most suitable error code :-) */
|
||||||
|
|
||||||
/* enforce simple/standard policy */
|
/* enforce simple/standard policy */
|
||||||
allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP |
|
allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK |
|
||||||
URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER);
|
URB_FREE_BUFFER);
|
||||||
switch (xfertype) {
|
switch (xfertype) {
|
||||||
case USB_ENDPOINT_XFER_BULK:
|
case USB_ENDPOINT_XFER_BULK:
|
||||||
if (is_out)
|
if (is_out)
|
||||||
|
|
|
@ -775,7 +775,7 @@ EXPORT_SYMBOL_GPL(usb_free_coherent);
|
||||||
* @urb: urb whose transfer_buffer/setup_packet will be mapped
|
* @urb: urb whose transfer_buffer/setup_packet will be mapped
|
||||||
*
|
*
|
||||||
* Return value is either null (indicating no buffer could be mapped), or
|
* Return value is either null (indicating no buffer could be mapped), or
|
||||||
* the parameter. URB_NO_TRANSFER_DMA_MAP and URB_NO_SETUP_DMA_MAP are
|
* the parameter. URB_NO_TRANSFER_DMA_MAP is
|
||||||
* added to urb->transfer_flags if the operation succeeds. If the device
|
* added to urb->transfer_flags if the operation succeeds. If the device
|
||||||
* is connected to this system through a non-DMA controller, this operation
|
* is connected to this system through a non-DMA controller, this operation
|
||||||
* always succeeds.
|
* always succeeds.
|
||||||
|
@ -803,17 +803,11 @@ struct urb *usb_buffer_map(struct urb *urb)
|
||||||
urb->transfer_buffer, urb->transfer_buffer_length,
|
urb->transfer_buffer, urb->transfer_buffer_length,
|
||||||
usb_pipein(urb->pipe)
|
usb_pipein(urb->pipe)
|
||||||
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
|
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
|
||||||
if (usb_pipecontrol(urb->pipe))
|
|
||||||
urb->setup_dma = dma_map_single(controller,
|
|
||||||
urb->setup_packet,
|
|
||||||
sizeof(struct usb_ctrlrequest),
|
|
||||||
DMA_TO_DEVICE);
|
|
||||||
/* FIXME generic api broken like pci, can't report errors */
|
/* FIXME generic api broken like pci, can't report errors */
|
||||||
/* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */
|
/* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */
|
||||||
} else
|
} else
|
||||||
urb->transfer_dma = ~0;
|
urb->transfer_dma = ~0;
|
||||||
urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP
|
urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
| URB_NO_SETUP_DMA_MAP);
|
|
||||||
return urb;
|
return urb;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(usb_buffer_map);
|
EXPORT_SYMBOL_GPL(usb_buffer_map);
|
||||||
|
@ -881,14 +875,8 @@ void usb_buffer_unmap(struct urb *urb)
|
||||||
urb->transfer_dma, urb->transfer_buffer_length,
|
urb->transfer_dma, urb->transfer_buffer_length,
|
||||||
usb_pipein(urb->pipe)
|
usb_pipein(urb->pipe)
|
||||||
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
|
? DMA_FROM_DEVICE : DMA_TO_DEVICE);
|
||||||
if (usb_pipecontrol(urb->pipe))
|
|
||||||
dma_unmap_single(controller,
|
|
||||||
urb->setup_dma,
|
|
||||||
sizeof(struct usb_ctrlrequest),
|
|
||||||
DMA_TO_DEVICE);
|
|
||||||
}
|
}
|
||||||
urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP
|
urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP;
|
||||||
| URB_NO_SETUP_DMA_MAP);
|
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(usb_buffer_unmap);
|
EXPORT_SYMBOL_GPL(usb_buffer_unmap);
|
||||||
#endif /* 0 */
|
#endif /* 0 */
|
||||||
|
|
|
@ -977,15 +977,13 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param)
|
||||||
if (!u)
|
if (!u)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL,
|
reqp = kmalloc(sizeof *reqp, GFP_KERNEL);
|
||||||
&u->setup_dma);
|
|
||||||
if (!reqp)
|
if (!reqp)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
reqp->setup = req;
|
reqp->setup = req;
|
||||||
reqp->number = i % NUM_SUBCASES;
|
reqp->number = i % NUM_SUBCASES;
|
||||||
reqp->expected = expected;
|
reqp->expected = expected;
|
||||||
u->setup_packet = (char *) &reqp->setup;
|
u->setup_packet = (char *) &reqp->setup;
|
||||||
u->transfer_flags |= URB_NO_SETUP_DMA_MAP;
|
|
||||||
|
|
||||||
u->context = &context;
|
u->context = &context;
|
||||||
u->complete = ctrl_complete;
|
u->complete = ctrl_complete;
|
||||||
|
@ -1017,10 +1015,7 @@ cleanup:
|
||||||
if (!urb [i])
|
if (!urb [i])
|
||||||
continue;
|
continue;
|
||||||
urb [i]->dev = udev;
|
urb [i]->dev = udev;
|
||||||
if (urb [i]->setup_packet)
|
kfree(urb[i]->setup_packet);
|
||||||
usb_buffer_free (udev, sizeof (struct usb_ctrlrequest),
|
|
||||||
urb [i]->setup_packet,
|
|
||||||
urb [i]->setup_dma);
|
|
||||||
simple_free_urb (urb [i]);
|
simple_free_urb (urb [i]);
|
||||||
}
|
}
|
||||||
kfree (urb);
|
kfree (urb);
|
||||||
|
|
|
@ -147,11 +147,9 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
|
||||||
* hasn't been mapped for DMA. Yes, this is clunky, but it's
|
* hasn't been mapped for DMA. Yes, this is clunky, but it's
|
||||||
* easier than always having the caller tell us whether the
|
* easier than always having the caller tell us whether the
|
||||||
* transfer buffer has already been mapped. */
|
* transfer buffer has already been mapped. */
|
||||||
us->current_urb->transfer_flags = URB_NO_SETUP_DMA_MAP;
|
|
||||||
if (us->current_urb->transfer_buffer == us->iobuf)
|
if (us->current_urb->transfer_buffer == us->iobuf)
|
||||||
us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
us->current_urb->transfer_dma = us->iobuf_dma;
|
us->current_urb->transfer_dma = us->iobuf_dma;
|
||||||
us->current_urb->setup_dma = us->cr_dma;
|
|
||||||
|
|
||||||
/* submit the URB */
|
/* submit the URB */
|
||||||
status = usb_submit_urb(us->current_urb, GFP_NOIO);
|
status = usb_submit_urb(us->current_urb, GFP_NOIO);
|
||||||
|
|
|
@ -407,9 +407,8 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf)
|
||||||
/* Store our private data in the interface */
|
/* Store our private data in the interface */
|
||||||
usb_set_intfdata(intf, us);
|
usb_set_intfdata(intf, us);
|
||||||
|
|
||||||
/* Allocate the device-related DMA-mapped buffers */
|
/* Allocate the control/setup and DMA-mapped buffers */
|
||||||
us->cr = usb_buffer_alloc(us->pusb_dev, sizeof(*us->cr),
|
us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL);
|
||||||
GFP_KERNEL, &us->cr_dma);
|
|
||||||
if (!us->cr) {
|
if (!us->cr) {
|
||||||
US_DEBUGP("usb_ctrlrequest allocation failed\n");
|
US_DEBUGP("usb_ctrlrequest allocation failed\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -757,13 +756,9 @@ static void dissociate_dev(struct us_data *us)
|
||||||
{
|
{
|
||||||
US_DEBUGP("-- %s\n", __func__);
|
US_DEBUGP("-- %s\n", __func__);
|
||||||
|
|
||||||
/* Free the device-related DMA-mapped buffers */
|
/* Free the buffers */
|
||||||
if (us->cr)
|
kfree(us->cr);
|
||||||
usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr,
|
usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
|
||||||
us->cr_dma);
|
|
||||||
if (us->iobuf)
|
|
||||||
usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf,
|
|
||||||
us->iobuf_dma);
|
|
||||||
|
|
||||||
/* Remove our private data from the interface */
|
/* Remove our private data from the interface */
|
||||||
usb_set_intfdata(us->pusb_intf, NULL);
|
usb_set_intfdata(us->pusb_intf, NULL);
|
||||||
|
|
|
@ -139,8 +139,7 @@ struct us_data {
|
||||||
struct usb_ctrlrequest *cr; /* control requests */
|
struct usb_ctrlrequest *cr; /* control requests */
|
||||||
struct usb_sg_request current_sg; /* scatter-gather req. */
|
struct usb_sg_request current_sg; /* scatter-gather req. */
|
||||||
unsigned char *iobuf; /* I/O buffer */
|
unsigned char *iobuf; /* I/O buffer */
|
||||||
dma_addr_t cr_dma; /* buffer DMA addresses */
|
dma_addr_t iobuf_dma; /* buffer DMA addresses */
|
||||||
dma_addr_t iobuf_dma;
|
|
||||||
struct task_struct *ctl_thread; /* the control thread */
|
struct task_struct *ctl_thread; /* the control thread */
|
||||||
|
|
||||||
/* mutual exclusion and synchronization structures */
|
/* mutual exclusion and synchronization structures */
|
||||||
|
|
|
@ -474,8 +474,6 @@ static void __wa_xfer_setup_hdr0(struct wa_xfer *xfer,
|
||||||
struct wa_xfer_ctl *xfer_ctl =
|
struct wa_xfer_ctl *xfer_ctl =
|
||||||
container_of(xfer_hdr0, struct wa_xfer_ctl, hdr);
|
container_of(xfer_hdr0, struct wa_xfer_ctl, hdr);
|
||||||
xfer_ctl->bmAttribute = xfer->is_inbound ? 1 : 0;
|
xfer_ctl->bmAttribute = xfer->is_inbound ? 1 : 0;
|
||||||
BUG_ON(xfer->urb->transfer_flags & URB_NO_SETUP_DMA_MAP
|
|
||||||
&& xfer->urb->setup_packet == NULL);
|
|
||||||
memcpy(&xfer_ctl->baSetupData, xfer->urb->setup_packet,
|
memcpy(&xfer_ctl->baSetupData, xfer->urb->setup_packet,
|
||||||
sizeof(xfer_ctl->baSetupData));
|
sizeof(xfer_ctl->baSetupData));
|
||||||
break;
|
break;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче