Re: [PATCH 2/4] USB: only check URB_SETUP_MAP_* flag for control endpoint

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 12 May 2010 tom.leiming@xxxxxxxxx wrote:

> From: Ming Lei <tom.leiming@xxxxxxxxx>
> 
> This patch only checks URB_SETUP_MAP_* flag for URB of control endpoint.
> 
> Since control transfer is very few compared with other kind of transfer,
> the fix decreases 2 compares to 1 compares for non-control transfer and
> is more efficient.
> 
> It does make sense for unmap_urb_for_dma() often runs in hardirq context.
> 
> Signed-off-by: Ming Lei <tom.leiming@xxxxxxxxx>
> ---
>  drivers/usb/core/hcd.c |   24 +++++++++++++-----------
>  1 files changed, 13 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 12742f1..df1f9af 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1263,17 +1263,19 @@ static void unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
>  {
>  	enum dma_data_direction dir;
>  
> -	if (urb->transfer_flags & URB_SETUP_MAP_SINGLE)
> -		dma_unmap_single(hcd->self.controller,
> -				urb->setup_dma,
> -				sizeof(struct usb_ctrlrequest),
> -				DMA_TO_DEVICE);
> -	else if (urb->transfer_flags & URB_SETUP_MAP_LOCAL)
> -		hcd_free_coherent(urb->dev->bus,
> -				&urb->setup_dma,
> -				(void **) &urb->setup_packet,
> -				sizeof(struct usb_ctrlrequest),
> -				DMA_TO_DEVICE);
> +	if (usb_endpoint_xfer_control(&urb->ep->desc)) {

If you really want to do this sort of micro-optimization, it would be
better to test

	if (urb->transfer_flags &
			(URB_SETUP_MAP_SINGLE | URB_SETUP_MAP_LOCAL))

because urb->transfer_flags gets reused immediately.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux