--- /dev/null
+From stable-bounces@linux.kernel.org Fri Jul 28 19:53:01 2006
+Date: Fri, 28 Jul 2006 22:52:09 -0400
+From: Dave Jones <davej@redhat.com>
+To: stable@kernel.org
+Message-ID: <20060729025209.GA19848@redhat.com>
+Content-Disposition: inline
+Cc: akpm@osdl.org
+Subject: cond_resched() fix
+
+
+From: Andrew Morton <akpm@osdl.org>
+
+[PATCH] cond_resched() fix
+
+Fix a bug identified by Zou Nan hai <nanhai.zou@intel.com>:
+
+If the system is in state SYSTEM_BOOTING, and need_resched() is true,
+cond_resched() returns true even though it didn't reschedule. Consequently
+need_resched() remains true and JBD locks up.
+
+Fix that by teaching cond_resched() to only return true if it really did call
+schedule().
+
+cond_resched_lock() and cond_resched_softirq() have a problem too. If we're
+in SYSTEM_BOOTING state and need_resched() is true, these functions will drop
+the lock and will then try to call schedule(), but the SYSTEM_BOOTING state
+will prevent schedule() from being called. So on return, need_resched() will
+still be true, but cond_resched_lock() has to return 1 to tell the caller that
+the lock was dropped. The caller will probably lock up.
+
+Bottom line: if these functions dropped the lock, they _must_ call schedule()
+to clear need_resched(). Make it so.
+
+Also, uninline __cond_resched(). It's largeish, and slowpath.
+
+Acked-by: Ingo Molnar <mingo@elte.hu>
+Signed-off-by: Andrew Morton <akpm@osdl.org>
+Signed-off-by: Linus Torvalds <torvalds@osdl.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ kernel/sched.c | 25 +++++++++++++------------
+ 1 file changed, 13 insertions(+), 12 deletions(-)
+
+--- linux-2.6.17.7.orig/kernel/sched.c
++++ linux-2.6.17.7/kernel/sched.c
+@@ -4044,17 +4044,22 @@ asmlinkage long sys_sched_yield(void)
+ return 0;
+ }
+
+-static inline void __cond_resched(void)
++static inline int __resched_legal(int expected_preempt_count)
++{
++ if (unlikely(preempt_count() != expected_preempt_count))
++ return 0;
++ if (unlikely(system_state != SYSTEM_RUNNING))
++ return 0;
++ return 1;
++}
++
++static void __cond_resched(void)
+ {
+ /*
+ * The BKS might be reacquired before we have dropped
+ * PREEMPT_ACTIVE, which could trigger a second
+ * cond_resched() call.
+ */
+- if (unlikely(preempt_count()))
+- return;
+- if (unlikely(system_state != SYSTEM_RUNNING))
+- return;
+ do {
+ add_preempt_count(PREEMPT_ACTIVE);
+ schedule();
+@@ -4064,13 +4069,12 @@ static inline void __cond_resched(void)
+
+ int __sched cond_resched(void)
+ {
+- if (need_resched()) {
++ if (need_resched() && __resched_legal(0)) {
+ __cond_resched();
+ return 1;
+ }
+ return 0;
+ }
+-
+ EXPORT_SYMBOL(cond_resched);
+
+ /*
+@@ -4091,7 +4095,7 @@ int cond_resched_lock(spinlock_t *lock)
+ ret = 1;
+ spin_lock(lock);
+ }
+- if (need_resched()) {
++ if (need_resched() && __resched_legal(1)) {
+ _raw_spin_unlock(lock);
+ preempt_enable_no_resched();
+ __cond_resched();
+@@ -4100,14 +4104,13 @@ int cond_resched_lock(spinlock_t *lock)
+ }
+ return ret;
+ }
+-
+ EXPORT_SYMBOL(cond_resched_lock);
+
+ int __sched cond_resched_softirq(void)
+ {
+ BUG_ON(!in_softirq());
+
+- if (need_resched()) {
++ if (need_resched() && __resched_legal(0)) {
+ __local_bh_enable();
+ __cond_resched();
+ local_bh_disable();
+@@ -4115,10 +4118,8 @@ int __sched cond_resched_softirq(void)
+ }
+ return 0;
+ }
+-
+ EXPORT_SYMBOL(cond_resched_softirq);
+
+-
+ /**
+ * yield - yield the current processor to other threads.
+ *
--- /dev/null
+From mkrufky@linuxtv.org Tue Jul 25 10:09:09 2006
+Message-ID: <44C64FC1.4060501@linuxtv.org>
+Date: Tue, 25 Jul 2006 13:07:13 -0400
+From: Michael Krufky <mkrufky@linuxtv.org>
+To: Arjan van de Ven <arjan@infradead.org>
+Cc: David Lang <dlang@digitalinsight.com>,
+ Andrew de Quincey <adq_dvb@lidskialf.net>,
+ Arnaud Patard <apatard@mandriva.com>, Greg KH <gregkh@suse.de>,
+ linux-kernel@vger.kernel.org, stable@kernel.org
+Subject: Fix budget-av compile failure
+
+From: Andrew de Quincey <adq_dvb@lidskialf.net>
+
+Currently I am doing lots of refactoring work in the dvb tree. This
+bugfix became necessary to fix 2.6.17 whilst I was in the middle of this
+work. Unfortunately after I tested the original code for the patch, I
+generated the diff against the wrong tree (I accidentally used a tree
+with part of the refactoring code in it). This resulted in the reported
+compile errors because that tree (a) was incomplete, and (b) used
+features which are simply not in the mainline kernel yet.
+
+Many apologies for the error and problems this has caused. :(
+
+Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
+Signed-off-by: Michael Krufky <mkrufky@linuxtv.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+---
+ drivers/media/dvb/ttpci/budget-av.c | 10 +++++-----
+ 1 file changed, 5 insertions(+), 5 deletions(-)
+
+--- linux-2.6.17.7.orig/drivers/media/dvb/ttpci/budget-av.c
++++ linux-2.6.17.7/drivers/media/dvb/ttpci/budget-av.c
+@@ -58,6 +58,7 @@ struct budget_av {
+ struct tasklet_struct ciintf_irq_tasklet;
+ int slot_status;
+ struct dvb_ca_en50221 ca;
++ u8 reinitialise_demod:1;
+ };
+
+ /* GPIO Connections:
+@@ -214,8 +215,9 @@ static int ciintf_slot_reset(struct dvb_
+ while (--timeout > 0 && ciintf_read_attribute_mem(ca, slot, 0) != 0x1d)
+ msleep(100);
+
+- /* reinitialise the frontend */
+- dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
++ /* reinitialise the frontend if necessary */
++ if (budget_av->reinitialise_demod)
++ dvb_frontend_reinitialise(budget_av->budget.dvb_frontend);
+
+ if (timeout <= 0)
+ {
+@@ -1064,12 +1066,10 @@ static void frontend_init(struct budget_
+ fe = tda10021_attach(&philips_cu1216_config,
+ &budget_av->budget.i2c_adap,
+ read_pwm(budget_av));
+- if (fe) {
+- fe->ops.tuner_ops.set_params = philips_cu1216_tuner_set_params;
+- }
+ break;
+
+ case SUBID_DVBC_KNC1_PLUS:
++ budget_av->reinitialise_demod = 1;
+ fe = tda10021_attach(&philips_cu1216_config,
+ &budget_av->budget.i2c_adap,
+ read_pwm(budget_av));