From 64f415f9bf5bb70376859055ec2d96fbb8c998ce Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 21 Mar 2019 17:23:03 -0700 Subject: [PATCH] mem: Add sendAtomicBackdoor/recvAtomicBackdoor port methods. These both perform atomic accesses like their non-backdoor equivalents, and also request a backdoor corresponding to the access. The default implementation for recvAtomicBackdoor prints a warning (once per port instance), calls recvAtomic to do the actual access, and leaves the backdoor pointer as nullptr. That way if an object doesn't know how to handle or transfer requests for a back door, it automatically replies in a safe way that ignores the back door request. Change-Id: Ia9fbbe9996eb4b71ea62214d203aa039a05f1618 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17590 Reviewed-by: Nikos Nikoleris Reviewed-by: Daniel Carvalho Maintainer: Gabe Black --- src/mem/port.cc | 20 +++++++++++++++++++- src/mem/port.hh | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/src/mem/port.cc b/src/mem/port.cc index 001576fe3..933e98243 100644 --- a/src/mem/port.cc +++ b/src/mem/port.cc @@ -144,6 +144,13 @@ MasterPort::sendAtomic(PacketPtr pkt) return _slavePort->recvAtomic(pkt); } +Tick +MasterPort::sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) +{ + assert(pkt->isRequest()); + return _slavePort->recvAtomicBackdoor(pkt, backdoor); +} + void MasterPort::sendFunctional(PacketPtr pkt) { @@ -195,7 +202,8 @@ MasterPort::printAddr(Addr a) * Slave port */ SlavePort::SlavePort(const std::string& name, MemObject* _owner, PortID id) - : BaseSlavePort(name, id), _masterPort(NULL), owner(*_owner) + : BaseSlavePort(name, id), _masterPort(NULL), defaultBackdoorWarned(false), + owner(*_owner) { } @@ -219,6 +227,16 @@ SlavePort::slaveBind(MasterPort& master_port) _connected = true; } +Tick +SlavePort::recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor) +{ + if (!defaultBackdoorWarned) { + warn("Port %s doesn't support requesting a back door.", name()); + defaultBackdoorWarned = true; + } + return recvAtomic(pkt); +} + Tick SlavePort::sendAtomicSnoop(PacketPtr pkt) { diff --git a/src/mem/port.hh b/src/mem/port.hh index 2154da007..72a02711c 100644 --- a/src/mem/port.hh +++ b/src/mem/port.hh @@ -51,6 +51,7 @@ #define __MEM_PORT_HH__ #include "base/addr_range.hh" +#include "mem/backdoor.hh" #include "mem/packet.hh" #include "sim/port.hh" @@ -152,6 +153,18 @@ class MasterPort : public BaseMasterPort */ Tick sendAtomic(PacketPtr pkt); + /** + * Send an atomic request packet like above, but also request a backdoor + * to the data being accessed. + * + * @param pkt Packet to send. + * @param backdoor Can be set to a back door pointer by the target to let + * caller have direct access to the requested data. + * + * @return Estimated latency of access. + */ + Tick sendAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor); + /** * Send a functional request packet, where the data is instantly * updated everywhere in the memory system, without affecting the @@ -300,6 +313,7 @@ class SlavePort : public BaseSlavePort private: MasterPort* _masterPort; + bool defaultBackdoorWarned; protected: @@ -415,6 +429,12 @@ class SlavePort : public BaseSlavePort */ virtual Tick recvAtomic(PacketPtr pkt) = 0; + /** + * Receive an atomic request packet from the master port, and optionally + * provide a backdoor to the data being accessed. + */ + virtual Tick recvAtomicBackdoor(PacketPtr pkt, MemBackdoorPtr &backdoor); + /** * Receive a functional request packet from the master port. */ -- 2.30.2