From de24aafc161f348f678e0e0fc30b1ff2d145043b Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Tue, 3 Mar 2020 16:28:19 -0800 Subject: [PATCH] x86: Track message based interrupt cleanup functions in sender state. This makes sure the completion function follows the packet, and allows multiple packets to be in flight at once without the functions overwritting each other. Change-Id: Ic49c7b646d56b32c0453931942ee22ae07828bb6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/26163 Reviewed-by: Jason Lowe-Power Reviewed-by: Ayaz Akram Maintainer: Jason Lowe-Power Tested-by: kokoro --- src/dev/x86/intdev.hh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dev/x86/intdev.hh b/src/dev/x86/intdev.hh index a40a1d4f5..a681a2e22 100644 --- a/src/dev/x86/intdev.hh +++ b/src/dev/x86/intdev.hh @@ -45,6 +45,7 @@ #include #include +#include "base/cast.hh" #include "mem/tport.hh" #include "sim/sim_object.hh" @@ -103,7 +104,11 @@ class IntMasterPort : public QueuedMasterPort Tick latency; typedef std::function OnCompletionFunc; - OnCompletionFunc onCompletion = nullptr; + struct OnCompletion : public Packet::SenderState + { + OnCompletionFunc func; + OnCompletion(OnCompletionFunc _func) : func(_func) {} + }; // If nothing extra needs to happen, just clean up the packet. static void defaultOnCompletion(PacketPtr pkt) { delete pkt; } @@ -120,8 +125,9 @@ class IntMasterPort : public QueuedMasterPort recvTimingResp(PacketPtr pkt) override { assert(pkt->isResponse()); - onCompletion(pkt); - onCompletion = nullptr; + auto *oc = safe_cast(pkt->popSenderState()); + oc->func(pkt); + delete oc; return true; } @@ -130,7 +136,7 @@ class IntMasterPort : public QueuedMasterPort OnCompletionFunc func=defaultOnCompletion) { if (timing) { - onCompletion = func; + pkt->pushSenderState(new OnCompletion(func)); schedTimingReq(pkt, curTick() + latency); // The target handles cleaning up the packet in timing mode. } else { -- 2.30.2