diff options
author | Zheng Da <zhengda1936@gmail.com> | 2010-08-09 12:32:17 +0200 |
---|---|---|
committer | Zheng Da <zhengda1936@gmail.com> | 2010-08-09 12:32:17 +0200 |
commit | 529d8041be254a2ba56543953b1daf8f1c83a204 (patch) | |
tree | 08af6de7666084e70b62e08d37667cdc803b92de | |
parent | 76f4a1e072033c98e4b7430a59929d7896064e83 (diff) |
fake irq disable and enable.
Some functions such as blk_plug_device checks whether irqs are disabled.
So I need to fake irq diable in spin_lock_irq and spin_lock_irqsave.
-rw-r--r-- | libdde_linux26/include/linux/spinlock.h | 10 | ||||
-rw-r--r-- | libdde_linux26/lib/src/arch/l4/cli_sti.c | 15 |
2 files changed, 23 insertions, 2 deletions
diff --git a/libdde_linux26/include/linux/spinlock.h b/libdde_linux26/include/linux/spinlock.h index f038d145..6830752b 100644 --- a/libdde_linux26/include/linux/spinlock.h +++ b/libdde_linux26/include/linux/spinlock.h @@ -372,6 +372,10 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); #else /* DDE_LINUX */ +unsigned long fake_local_irq_disable_flags(void); +void fake_local_irq_enable(void); +void fake_local_irq_restore(unsigned long flags); + #define spin_lock_init(l) \ do { \ ddekit_lock_init(&(l)->ddekit_lock); \ @@ -394,7 +398,7 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); #define read_lock(lock) spin_lock(lock) #define write_lock(lock) spin_lock(lock) -#define spin_lock_irq(lock) spin_lock(lock) +#define spin_lock_irq(lock) fake_local_irq_disable_flags(); spin_lock(lock) #define spin_lock_bh(lock) spin_lock(lock) #define read_lock_irq(lock) spin_lock_irq(lock) #define read_lock_bh(lock) spin_lock_bh(lock) @@ -411,7 +415,7 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); #define read_unlock(lock) spin_unlock(lock) #define write_unlock(lock) spin_unlock(lock) -#define spin_unlock_irq(lock) spin_unlock(lock) +#define spin_unlock_irq(lock) spin_unlock(lock); fake_local_irq_enable() #define spin_unlock_bh(lock) spin_unlock(lock) #define read_unlock_irq(lock) spin_unlock_irq(lock) #define read_unlock_bh(lock) spin_unlock_bh(lock) @@ -420,6 +424,7 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); #define spin_lock_irqsave(lock, flags) \ do { \ + flags = fake_local_irq_disable_flags(); \ spin_lock(lock);\ } while (0); @@ -429,6 +434,7 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock); #define spin_unlock_irqrestore(lock, flags) \ do { \ spin_unlock(lock); \ + fake_local_irq_restore (flags); \ } while (0); #define read_unlock_irqrestore(lock, flags) spin_unlock_irqrestore(lock, flags) diff --git a/libdde_linux26/lib/src/arch/l4/cli_sti.c b/libdde_linux26/lib/src/arch/l4/cli_sti.c index 3f5ba4cf..051f2598 100644 --- a/libdde_linux26/lib/src/arch/l4/cli_sti.c +++ b/libdde_linux26/lib/src/arch/l4/cli_sti.c @@ -39,6 +39,21 @@ static int nested_lock(ddekit_lock_t lock) return do_lock; } +unsigned long fake_local_irq_disable_flags(void) +{ + return atomic_add_return (1, &_refcnt) - 1; +} + +void fake_local_irq_enable(void) +{ + atomic_set(&_refcnt, 0); +} + +void fake_local_irq_restore(unsigned long flags) +{ + atomic_set(&_refcnt, flags); +} + /* Store the current flags state. * * This is done by returning the current refcnt. |