diff --git a/dde_linux/src/lib/usb/include/signal.h b/dde_linux/src/lib/usb/include/signal.h index 8b3d0e4f0f..bf3e2ea8b0 100644 --- a/dde_linux/src/lib/usb/include/signal.h +++ b/dde_linux/src/lib/usb/include/signal.h @@ -116,6 +116,7 @@ namespace Irq { void init(Genode::Signal_receiver *recv); void check_irq(); + void wait_for_irq(); } namespace Event diff --git a/dde_linux/src/lib/usb/nic/nic.cc b/dde_linux/src/lib/usb/nic/nic.cc index c5f78fa17f..41e986d29d 100644 --- a/dde_linux/src/lib/usb/nic/nic.cc +++ b/dde_linux/src/lib/usb/nic/nic.cc @@ -98,9 +98,8 @@ class Skb /* wait until some SKBs are freed */ - _wait_free = false; - //PDBG("wait for free skbs ..."); - _wait_event(_wait_free); + for (_wait_free = false; !_wait_free;) + Irq::wait_for_irq(); return alloc(); } diff --git a/dde_linux/src/lib/usb/signal/irq.cc b/dde_linux/src/lib/usb/signal/irq.cc index e75aa37755..c5debb4062 100644 --- a/dde_linux/src/lib/usb/signal/irq.cc +++ b/dde_linux/src/lib/usb/signal/irq.cc @@ -22,6 +22,7 @@ extern "C" { /* our local incarnation of sender and receiver */ static Signal_helper *_signal = 0; static Genode::Lock _irq_sync(Genode::Lock::LOCKED); +static Genode::Lock _irq_wait(Genode::Lock::LOCKED); /** * This contains the Linux-driver handlers @@ -80,6 +81,9 @@ class Irq_context : public Driver_context, static Genode::Lock handler_lock; Genode::Lock::Guard guard(handler_lock); + /* unlock if main thread is waiting */ + _irq_wait.unlock(); + Irq_context *ctx = static_cast(irq); /* set context & submit signal */ @@ -120,7 +124,7 @@ class Irq_context : public Driver_context, /* report IRQ to all clients */ for (Irq_handler *h = _handler_list.first(); h; h = h->next()) { - if (_handle_one(h)) + if ((handled = _handle_one(h))) break; dde_kit_log(DEBUG_IRQ, "IRQ: %u ret: %u h: %p dev: %p", _irq, handled, h->handler, h->dev); @@ -191,6 +195,13 @@ void Irq::check_irq() } +void Irq::wait_for_irq() +{ + while (!Irq_context::check_irq()) + _irq_wait.lock(); +} + + /*********************** ** linux/interrupt.h ** ***********************/