ENGR00138121 Fix system hangs when arecord/aplay continuously

Sdma iapi start loading sdma script by write HSTART register as
memory. When instruction reorder and IRQ delay may let the next
synchronize operation wait forever.

We change it by using writel() to access sdma registers,
and introduce timeout to show this error.

HSTART and STOP_STAT contain bits that are reset by hardware.
So if we read-modify-write, we are in danger of setting a bit
after SDMA has cleared it.

The spec calls these registers "write-ones" register.  So the
ARM can write a 1 to any bit, but does not need to worry about
clearing any bits that were previously set.  SDMA hardware
keeps track of all bits that were set.

Signed-off-by: Zeng Zhaoming <b32542@freescale.com>
Signed-off-by: Alan Tull <alan.tull@freescale.com>
This commit is contained in:
Zeng Zhaoming
2011-01-26 10:35:15 +08:00
committed by Matt Sealey
parent 258c10961b
commit afca8068ea
3 changed files with 43 additions and 33 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2007-2010 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright (C) 2007-2011 Freescale Semiconductor, Inc. All Rights Reserved.
*/
/*
@@ -20,32 +20,35 @@
extern void __iomem *sdma_base;
#define SDMA_BASE_IO_ADDR (sdma_base)
#define SDMA_H_C0PTR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x000))
#define SDMA_H_INTR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x004))
#define SDMA_H_STATSTOP *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x008))
#define SDMA_H_START *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x00C))
#define SDMA_H_EVTOVR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x010))
#define SDMA_H_DSPOVR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x014))
#define SDMA_H_HOSTOVR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x018))
#define SDMA_H_EVTPEND *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x01C))
#define SDMA_H_DSPENBL *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x020))
#define SDMA_H_RESET *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x024))
#define SDMA_H_EVTERR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x028))
#define SDMA_H_INTRMSK *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x02C))
#define SDMA_H_PSW *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x030))
#define SDMA_H_EVTERRDBG *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x034))
#define SDMA_H_CONFIG *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x038))
#define SDMA_ONCE_ENB *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x040))
#define SDMA_ONCE_DATA *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x044))
#define SDMA_ONCE_INSTR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x048))
#define SDMA_ONCE_STAT *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x04C))
#define SDMA_ONCE_CMD *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x050))
#define SDMA_EVT_MIRROR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x054))
#define SDMA_ILLINSTADDR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x058))
#define SDMA_CHN0ADDR *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x05C))
#define SDMA_ONCE_RTB *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x060))
#define SDMA_XTRIG_CONF1 *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x070))
#define SDMA_XTRIG_CONF2 *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x074))
#define SDMA_H_STATSTOP_ADDR (SDMA_BASE_IO_ADDR + 0x008)
#define SDMA_H_START_ADDR (SDMA_BASE_IO_ADDR + 0x00C)
#define SDMA_H_C0PTR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x000)))
#define SDMA_H_INTR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x004)))
#define SDMA_H_STATSTOP (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x008)))
#define SDMA_H_START (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x00C)))
#define SDMA_H_EVTOVR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x010)))
#define SDMA_H_DSPOVR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x014)))
#define SDMA_H_HOSTOVR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x018)))
#define SDMA_H_EVTPEND (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x01C)))
#define SDMA_H_DSPENBL (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x020)))
#define SDMA_H_RESET (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x024)))
#define SDMA_H_EVTERR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x028)))
#define SDMA_H_INTRMSK (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x02C)))
#define SDMA_H_PSW (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x030)))
#define SDMA_H_EVTERRDBG (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x034)))
#define SDMA_H_CONFIG (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x038)))
#define SDMA_ONCE_ENB (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x040)))
#define SDMA_ONCE_DATA (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x044)))
#define SDMA_ONCE_INSTR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x048)))
#define SDMA_ONCE_STAT (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x04C)))
#define SDMA_ONCE_CMD (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x050)))
#define SDMA_EVT_MIRROR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x054)))
#define SDMA_ILLINSTADDR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x058)))
#define SDMA_CHN0ADDR (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x05C)))
#define SDMA_ONCE_RTB (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x060)))
#define SDMA_XTRIG_CONF1 (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x070)))
#define SDMA_XTRIG_CONF2 (*((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x074)))
#ifdef MXC_SDMA_V2
#define SDMA_CHNENBL_0 *((volatile unsigned long *)(SDMA_BASE_IO_ADDR + 0x200))

View File

@@ -1,6 +1,6 @@
/******************************************************************************
*
* Copyright 2007-2009 Freescale Semiconductor, Inc. All Rights Reserved.
* Copyright 2007-2011 Freescale Semiconductor, Inc. All Rights Reserved.
*
*
* The code contained herein is licensed under the GNU General Public
@@ -34,6 +34,7 @@
* Include File Section
*****************************************************************************/
#include <string.h>
#include <io.h>
#include "epm.h"
#include "iapiLow.h"
@@ -134,7 +135,8 @@ iapi_Channel0Command( channelDescriptor * cd_p, void * buf,
void
iapi_lowStartChannel (unsigned char channel)
{
SDMA_H_START |= 1 << channel;
/* HSTART is a 'write-ones' register */
writel(1UL << channel, SDMA_H_START_ADDR);
}
/* ***************************************************************************/
@@ -153,7 +155,8 @@ iapi_lowStartChannel (unsigned char channel)
void
iapi_lowStopChannel (unsigned char channel)
{
SDMA_H_STATSTOP &= 1 << channel;
/* Another 'write-ones' register */
writel(1UL << channel, SDMA_H_STATSTOP_ADDR);
}
/* ***************************************************************************/

View File

@@ -134,9 +134,13 @@ static void sdma_init_sleep(int channel)
static void sdma_sleep_channel(int channel)
{
while ((iapi_SDMAIntr & (1 << channel)) == 0) {
wait_event_interruptible(sdma_sleep_queue[channel],
((iapi_SDMAIntr & (1 << channel)) !=
0));
int timeout = 10; /* timeout 10ms */
timeout = wait_event_interruptible_timeout(
sdma_sleep_queue[channel],
((iapi_SDMAIntr & (1 << channel)) !=
0), timeout);
if (!timeout)
printk(KERN_WARNING "sdma channel timeout\n");
}
}