diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-03-05 15:10:17 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:31 -0400 |
commit | 0ede76fcec5415ef82a423a95120286895822e2d (patch) | |
tree | 61aa2a0b499a0101033c59b8884328bdb31e5956 /drivers/usb | |
parent | 749da5f82fe33ff68dd4aa1a5e35cd9aa6246dab (diff) |
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>
Diffstat (limited to 'drivers/usb')
-rw-r--r-- | drivers/usb/core/urb.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 18 | ||||
-rw-r--r-- | drivers/usb/misc/usbtest.c | 9 | ||||
-rw-r--r-- | drivers/usb/storage/transport.c | 2 | ||||
-rw-r--r-- | drivers/usb/storage/usb.c | 15 | ||||
-rw-r--r-- | drivers/usb/storage/usb.h | 3 | ||||
-rw-r--r-- | drivers/usb/wusbcore/wa-xfer.c | 2 |
7 files changed, 13 insertions, 40 deletions
diff --git a/drivers/usb/core/urb.c b/drivers/usb/core/urb.c index 09301f4b7225..2532a0917f8c 100644 --- a/drivers/usb/core/urb.c +++ b/drivers/usb/core/urb.c | |||
@@ -396,8 +396,8 @@ int usb_submit_urb(struct urb *urb, gfp_t mem_flags) | |||
396 | return -EPIPE; /* The most suitable error code :-) */ | 396 | return -EPIPE; /* The most suitable error code :-) */ |
397 | 397 | ||
398 | /* enforce simple/standard policy */ | 398 | /* enforce simple/standard policy */ |
399 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP | | 399 | allowed = (URB_NO_TRANSFER_DMA_MAP | URB_NO_INTERRUPT | URB_DIR_MASK | |
400 | URB_NO_INTERRUPT | URB_DIR_MASK | URB_FREE_BUFFER); | 400 | URB_FREE_BUFFER); |
401 | switch (xfertype) { | 401 | switch (xfertype) { |
402 | case USB_ENDPOINT_XFER_BULK: | 402 | case USB_ENDPOINT_XFER_BULK: |
403 | if (is_out) | 403 | if (is_out) |
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 1088abb4416c..097172e2ba06 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -775,7 +775,7 @@ EXPORT_SYMBOL_GPL(usb_free_coherent); | |||
775 | * @urb: urb whose transfer_buffer/setup_packet will be mapped | 775 | * @urb: urb whose transfer_buffer/setup_packet will be mapped |
776 | * | 776 | * |
777 | * Return value is either null (indicating no buffer could be mapped), or | 777 | * Return value is either null (indicating no buffer could be mapped), or |
778 | * the parameter. URB_NO_TRANSFER_DMA_MAP and URB_NO_SETUP_DMA_MAP are | 778 | * the parameter. URB_NO_TRANSFER_DMA_MAP is |
779 | * added to urb->transfer_flags if the operation succeeds. If the device | 779 | * added to urb->transfer_flags if the operation succeeds. If the device |
780 | * is connected to this system through a non-DMA controller, this operation | 780 | * is connected to this system through a non-DMA controller, this operation |
781 | * always succeeds. | 781 | * always succeeds. |
@@ -803,17 +803,11 @@ struct urb *usb_buffer_map(struct urb *urb) | |||
803 | urb->transfer_buffer, urb->transfer_buffer_length, | 803 | urb->transfer_buffer, urb->transfer_buffer_length, |
804 | usb_pipein(urb->pipe) | 804 | usb_pipein(urb->pipe) |
805 | ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 805 | ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
806 | if (usb_pipecontrol(urb->pipe)) | ||
807 | urb->setup_dma = dma_map_single(controller, | ||
808 | urb->setup_packet, | ||
809 | sizeof(struct usb_ctrlrequest), | ||
810 | DMA_TO_DEVICE); | ||
811 | /* FIXME generic api broken like pci, can't report errors */ | 806 | /* FIXME generic api broken like pci, can't report errors */ |
812 | /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ | 807 | /* if (urb->transfer_dma == DMA_ADDR_INVALID) return 0; */ |
813 | } else | 808 | } else |
814 | urb->transfer_dma = ~0; | 809 | urb->transfer_dma = ~0; |
815 | urb->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP | 810 | urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
816 | | URB_NO_SETUP_DMA_MAP); | ||
817 | return urb; | 811 | return urb; |
818 | } | 812 | } |
819 | EXPORT_SYMBOL_GPL(usb_buffer_map); | 813 | EXPORT_SYMBOL_GPL(usb_buffer_map); |
@@ -881,14 +875,8 @@ void usb_buffer_unmap(struct urb *urb) | |||
881 | urb->transfer_dma, urb->transfer_buffer_length, | 875 | urb->transfer_dma, urb->transfer_buffer_length, |
882 | usb_pipein(urb->pipe) | 876 | usb_pipein(urb->pipe) |
883 | ? DMA_FROM_DEVICE : DMA_TO_DEVICE); | 877 | ? DMA_FROM_DEVICE : DMA_TO_DEVICE); |
884 | if (usb_pipecontrol(urb->pipe)) | ||
885 | dma_unmap_single(controller, | ||
886 | urb->setup_dma, | ||
887 | sizeof(struct usb_ctrlrequest), | ||
888 | DMA_TO_DEVICE); | ||
889 | } | 878 | } |
890 | urb->transfer_flags &= ~(URB_NO_TRANSFER_DMA_MAP | 879 | urb->transfer_flags &= ~URB_NO_TRANSFER_DMA_MAP; |
891 | | URB_NO_SETUP_DMA_MAP); | ||
892 | } | 880 | } |
893 | EXPORT_SYMBOL_GPL(usb_buffer_unmap); | 881 | EXPORT_SYMBOL_GPL(usb_buffer_unmap); |
894 | #endif /* 0 */ | 882 | #endif /* 0 */ |
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c index a21cce6f7403..9dcc82337ced 100644 --- a/drivers/usb/misc/usbtest.c +++ b/drivers/usb/misc/usbtest.c | |||
@@ -977,15 +977,13 @@ test_ctrl_queue (struct usbtest_dev *dev, struct usbtest_param *param) | |||
977 | if (!u) | 977 | if (!u) |
978 | goto cleanup; | 978 | goto cleanup; |
979 | 979 | ||
980 | reqp = usb_buffer_alloc (udev, sizeof *reqp, GFP_KERNEL, | 980 | reqp = kmalloc(sizeof *reqp, GFP_KERNEL); |
981 | &u->setup_dma); | ||
982 | if (!reqp) | 981 | if (!reqp) |
983 | goto cleanup; | 982 | goto cleanup; |
984 | reqp->setup = req; | 983 | reqp->setup = req; |
985 | reqp->number = i % NUM_SUBCASES; | 984 | reqp->number = i % NUM_SUBCASES; |
986 | reqp->expected = expected; | 985 | reqp->expected = expected; |
987 | u->setup_packet = (char *) &reqp->setup; | 986 | u->setup_packet = (char *) &reqp->setup; |
988 | u->transfer_flags |= URB_NO_SETUP_DMA_MAP; | ||
989 | 987 | ||
990 | u->context = &context; | 988 | u->context = &context; |
991 | u->complete = ctrl_complete; | 989 | u->complete = ctrl_complete; |
@@ -1017,10 +1015,7 @@ cleanup: | |||
1017 | if (!urb [i]) | 1015 | if (!urb [i]) |
1018 | continue; | 1016 | continue; |
1019 | urb [i]->dev = udev; | 1017 | urb [i]->dev = udev; |
1020 | if (urb [i]->setup_packet) | 1018 | kfree(urb[i]->setup_packet); |
1021 | usb_buffer_free (udev, sizeof (struct usb_ctrlrequest), | ||
1022 | urb [i]->setup_packet, | ||
1023 | urb [i]->setup_dma); | ||
1024 | simple_free_urb (urb [i]); | 1019 | simple_free_urb (urb [i]); |
1025 | } | 1020 | } |
1026 | kfree (urb); | 1021 | kfree (urb); |
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index f253edec3bb8..44716427c51c 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c | |||
@@ -147,11 +147,9 @@ static int usb_stor_msg_common(struct us_data *us, int timeout) | |||
147 | * hasn't been mapped for DMA. Yes, this is clunky, but it's | 147 | * hasn't been mapped for DMA. Yes, this is clunky, but it's |
148 | * easier than always having the caller tell us whether the | 148 | * easier than always having the caller tell us whether the |
149 | * transfer buffer has already been mapped. */ | 149 | * transfer buffer has already been mapped. */ |
150 | us->current_urb->transfer_flags = URB_NO_SETUP_DMA_MAP; | ||
151 | if (us->current_urb->transfer_buffer == us->iobuf) | 150 | if (us->current_urb->transfer_buffer == us->iobuf) |
152 | us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | 151 | us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; |
153 | us->current_urb->transfer_dma = us->iobuf_dma; | 152 | us->current_urb->transfer_dma = us->iobuf_dma; |
154 | us->current_urb->setup_dma = us->cr_dma; | ||
155 | 153 | ||
156 | /* submit the URB */ | 154 | /* submit the URB */ |
157 | status = usb_submit_urb(us->current_urb, GFP_NOIO); | 155 | status = usb_submit_urb(us->current_urb, GFP_NOIO); |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index bbeeb92a2131..c54a370c76c5 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c | |||
@@ -407,9 +407,8 @@ static int associate_dev(struct us_data *us, struct usb_interface *intf) | |||
407 | /* Store our private data in the interface */ | 407 | /* Store our private data in the interface */ |
408 | usb_set_intfdata(intf, us); | 408 | usb_set_intfdata(intf, us); |
409 | 409 | ||
410 | /* Allocate the device-related DMA-mapped buffers */ | 410 | /* Allocate the control/setup and DMA-mapped buffers */ |
411 | us->cr = usb_buffer_alloc(us->pusb_dev, sizeof(*us->cr), | 411 | us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL); |
412 | GFP_KERNEL, &us->cr_dma); | ||
413 | if (!us->cr) { | 412 | if (!us->cr) { |
414 | US_DEBUGP("usb_ctrlrequest allocation failed\n"); | 413 | US_DEBUGP("usb_ctrlrequest allocation failed\n"); |
415 | return -ENOMEM; | 414 | return -ENOMEM; |
@@ -757,13 +756,9 @@ static void dissociate_dev(struct us_data *us) | |||
757 | { | 756 | { |
758 | US_DEBUGP("-- %s\n", __func__); | 757 | US_DEBUGP("-- %s\n", __func__); |
759 | 758 | ||
760 | /* Free the device-related DMA-mapped buffers */ | 759 | /* Free the buffers */ |
761 | if (us->cr) | 760 | kfree(us->cr); |
762 | usb_buffer_free(us->pusb_dev, sizeof(*us->cr), us->cr, | 761 | usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma); |
763 | us->cr_dma); | ||
764 | if (us->iobuf) | ||
765 | usb_buffer_free(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, | ||
766 | us->iobuf_dma); | ||
767 | 762 | ||
768 | /* Remove our private data from the interface */ | 763 | /* Remove our private data from the interface */ |
769 | usb_set_intfdata(us->pusb_intf, NULL); | 764 | usb_set_intfdata(us->pusb_intf, NULL); |
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h index 69717134231b..89d3bfff98df 100644 --- a/drivers/usb/storage/usb.h +++ b/drivers/usb/storage/usb.h | |||
@@ -139,8 +139,7 @@ struct us_data { | |||
139 | struct usb_ctrlrequest *cr; /* control requests */ | 139 | struct usb_ctrlrequest *cr; /* control requests */ |
140 | struct usb_sg_request current_sg; /* scatter-gather req. */ | 140 | struct usb_sg_request current_sg; /* scatter-gather req. */ |
141 | unsigned char *iobuf; /* I/O buffer */ | 141 | unsigned char *iobuf; /* I/O buffer */ |
142 | dma_addr_t cr_dma; /* buffer DMA addresses */ | 142 | dma_addr_t iobuf_dma; /* buffer DMA addresses */ |
143 | dma_addr_t iobuf_dma; | ||
144 | struct task_struct *ctl_thread; /* the control thread */ | 143 | struct task_struct *ctl_thread; /* the control thread */ |
145 | 144 | ||
146 | /* mutual exclusion and synchronization structures */ | 145 | /* mutual exclusion and synchronization structures */ |
diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c index 112ef7e26f6b..2ce6b7eccc6a 100644 --- a/drivers/usb/wusbcore/wa-xfer.c +++ b/drivers/usb/wusbcore/wa-xfer.c | |||
@@ -474,8 +474,6 @@ static void __wa_xfer_setup_hdr0(struct wa_xfer *xfer, | |||
474 | struct wa_xfer_ctl *xfer_ctl = | 474 | struct wa_xfer_ctl *xfer_ctl = |
475 | container_of(xfer_hdr0, struct wa_xfer_ctl, hdr); | 475 | container_of(xfer_hdr0, struct wa_xfer_ctl, hdr); |
476 | xfer_ctl->bmAttribute = xfer->is_inbound ? 1 : 0; | 476 | xfer_ctl->bmAttribute = xfer->is_inbound ? 1 : 0; |
477 | BUG_ON(xfer->urb->transfer_flags & URB_NO_SETUP_DMA_MAP | ||
478 | && xfer->urb->setup_packet == NULL); | ||
479 | memcpy(&xfer_ctl->baSetupData, xfer->urb->setup_packet, | 477 | memcpy(&xfer_ctl->baSetupData, xfer->urb->setup_packet, |
480 | sizeof(xfer_ctl->baSetupData)); | 478 | sizeof(xfer_ctl->baSetupData)); |
481 | break; | 479 | break; |