[PATCH] fix SMP support in cdu535 cdrom driver

From: Felipe W Damasio
Date: Wed Oct 08 2003 - 14:21:51 EST


Hi Jens,

Patch against 2.6.0-test6.

Even though cdu535 is polled, not interrupt driven, Matthew pointed out[1] that is a good idea to fix SMP support on that bit, so that people who wants to fix cdu31a don't get that wrong.

Move prepare_to_wait before enable_interrupts, so that if we enter the interrupt handler (after enable_interrupts) on a different CPU that's executing sony_sleep's poll version, "wait" is already on the irq_wait list, which I think fixes the race that Matthew pointed out, doesn't it?

CC'ing kernel-janitors since it also replaces yield for schedule_timeout[2], as Matthew suggested.

Please consider applying.

Thanks,

Felipe

[1] http://marc.theaimsgroup.com/?l=linux-kernel&m=106322465303649&w=2

[2] http://lists.osdl.org/pipermail/kernel-janitors/2003-October/000173.html --- linux-2.6.0-test6/drivers/cdrom/sonycd535.c.orig 2003-10-08 14:42:43.000000000 -0300
+++ linux-2.6.0-test6/drivers/cdrom/sonycd535.c 2003-10-08 16:00:09.000000000 -0300
@@ -342,13 +342,14 @@
sony_sleep(void)
{
if (sony535_irq_used <= 0) { /* poll */
- yield();
+ set_current_state(TASK_INTERRUPTIBLE);
+ schedule_timeout(1);
} else { /* Interrupt driven */
DEFINE_WAIT(wait);
-
+
spin_lock_irq(&sonycd535_lock);
- enable_interrupts();
prepare_to_wait(&cdu535_irq_wait, &wait, TASK_INTERRUPTIBLE);
+ enable_interrupts();
spin_unlock_irq(&sonycd535_lock);
schedule();
finish_wait(&cdu535_irq_wait, &wait);