cpu.cc (13981:577196ddd040) cpu.cc (14085:0075b0d29d55)
1/*
2 * Copyright (c) 2011-2012, 2014, 2016, 2017, 2019 ARM Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 1008 unchanged lines hidden (view full) ---

1017 // stage commits an instruction where it is safe to stop, it'll
1018 // squash the rest of the instructions in the pipeline and force
1019 // the fetch stage to stall. The pipeline will be drained once all
1020 // in-flight instructions have retired.
1021 commit.drain();
1022
1023 // Wake the CPU and record activity so everything can drain out if
1024 // the CPU was not able to immediately drain.
1/*
2 * Copyright (c) 2011-2012, 2014, 2016, 2017, 2019 ARM Limited
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
4 * All rights reserved
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating

--- 1008 unchanged lines hidden (view full) ---

1017 // stage commits an instruction where it is safe to stop, it'll
1018 // squash the rest of the instructions in the pipeline and force
1019 // the fetch stage to stall. The pipeline will be drained once all
1020 // in-flight instructions have retired.
1021 commit.drain();
1022
1023 // Wake the CPU and record activity so everything can drain out if
1024 // the CPU was not able to immediately drain.
1025 if (!isDrained()) {
1025 if (!isCpuDrained()) {
1026 // If a thread is suspended, wake it up so it can be drained
1027 for (auto t : threadContexts) {
1028 if (t->status() == ThreadContext::Suspended){
1029 DPRINTF(Drain, "Currently suspended so activate %i \n",
1030 t->threadId());
1031 t->activate();
1032 // As the thread is now active, change the power state as well
1033 activateContext(t->threadId());

--- 9 unchanged lines hidden (view full) ---

1043 } else {
1044 DPRINTF(Drain, "CPU is already drained\n");
1045 if (tickEvent.scheduled())
1046 deschedule(tickEvent);
1047
1048 // Flush out any old data from the time buffers. In
1049 // particular, there might be some data in flight from the
1050 // fetch stage that isn't visible in any of the CPU buffers we
1026 // If a thread is suspended, wake it up so it can be drained
1027 for (auto t : threadContexts) {
1028 if (t->status() == ThreadContext::Suspended){
1029 DPRINTF(Drain, "Currently suspended so activate %i \n",
1030 t->threadId());
1031 t->activate();
1032 // As the thread is now active, change the power state as well
1033 activateContext(t->threadId());

--- 9 unchanged lines hidden (view full) ---

1043 } else {
1044 DPRINTF(Drain, "CPU is already drained\n");
1045 if (tickEvent.scheduled())
1046 deschedule(tickEvent);
1047
1048 // Flush out any old data from the time buffers. In
1049 // particular, there might be some data in flight from the
1050 // fetch stage that isn't visible in any of the CPU buffers we
1051 // test in isDrained().
1051 // test in isCpuDrained().
1052 for (int i = 0; i < timeBuffer.getSize(); ++i) {
1053 timeBuffer.advance();
1054 fetchQueue.advance();
1055 decodeQueue.advance();
1056 renameQueue.advance();
1057 iewQueue.advance();
1058 }
1059
1060 drainSanityCheck();
1061 return DrainState::Drained;
1062 }
1063}
1064
1065template <class Impl>
1066bool
1067FullO3CPU<Impl>::tryDrain()
1068{
1052 for (int i = 0; i < timeBuffer.getSize(); ++i) {
1053 timeBuffer.advance();
1054 fetchQueue.advance();
1055 decodeQueue.advance();
1056 renameQueue.advance();
1057 iewQueue.advance();
1058 }
1059
1060 drainSanityCheck();
1061 return DrainState::Drained;
1062 }
1063}
1064
1065template <class Impl>
1066bool
1067FullO3CPU<Impl>::tryDrain()
1068{
1069 if (drainState() != DrainState::Draining || !isDrained())
1069 if (drainState() != DrainState::Draining || !isCpuDrained())
1070 return false;
1071
1072 if (tickEvent.scheduled())
1073 deschedule(tickEvent);
1074
1075 DPRINTF(Drain, "CPU done draining, processing drain event\n");
1076 signalDrainDone();
1077
1078 return true;
1079}
1080
1081template <class Impl>
1082void
1083FullO3CPU<Impl>::drainSanityCheck() const
1084{
1070 return false;
1071
1072 if (tickEvent.scheduled())
1073 deschedule(tickEvent);
1074
1075 DPRINTF(Drain, "CPU done draining, processing drain event\n");
1076 signalDrainDone();
1077
1078 return true;
1079}
1080
1081template <class Impl>
1082void
1083FullO3CPU<Impl>::drainSanityCheck() const
1084{
1085 assert(isDrained());
1085 assert(isCpuDrained());
1086 fetch.drainSanityCheck();
1087 decode.drainSanityCheck();
1088 rename.drainSanityCheck();
1089 iew.drainSanityCheck();
1090 commit.drainSanityCheck();
1091}
1092
1093template <class Impl>
1094bool
1086 fetch.drainSanityCheck();
1087 decode.drainSanityCheck();
1088 rename.drainSanityCheck();
1089 iew.drainSanityCheck();
1090 commit.drainSanityCheck();
1091}
1092
1093template <class Impl>
1094bool
1095FullO3CPU::isDrained() const
1095FullO3CPU<Impl>::isCpuDrained() const
1096{
1097 bool drained(true);
1098
1099 if (!instList.empty() || !removeList.empty()) {
1100 DPRINTF(Drain, "Main CPU structures not drained.\n");
1101 drained = false;
1102 }
1103

--- 782 unchanged lines hidden ---
1096{
1097 bool drained(true);
1098
1099 if (!instList.empty() || !removeList.empty()) {
1100 DPRINTF(Drain, "Main CPU structures not drained.\n");
1101 drained = false;
1102 }
1103

--- 782 unchanged lines hidden ---