Skip to content

Commit

Permalink
[media] [3.3.0] ir-raw: remove BUG_ON in ir_raw_event_thread
Browse files Browse the repository at this point in the history
This patch removes BUG_ON in ir_raw_event_thread which IMO is a
over-kill, and this kills the ir_raw_event_thread too. With a bit of
additional logic in this patch, we nomore need to kill this thread.
Other disadvantage of having a BUG-ON is,
wake_up_process(dev->raw->thread) called on dead thread via
ir_raw_event_handle will result in total lockup in SMP system.

Advantage of this patch is ir-raw event thread is left in a usable state
even if the fifo does not have enough bytes.

This patch sets the thread into TASK_INTERRUPTIBLE if raw-fifo has less
then sizeof(struct ir_raw_event) bytes.

Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@st.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Srinivas Kandagatla authored and Mauro Carvalho Chehab committed Apr 10, 2012
1 parent 2863860 commit 004ac38
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions drivers/media/rc/ir-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ static int ir_raw_event_thread(void *data)
while (!kthread_should_stop()) {

spin_lock_irq(&raw->lock);
retval = kfifo_out(&raw->kfifo, &ev, sizeof(ev));
retval = kfifo_len(&raw->kfifo);

if (!retval) {
if (retval < sizeof(ev)) {
set_current_state(TASK_INTERRUPTIBLE);

if (kthread_should_stop())
Expand All @@ -59,11 +59,9 @@ static int ir_raw_event_thread(void *data)
continue;
}

retval = kfifo_out(&raw->kfifo, &ev, sizeof(ev));
spin_unlock_irq(&raw->lock);


BUG_ON(retval != sizeof(ev));

mutex_lock(&ir_raw_handler_lock);
list_for_each_entry(handler, &ir_raw_handler_list, list)
handler->decode(raw->dev, ev);
Expand Down

0 comments on commit 004ac38

Please sign in to comment.