--- /dev/null
+From 60a445405a1731bac2279eab354173c9c3156747 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+Date: Wed, 21 May 2014 17:43:59 +0200
+Subject: drm/radeon: avoid crash if VM command submission isn't available
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+From: =?UTF-8?q?Christian=20K=C3=B6nig?= <christian.koenig@amd.com>
+
+commit 60a445405a1731bac2279eab354173c9c3156747 upstream.
+
+Signed-off-by: Christian König <christian.koenig@amd.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/gpu/drm/radeon/radeon_cs.c | 15 +++++++++++----
+ 1 file changed, 11 insertions(+), 4 deletions(-)
+
+--- a/drivers/gpu/drm/radeon/radeon_cs.c
++++ b/drivers/gpu/drm/radeon/radeon_cs.c
+@@ -276,10 +276,17 @@ int radeon_cs_parser_init(struct radeon_
+ return -EINVAL;
+
+ /* we only support VM on some SI+ rings */
+- if ((p->rdev->asic->ring[p->ring]->cs_parse == NULL) &&
+- ((p->cs_flags & RADEON_CS_USE_VM) == 0)) {
+- DRM_ERROR("Ring %d requires VM!\n", p->ring);
+- return -EINVAL;
++ if ((p->cs_flags & RADEON_CS_USE_VM) == 0) {
++ if (p->rdev->asic->ring[p->ring]->cs_parse == NULL) {
++ DRM_ERROR("Ring %d requires VM!\n", p->ring);
++ return -EINVAL;
++ }
++ } else {
++ if (p->rdev->asic->ring[p->ring]->ib_parse == NULL) {
++ DRM_ERROR("VM not supported on ring %d!\n",
++ p->ring);
++ return -EINVAL;
++ }
+ }
+ }
+
--- /dev/null
+From ce5f7f8200ca2504f6f290044393d73ca314965a Mon Sep 17 00:00:00 2001
+From: Peter Zijlstra <peterz@infradead.org>
+Date: Mon, 12 May 2014 22:50:34 +0200
+Subject: sched/deadline: Change sched_getparam() behaviour vs SCHED_DEADLINE
+
+From: Peter Zijlstra <peterz@infradead.org>
+
+commit ce5f7f8200ca2504f6f290044393d73ca314965a upstream.
+
+The way we read POSIX one should only call sched_getparam() when
+sched_getscheduler() returns either SCHED_FIFO or SCHED_RR.
+
+Given that we currently return sched_param::sched_priority=0 for all
+others, extend the same behaviour to SCHED_DEADLINE.
+
+Requested-by: Michael Kerrisk <mtk.manpages@gmail.com>
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Acked-by: Michael Kerrisk <mtk.manpages@gmail.com>
+Cc: Dario Faggioli <raistlin@linux.it>
+Cc: linux-man <linux-man@vger.kernel.org>
+Cc: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
+Cc: Juri Lelli <juri.lelli@gmail.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Link: http://lkml.kernel.org/r/20140512205034.GH13467@laptop.programming.kicks-ass.net
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/sched/core.c | 9 +++------
+ 1 file changed, 3 insertions(+), 6 deletions(-)
+
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -3735,7 +3735,7 @@ SYSCALL_DEFINE1(sched_getscheduler, pid_
+ */
+ SYSCALL_DEFINE2(sched_getparam, pid_t, pid, struct sched_param __user *, param)
+ {
+- struct sched_param lp;
++ struct sched_param lp = { .sched_priority = 0 };
+ struct task_struct *p;
+ int retval;
+
+@@ -3752,11 +3752,8 @@ SYSCALL_DEFINE2(sched_getparam, pid_t, p
+ if (retval)
+ goto out_unlock;
+
+- if (task_has_dl_policy(p)) {
+- retval = -EINVAL;
+- goto out_unlock;
+- }
+- lp.sched_priority = p->rt_priority;
++ if (task_has_rt_policy(p))
++ lp.sched_priority = p->rt_priority;
+ rcu_read_unlock();
+
+ /*
--- /dev/null
+From b0827819b0da4acfbc1df1e05edcf50efd07cbd1 Mon Sep 17 00:00:00 2001
+From: Juri Lelli <juri.lelli@gmail.com>
+Date: Tue, 13 May 2014 14:11:31 +0200
+Subject: sched/deadline: Restrict user params max value to 2^63 ns
+
+From: Juri Lelli <juri.lelli@gmail.com>
+
+commit b0827819b0da4acfbc1df1e05edcf50efd07cbd1 upstream.
+
+Michael Kerrisk noticed that creating SCHED_DEADLINE reservations
+with certain parameters (e.g, a runtime of something near 2^64 ns)
+can cause a system freeze for some amount of time.
+
+The problem is that in the interface we have
+
+ u64 sched_runtime;
+
+while internally we need to have a signed runtime (to cope with
+budget overruns)
+
+ s64 runtime;
+
+At the time we setup a new dl_entity we copy the first value in
+the second. The cast turns out with negative values when
+sched_runtime is too big, and this causes the scheduler to go crazy
+right from the start.
+
+Moreover, considering how we deal with deadlines wraparound
+
+ (s64)(a - b) < 0
+
+we also have to restrict acceptable values for sched_{deadline,period}.
+
+This patch fixes the thing checking that user parameters are always
+below 2^63 ns (still large enough for everyone).
+
+It also rewrites other conditions that we check, since in
+__checkparam_dl we don't have to deal with deadline wraparounds
+and what we have now erroneously fails when the difference between
+values is too big.
+
+Reported-by: Michael Kerrisk <mtk.manpages@gmail.com>
+Suggested-by: Peter Zijlstra <peterz@infradead.org>
+Signed-off-by: Juri Lelli <juri.lelli@gmail.com>
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Cc: Dario Faggioli<raistlin@linux.it>
+Cc: Dave Jones <davej@redhat.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Link: http://lkml.kernel.org/r/20140513141131.20d944f81633ee937f256385@gmail.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/sched/core.c | 37 ++++++++++++++++++++++++++++++-------
+ 1 file changed, 30 insertions(+), 7 deletions(-)
+
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -3242,17 +3242,40 @@ __getparam_dl(struct task_struct *p, str
+ * We ask for the deadline not being zero, and greater or equal
+ * than the runtime, as well as the period of being zero or
+ * greater than deadline. Furthermore, we have to be sure that
+- * user parameters are above the internal resolution (1us); we
+- * check sched_runtime only since it is always the smaller one.
++ * user parameters are above the internal resolution of 1us (we
++ * check sched_runtime only since it is always the smaller one) and
++ * below 2^63 ns (we have to check both sched_deadline and
++ * sched_period, as the latter can be zero).
+ */
+ static bool
+ __checkparam_dl(const struct sched_attr *attr)
+ {
+- return attr && attr->sched_deadline != 0 &&
+- (attr->sched_period == 0 ||
+- (s64)(attr->sched_period - attr->sched_deadline) >= 0) &&
+- (s64)(attr->sched_deadline - attr->sched_runtime ) >= 0 &&
+- attr->sched_runtime >= (2 << (DL_SCALE - 1));
++ /* deadline != 0 */
++ if (attr->sched_deadline == 0)
++ return false;
++
++ /*
++ * Since we truncate DL_SCALE bits, make sure we're at least
++ * that big.
++ */
++ if (attr->sched_runtime < (1ULL << DL_SCALE))
++ return false;
++
++ /*
++ * Since we use the MSB for wrap-around and sign issues, make
++ * sure it's not set (mind that period can be equal to zero).
++ */
++ if (attr->sched_deadline & (1ULL << 63) ||
++ attr->sched_period & (1ULL << 63))
++ return false;
++
++ /* runtime <= deadline <= period (if period != 0) */
++ if ((attr->sched_period != 0 &&
++ attr->sched_period < attr->sched_deadline) ||
++ attr->sched_deadline < attr->sched_runtime)
++ return false;
++
++ return true;
+ }
+
+ /*
--- /dev/null
+From 0f397f2c90ce68821ee864c2c53baafe78de765d Mon Sep 17 00:00:00 2001
+From: Kirill Tkhai <tkhai@yandex.ru>
+Date: Tue, 20 May 2014 13:33:42 +0400
+Subject: sched/dl: Fix race in dl_task_timer()
+
+From: Kirill Tkhai <tkhai@yandex.ru>
+
+commit 0f397f2c90ce68821ee864c2c53baafe78de765d upstream.
+
+Throttled task is still on rq, and it may be moved to other cpu
+if user is playing with sched_setaffinity(). Therefore, unlocked
+task_rq() access makes the race.
+
+Juri Lelli reports he got this race when dl_bandwidth_enabled()
+was not set.
+
+Other thing, pointed by Peter Zijlstra:
+
+ "Now I suppose the problem can still actually happen when
+ you change the root domain and trigger a effective affinity
+ change that way".
+
+To fix that we do the same as made in __task_rq_lock(). We do not
+use __task_rq_lock() itself, because it has a useful lockdep check,
+which is not correct in case of dl_task_timer(). We do not need
+pi_lock locked here. This case is an exception (PeterZ):
+
+ "The only reason we don't strictly need ->pi_lock now is because
+ we're guaranteed to have p->state == TASK_RUNNING here and are
+ thus free of ttwu races".
+
+Signed-off-by: Kirill Tkhai <tkhai@yandex.ru>
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Link: http://lkml.kernel.org/r/3056991400578422@web14g.yandex.ru
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/sched/deadline.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/kernel/sched/deadline.c
++++ b/kernel/sched/deadline.c
+@@ -490,9 +490,17 @@ static enum hrtimer_restart dl_task_time
+ struct sched_dl_entity,
+ dl_timer);
+ struct task_struct *p = dl_task_of(dl_se);
+- struct rq *rq = task_rq(p);
++ struct rq *rq;
++again:
++ rq = task_rq(p);
+ raw_spin_lock(&rq->lock);
+
++ if (rq != task_rq(p)) {
++ /* Task was moved, retrying. */
++ raw_spin_unlock(&rq->lock);
++ goto again;
++ }
++
+ /*
+ * We need to take care of a possible races here. In fact, the
+ * task might have changed its scheduling policy to something
--- /dev/null
+From 6acbfb96976fc3350e30d964acb1dbbdf876d55e Mon Sep 17 00:00:00 2001
+From: Lai Jiangshan <laijs@cn.fujitsu.com>
+Date: Fri, 16 May 2014 11:50:42 +0800
+Subject: sched: Fix hotplug vs. set_cpus_allowed_ptr()
+
+From: Lai Jiangshan <laijs@cn.fujitsu.com>
+
+commit 6acbfb96976fc3350e30d964acb1dbbdf876d55e upstream.
+
+Lai found that:
+
+ WARNING: CPU: 1 PID: 13 at arch/x86/kernel/smp.c:124 native_smp_send_reschedule+0x2d/0x4b()
+ ...
+ migration_cpu_stop+0x1d/0x22
+
+was caused by set_cpus_allowed_ptr() assuming that cpu_active_mask is
+always a sub-set of cpu_online_mask.
+
+This isn't true since 5fbd036b552f ("sched: Cleanup cpu_active madness").
+
+So set active and online at the same time to avoid this particular
+problem.
+
+Fixes: 5fbd036b552f ("sched: Cleanup cpu_active madness")
+Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
+Signed-off-by: Peter Zijlstra <peterz@infradead.org>
+Cc: Andrew Morton <akpm@linux-foundation.org>
+Cc: Gautham R. Shenoy <ego@linux.vnet.ibm.com>
+Cc: Linus Torvalds <torvalds@linux-foundation.org>
+Cc: Michael wang <wangyun@linux.vnet.ibm.com>
+Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
+Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
+Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
+Cc: Toshi Kani <toshi.kani@hp.com>
+Link: http://lkml.kernel.org/r/53758B12.8060609@cn.fujitsu.com
+Signed-off-by: Ingo Molnar <mingo@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ kernel/cpu.c | 6 ++++--
+ kernel/sched/core.c | 1 -
+ 2 files changed, 4 insertions(+), 3 deletions(-)
+
+--- a/kernel/cpu.c
++++ b/kernel/cpu.c
+@@ -692,10 +692,12 @@ void set_cpu_present(unsigned int cpu, b
+
+ void set_cpu_online(unsigned int cpu, bool online)
+ {
+- if (online)
++ if (online) {
+ cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits));
+- else
++ cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));
++ } else {
+ cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits));
++ }
+ }
+
+ void set_cpu_active(unsigned int cpu, bool active)
+--- a/kernel/sched/core.c
++++ b/kernel/sched/core.c
+@@ -5075,7 +5075,6 @@ static int sched_cpu_active(struct notif
+ unsigned long action, void *hcpu)
+ {
+ switch (action & ~CPU_TASKS_FROZEN) {
+- case CPU_STARTING:
+ case CPU_DOWN_FAILED:
+ set_cpu_active((long)hcpu, true);
+ return NOTIFY_OK;
virtio_blk-fix-race-between-start-and-stop-queue.patch
sched-disallow-sched_attr-sched_policy-0.patch
sched-make-sched_setattr-correctly-return-efbig.patch
+sched-deadline-change-sched_getparam-behaviour-vs-sched_deadline.patch
+sched-deadline-restrict-user-params-max-value-to-2-63-ns.patch
+sched-fix-hotplug-vs.-set_cpus_allowed_ptr.patch
+sched-dl-fix-race-in-dl_task_timer.patch
+drm-radeon-avoid-crash-if-vm-command-submission-isn-t-available.patch