diff mbox series

[v2,3/3] usb: core: hcd: use map_urb_for_dma for single step set feature urb

Message ID 1619763393-20029-3-git-send-email-jun.li@nxp.com
State Superseded
Headers show
Series [v2,1/3] usb: host: move EH SINGLE_STEP_SET_FEATURE implementation to core | expand

Commit Message

Jun Li April 30, 2021, 6:16 a.m. UTC
Use map_urb_for_dma() to improve the dma map code for single step
set feature request urb in test mode.

Signed-off-by: Li Jun <jun.li@nxp.com>
---
change for v2:
- Add this new patch to use map_urb_for_dma API to
  replace both of dma_map_single() calls, suggested by
  Jack Pham.

 drivers/usb/core/hcd.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

Comments

Alan Stern April 30, 2021, 2:49 p.m. UTC | #1
On Fri, Apr 30, 2021 at 02:16:33PM +0800, Li Jun wrote:
> Use map_urb_for_dma() to improve the dma map code for single step
> set feature request urb in test mode.
> 
> Signed-off-by: Li Jun <jun.li@nxp.com>
> ---
> change for v2:
> - Add this new patch to use map_urb_for_dma API to
>   replace both of dma_map_single() calls, suggested by
>   Jack Pham.
> 
>  drivers/usb/core/hcd.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index d7eb9f179ca6..0b89a3dc99a3 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -2159,16 +2159,8 @@ static struct urb *request_single_step_set_feature_urb(
>  	usb_get_urb(urb);
>  	atomic_inc(&urb->use_count);
>  	atomic_inc(&urb->dev->urbnum);
> -	urb->setup_dma = dma_map_single(
> -			hcd->self.sysdev,
> -			urb->setup_packet,
> -			sizeof(struct usb_ctrlrequest),
> -			DMA_TO_DEVICE);
> -	urb->transfer_dma = dma_map_single(
> -			hcd->self.sysdev,
> -			urb->transfer_buffer,
> -			urb->transfer_buffer_length,
> -			DMA_FROM_DEVICE);
> +	if (map_urb_for_dma(hcd, urb, GFP_KERNEL))
> +		unmap_urb_for_dma(hcd, urb);

That looks awfully weird.  Are you sure about it?

Alan Stern

>  	urb->context = done;
>  	return urb;
>  }
> -- 
> 2.25.1
>
Jun Li May 6, 2021, 11:51 a.m. UTC | #2
> -----Original Message-----

> From: Alan Stern <stern@rowland.harvard.edu>

> Sent: Friday, April 30, 2021 10:49 PM

> To: Jun Li <jun.li@nxp.com>

> Cc: gregkh@linuxfoundation.org; mathias.nyman@intel.com;

> peter.chen@kernel.org; jackp@codeaurora.org; linux-usb@vger.kernel.org;

> dl-linux-imx <linux-imx@nxp.com>

> Subject: Re: [PATCH v2 3/3] usb: core: hcd: use map_urb_for_dma for single

> step set feature urb

> 

> On Fri, Apr 30, 2021 at 02:16:33PM +0800, Li Jun wrote:

> > Use map_urb_for_dma() to improve the dma map code for single step set

> > feature request urb in test mode.

> >

> > Signed-off-by: Li Jun <jun.li@nxp.com>

> > ---

> > change for v2:

> > - Add this new patch to use map_urb_for_dma API to

> >   replace both of dma_map_single() calls, suggested by

> >   Jack Pham.

> >

> >  drivers/usb/core/hcd.c | 12 ++----------

> >  1 file changed, 2 insertions(+), 10 deletions(-)

> >

> > diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index

> > d7eb9f179ca6..0b89a3dc99a3 100644

> > --- a/drivers/usb/core/hcd.c

> > +++ b/drivers/usb/core/hcd.c

> > @@ -2159,16 +2159,8 @@ static struct urb

> *request_single_step_set_feature_urb(

> >  	usb_get_urb(urb);

> >  	atomic_inc(&urb->use_count);

> >  	atomic_inc(&urb->dev->urbnum);

> > -	urb->setup_dma = dma_map_single(

> > -			hcd->self.sysdev,

> > -			urb->setup_packet,

> > -			sizeof(struct usb_ctrlrequest),

> > -			DMA_TO_DEVICE);

> > -	urb->transfer_dma = dma_map_single(

> > -			hcd->self.sysdev,

> > -			urb->transfer_buffer,

> > -			urb->transfer_buffer_length,

> > -			DMA_FROM_DEVICE);

> > +	if (map_urb_for_dma(hcd, urb, GFP_KERNEL))

> > +		unmap_urb_for_dma(hcd, urb);

> 

> That looks awfully weird.  Are you sure about it?


Oops, will update the "awfully weird" error handling in v3.

Thanks
Li Jun 

> 

> Alan Stern

> 

> >  	urb->context = done;

> >  	return urb;

> >  }

> > --

> > 2.25.1

> >
diff mbox series

Patch

diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index d7eb9f179ca6..0b89a3dc99a3 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -2159,16 +2159,8 @@  static struct urb *request_single_step_set_feature_urb(
 	usb_get_urb(urb);
 	atomic_inc(&urb->use_count);
 	atomic_inc(&urb->dev->urbnum);
-	urb->setup_dma = dma_map_single(
-			hcd->self.sysdev,
-			urb->setup_packet,
-			sizeof(struct usb_ctrlrequest),
-			DMA_TO_DEVICE);
-	urb->transfer_dma = dma_map_single(
-			hcd->self.sysdev,
-			urb->transfer_buffer,
-			urb->transfer_buffer_length,
-			DMA_FROM_DEVICE);
+	if (map_urb_for_dma(hcd, urb, GFP_KERNEL))
+		unmap_urb_for_dma(hcd, urb);
 	urb->context = done;
 	return urb;
 }