linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fix memory issue in non-DMA mode for MUSB gadget
@ 2018-07-26 12:52 Alexey Spirkov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Spirkov @ 2018-07-26 12:52 UTC (permalink / raw)
  To: Bin Liu, Greg Kroah-Hartman, linux-usb@vger.kernel.org; +Cc: andrew@ncrmnt.org

dma_mapping_error function unable to works in PowerPC arch
when MUSB do not use DMA (illegal memory access). Proposed
patch replace its usage to usual define for checking DMA mapping.

Signed-off-by: Alexey Spirkov <alexeis@astrosoft.ru>
---
 drivers/usb/musb/musb_gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index eae8b1b..3bc7c25 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -140,7 +140,7 @@ __acquires(ep->musb->lock)
 	ep->busy = 1;
 	spin_unlock(&musb->lock);
 
-	if (!dma_mapping_error(&musb->g.dev, request->dma))
+	if (req && is_buffer_mapped(req))
 		unmap_dma_buffer(req, musb);
 
 	trace_musb_req_gb(req);

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Fix memory issue in non-DMA mode for MUSB gadget
@ 2018-08-02 16:14 Bin Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Bin Liu @ 2018-08-02 16:14 UTC (permalink / raw)
  To: Alexey Spirkov
  Cc: Greg Kroah-Hartman, linux-usb@vger.kernel.org, andrew@ncrmnt.org

Hi,

On Thu, Jul 26, 2018 at 12:52:57PM +0000, Alexey Spirkov wrote:
> dma_mapping_error function unable to works in PowerPC arch
> when MUSB do not use DMA (illegal memory access). Proposed
> patch replace its usage to usual define for checking DMA mapping.
> 
> Signed-off-by: Alexey Spirkov <alexeis@astrosoft.ru>
> ---
>  drivers/usb/musb/musb_gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> index eae8b1b..3bc7c25 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -140,7 +140,7 @@ __acquires(ep->musb->lock)
>  	ep->busy = 1;
>  	spin_unlock(&musb->lock);
>  
> -	if (!dma_mapping_error(&musb->g.dev, request->dma))
> +	if (req && is_buffer_mapped(req))

unmap_dma_buffer() checks for is_buffer_mapped(), so this line can be
dropped.

>  		unmap_dma_buffer(req, musb);
>  
>  	trace_musb_req_gb(req);

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fix memory issue in non-DMA mode for MUSB gadget
@ 2018-08-02 16:49 Bin Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Bin Liu @ 2018-08-02 16:49 UTC (permalink / raw)
  To: Alexey Spirkov, Greg Kroah-Hartman, linux-usb@vger.kernel.org,
	andrew@ncrmnt.org

On Thu, Aug 02, 2018 at 11:14:32AM -0500, Bin Liu wrote:
> Hi,
> 
> On Thu, Jul 26, 2018 at 12:52:57PM +0000, Alexey Spirkov wrote:
> > dma_mapping_error function unable to works in PowerPC arch
> > when MUSB do not use DMA (illegal memory access). Proposed
> > patch replace its usage to usual define for checking DMA mapping.
> > 
> > Signed-off-by: Alexey Spirkov <alexeis@astrosoft.ru>
> > ---
> >  drivers/usb/musb/musb_gadget.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
> > index eae8b1b..3bc7c25 100644
> > --- a/drivers/usb/musb/musb_gadget.c
> > +++ b/drivers/usb/musb/musb_gadget.c
> > @@ -140,7 +140,7 @@ __acquires(ep->musb->lock)
> >  	ep->busy = 1;
> >  	spin_unlock(&musb->lock);
> >  
> > -	if (!dma_mapping_error(&musb->g.dev, request->dma))
> > +	if (req && is_buffer_mapped(req))
> 
> unmap_dma_buffer() checks for is_buffer_mapped(), so this line can be
> dropped.
> 
> >  		unmap_dma_buffer(req, musb);
> >  
> >  	trace_musb_req_gb(req);

Please also fix the patch subject to "usb: musb: gadget: ..." in your
v2. I prefer

"usb: musb: gadget: fix illegal dma address check in non-DMA mode"

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fix memory issue in non-DMA mode for MUSB gadget
@ 2018-08-03  6:25 Alexey Spirkov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexey Spirkov @ 2018-08-03  6:25 UTC (permalink / raw)
  To: Bin Liu; +Cc: Greg Kroah-Hartman, linux-usb@vger.kernel.org, andrew@ncrmnt.org

Hi, Bin,

Thanks for note, but what do you think - is 'dma_mapping_error' checking still needed before call 
of unmap_dma_buffer? If yes than I'll check DMA usage in this check instead of is_buffer_map.

Best regards,
Alexey Spirkov

-----Original Message-----
From: Bin Liu <b-liu@ti.com> 
Sent: Thursday, August 2, 2018 7:15 PM
To: Alexey Spirkov <AlexeiS@astrosoft.ru>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; linux-usb@vger.kernel.org; andrew@ncrmnt.org
Subject: Re: [PATCH] Fix memory issue in non-DMA mode for MUSB gadget

Hi,

On Thu, Jul 26, 2018 at 12:52:57PM +0000, Alexey Spirkov wrote:
> dma_mapping_error function unable to works in PowerPC arch when MUSB 
> do not use DMA (illegal memory access). Proposed patch replace its 
> usage to usual define for checking DMA mapping.
> 
> Signed-off-by: Alexey Spirkov <alexeis@astrosoft.ru>
> ---
>  drivers/usb/musb/musb_gadget.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/musb/musb_gadget.c 
> b/drivers/usb/musb/musb_gadget.c index eae8b1b..3bc7c25 100644
> --- a/drivers/usb/musb/musb_gadget.c
> +++ b/drivers/usb/musb/musb_gadget.c
> @@ -140,7 +140,7 @@ __acquires(ep->musb->lock)
>  	ep->busy = 1;
>  	spin_unlock(&musb->lock);
>  
> -	if (!dma_mapping_error(&musb->g.dev, request->dma))
> +	if (req && is_buffer_mapped(req))

unmap_dma_buffer() checks for is_buffer_mapped(), so this line can be dropped.

>  		unmap_dma_buffer(req, musb);
>  
>  	trace_musb_req_gb(req);

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Fix memory issue in non-DMA mode for MUSB gadget
@ 2018-08-03 12:06 Bin Liu
  0 siblings, 0 replies; 5+ messages in thread
From: Bin Liu @ 2018-08-03 12:06 UTC (permalink / raw)
  To: Alexey Spirkov
  Cc: Greg Kroah-Hartman, linux-usb@vger.kernel.org, andrew@ncrmnt.org

Hi,

Please don't top-posting.

On Fri, Aug 03, 2018 at 06:25:50AM +0000, Alexey Spirkov wrote:
> Hi, Bin,
> 
> Thanks for note, but what do you think - is 'dma_mapping_error'
> checking still needed before call of unmap_dma_buffer? If yes than
> I'll check DMA usage in this check instead of is_buffer_map.

No, unmap_dma_buffer() can be called unconditionally here because
unmap_dma_buffer() already calls is_buffer_mapped() internally.

So my comment below is to remove the 'if' condition check you modified.

Regards,
-Bin.

> 
> Best regards,
> Alexey Spirkov
> 
> -----Original Message-----
> From: Bin Liu <b-liu@ti.com> 
> Sent: Thursday, August 2, 2018 7:15 PM
> To: Alexey Spirkov <AlexeiS@astrosoft.ru>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>; linux-usb@vger.kernel.org; andrew@ncrmnt.org
> Subject: Re: [PATCH] Fix memory issue in non-DMA mode for MUSB gadget
> 
> Hi,
> 
> On Thu, Jul 26, 2018 at 12:52:57PM +0000, Alexey Spirkov wrote:
> > dma_mapping_error function unable to works in PowerPC arch when MUSB 
> > do not use DMA (illegal memory access). Proposed patch replace its 
> > usage to usual define for checking DMA mapping.
> > 
> > Signed-off-by: Alexey Spirkov <alexeis@astrosoft.ru>
> > ---
> >  drivers/usb/musb/musb_gadget.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/musb/musb_gadget.c 
> > b/drivers/usb/musb/musb_gadget.c index eae8b1b..3bc7c25 100644
> > --- a/drivers/usb/musb/musb_gadget.c
> > +++ b/drivers/usb/musb/musb_gadget.c
> > @@ -140,7 +140,7 @@ __acquires(ep->musb->lock)
> >  	ep->busy = 1;
> >  	spin_unlock(&musb->lock);
> >  
> > -	if (!dma_mapping_error(&musb->g.dev, request->dma))
> > +	if (req && is_buffer_mapped(req))
> 
> unmap_dma_buffer() checks for is_buffer_mapped(), so this line can be dropped.
> 
> >  		unmap_dma_buffer(req, musb);
> >  
> >  	trace_musb_req_gb(req);
> 
> Regards,
> -Bin.
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-03 12:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-03 12:06 Fix memory issue in non-DMA mode for MUSB gadget Bin Liu
  -- strict thread matches above, loose matches on Subject: below --
2018-08-03  6:25 Alexey Spirkov
2018-08-02 16:49 Bin Liu
2018-08-02 16:14 Bin Liu
2018-07-26 12:52 Alexey Spirkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).