kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* wake_up & wait_event are counting events ?
@ 2017-01-19 13:14 Ran Shalit
  2017-01-19 17:16 ` michi1 at michaelblizek.twilightparadox.com
  0 siblings, 1 reply; 2+ messages in thread
From: Ran Shalit @ 2017-01-19 13:14 UTC (permalink / raw)
  To: kernelnewbies

Hello,

I am trying to correctly register interrupt in kernel for user interface:

irq handler
=========

static irqreturn_t irq_handler(int irq, void *dev_id)
{
   struct elbit_irq_dev *elbit_irq = &elbit_irq_devices[0];
    printk("irq in\n");

 <<==== clear interrupt in fpga  here or after the call to wake_up,
(at the bottom of routine below ) ?

    atomic_set(&elbit_irq->flag, 1);
    wake_up_interruptible(&elbit_irq->pollw);



    return IRQ_HANDLED;
}

ioctl for waiting on interrupts
======================

static long elbit_device_ioctl( struct file *filp, /* ditto */
         unsigned int ioctl_num, /* number and param for ioctl */
         unsigned long ioctl_param)
{
    struct elbit_irq_dev *elbit_irq = &elbit_irq_devices[0];

    switch (ioctl_num) {
    case IOCTL_WAIT_IRQ:
        atomic_set(&elbit_irq->flag, 0);
        wait_event_interruptible(elbit_irq->pollw,
atomic_read(&elbit_irq->flag) != 0) ;
        break;


    default:
        break;
    }
    return 0;
}

my questions:
1. does wake_up and wait_event are countable, i.e. if there are 2
interrupts for example before wait_event is called, does it mean it
wake_event will not sleep on 2 consecutive calls ?

2. should we put the clear of interrupts in fpga in the interrupt
before or after the wake_up ? can we put them instead in the userspace
handler (IOCTL_WAIT_IRQ)  instead of  clearing the interrupt in the
interrupt handler ?

Thank you,
Ran

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-19 17:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19 13:14 wake_up & wait_event are counting events ? Ran Shalit
2017-01-19 17:16 ` michi1 at michaelblizek.twilightparadox.com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).