dma: pl330: Add timeout error on transient states
authorlakkyung jung <lakkyung.jung@samsung.com>
Mon, 25 Aug 2014 05:51:56 +0000 (14:51 +0900)
committerTaekki Kim <taekki.kim@samsung.com>
Mon, 14 May 2018 05:42:46 +0000 (14:42 +0900)
Change-Id: I096698308a88376073588a7b1da42ed407261514
Signed-off-by: Lee Yongjin <yongjin0.lee@samsung.com>
drivers/dma/pl330.c

index 3f23c5137517b105dbfc60aa1d96725b94e35637..b0b31f71ad9e2732e137490123d8a336cc212776 100644 (file)
@@ -249,7 +249,18 @@ enum pl330_byteswap {
 #define MCODE_BUFF_PER_REQ     256
 
 /* Use this _only_ to wait on transient states */
-#define UNTIL(t, s)    while (!(_state(t) & (s))) cpu_relax();
+#define UNTIL(t, s)    do {                                                                    \
+                               unsigned long timeout = msecs_to_jiffies(5);                    \
+                               bool timeout_flag = true;                                       \
+                               do {                                                            \
+                                       if (_state(t) & (s)) {                                  \
+                                               timeout_flag = false;                           \
+                                               break;                                          \
+                                       }                                                       \
+                                       cpu_relax();                                            \
+                               } while (time_before(jiffies, timeout));                        \
+                               if (timeout_flag) pr_err("%s Timeout error!!!!\n", __func__);   \
+                       } while (0)
 
 #ifdef PL330_DEBUG_MCGEN
 static unsigned cmd_line;
@@ -1040,14 +1051,14 @@ static bool _start(struct pl330_thread *thrd)
                UNTIL(thrd, PL330_STATE_FAULTING | PL330_STATE_KILLING);
 
                if (_state(thrd) == PL330_STATE_KILLING)
-                       UNTIL(thrd, PL330_STATE_STOPPED)
+                       UNTIL(thrd, PL330_STATE_STOPPED);
 
        case PL330_STATE_FAULTING:
                _stop(thrd);
 
        case PL330_STATE_KILLING:
        case PL330_STATE_COMPLETING:
-               UNTIL(thrd, PL330_STATE_STOPPED)
+               UNTIL(thrd, PL330_STATE_STOPPED);
 
        case PL330_STATE_STOPPED:
                return _trigger(thrd);