EHCI: Fix backward arguments to memalign in previous alignment fix; extend fix to OHCI too

This commit is contained in:
Gregory Nutt 2015-05-03 14:31:16 -06:00
parent ca8fd8c964
commit ef2ef35600
3 changed files with 33 additions and 7 deletions

View File

@ -3808,7 +3808,15 @@ static int lpc31_enumerate(FAR struct usbhost_connection_s *conn,
ret = usbhost_enumerate(hport, &hport->devclass);
if (ret < 0)
{
/* Failed to enumerate */
usbhost_trace2(EHCI_TRACE2_CLASSENUM_FAILED, hport->port + 1, -ret);
/* If this is a root hub port, then marking the hub port not connected will
* cause sam_wait() to return and we will try the connection again.
*/
hport->connected = false;
}
return ret;
@ -4018,7 +4026,7 @@ static int lpc31_alloc(FAR struct usbhost_driver_s *drvr,
* cache line size in length.
*/
*buffer = (FAR uint8_t *)kmm_memalign(LPC31_EHCI_BUFSIZE, ARM_DCACHE_LINESIZE);
*buffer = (FAR uint8_t *)kmm_memalign(ARM_DCACHE_LINESIZE, LPC31_EHCI_BUFSIZE);
if (*buffer)
{
*maxlen = LPC31_EHCI_BUFSIZE;
@ -4100,7 +4108,7 @@ static int lpc31_ioalloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer
*/
buflen = (buflen + DCACHE_LINEMASK) & ~DCACHE_LINEMASK;
*buffer = (FAR uint8_t *)kumm_memalign(buflen, ARM_DCACHE_LINESIZE);
*buffer = (FAR uint8_t *)kumm_memalign(ARM_DCACHE_LINESIZE, buflen);
return *buffer ? OK : -ENOMEM;
}

View File

@ -3634,7 +3634,15 @@ static int sam_enumerate(FAR struct usbhost_connection_s *conn,
ret = usbhost_enumerate(hport, &hport->devclass);
if (ret < 0)
{
/* Failed to enumerate */
usbhost_trace2(EHCI_TRACE2_CLASSENUM_FAILED, hport->port + 1, -ret);
/* If this is a root hub port, then marking the hub port not connected will
* cause sam_wait() to return and we will try the connection again.
*/
hport->connected = false;
}
return ret;
@ -3845,7 +3853,7 @@ static int sam_alloc(FAR struct usbhost_driver_s *drvr,
* cache line size in length.
*/
*buffer = (FAR uint8_t *)kmm_memalign(SAMA5_EHCI_BUFSIZE, ARMV7A_DCACHE_LINESIZE);
*buffer = (FAR uint8_t *)kmm_memalign(ARMV7A_DCACHE_LINESIZE, SAMA5_EHCI_BUFSIZE);
if (*buffer)
{
*maxlen = SAMA5_EHCI_BUFSIZE;
@ -3927,7 +3935,7 @@ static int sam_ioalloc(FAR struct usbhost_driver_s *drvr, FAR uint8_t **buffer,
*/
buflen = (buflen + DCACHE_LINEMASK) & ~DCACHE_LINEMASK;
*buffer = (FAR uint8_t *)kumm_memalign(buflen, ARMV7A_DCACHE_LINESIZE);
*buffer = (FAR uint8_t *)kumm_memalign(ARMV7A_DCACHE_LINESIZE, buflen);
return *buffer ? OK : -ENOMEM;
}

View File

@ -103,6 +103,16 @@
# error Insufficent number of transfer descriptors (CONFIG_SAMA5_OHCI_NTDS < 2)
#endif
/* Minimum alignment for DMA access is 16 bytes, but it is safer to align to the
* cache line size.
*/
#if ARMV7A_DCACHE_LINESIZE > 16
# define SAMA5_DMA_ALIGN ARMV7A_DCACHE_LINESIZE
#else
# define SAMA5_DMA_ALIGN 16
#endif
/* Configurable number of request/descriptor buffers (TDBUFFER) */
#ifndef CONFIG_SAMA5_OHCI_TDBUFFERS
@ -487,11 +497,11 @@ static struct ohci_hcca_s g_hcca
*/
static struct sam_ed_s g_edalloc[SAMA5_OHCI_NEDS]
__attribute__ ((aligned (16)));
__attribute__ ((aligned (SAMA5_DMA_ALIGN)));
static struct sam_gtd_s g_tdalloc[SAMA5_OHCI_NTDS]
__attribute__ ((aligned (16)));
__attribute__ ((aligned (SAMA5_DMA_ALIGN)));
static uint8_t g_bufalloc[SAM_BUFALLOC]
__attribute__ ((aligned (16)));
__attribute__ ((aligned (SAMA5_DMA_ALIGN)));
/*******************************************************************************
* Public Data