1/* |
2 * Copyright (c) 2012, 2015, 2017 ARM Limited |
3 * All rights reserved 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software 9 * licensed hereunder. You may use the software subject to the license 10 * terms below provided that you ensure that this notice is replicated --- 85 unchanged lines hidden (view full) --- 96{ 97 panic_if(_state == DrainState::Running, 98 "Trying to resume a system that is already running\n"); 99 100 warn_if(_state == DrainState::Draining, 101 "Resuming a system that isn't fully drained, this is untested and " 102 "likely to break\n"); 103 |
104 panic_if(_state == DrainState::Resuming, 105 "Resuming a system that is already trying to resume. This should " 106 "never happen.\n"); 107 |
108 panic_if(_count != 0, 109 "Resume called in the middle of a drain cycle. %u objects " 110 "left to drain.\n", _count); 111 |
112 // At this point in time the DrainManager and all objects will be 113 // in the the Drained state. New objects (i.e., objects created 114 // while resuming) will inherit the Resuming state from the 115 // DrainManager, which means we have to resume objects until all 116 // objects are in the Running state. 117 _state = DrainState::Resuming; 118 119 do { 120 DPRINTF(Drain, "Resuming %u objects.\n", drainableCount()); 121 for (auto *obj : _allDrainable) { 122 if (obj->drainState() != DrainState::Running) { 123 assert(obj->drainState() == DrainState::Drained || 124 obj->drainState() == DrainState::Resuming); 125 obj->dmDrainResume(); 126 } 127 } 128 } while (!allInState(DrainState::Running)); 129 |
130 _state = DrainState::Running; |
131} 132 133void 134DrainManager::preCheckpointRestore() 135{ 136 panic_if(_state != DrainState::Running, 137 "preCheckpointRestore() called on a system that isn't in the " 138 "Running state.\n"); --- 29 unchanged lines hidden (view full) --- 168DrainManager::unregisterDrainable(Drainable *obj) 169{ 170 std::lock_guard<std::mutex> lock(globalLock); 171 auto o = std::find(_allDrainable.begin(), _allDrainable.end(), obj); 172 assert(o != _allDrainable.end()); 173 _allDrainable.erase(o); 174} 175 |
176bool 177DrainManager::allInState(DrainState state) const 178{ 179 for (const auto *obj : _allDrainable) { 180 if (obj->drainState() != state) 181 return false; 182 } 183 184 return true; 185} 186 |
187size_t 188DrainManager::drainableCount() const 189{ 190 std::lock_guard<std::mutex> lock(globalLock); 191 return _allDrainable.size(); 192} 193 194 --- 19 unchanged lines hidden (view full) --- 214 _drainState == DrainState::Drained); 215 216 return _drainState; 217} 218 219void 220Drainable::dmDrainResume() 221{ |
222 panic_if(_drainState != DrainState::Drained && 223 _drainState != DrainState::Resuming, |
224 "Trying to resume an object that hasn't been drained\n"); 225 226 _drainState = DrainState::Running; 227 drainResume(); 228} |