Find the answer to your Linux question:
Results 1 to 3 of 3
Hi there! I'm writing a device driver for an embedded-system (Linux-Version: 2.6.16.11-rt18) an have a problem with the wake_up() function. Here's a part of the Code: Code: u8 u8tmp = ...
  1. #1
    Just Joined!
    Join Date
    Jul 2008
    Posts
    15

    lang: C - device driver - problems with wake_up_interruptible()

    Hi there!

    I'm writing a device driver for an embedded-system (Linux-Version: 2.6.16.11-rt18) an have a problem with the wake_up() function.

    Here's a part of the Code:
    Code:
    u8 u8tmp = 0;   //that wake_up isn't called before sleeping
    u8 condition = 0; //...for wait_event_interruptible()
    
    struct dd_private_t {
       (...)
       pid_t thr_pid;
       wait_queue_head_t thr_wait;
       (...)
    }
    
    static int dd_open(struct net_device* dev)
    {
       (...)
       int result;
       result = request_irq(dev->irq, my_irq_handler, SA_INTERRUPT|SA_SHIRQ, dev->name, dev);
       if(result)
          printk("can't get assign IRQ\n");
       (...)
    }
    
    static int dd_start(struct net_device *dev)
    {
       struct dd_private_t* priv = (struct dd_private_t*)dev->priv;
       (...)
       init_waitqueue_head(&priv->thr_wait);
       priv->thr_pid = kernel_thread(dd_thread, dev, CLONE_FS|CLONE_FILES);
       (...)
    }
    
    irqreturn_t my_irq_handler(int irq, void *dev_id, struct pt_regs *regs)
    {
       struct net_device *dev = dev_id;
       struct dd_private_t *priv = (struct dd_private_t*)dev->priv;
    
       if(u8tmp) {
          condition = 1;
          wake_up_interruptible(&priv->thr_wait);
          return IRQ_HANDLED;
       }
       return IRQ_NONE;
    }
    
    static int dd_thread(void* data)
    {
       struct net_device* dev = data;
       struct dd_private_t* priv = (struct dd_private_t*)dev->priv;
       int tmpVal;
    
       daemonize("%s", dev->name);
       allow_signal(SIGTERM);
    
       while(1) {
          u8tmp = 1; //now you can try to wake up...
          tmpVal = wait_event_interruptible(priv->thr_wait, condition);
          printk("juhuu! - woke up\n");
          (...)
    }
    i'm sure, the wake_up_interruptible function is executed. (printk's in line above and line below), but the "juhuu!" never comes...

    is there anything else missing or should be called earlier/later?
    can't help, but for me it looks like the wake_up-call can't find the queue.

    i also tried with interruptible_sleep_on() but then, i get a kernel-oops
    "BUG: scheduling with irqs disabled"

    has anyone suggestions what could be wrong?

    thanks in advance!

  2. #2
    Just Joined!
    Join Date
    Jul 2008
    Posts
    15
    here is a part of the kernel oops:

    Code:
    BUG: scheduling with  irqs disabled: eth1/0x00000000/746
    caller is interruptible_sleep_on+0x58/0xa4
    Call Trace:
    [C7803F40] [C000B98C] show_stack+0x40/0x194 (unreliable)
    [C7803F70] [C0210A18] schedule+0xd8/0x110
    [C7803F80] [C0210F6C] interruptible_sleep_on+0x58/0xa4
    ...

  3. #3
    Just Joined!
    Join Date
    Jul 2008
    Posts
    15
    I think, I solved it.

    The acknowledge for the chip, that I received an interrupt wasn't sent in good time.
    So, the ISR was called all the time and can't handle the wake_up()-function.

    I don't know, if this is the right explanation, but now, I send the acknowledge before I call the wake_up()-function, therefore the IRQ is no longer active and it works!

    But now, there's another problem
    The first time the thread wakes up, everything seems to be ok. But after the first loop of "while(1)" the thread is in the "wait_event_interruptible()"-function again and nothing happens. Of course: there's no interrupt - but the console freeze and I can't even type a letter...

    Is wait_event_interruptible() active-waiting? And is it possible to wait passive. (Eventually without interruptible_sleep_on() - this function produces a kernel oops).

    Kind regards,

    Andy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...