Discussion:
Blocking wait for interrupt
Johannes Kliemann
2017-07-25 06:54:30 UTC
Permalink
Hi,

I'm currently writing a dde_linux driver that requires to wait for an
interrupt to be handled.
It basically initializes the hardware and then waits for an event to
occur. This event is usually triggered by the interrupt (respectively
its handler) which occurs after hardware initialization.
My problem is that this interrupt doesn't appear while the function
triggering it didn't return. So when this function blocks to wait for
the interrupt, a deadlock is created. Besides using the timer I tried to
block the execution with a semaphore creating the same problem.
Creating an async version is no option due to the architecture of the
Linux driver.

How are interrupts handled in this case? What causes them to block and
how can I work around this?

Regards,

JK
Sebastian Sumpf
2017-07-25 10:52:24 UTC
Permalink
Hi Johannes,
Post by Johannes Kliemann
Hi,
I'm currently writing a dde_linux driver that requires to wait for an
interrupt to be handled.
It basically initializes the hardware and then waits for an event to
occur. This event is usually triggered by the interrupt (respectively
its handler) which occurs after hardware initialization.
My problem is that this interrupt doesn't appear while the function
triggering it didn't return. So when this function blocks to wait for
the interrupt, a deadlock is created. Besides using the timer I tried to
block the execution with a semaphore creating the same problem.
Creating an async version is no option due to the architecture of the
Linux driver.
How are interrupts handled in this case? What causes them to block and
how can I work around this?
If I gather your description correctly, you are executing Linux code
from the entrypoint context. If this code somehow blocks, lets say by
calling 'wait_event_interruptible' or something else, the EP cannot
receive signals, and therefore no interrupts. The solution to this
problem are 'Lx::Task'(s). All Linux code should be executed by these
tasks, which are able to block and can be unblocked by the EP upon
signal reception. A small example can be found under
'dde_linux/src/drivers/framebuffer/intel/main.cc', there the Linux code
is executed by a task in 'run_linux', which is woken up by the
'Policy_agent' signal handler.

Regards,

Sebastian

P.S. I hope you are porting a driver and not writing one from scratch ;)
--
Sebastian Sumpf
Genode Labs

http://www.genode-labs.com · http://genode.org

Genode Labs GmbH · Amtsgericht Dresden · HRB 28424 · Sitz Dresden
Geschäftsführer: Dr.-Ing. Norman Feske, Christian Helmuth
Continue reading on narkive:
Loading...