aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/layerscape/patches-4.4/7195-increment-MC_CMD_COMPLETION_TIMEOUT_MS.patch
blob: 438234b14822bff6af7ba158429325eeeec0492d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
From 71d19cd1107fa435d056e08e7d7ef7d8f714cf35 Mon Sep 17 00:00:00 2001
From: Lijun Pan <Lijun.Pan@freescale.com>
Date: Fri, 31 Jul 2015 15:07:32 -0500
Subject: [PATCH 195/226] increment MC_CMD_COMPLETION_TIMEOUT_MS

5000ms is barely enough for dpsw/dpdmux creation.
If MC firmware could run faster, we would decrement the value later on.

Signed-off-by: Lijun Pan <Lijun.Pan@freescale.com>
(Stuart: resolved merge conflict)
Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
---
 drivers/staging/fsl-mc/bus/mc-sys.c |   38 +++++++++++++++--------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

--- a/drivers/staging/fsl-mc/bus/mc-sys.c
+++ b/drivers/staging/fsl-mc/bus/mc-sys.c
@@ -43,8 +43,10 @@
 
 /**
  * Timeout in milliseconds to wait for the completion of an MC command
+ * 5000 ms is barely enough for dpsw/dpdmux creation
+ * TODO: if MC firmware could response faster, we should decrease this value
  */
-#define MC_CMD_COMPLETION_TIMEOUT_MS	500
+#define MC_CMD_COMPLETION_TIMEOUT_MS	5000
 
 /*
  * usleep_range() min and max values used to throttle down polling
@@ -327,17 +329,8 @@ static int mc_polling_wait_preemptible(s
 		usleep_range(MC_CMD_COMPLETION_POLLING_MIN_SLEEP_USECS,
 			     MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS);
 
-		if (time_after_eq(jiffies, jiffies_until_timeout)) {
-			dev_dbg(mc_io->dev,
-				"MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
-				 mc_io->portal_phys_addr,
-				 (unsigned int)
-					MC_CMD_HDR_READ_TOKEN(cmd->header),
-				 (unsigned int)
-					MC_CMD_HDR_READ_CMDID(cmd->header));
-
+		if (time_after_eq(jiffies, jiffies_until_timeout))
 			return -ETIMEDOUT;
-		}
 	}
 
 	*mc_status = status;
@@ -369,17 +362,8 @@ static int mc_polling_wait_atomic(struct
 
 		udelay(MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS);
 		timeout_usecs -= MC_CMD_COMPLETION_POLLING_MAX_SLEEP_USECS;
-		if (timeout_usecs == 0) {
-			dev_dbg(mc_io->dev,
-				"MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
-				 mc_io->portal_phys_addr,
-				 (unsigned int)
-					MC_CMD_HDR_READ_TOKEN(cmd->header),
-				 (unsigned int)
-					MC_CMD_HDR_READ_CMDID(cmd->header));
-
+		if (timeout_usecs == 0)
 			return -ETIMEDOUT;
-		}
 	}
 
 	*mc_status = status;
@@ -422,9 +406,19 @@ int mc_send_command(struct fsl_mc_io *mc
 	else
 		error = mc_polling_wait_atomic(mc_io, cmd, &status);
 
-	if (error < 0)
+	if (error < 0) {
+		if (error == -ETIMEDOUT) {
+			pr_debug("MC command timed out (portal: %#llx, obj handle: %#x, command: %#x)\n",
+				 mc_io->portal_phys_addr,
+				 (unsigned int)
+					MC_CMD_HDR_READ_TOKEN(cmd->header),
+				 (unsigned int)
+					MC_CMD_HDR_READ_CMDID(cmd->header));
+		}
 		goto common_exit;
 
+	}
+
 	if (status != MC_CMD_STATUS_OK) {
 		dev_dbg(mc_io->dev,
 			"MC command failed: portal: %#llx, obj handle: %#x, command: %#x, status: %s (%#x)\n",