public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send
@ 2010-08-14  8:19 Stefano Babic
  2010-08-14 12:26 ` Sergei Shtylyov
  2010-08-14 15:48 ` Remy Bohmer
  0 siblings, 2 replies; 4+ messages in thread
From: Stefano Babic @ 2010-08-14  8:19 UTC (permalink / raw)
  To: u-boot

The patch removes an endless loop  in the usb_eth_send
if the tx_complete is not called before going
in the loop. The driver interrupt routine is called
allowing the driver to check if the TX is completed.

Signed-off-by: Stefano Babic <sbabic@denx.de>
---

Changes from V1:
- Comments by Remy Bohmer: moved usb_ep_queue inside timeout
to not break at91 code

 drivers/usb/gadget/ether.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 0b4ed18..f082c03 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -1808,6 +1808,8 @@ static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int le
 	struct usb_request	*req = NULL;
 
 	struct eth_dev *dev = &l_ethdev;
+	unsigned long ts;
+	unsigned long timeout = USB_CONNECT_TIMEOUT;
 	dprintf("%s:...\n",__func__);
 
 	req = dev->tx_req;
@@ -1833,13 +1835,19 @@ static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int le
 #endif
 	dev->tx_qlen=1;
 
+	ts = get_timer(0);
+	packet_sent=0;
 	retval = usb_ep_queue (dev->in_ep, req, GFP_ATOMIC);
 
 	if (!retval)
-		dprintf("%s: packet queued\n",__func__);
+		debug("%s: packet queued\n",__func__);
 	while(!packet_sent)
 	{
-		packet_sent=0;
+		if (get_timer(ts) > timeout) {
+			printf ("timeout sending packets to usb ethernet\n");
+			return -1;
+		}
+		usb_gadget_handle_interrupts();
 	}
 
 	return 0;
-- 
1.6.3.3

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

* [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send
  2010-08-14  8:19 [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send Stefano Babic
@ 2010-08-14 12:26 ` Sergei Shtylyov
  2010-08-14 15:48 ` Remy Bohmer
  1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2010-08-14 12:26 UTC (permalink / raw)
  To: u-boot

Stefano Babic wrote:

> The patch removes an endless loop  in the usb_eth_send
> if the tx_complete is not called before going
> in the loop. The driver interrupt routine is called
> allowing the driver to check if the TX is completed.

> Signed-off-by: Stefano Babic <sbabic@denx.de>
> ---

[...]

> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index 0b4ed18..f082c03 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -1808,6 +1808,8 @@ static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int le
>  	struct usb_request	*req = NULL;
>  
>  	struct eth_dev *dev = &l_ethdev;
> +	unsigned long ts;
> +	unsigned long timeout = USB_CONNECT_TIMEOUT;

    Please keep an empty line after the declaration block.

> @@ -1833,13 +1835,19 @@ static int usb_eth_send(struct eth_device* netdev, volatile void* packet, int le
>  #endif
>  	dev->tx_qlen=1;
>  
> +	ts = get_timer(0);
> +	packet_sent=0;

    Please keep the style consistent and add spaces before/after =.

>  	retval = usb_ep_queue (dev->in_ep, req, GFP_ATOMIC);
>  
>  	if (!retval)
> -		dprintf("%s: packet queued\n",__func__);
> +		debug("%s: packet queued\n",__func__);
>  	while(!packet_sent)
>  	{
> -		packet_sent=0;
> +		if (get_timer(ts) > timeout) {
> +			printf ("timeout sending packets to usb ethernet\n");

    Please be consistent and remove space before paren. U-Boot nwo seems to 
follow the Linux coding style...

WBR, Sergei

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

* [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send
  2010-08-14  8:19 [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send Stefano Babic
  2010-08-14 12:26 ` Sergei Shtylyov
@ 2010-08-14 15:48 ` Remy Bohmer
  2010-08-15 12:17   ` Stefano Babic
  1 sibling, 1 reply; 4+ messages in thread
From: Remy Bohmer @ 2010-08-14 15:48 UTC (permalink / raw)
  To: u-boot

Hi,

2010/8/14 Stefano Babic <sbabic@denx.de>:
> The patch removes an endless loop ?in the usb_eth_send
> if the tx_complete is not called before going
> in the loop. The driver interrupt routine is called
> allowing the driver to check if the TX is completed.
>
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> ---
>
> Changes from V1:
> - Comments by Remy Bohmer: moved usb_ep_queue inside timeout
> to not break at91 code

Sorry, patch does not apply any more after applying the series from
Vitaly yesterday. please rebase.

Kind regards,

Remy

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

* [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send
  2010-08-14 15:48 ` Remy Bohmer
@ 2010-08-15 12:17   ` Stefano Babic
  0 siblings, 0 replies; 4+ messages in thread
From: Stefano Babic @ 2010-08-15 12:17 UTC (permalink / raw)
  To: u-boot

Remy Bohmer wrote:
> Hi,
> 
> 2010/8/14 Stefano Babic <sbabic@denx.de>:
>> The patch removes an endless loop  in the usb_eth_send
>> if the tx_complete is not called before going
>> in the loop. The driver interrupt routine is called
>> allowing the driver to check if the TX is completed.
>>
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>> ---
>>
>> Changes from V1:
>> - Comments by Remy Bohmer: moved usb_ep_queue inside timeout
>> to not break at91 code
> 
> Sorry, patch does not apply any more after applying the series from
> Vitaly yesterday. please rebase.

No problem, I rebase it.

Best regards,
Stefano

-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

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

end of thread, other threads:[~2010-08-15 12:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-14  8:19 [U-Boot] [PATCH V2 2/2] USB-CDC: called handle_interrupts inside usb_eth_send Stefano Babic
2010-08-14 12:26 ` Sergei Shtylyov
2010-08-14 15:48 ` Remy Bohmer
2010-08-15 12:17   ` Stefano Babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox