diff options
author | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:37 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:37 -0500 |
commit | 63f1d0516d8a4e5a688cc3000b5a3597518d3dc7 (patch) | |
tree | a1a33ec62895dd6f8fa2de234a6186112e33b40c /src/dev/arm/pl111.hh | |
parent | fffdc6a45019639cd8f899fa81eeb732db3e6f8c (diff) | |
download | gem5-63f1d0516d8a4e5a688cc3000b5a3597518d3dc7.tar.xz |
arm: Fix DMA event handling bug in the PL111 model
The PL111 model currently maintains a list of pre-allocated
DmaDoneEvents to prevent unnecessary heap allocations. This list
effectively works like a stack where the top element is the latest
scheduled event. When an event triggers, the top pointer is moved down
the stack. This obviously breaks since events usually retire from the
bottom (events don't necessarily have to retire in order), which
triggers the following assertion:
gem5.debug: build/ARM/dev/arm/pl111.cc:460: void Pl111::fillFifo(): \
Assertion `!dmaDoneEvent[dmaPendingNum-1].scheduled()' failed.
This changeset adds a vector listing the currently unused events. This
vector acts like a stack where the an element is popped off the stack
when a new event is needed an pushed on the stack when they trigger.
Diffstat (limited to 'src/dev/arm/pl111.hh')
-rw-r--r-- | src/dev/arm/pl111.hh | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/src/dev/arm/pl111.hh b/src/dev/arm/pl111.hh index 2388e1c7a..2245d8124 100644 --- a/src/dev/arm/pl111.hh +++ b/src/dev/arm/pl111.hh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010 ARM Limited + * Copyright (c) 2010-2012 ARM Limited * All rights reserved * * The license below extends only to copyright in the software and shall @@ -161,6 +161,31 @@ class Pl111: public AmbaDmaDevice Bitfield<16> watermark; EndBitUnion(ControlReg) + /** + * Event wrapper for dmaDone() + * + * This event calls pushes its this pointer onto the freeDoneEvent + * vector and calls dmaDone() when triggered. + */ + class DmaDoneEvent : public Event + { + private: + Pl111 &obj; + + public: + DmaDoneEvent(Pl111 *_obj) + : Event(), obj(*_obj) {} + + void process() { + obj.dmaDoneEventFree.push_back(this); + obj.dmaDone(); + } + + const std::string name() const { + return obj.name() + ".DmaDoneEvent"; + } + }; + /** Horizontal axis panel control register */ TimingReg0 lcdTiming0; @@ -296,8 +321,28 @@ class Pl111: public AmbaDmaDevice /** Fill fifo */ EventWrapper<Pl111, &Pl111::fillFifo> fillFifoEvent; - /** DMA done event */ - std::vector<EventWrapper<Pl111, &Pl111::dmaDone> > dmaDoneEvent; + /**@{*/ + /** + * All pre-allocated DMA done events + * + * The PL111 model preallocates maxOutstandingDma number of + * DmaDoneEvents to avoid having to heap allocate every single + * event when it is needed. In order to keep track of which events + * are in flight and which are ready to be used, we use two + * different vectors. dmaDoneEventAll contains <i>all</i> + * DmaDoneEvents that the object may use, while dmaDoneEventFree + * contains a list of currently <i>unused</i> events. When an + * event needs to be scheduled, the last element of the + * dmaDoneEventFree is used and removed from the list. When an + * event fires, it is added to the end of the + * dmaEventFreeList. dmaDoneEventAll is never used except for in + * initialization and serialization. + */ + std::vector<DmaDoneEvent> dmaDoneEventAll; + + /** Unused DMA done events that are ready to be scheduled */ + std::vector<DmaDoneEvent *> dmaDoneEventFree; + /**@}*/ /** Wrapper to create an event out of the interrupt */ EventWrapper<Pl111, &Pl111::generateInterrupt> intEvent; |