usb_drv: Wait for IRQ on SKB exhaustion

Do not use 'wait_event' when SKB-backend allocation fails, explicitly wait for
an interrupt, which in turn frees SKBs, instead.

Fixes issue #788
This commit is contained in:
Sebastian Sumpf 2013-07-01 16:28:40 +02:00 committed by Norman Feske
parent 2045fffe2a
commit aacb91f22a
3 changed files with 15 additions and 4 deletions

View File

@ -116,6 +116,7 @@ namespace Irq
{
void init(Genode::Signal_receiver *recv);
void check_irq();
void wait_for_irq();
}
namespace Event

View File

@ -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();
}

View File

@ -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_context *>(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 **
***********************/