Yu-hsin Wang has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/66054?usp=email )

Change subject: systemc: fix the payload and packet association in Gem5ToTlm bridge
......................................................................

systemc: fix the payload and packet association in Gem5ToTlm bridge

If a request is initiated by systemc, passed through TlmToGem5 bridge
and Gem5ToTlm bridge, it wouldn't have the systemc extension about the
association. This feature is also used in TlmToGem5 bridge to detect if
the packet is allocated in the current instance in async interface. In
that case, we would lose the association in the Gem5ToTlm bridge async
interface. For not making wide change, we need an extra way to support
the association in Gem5ToTlm bridge async interface.

This change adds another map to record the association and clears when
the TLM transaction is completed.

Change-Id: I486441e813236ea2cabd1bd6cbb085b08d75ec8f
---
M src/systemc/tlm_bridge/gem5_to_tlm.cc
M src/systemc/tlm_bridge/gem5_to_tlm.hh
2 files changed, 35 insertions(+), 4 deletions(-)



diff --git a/src/systemc/tlm_bridge/gem5_to_tlm.cc b/src/systemc/tlm_bridge/gem5_to_tlm.cc
index a5eb9df..5159752 100644
--- a/src/systemc/tlm_bridge/gem5_to_tlm.cc
+++ b/src/systemc/tlm_bridge/gem5_to_tlm.cc
@@ -231,10 +231,10 @@
         }
     }
     if (phase == tlm::BEGIN_RESP) {
-        auto &extension = Gem5SystemC::Gem5Extension::getExtension(trans);
-        auto packet = extension.getPacket();
+        PacketPtr packet = packetMap[&trans];

         sc_assert(!blockingResponse);
+        sc_assert(packet);

         bool need_retry = false;

@@ -258,6 +258,7 @@
                 sc_core::sc_time delay = sc_core::SC_ZERO_TIME;
                 socket->nb_transport_fw(trans, fw_phase, delay);
                 // Release the transaction with all the extensions.
+                packetMap.erase(&trans);
                 trans.release();
             }
         }
@@ -433,11 +434,13 @@
         sc_assert(phase == tlm::BEGIN_REQ);
         // Accepted but is now blocking until END_REQ (exclusion rule).
         blockingRequest = trans;
+        packetMap.emplace(trans, packet);
     } else if (status == tlm::TLM_UPDATED) {
         // The Timing annotation must be honored:
         sc_assert(phase == tlm::END_REQ || phase == tlm::BEGIN_RESP);
         // Accepted but is now blocking until END_REQ (exclusion rule).
         blockingRequest = trans;
+        packetMap.emplace(trans, packet);
         auto cb = [this, trans, phase]() { pec(*trans, phase); };
         auto event = new EventFunctionWrapper(
                 cb, "pec", true, getPriorityOfTlmPhase(phase));
@@ -477,8 +480,8 @@

     tlm::tlm_generic_payload *trans = blockingResponse;
     blockingResponse = nullptr;
-    PacketPtr packet =
-        Gem5SystemC::Gem5Extension::getExtension(trans).getPacket();
+    PacketPtr packet = packetMap[blockingResponse];
+    sc_assert(packet);

     bool need_retry = !bridgeResponsePort.sendTimingResp(packet);

@@ -488,6 +491,7 @@
     tlm::tlm_phase phase = tlm::END_RESP;
     socket->nb_transport_fw(*trans, phase, delay);
     // Release transaction with all the extensions
+    packetMap.erase(trans);
     trans->release();
 }

diff --git a/src/systemc/tlm_bridge/gem5_to_tlm.hh b/src/systemc/tlm_bridge/gem5_to_tlm.hh
index 23415b8..35d6ba3 100644
--- a/src/systemc/tlm_bridge/gem5_to_tlm.hh
+++ b/src/systemc/tlm_bridge/gem5_to_tlm.hh
@@ -61,6 +61,7 @@

 #include <functional>
 #include <string>
+#include <unordered_map>

 #include "mem/backdoor.hh"
 #include "mem/port.hh"
@@ -173,6 +174,12 @@
      */
     tlm::tlm_generic_payload *blockingResponse;

+    /**
+ * A map to record the association between payload and packet. This helps us
+     * could get the correct packet when handling nonblocking interfaces.
+     */
+ std::unordered_map<tlm::tlm_generic_payload *, gem5::PacketPtr> packetMap;
+
     gem5::AddrRangeList addrRanges;

   protected:

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/66054?usp=email To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I486441e813236ea2cabd1bd6cbb085b08d75ec8f
Gerrit-Change-Number: 66054
Gerrit-PatchSet: 1
Gerrit-Owner: Yu-hsin Wang <yuhsi...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to