2014-12-17 09:19:05

by Bo Shen

[permalink] [raw]
Subject: [PATCH 1/2] USB: gadget: udc: atmel: change setting for DMA

According to the datasheet, when transfer using DMA, the control
setting for IN packet only need END_BUF_EN, END_BUF_IE, CH_EN,
while for OUT packet, need more two bits END_TR_EN and END_TR_IE
to be configured.

Signed-off-by: Bo Shen <[email protected]>
---

drivers/usb/gadget/udc/atmel_usba_udc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index ce88237..63e90f5 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -716,10 +716,10 @@ static int queue_dma(struct usba_udc *udc, struct usba_ep *ep,
req->using_dma = 1;
req->ctrl = USBA_BF(DMA_BUF_LEN, req->req.length)
| USBA_DMA_CH_EN | USBA_DMA_END_BUF_IE
- | USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;
+ | USBA_DMA_END_BUF_EN;

- if (ep->is_in)
- req->ctrl |= USBA_DMA_END_BUF_EN;
+ if (!ep->is_in)
+ req->ctrl |= USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;

/*
* Add this request to the queue and submit for DMA if
--
2.1.0.24.g4109c28


2014-12-17 09:19:06

by Bo Shen

[permalink] [raw]
Subject: [PATCH 2/2] USB: gadget: udc: atmel: fix possible IN hang issue

When receive data, the RXRDY in status register set by hardware
after a new packet has been stored in the endpoint FIFO. When it
is copied from FIFO, this bit is cleared which make the FIFO can
be accessed again.

In the receive_data() function, this bit RXRDY has been cleared.
So, after the receive_data() function return, this bit should
not be cleared again, or else it may cause the accessing FIFO
corrupt, which will make the data loss.

Signed-off-by: Bo Shen <[email protected]>
---

drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
index 63e90f5..93328ea 100644
--- a/drivers/usb/gadget/udc/atmel_usba_udc.c
+++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
@@ -1563,7 +1563,6 @@ static void usba_ep_irq(struct usba_udc *udc, struct usba_ep *ep)
if ((epstatus & epctrl) & USBA_RX_BK_RDY) {
DBG(DBG_BUS, "%s: RX data ready\n", ep->ep.name);
receive_data(ep);
- usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY);
}
}

--
2.1.0.24.g4109c28

2014-12-18 17:20:46

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 1/2] USB: gadget: udc: atmel: change setting for DMA

Le 17/12/2014 10:18, Bo Shen a ?crit :
> According to the datasheet, when transfer using DMA, the control
> setting for IN packet only need END_BUF_EN, END_BUF_IE, CH_EN,
> while for OUT packet, need more two bits END_TR_EN and END_TR_IE
> to be configured.
>
> Signed-off-by: Bo Shen <[email protected]>

Seems okay, even if I am not used to these aspects:
Acked-by: Nicolas Ferre <[email protected]>

I would also add a "stable" tag to these patches, something like this:

Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: [email protected] # always been there...


Felipe,

Can you take both of these patches as fixes?

> ---
>
> drivers/usb/gadget/udc/atmel_usba_udc.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index ce88237..63e90f5 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -716,10 +716,10 @@ static int queue_dma(struct usba_udc *udc, struct usba_ep *ep,
> req->using_dma = 1;
> req->ctrl = USBA_BF(DMA_BUF_LEN, req->req.length)
> | USBA_DMA_CH_EN | USBA_DMA_END_BUF_IE
> - | USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;
> + | USBA_DMA_END_BUF_EN;
>
> - if (ep->is_in)
> - req->ctrl |= USBA_DMA_END_BUF_EN;
> + if (!ep->is_in)
> + req->ctrl |= USBA_DMA_END_TR_EN | USBA_DMA_END_TR_IE;
>
> /*
> * Add this request to the queue and submit for DMA if
>


--
Nicolas Ferre

2014-12-18 17:22:16

by Nicolas Ferre

[permalink] [raw]
Subject: Re: [PATCH 2/2] USB: gadget: udc: atmel: fix possible IN hang issue

Le 17/12/2014 10:18, Bo Shen a ?crit :
> When receive data, the RXRDY in status register set by hardware
> after a new packet has been stored in the endpoint FIFO. When it
> is copied from FIFO, this bit is cleared which make the FIFO can
> be accessed again.
>
> In the receive_data() function, this bit RXRDY has been cleared.
> So, after the receive_data() function return, this bit should
> not be cleared again, or else it may cause the accessing FIFO
> corrupt, which will make the data loss.
>
> Signed-off-by: Bo Shen <[email protected]>


Seems okay:
Acked-by: Nicolas Ferre <[email protected]>

Like the former one:

Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
Cc: [email protected] # always been there...

> ---
>
> drivers/usb/gadget/udc/atmel_usba_udc.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c
> index 63e90f5..93328ea 100644
> --- a/drivers/usb/gadget/udc/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c
> @@ -1563,7 +1563,6 @@ static void usba_ep_irq(struct usba_udc *udc, struct usba_ep *ep)
> if ((epstatus & epctrl) & USBA_RX_BK_RDY) {
> DBG(DBG_BUS, "%s: RX data ready\n", ep->ep.name);
> receive_data(ep);
> - usba_ep_writel(ep, CLR_STA, USBA_RX_BK_RDY);
> }
> }
>
>


--
Nicolas Ferre

2014-12-22 16:38:56

by Felipe Balbi

[permalink] [raw]
Subject: Re: [PATCH 1/2] USB: gadget: udc: atmel: change setting for DMA

On Thu, Dec 18, 2014 at 06:20:39PM +0100, Nicolas Ferre wrote:
> Le 17/12/2014 10:18, Bo Shen a ?crit :
> > According to the datasheet, when transfer using DMA, the control
> > setting for IN packet only need END_BUF_EN, END_BUF_IE, CH_EN,
> > while for OUT packet, need more two bits END_TR_EN and END_TR_IE
> > to be configured.
> >
> > Signed-off-by: Bo Shen <[email protected]>
>
> Seems okay, even if I am not used to these aspects:
> Acked-by: Nicolas Ferre <[email protected]>
>
> I would also add a "stable" tag to these patches, something like this:
>
> Fixes: 914a3f3b3754 (USB: add atmel_usba_udc driver)
> Cc: [email protected] # always been there...
>
>
> Felipe,
>
> Can you take both of these patches as fixes?

I'll get back to them... Still other patches to go through.

--
balbi


Attachments:
(No filename) (819.00 B)
signature.asc (819.00 B)
Digital signature
Download all attachments