Re: 2.5.67-mm3: Bad: scheduling while atomic with IEEE1394 then hard freeze ( lockup on CPU0)

From: Andrew Morton (akpm@digeo.com)
Date: Tue Apr 15 2003 - 18:34:56 EST


Philippe Gramoullé <philippe.gramoulle@mmania.com> wrote:
>
> I'll wait for the fix and will happily try it once it's available.

Something like this...

diff -puN lib/kobject.c~kobj_lock-fix lib/kobject.c
--- 25/lib/kobject.c~kobj_lock-fix Tue Apr 15 16:31:28 2003
+++ 25-akpm/lib/kobject.c Tue Apr 15 16:34:33 2003
@@ -336,12 +336,14 @@ void kobject_unregister(struct kobject *
 struct kobject * kobject_get(struct kobject * kobj)
 {
         struct kobject * ret = kobj;
- spin_lock(&kobj_lock);
+ unsigned long flags;
+
+ spin_lock_irqsave(&kobj_lock, flags);
         if (kobj && atomic_read(&kobj->refcount) > 0)
                 atomic_inc(&kobj->refcount);
         else
                 ret = NULL;
- spin_unlock(&kobj_lock);
+ spin_unlock_irqrestore(&kobj_lock, flags);
         return ret;
 }
 
@@ -371,10 +373,15 @@ void kobject_cleanup(struct kobject * ko
 
 void kobject_put(struct kobject * kobj)
 {
- if (!atomic_dec_and_lock(&kobj->refcount, &kobj_lock))
- return;
- spin_unlock(&kobj_lock);
- kobject_cleanup(kobj);
+ unsigned long flags;
+
+ local_irq_save(flags);
+ if (atomic_dec_and_lock(&kobj->refcount, &kobj_lock)) {
+ spin_unlock_irqrestore(&kobj_lock, flags);
+ kobject_cleanup(kobj);
+ } else {
+ local_irq_restore(flags);
+ }
 }
 
 

_

-
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/



This archive was generated by hypermail 2b29 : Tue Apr 15 2003 - 22:00:37 EST