diff options
author | David Hashe <david.hashe@amd.com> | 2015-07-20 09:15:18 -0500 |
---|---|---|
committer | David Hashe <david.hashe@amd.com> | 2015-07-20 09:15:18 -0500 |
commit | 21aa5734a0f2c03263e26c66e5cd95ad64c70697 (patch) | |
tree | 43cf18ec392aea120c025bf818a0ce30efab201c /src/mem/ruby/structures/BankedArray.cc | |
parent | 63a9f10de80a2a117aa06858e65dee2b6654762f (diff) | |
download | gem5-21aa5734a0f2c03263e26c66e5cd95ad64c70697.tar.xz |
ruby: fix deadlock bug in banked array resource checks
The Ruby banked array resource checks (initiated from SLICC) did a check and
allocate at the same time. If a transition needs more than one resource, then
it might check/allocate resource #1, then fail to get resource #2. Another
transition might then try to get the same resources, but in reverse order.
Deadlock.
This patch separates resource checking and resource reservation into two
steps to avoid deadlock.
Diffstat (limited to 'src/mem/ruby/structures/BankedArray.cc')
-rw-r--r-- | src/mem/ruby/structures/BankedArray.cc | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/mem/ruby/structures/BankedArray.cc b/src/mem/ruby/structures/BankedArray.cc index dbde2ab9a..8bc3cf584 100644 --- a/src/mem/ruby/structures/BankedArray.cc +++ b/src/mem/ruby/structures/BankedArray.cc @@ -58,13 +58,29 @@ BankedArray::tryAccess(int64 idx) assert(bank < banks); if (busyBanks[bank].endAccess >= curTick()) { - if (!(busyBanks[bank].startAccess == curTick() && - busyBanks[bank].idx == idx)) { return false; + } + + return true; +} + +void +BankedArray::reserve(int64 idx) +{ + if (accessLatency == 0) + return; + + unsigned int bank = mapIndexToBank(idx); + assert(bank < banks); + + if(busyBanks[bank].endAccess >= curTick()) { + if (busyBanks[bank].startAccess == curTick() && + busyBanks[bank].idx == idx) { + // this is the same reservation (can happen when + // e.g., reserve the same resource for read and write) + return; // OK } else { - // We tried to allocate resources twice - // in the same cycle for the same addr - return true; + panic("BankedArray reservation error"); } } @@ -72,8 +88,6 @@ BankedArray::tryAccess(int64 idx) busyBanks[bank].startAccess = curTick(); busyBanks[bank].endAccess = curTick() + (accessLatency-1) * m_ruby_system->clockPeriod(); - - return true; } unsigned int |