From b1482777e08ffb43c5e695bb0b756169bda09382 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Aug 2013 08:57:35 -0600 Subject: SAMA5 OHCI: Fix semaphore handling bug. OHCI is now function by itself again after changes to integrate with EHCI --- nuttx/ChangeLog | 3 +++ nuttx/arch/arm/src/sama5/sam_ohci.c | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 97e278028..7a82c230d 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -5443,4 +5443,7 @@ logic (2013-8-24). * net/uip/uip_arp.c: Correct backward condition in netmask task. From Max Holtzberg (2013-8-25). + * arch/arm/src/sama5/sam_ohci.c: SAMA5 OHCI is again functional by + itself after all of the changes to integrate with EHCI. (2013-8-25). + diff --git a/nuttx/arch/arm/src/sama5/sam_ohci.c b/nuttx/arch/arm/src/sama5/sam_ohci.c index 290db8157..ea6f94ddb 100644 --- a/nuttx/arch/arm/src/sama5/sam_ohci.c +++ b/nuttx/arch/arm/src/sama5/sam_ohci.c @@ -1661,7 +1661,19 @@ static int sam_ctrltd(struct sam_rhport_s *rhport, uint32_t dirpid, regval |= OHCI_CMDST_CLF; sam_putreg(regval, SAM_USBHOST_CMDST); - /* Wait for the Writeback Done Head interrupt. Loop to handle any false + /* Release the OHCI semaphore while we wait. Other threads need the + * opportunity to access the EHCI resources while we wait. + * + * REVISIT: Is this safe? NO. This is a bug and needs rethinking. + * We need to lock all of the port-resources (not EHCI common) until + * the transfer is complete. But we can't use the common OHCI exclsem + * or we will deadlock while waiting (because the working thread that + * wakes this thread up needs the exclsem). + */ +#warning REVISIT + sam_givesem(&g_ohci.exclsem); + + /* Wait for the Writeback Done Head interrupt Loop to handle any false * alarm semaphore counts. */ @@ -1670,6 +1682,12 @@ static int sam_ctrltd(struct sam_rhport_s *rhport, uint32_t dirpid, sam_takesem(&eplist->wdhsem); } + /* Re-aquire the ECHI semaphore. The caller expects to be holding + * this upon return. + */ + + sam_takesem(&g_ohci.exclsem); + /* Check the TD completion status bits */ if (edctrl->tdstatus == TD_CC_NOERROR) -- cgit v1.2.3