dev: Fix infinite recursion in DMA devices
authorAndreas Sandberg <Andreas.Sandberg@ARM.com>
Mon, 7 Jan 2013 21:56:39 +0000 (16:56 -0500)
committerAndreas Sandberg <Andreas.Sandberg@ARM.com>
Mon, 7 Jan 2013 21:56:39 +0000 (16:56 -0500)
The DMA device sometimes calls the process() method on a completion
event directly instead of scheduling it on the current tick. This
breaks some devices that assume that the completion handler won't be
called until the current event handler has returned. Specifically, it
causes infinite recursion in the IdeDisk component because it does not
advance its chunk generator until after a dmaRead()/dmaWrite() has
returned. This changeset removes this mico-optimization and schedules
the event in the current tick instead. This way the semantics event
handling stay the same even when the delay is 0.

src/dev/dma_device.cc

index 952d6f622c811003ff50e467ad916089e491fbf5..7703703202556c3e7d17dd6a6184c6ba73ea86fc 100644 (file)
@@ -85,10 +85,7 @@ DmaPort::handleResp(PacketPtr pkt, Tick delay)
     if (state->totBytes == state->numBytes) {
         if (state->completionEvent) {
             delay += state->delay;
-            if (delay)
-                device->schedule(state->completionEvent, curTick() + delay);
-            else
-                state->completionEvent->process();
+            device->schedule(state->completionEvent, curTick() + delay);
         }
         delete state;
     }