]>
Commit | Line | Data |
---|---|---|
cd1a2927 MT |
1 | # patch found at http://freiburg.linux.de/~zeisberg/howtos/fritzcarddsl.html |
2 | --- fritz.old/src.drv/driver.c.orig Sun Dec 7 17:46:27 2003 | |
3 | +++ fritz/src.drv/driver.c Wed Dec 17 23:46:53 2003 | |
4 | @@ -18,6 +18,11 @@ | |
5 | * http://www.opensource.org/licenses/lgpl-license.html | |
6 | * | |
7 | * Contact: AVM GmbH, Alt-Moabit 95, 10559 Berlin, Germany, email: info@avm.de | |
8 | + * | |
9 | + * Sunday Dec 07 18:10 2003 | |
10 | + * Modified by Christian 'greeny' Heckhoff to improve locking | |
11 | + * based on modifications by Joerg Lehrke for Fritz!Card DSL | |
12 | + * | |
13 | */ | |
14 | ||
15 | #include <asm/io.h> | |
16 | @@ -53,6 +58,8 @@ | |
17 | #include "devif.h" | |
18 | #include "driver.h" | |
19 | ||
20 | +#undef SINGLE_LOCK | |
21 | + | |
22 | #if defined (LOG_MESSAGES) | |
23 | # define mlog log | |
24 | #else | |
25 | @@ -108,7 +115,11 @@ | |
26 | static bundle_t ctrl_context[2]; | |
27 | static per_ctrl_t ctrl_params[2]; | |
28 | static unsigned long qt_flags; | |
29 | +#if defined (SINGLE_LOCK) | |
30 | +# define stack_lock qt_lock | |
31 | +#else | |
32 | static spinlock_t qt_lock = SPIN_LOCK_UNLOCKED; | |
33 | +#endif | |
34 | static atomic_t thread_flag = ATOMIC_INIT (0); | |
35 | static atomic_t thread_capi_flag = ATOMIC_INIT (0); | |
36 | static int thread_pid = -1; | |
37 | @@ -1128,7 +1139,7 @@ | |
38 | } /* remove_ctrl */ | |
39 | ||
40 | /*---------------------------------------------------------------------------*\ | |
41 | -\*-L-------------------------------------------------------------------------*/ | |
42 | +\*---------------------------------------------------------------------------*/ | |
43 | void lock (void) { | |
44 | unsigned long local_flags; | |
45 | ||
46 | @@ -1146,15 +1157,14 @@ | |
47 | } /* unlock */ | |
48 | ||
49 | /*---------------------------------------------------------------------------*\ | |
50 | -\*-C-------------------------------------------------------------------------*/ | |
51 | +\*---------------------------------------------------------------------------*/ | |
52 | static inline void check (void) { | |
53 | unsigned long flags; | |
54 | - spinlock_t chk_lock = SPIN_LOCK_UNLOCKED; | |
55 | ||
56 | if (atomic_xchg (&xfer_flag, 0)) { | |
57 | - spin_lock_irqsave (&chk_lock, flags); | |
58 | + spin_lock_irqsave (&stack_lock, flags); | |
59 | xfer_handler (capi_card); | |
60 | - spin_unlock_irqrestore (&chk_lock, flags); | |
61 | + spin_unlock_irqrestore (&stack_lock, flags); | |
62 | } | |
63 | } /* check */ | |
64 | ||
65 | @@ -1687,9 +1697,10 @@ | |
66 | return ncci_data_buffer (capi_card->appls, appp, ncci, handle); | |
67 | } /* data_block */ | |
68 | ||
69 | -/*-S-------------------------------------------------------------------------*\ | |
70 | +/*---------------------------------------------------------------------------*\ | |
71 | \*---------------------------------------------------------------------------*/ | |
72 | static int sched_thread (void * arg) { | |
73 | + unsigned long flags; | |
74 | ||
75 | UNUSED_ARG (arg); | |
76 | daemonize (); | |
77 | @@ -1721,6 +1732,7 @@ | |
78 | continue; | |
79 | } | |
80 | /* Body of thread, invoke scheduler */ | |
81 | + local_irq_save(flags); | |
82 | if (spin_trylock (&stack_lock)) { | |
83 | os_timer_poll (); | |
84 | assert (capi_lib->cm_schedule); | |
85 | @@ -1729,6 +1741,7 @@ | |
86 | } | |
87 | spin_unlock (&stack_lock); | |
88 | } | |
89 | + local_irq_restore(flags); | |
90 | } | |
91 | log ("Scheduler thread stopped.\n"); | |
92 | up (&thread_sync); |