linux: timeout in ioctl request to kernel module
by zvivered from LinuxQuestions.org on (#5RV6J)
Hello,
I wrote a kernel module for an FPGA that generates an interrupt every N msec.
O.S: 4.9.20 (no distribution, directly from kernel.org)
Arch: x64
In the application, the code is:
Code:ioctl(m_Handle, INTERRUPT_REQUEST_CODE,&Request);The ioctl should block till interrupt or till timeout.
In the kernel module, the case which handles this ioctl is:
Code:case INTERRUPT_REQUEST_CODE:
copy_from_user(&InterruptRequest, (void*)IoctlParam, sizeof(INTERRUPT_REQUEST));
rc=wait_event_interruptible_timeout(sWaitQueuePacket, sInterruptFlagPacket != 0, Request.timeout);
sInterruptFlagPacket = 0;
InterruptRequest.Error = rc;
copy_to_user((void*)IoctlParam, &InterruptRequest, sizeof(INTERRUPT_REQUEST));
break;Is this the right way to be notified in the application about a timeout ?
must I use wait_event_interruptible_timeout or can I get timeout notification with ioctl in the application only ?
Thank you,
Zvika
I wrote a kernel module for an FPGA that generates an interrupt every N msec.
O.S: 4.9.20 (no distribution, directly from kernel.org)
Arch: x64
In the application, the code is:
Code:ioctl(m_Handle, INTERRUPT_REQUEST_CODE,&Request);The ioctl should block till interrupt or till timeout.
In the kernel module, the case which handles this ioctl is:
Code:case INTERRUPT_REQUEST_CODE:
copy_from_user(&InterruptRequest, (void*)IoctlParam, sizeof(INTERRUPT_REQUEST));
rc=wait_event_interruptible_timeout(sWaitQueuePacket, sInterruptFlagPacket != 0, Request.timeout);
sInterruptFlagPacket = 0;
InterruptRequest.Error = rc;
copy_to_user((void*)IoctlParam, &InterruptRequest, sizeof(INTERRUPT_REQUEST));
break;Is this the right way to be notified in the application about a timeout ?
must I use wait_event_interruptible_timeout or can I get timeout notification with ioctl in the application only ?
Thank you,
Zvika