--- driver.c.orig 2004-07-01 00:00:00.000000000 +0200 +++ driver.c 2005-02-26 11:15:41.000000000 +0100 @@ -18,6 +18,10 @@ * http://www.opensource.org/licenses/lgpl-license.html * * Contact: AVM GmbH, Alt-Moabit 95, 10559 Berlin, Germany, email: info@avm.de + * + * Mon Oct 20 22:43:31 2003 + * Modified by Joerg Lehrke to improve locking + * Fixed for rev 0.4.1 by Stefan Schweizer */ #include @@ -54,6 +58,8 @@ #include "devif.h" #include "driver.h" +#undef SINGLE_LOCK + #define KILOBYTE 1024 #define MEGABYTE (1024*KILOBYTE) #define _2_MEGS_ (2*MEGABYTE) @@ -92,7 +98,11 @@ typedef struct __db { card_p capi_card = NULL; lib_callback_t * capi_lib = NULL; atomic_t crit_count = ATOMIC_INIT(0); +#if defined (SINGLE_LOCK) +# define stack_lock qt_lock +#else spinlock_t stack_lock = SPIN_LOCK_UNLOCKED; +#endif static int nvers = 0; static atomic_t scheduler_enabled = ATOMIC_INIT (1); @@ -1322,9 +1332,10 @@ void msg2capi (unsigned char * msg) { capi_ctr_handle_message (ctrl, appl, skb); } /* msg2capi */ -/*-S-------------------------------------------------------------------------*\ +/*---------------------------------------------------------------------------*\ \*---------------------------------------------------------------------------*/ static int sched_thread (void * arg) { + unsigned long flags; UNUSED_ARG (arg); daemonize (TARGET); @@ -1356,6 +1367,7 @@ static int sched_thread (void * arg) { continue; } /* Body of thread, invoke scheduler */ + local_irq_save(flags); if (spin_trylock (&stack_lock)) { os_timer_poll (); assert (capi_lib->cm_schedule); @@ -1364,6 +1376,7 @@ static int sched_thread (void * arg) { } spin_unlock (&stack_lock); } + local_irq_restore(flags); } LOG("Scheduler thread stopped.\n"); up (&thread_sync);