0

Inside my linux driver I have an ioctl dispatcher, and one branch uses msleep() function.

static long p347_fpga_ioctl(struct file *filp, uint cmd, unsigned long arg) 
{
    long ret_code = 0;
    ...

    switch (cmd) {
        ...
        case p347_IOCTL_CLIENT_START_ROT: {
            if (arg != 0) {
                ret_code = rot_set_params(trp); //idx
                if (ret_code == 0) {
                    ret_code = rot_run(trp->rot_idx);
                } else {
                    printk("Cannot setup rot channel with error=%d\n",ret_code);
                }
            }
        }
    break; }
        ...
    };
    ...
    return ret_code;
}

int rot_run(unsigned char rot_idx) contains msleep() call

Further, my userspace program uses all of ioctls inside mutex to prevent simultaneous calls.

...
pthread_mutex_lock(&FMutex);
ret = ioctl(dev_desc, p347_IOCTL_CLIENT_START_ROT, &params);
pthread_mutex_unlock(&FMutex);
...

That way, can msleep() cause any problems?

Konstantin Utkin
  • 478
  • 1
  • 5
  • 16
  • Yes, it can cause a problem... when you [read](http://www.unix.com/man-page/FreeBSD/9/msleep/) about msleep it is a blocking call, it will block the thread... but it depends on how are you waking up the tread and so on... – Dusan Plavak Aug 26 '13 at 09:10
  • So it is better to implement delayed execution in driver? – Konstantin Utkin Aug 26 '13 at 09:16
  • Well it depends on how you are using the locks and sleeps... because what can happen is deadlock, but if you are just wondering if these ioctl calls can be running in same time, it should not happen if you are using these locks... – Dusan Plavak Aug 26 '13 at 10:25

0 Answers0