Article 5RV6J linux: timeout in ioctl request to kernel module

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,
Zvikalatest?d=yIl2AUoC8zA latest?i=oLqDTeaw3Y8:bpOv12u2WFg:F7zBnMy latest?i=oLqDTeaw3Y8:bpOv12u2WFg:V_sGLiP latest?d=qj6IDK7rITs latest?i=oLqDTeaw3Y8:bpOv12u2WFg:gIN9vFw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments