diff options
author | Max Asbock <masbock@us.ibm.com> | 2005-06-21 20:16:33 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-21 22:07:34 -0400 |
commit | b8acb808468a88a188d7c5aba3681c583a5785f9 (patch) | |
tree | 7a4e5367e05cc52bc8008baaa8c35ed05989ec60 /drivers/misc/ibmasm/event.c | |
parent | f5ccc842318efcd7c05dee3203dfdbbafae47bd6 (diff) |
[PATCH] ibmasm driver: correctly wake up sleeping threads
Due to my incomplete understanding of the wait_event_interruptible() function
threads waiting for service processor events were not woken up. This patch
fixes that problem.
Signed-off-by: Max Asbock <masbock@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/misc/ibmasm/event.c')
-rw-r--r-- | drivers/misc/ibmasm/event.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/misc/ibmasm/event.c b/drivers/misc/ibmasm/event.c index e100f34f1587..fe1e819235a4 100644 --- a/drivers/misc/ibmasm/event.c +++ b/drivers/misc/ibmasm/event.c | |||
@@ -23,6 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "ibmasm.h" | 25 | #include "ibmasm.h" |
26 | #include "lowlevel.h" | ||
26 | 27 | ||
27 | /* | 28 | /* |
28 | * ASM service processor event handling routines. | 29 | * ASM service processor event handling routines. |
@@ -34,7 +35,6 @@ | |||
34 | * circular buffer. | 35 | * circular buffer. |
35 | */ | 36 | */ |
36 | 37 | ||
37 | |||
38 | static void wake_up_event_readers(struct service_processor *sp) | 38 | static void wake_up_event_readers(struct service_processor *sp) |
39 | { | 39 | { |
40 | struct event_reader *reader; | 40 | struct event_reader *reader; |
@@ -63,7 +63,7 @@ void ibmasm_receive_event(struct service_processor *sp, void *data, unsigned int | |||
63 | spin_lock_irqsave(&sp->lock, flags); | 63 | spin_lock_irqsave(&sp->lock, flags); |
64 | /* copy the event into the next slot in the circular buffer */ | 64 | /* copy the event into the next slot in the circular buffer */ |
65 | event = &buffer->events[buffer->next_index]; | 65 | event = &buffer->events[buffer->next_index]; |
66 | memcpy(event->data, data, data_size); | 66 | memcpy_fromio(event->data, data, data_size); |
67 | event->data_size = data_size; | 67 | event->data_size = data_size; |
68 | event->serial_number = buffer->next_serial_number; | 68 | event->serial_number = buffer->next_serial_number; |
69 | 69 | ||
@@ -93,7 +93,10 @@ int ibmasm_get_next_event(struct service_processor *sp, struct event_reader *rea | |||
93 | unsigned int index; | 93 | unsigned int index; |
94 | unsigned long flags; | 94 | unsigned long flags; |
95 | 95 | ||
96 | if (wait_event_interruptible(reader->wait, event_available(buffer, reader))) | 96 | reader->cancelled = 0; |
97 | |||
98 | if (wait_event_interruptible(reader->wait, | ||
99 | event_available(buffer, reader) || reader->cancelled)) | ||
97 | return -ERESTARTSYS; | 100 | return -ERESTARTSYS; |
98 | 101 | ||
99 | if (!event_available(buffer, reader)) | 102 | if (!event_available(buffer, reader)) |
@@ -116,6 +119,12 @@ int ibmasm_get_next_event(struct service_processor *sp, struct event_reader *rea | |||
116 | return event->data_size; | 119 | return event->data_size; |
117 | } | 120 | } |
118 | 121 | ||
122 | void ibmasm_cancel_next_event(struct event_reader *reader) | ||
123 | { | ||
124 | reader->cancelled = 1; | ||
125 | wake_up_interruptible(&reader->wait); | ||
126 | } | ||
127 | |||
119 | void ibmasm_event_reader_register(struct service_processor *sp, struct event_reader *reader) | 128 | void ibmasm_event_reader_register(struct service_processor *sp, struct event_reader *reader) |
120 | { | 129 | { |
121 | unsigned long flags; | 130 | unsigned long flags; |
@@ -131,8 +140,6 @@ void ibmasm_event_reader_unregister(struct service_processor *sp, struct event_r | |||
131 | { | 140 | { |
132 | unsigned long flags; | 141 | unsigned long flags; |
133 | 142 | ||
134 | wake_up_interruptible(&reader->wait); | ||
135 | |||
136 | spin_lock_irqsave(&sp->lock, flags); | 143 | spin_lock_irqsave(&sp->lock, flags); |
137 | list_del(&reader->node); | 144 | list_del(&reader->node); |
138 | spin_unlock_irqrestore(&sp->lock, flags); | 145 | spin_unlock_irqrestore(&sp->lock, flags); |
@@ -164,6 +171,5 @@ int ibmasm_event_buffer_init(struct service_processor *sp) | |||
164 | 171 | ||
165 | void ibmasm_event_buffer_exit(struct service_processor *sp) | 172 | void ibmasm_event_buffer_exit(struct service_processor *sp) |
166 | { | 173 | { |
167 | wake_up_event_readers(sp); | ||
168 | kfree(sp->event_buffer); | 174 | kfree(sp->event_buffer); |
169 | } | 175 | } |