gem5  [DEVELOP-FOR-23.0]
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
smmu_v3_deviceifc.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2019 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
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
39 
40 #include "base/trace.hh"
41 #include "debug/SMMUv3.hh"
42 #include "dev/arm/smmu_v3.hh"
44 
45 namespace gem5
46 {
47 
49  const SMMUv3DeviceInterfaceParams &p) :
51  smmu(nullptr),
52  microTLB(new SMMUTLB(p.utlb_entries,
53  p.utlb_assoc,
54  p.utlb_policy,
55  this, "utlb")),
56  mainTLB(new SMMUTLB(p.tlb_entries,
57  p.tlb_assoc,
58  p.tlb_policy,
59  this, "maintlb")),
60  microTLBEnable(p.utlb_enable),
61  mainTLBEnable(p.tlb_enable),
62  devicePortSem(1),
63  microTLBSem(p.utlb_slots),
64  mainTLBSem(p.tlb_slots),
65  microTLBLat(p.utlb_lat),
66  mainTLBLat(p.tlb_lat),
67  devicePort(new SMMUDevicePort(csprintf("%s.device_port",
68  name()), *this)),
69  atsDevicePort(name() + ".atsDevicePort", *this),
70  atsMemPort(name() + ".atsMemPort", *this),
71  portWidth(p.port_width),
72  wrBufSlotsRemaining(p.wrbuf_slots),
73  xlateSlotsRemaining(p.xlate_slots),
74  pendingMemAccesses(0),
75  prefetchEnable(p.prefetch_enable),
76  prefetchReserveLastWay(
77  p.prefetch_reserve_last_way),
78  deviceNeedsRetry(false),
79  atsDeviceNeedsRetry(false),
80  sendDeviceRetryEvent(*this),
81  atsSendDeviceRetryEvent(*this)
82 {}
83 
84 void
86 {
87  if (devicePort->isConnected()) {
88  inform("Device port is connected to %s\n", devicePort->getPeer());
89 
91  } else {
92  fatal("Device port is not connected.\n");
93  }
94 }
95 
96 Port&
98 {
99  if (name == "ats_mem_side_port") {
100  return atsMemPort;
101  } else if (name == "device_port") {
102  return *devicePort;
103  } else if (name == "ats_dev_side_port") {
104  return atsDevicePort;
105  } else {
106  return ClockedObject::getPort(name, id);
107  }
108 }
109 
110 void
112 {
114 }
115 
116 void
118 {
120 
121  if (atsDeviceNeedsRetry) {
122  atsDeviceNeedsRetry = false;
124  }
125 }
126 
127 Tick
129 {
130  DPRINTF(SMMUv3, "[a] req from %s addr=%#x size=%#x\n",
131  devicePort->getPeer(), pkt->getAddr(), pkt->getSize());
132 
133  std::string proc_name = csprintf("%s.port", name());
134  SMMUTranslationProcess proc(proc_name, *smmu, *this);
136 
137  SMMUAction a = smmu->runProcessAtomic(&proc, pkt);
138  assert(a.type == ACTION_SEND_RESP);
139 
140  return a.delay;
141 }
142 
143 bool
145 {
146  DPRINTF(SMMUv3, "[t] req from %s addr=%#x size=%#x\n",
147  devicePort->getPeer(), pkt->getAddr(), pkt->getSize());
148 
149  // @todo: We need to pay for this and not just zero it out
150  pkt->headerDelay = pkt->payloadDelay = 0;
151 
152  unsigned nbeats =
153  (pkt->getSize() + (portWidth-1)) / portWidth;
154 
155  if (xlateSlotsRemaining==0 ||
156  (pkt->isWrite() && wrBufSlotsRemaining < nbeats))
157  {
158  deviceNeedsRetry = true;
159  return false;
160  }
161 
162  if (pkt->isWrite())
163  wrBufSlotsRemaining -= nbeats;
164 
165  std::string proc_name = csprintf("%s.port", name());
166  SMMUTranslationProcess *proc =
167  new SMMUTranslationProcess(proc_name, *smmu, *this);
169 
170  smmu->runProcessTiming(proc, pkt);
171 
172  return true;
173 }
174 
175 Tick
177 {
178  DPRINTF(SMMUv3, "[a] ATS responder req addr=%#x size=%#x\n",
179  pkt->getAddr(), pkt->getSize());
180 
181  std::string proc_name = csprintf("%s.atsport", name());
182  const bool ats_request = true;
184  proc_name, *smmu, *this);
185  proc.beginTransaction(SMMUTranslRequest::fromPacket(pkt, ats_request));
186 
187  SMMUAction a = smmu->runProcessAtomic(&proc, pkt);
188  assert(a.type == ACTION_SEND_RESP_ATS);
189 
190  return a.delay;
191 }
192 
193 bool
195 {
196  DPRINTF(SMMUv3, "[t] ATS responder req addr=%#x size=%#x\n",
197  pkt->getAddr(), pkt->getSize());
198 
199  // @todo: We need to pay for this and not just zero it out
200  pkt->headerDelay = pkt->payloadDelay = 0;
201 
202  if (xlateSlotsRemaining == 0) {
203  deviceNeedsRetry = true;
204  return false;
205  }
206 
207  std::string proc_name = csprintf("%s.atsport", name());
208  const bool ats_request = true;
209  SMMUTranslationProcess *proc =
210  new SMMUTranslationProcess(proc_name, *smmu, *this);
211  proc->beginTransaction(SMMUTranslRequest::fromPacket(pkt, ats_request));
212 
213  smmu->runProcessTiming(proc, pkt);
214 
215  return true;
216 }
217 
218 bool
220 {
221  DPRINTF(SMMUv3, "[t] ATS requestor resp addr=%#x size=%#x\n",
222  pkt->getAddr(), pkt->getSize());
223 
224  // @todo: We need to pay for this and not just zero it out
225  pkt->headerDelay = pkt->payloadDelay = 0;
226 
227  SMMUProcess *proc =
228  safe_cast<SMMUProcess *>(pkt->popSenderState());
229 
230  smmu->runProcessTiming(proc, pkt);
231 
232  return true;
233 }
234 
235 void
237 {
239 }
240 
241 void
243 {
244  DPRINTF(SMMUv3, "ATS retry\n");
246 }
247 
248 void
250 {
252  DPRINTF(SMMUv3, "sched responder retry\n");
253  deviceNeedsRetry = false;
255  }
256 }
257 
260 {
261  // Wait until all SMMU translations are completed
262  if (xlateSlotsRemaining < params().xlate_slots) {
263  return DrainState::Draining;
264  }
265  return DrainState::Drained;
266 }
267 
268 } // namespace gem5
gem5::SMMUv3DeviceInterface::recvTimingReq
bool recvTimingReq(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:144
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:200
gem5::PortID
int16_t PortID
Port index/ID type, and a symbolic name for an invalid port id.
Definition: types.hh:245
gem5::Port::getPeer
Port & getPeer()
Return a reference to this port's peer.
Definition: port.hh:108
gem5::SimObject::getPort
virtual Port & getPort(const std::string &if_name, PortID idx=InvalidPortID)
Get a port with a given name and index.
Definition: sim_object.cc:123
gem5::ResponsePort::sendRetryReq
void sendRetryReq()
Send a retry to the request port that previously attempted a sendTimingReq to this response port and ...
Definition: port.hh:473
gem5::SMMUProcess
Definition: smmu_v3_proc.hh:97
gem5::SMMUv3DeviceInterface::deviceNeedsRetry
bool deviceNeedsRetry
Definition: smmu_v3_deviceifc.hh:113
gem5::SMMUv3::runProcessTiming
SMMUAction runProcessTiming(SMMUProcess *proc, PacketPtr pkt)
Definition: smmu_v3.cc:286
gem5::SMMUAction
Definition: smmu_v3_proc.hh:70
gem5::SMMUv3DeviceInterface::schedTimingResp
void schedTimingResp(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:111
gem5::SMMUv3DeviceInterface::atsMemPort
SMMUATSMemoryPort atsMemPort
Definition: smmu_v3_deviceifc.hh:80
smmu_v3_transl.hh
gem5::ArmISA::a
Bitfield< 8 > a
Definition: misc_types.hh:66
gem5::Packet::isWrite
bool isWrite() const
Definition: packet.hh:594
gem5::ACTION_SEND_RESP
@ ACTION_SEND_RESP
Definition: smmu_v3_proc.hh:63
gem5::EventManager::schedule
void schedule(Event &event, Tick when)
Definition: eventq.hh:1012
gem5::csprintf
std::string csprintf(const char *format, const Args &...args)
Definition: cprintf.hh:161
gem5::Packet::headerDelay
uint32_t headerDelay
The extra delay from seeing the packet until the header is transmitted.
Definition: packet.hh:431
gem5::SMMUv3DeviceInterface::sendDeviceRetryEvent
SMMUDeviceRetryEvent sendDeviceRetryEvent
Definition: smmu_v3_deviceifc.hh:116
gem5::SMMUv3::runProcessAtomic
SMMUAction runProcessAtomic(SMMUProcess *proc, PacketPtr pkt)
Definition: smmu_v3.cc:237
gem5::SMMUTranslRequest::fromPacket
static SMMUTranslRequest fromPacket(PacketPtr pkt, bool ats=false)
Definition: smmu_v3_transl.cc:53
gem5::SMMUv3DeviceInterface::sendRange
void sendRange()
Definition: smmu_v3_deviceifc.cc:85
gem5::SMMUv3
Definition: smmu_v3.hh:84
gem5::SMMUv3DeviceInterface::atsRecvAtomic
Tick atsRecvAtomic(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:176
gem5::Packet::payloadDelay
uint32_t payloadDelay
The extra pipelining delay from seeing the packet until the end of payload is transmitted by the comp...
Definition: packet.hh:449
gem5::SMMUTLB
Definition: smmu_v3_caches.hh:99
gem5::SMMUv3DeviceInterface::portWidth
const unsigned portWidth
Definition: smmu_v3_deviceifc.hh:83
gem5::SMMUv3DeviceInterface::atsRecvTimingReq
bool atsRecvTimingReq(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:194
gem5::SMMUv3DeviceInterface::schedAtsTimingResp
void schedAtsTimingResp(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:117
gem5::DrainState
DrainState
Object drain/handover states.
Definition: drain.hh:74
gem5::ACTION_SEND_RESP_ATS
@ ACTION_SEND_RESP_ATS
Definition: smmu_v3_proc.hh:64
gem5::SMMUv3DeviceInterface::devicePort
SMMUDevicePort * devicePort
Definition: smmu_v3_deviceifc.hh:78
gem5::SMMUv3DeviceInterface::atsSendDeviceRetry
void atsSendDeviceRetry()
Definition: smmu_v3_deviceifc.cc:242
gem5::Named::name
virtual std::string name() const
Definition: named.hh:47
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:210
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
gem5::SMMUv3DeviceInterface::SMMUv3DeviceInterface
SMMUv3DeviceInterface(const Params &p)
Definition: smmu_v3_deviceifc.cc:48
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::SMMUv3DeviceInterface::atsDevicePort
SMMUATSDevicePort atsDevicePort
Definition: smmu_v3_deviceifc.hh:79
gem5::SMMUDevicePort
Definition: smmu_v3_ports.hh:77
gem5::SMMUv3DeviceInterface::sendDeviceRetry
void sendDeviceRetry()
Definition: smmu_v3_deviceifc.cc:236
gem5::SMMUTranslationProcess::beginTransaction
void beginTransaction(const SMMUTranslRequest &req)
Definition: smmu_v3_transl.cc:113
gem5::Port::isConnected
bool isConnected() const
Is this port currently connected to a peer?
Definition: port.hh:133
gem5::DrainState::Drained
@ Drained
Buffers drained, ready for serialization/handover.
gem5::SMMUv3DeviceInterface::smmu
SMMUv3 * smmu
Definition: smmu_v3_deviceifc.hh:64
smmu_v3_deviceifc.hh
name
const std::string & name()
Definition: trace.cc:48
gem5::ClockedObject
The ClockedObject class extends the SimObject with a clock and accessor functions to relate ticks to ...
Definition: clocked_object.hh:234
gem5::SMMUv3DeviceInterface::SMMUTranslationProcess
friend class SMMUTranslationProcess
Definition: smmu_v3_deviceifc.hh:61
gem5::ResponsePort::sendRangeChange
void sendRangeChange() const
Called by the owner to send a range change.
Definition: port.hh:364
gem5::Packet::popSenderState
SenderState * popSenderState()
Pop the top of the state stack and return a pointer to it.
Definition: packet.cc:342
gem5::SMMUv3DeviceInterface::drain
DrainState drain() override
Draining is the process of clearing out the states of SimObjects.These are the SimObjects that are pa...
Definition: smmu_v3_deviceifc.cc:259
gem5::Clocked::nextCycle
Tick nextCycle() const
Based on the clock of the object, determine the start tick of the first cycle that is at least one cy...
Definition: clocked_object.hh:213
gem5::SMMUv3DeviceInterface::scheduleDeviceRetry
void scheduleDeviceRetry()
Definition: smmu_v3_deviceifc.cc:249
gem5::SMMUv3DeviceInterface::xlateSlotsRemaining
unsigned xlateSlotsRemaining
Definition: smmu_v3_deviceifc.hh:86
gem5::SMMUv3DeviceInterface::recvAtomic
Tick recvAtomic(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:128
smmu_v3.hh
inform
#define inform(...)
Definition: logging.hh:257
gem5::Port
Ports are used to interface objects to each other.
Definition: port.hh:61
gem5::SMMUv3DeviceInterface::atsDeviceNeedsRetry
bool atsDeviceNeedsRetry
Definition: smmu_v3_deviceifc.hh:114
trace.hh
gem5::SMMUv3DeviceInterface::wrBufSlotsRemaining
unsigned wrBufSlotsRemaining
Definition: smmu_v3_deviceifc.hh:85
gem5::Packet::getAddr
Addr getAddr() const
Definition: packet.hh:807
gem5::QueuedResponsePort::schedTimingResp
void schedTimingResp(PacketPtr pkt, Tick when)
Schedule the sending of a timing response.
Definition: qport.hh:94
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::SMMUv3DeviceInterface::atsSendDeviceRetryEvent
MemberEventWrapper<&SMMUv3DeviceInterface::atsSendDeviceRetry > atsSendDeviceRetryEvent
Definition: smmu_v3_deviceifc.hh:117
gem5::SMMUv3DeviceInterface::atsRecvTimingResp
bool atsRecvTimingResp(PacketPtr pkt)
Definition: smmu_v3_deviceifc.cc:219
gem5::SMMUv3DeviceInterface::getPort
Port & getPort(const std::string &name, PortID id) override
Get a port with a given name and index.
Definition: smmu_v3_deviceifc.cc:97
gem5::SMMUTranslationProcess
Definition: smmu_v3_transl.hh:70
gem5::Packet::getSize
unsigned getSize() const
Definition: packet.hh:817
gem5::DrainState::Draining
@ Draining
Draining buffers pending serialization/handover.
gem5::Event::scheduled
bool scheduled() const
Determine if the current event is scheduled.
Definition: eventq.hh:458

Generated on Sun Jul 30 2023 01:56:55 for gem5 by doxygen 1.8.17