lkml.org 
[lkml]   [2003]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Three drivers/i2c/ patches
Christoph Hellwig wrote:
>
> Sleeping with interrupts disabled and a spinlock held still isn't exactly a
> good idea. As is sleep_on..

So something like the following does make more sense?
I don't quite understand, how that code worked before - I suppose
interruptible_sleep_on_timeout activates irqs again, otherwise the interrupt
handler would have never been called? But then, the sti() doesn't make much
sense and should have been moved to the else path?

Thanks,

Jan

--- 2.5.75/drivers/i2c/i2c-elektor.c 2003-07-11 09:35:37.000000000 +0200
+++ 2.5.75-bk1/drivers/i2c/i2c-elektor.c 2003-07-13 12:06:06.000000000
+0200
@@ -59,6 +59,8 @@
need to be rewriten - but for now just remove this for simpler reading */

static wait_queue_head_t pcf_wait;
+
+spinlock_t pcf_pending_lock = SPIN_LOCK_UNLOCKED;
static int pcf_pending;

/* ----- global defines -----------------------------------------------
*/
@@ -120,12 +122,14 @@
int timeout = 2;

if (irq > 0) {
- cli();
+ spin_lock_irq(&pcf_pending_lock);
if (pcf_pending == 0) {
+ spin_unlock_irq(&pcf_pending_lock);
interruptible_sleep_on_timeout(&pcf_wait, timeout*HZ );
- } else
+ } else {
pcf_pending = 0;
- sti();
+ spin_unlock_irq(&pcf_pending_lock);
+ }
} else {
udelay(100);
}
@@ -133,7 +137,10 @@


static irqreturn_t pcf_isa_handler(int this_irq, void *dev_id, struct pt_regs
*regs) {
+ unsigned long flags;
+ spin_lock_irqsave(&pcf_pending_lock, flags);
pcf_pending = 1;
+ spin_unlock_irqrestore(&pcf_pending_lock, flags);
wake_up_interruptible(&pcf_wait);
return IRQ_HANDLED;
}

--
Linux rubicon 2.5.75-mm1-jd10 #1 SMP Sat Jul 12 19:40:28 CEST 2003 i686

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:46    [W:0.028 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site