[Feature][ZXW-241]merge P56U01 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I7985538dde6951dd824c36149bf9a1e3ca23c734
diff --git a/ap/os/linux/linux-3.4.x/kernel/relay.c b/ap/os/linux/linux-3.4.x/kernel/relay.c
old mode 100644
new mode 100755
index 56ba44f..e00cbea
--- a/ap/os/linux/linux-3.4.x/kernel/relay.c
+++ b/ap/os/linux/linux-3.4.x/kernel/relay.c
@@ -1050,7 +1050,8 @@
 	size_t consumed = buf->subbufs_consumed % n_subbufs;
 
 	if (!read_pos)
-		read_pos = consumed * subbuf_size + buf->bytes_consumed;
+		read_pos = (consumed * subbuf_size + buf->bytes_consumed)
+				% (n_subbufs * subbuf_size);
 	read_subbuf = read_pos / subbuf_size;
 	padding = buf->padding[read_subbuf];
 	padding_start = (read_subbuf + 1) * subbuf_size - padding;
diff --git a/ap/os/linux/linux-3.4.x/kernel/sched/rt.c b/ap/os/linux/linux-3.4.x/kernel/sched/rt.c
old mode 100644
new mode 100755
index 89a985a..f07101d
--- a/ap/os/linux/linux-3.4.x/kernel/sched/rt.c
+++ b/ap/os/linux/linux-3.4.x/kernel/sched/rt.c
@@ -1371,6 +1371,8 @@
 	BUG_ON(idx >= MAX_RT_PRIO);
 
 	queue = array->queue + idx;
+	if (SCHED_WARN_ON(list_empty(queue)))
+		return NULL;
 	next = list_entry(queue->next, struct sched_rt_entity, run_list);
 
 	return next;
@@ -1392,7 +1394,8 @@
 
 	do {
 		rt_se = pick_next_rt_entity(rq, rt_rq);
-		BUG_ON(!rt_se);
+		if (unlikely(!rt_se))
+			return NULL;
 		rt_rq = group_rt_rq(rt_se);
 	} while (rt_rq);
 
diff --git a/ap/os/linux/linux-3.4.x/kernel/sched/sched.h b/ap/os/linux/linux-3.4.x/kernel/sched/sched.h
old mode 100644
new mode 100755
index ed2bab5..7260678
--- a/ap/os/linux/linux-3.4.x/kernel/sched/sched.h
+++ b/ap/os/linux/linux-3.4.x/kernel/sched/sched.h
@@ -6,6 +6,12 @@
 
 #include "cpupri.h"
 
+#ifdef CONFIG_SCHED_DEBUG
+# define SCHED_WARN_ON(x)	WARN_ONCE(x, #x)
+#else
+# define SCHED_WARN_ON(x)	({ (void)(x), 0; })
+#endif
+
 extern __read_mostly int scheduler_running;
 
 /*