at91udc: fix recursive poll()
Subsystems (2)
PATCH 3/5 at91udc: fix recursive poll()
I noticed some weird behavior using DFU gadget on AT91SAM9260 which worked 1 of 10 times. The bug was due to the usb_gadget_poll() being called while the previous call was still in progress : some USB calls may takes a lot of time (ex : DFU erase-then-write), resulting in the poller to be triggered again while still in the poll() function.
This patch adds a poll lock to the AT91 UDC driver.
Signed-off-by Cerrato Renaud <[email protected]>
--- drivers/usb/gadget/at91_udc.c | 14 ++++++++------ drivers/usb/gadget/at91_udc.h | 1 + 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/usb/gadget/at91_udc.c +8 -6
@@ -1340,22 +1340,24 @@ int usb_gadget_poll(void)struct at91_udc *udc = &controller;u32 value; -if (!udc->udp_baseaddr) +if (!udc->udp_baseaddr || udc->poll_lock)return 0 ; + udc->poll_lock =1 ; + value =gpio_get_value (udc->board.vbus_pin); value ^= udc->board.vbus_active_low; - -if (!value) { -at91_update_vbus (udc, value); -return 0 ; - }at91_update_vbus (udc, value); +if (!value) + goto exit; + value =at91_udp_read (udc,AT91_UDP_ISR ) & (~(AT91_UDP_SOFINT ));if (value)at91_udc_irq (udc); +exit: + udc->poll_lock =0 ;return value; }
drivers/usb/gadget/at91_udc.h +1 -0
@@ -127,6 +127,7 @@ struct at91_udc { unsigned wait_for_config_ack:1; unsigned selfpowered:1; unsigned active_suspend:1; + unsigned poll_lock:1;u8 addr;u32 gpio_vbus_val;struct at91_udc_data board;
Signature · 7 lines
1.7.2.5 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox