gem5 v24.0.0.0
Loading...
Searching...
No Matches
sdma_engine.hh
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Advanced Micro Devices, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * 3. Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived from this
17 * software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef __DEV_AMDGPU_SDMA_ENGINE_HH__
33#define __DEV_AMDGPU_SDMA_ENGINE_HH__
34
35#include "base/bitunion.hh"
40#include "params/SDMAEngine.hh"
41
42namespace gem5
43{
44
49{
55
57 {
64 bool _valid;
71 bool _priv = true; // Only used for RLC queues. True otherwise.
72 public:
73 SDMAQueue() : _rptr(0), _wptr(0), _valid(false), _processing(false),
74 _parent(nullptr), _ib(nullptr), _type(SDMAGfx), _mqd(nullptr) {}
75
76 Addr base() { return _base; }
77 Addr rptr() { return _base + _rptr; }
78 Addr getRptr() { return _rptr; }
79 Addr wptr() { return _base + _wptr; }
80 Addr getWptr() { return _wptr; }
81 Addr size() { return _size; }
84 bool valid() { return _valid; }
85 bool processing() { return _processing; }
86 SDMAQueue* parent() { return _parent; }
87 SDMAQueue* ib() { return _ib; }
88 SDMAType queueType() { return _type; }
89 SDMAQueueDesc* getMQD() { return _mqd; }
91 bool priv() { return _priv; }
92
93 void base(Addr value) { _base = value; }
94
95 void
96 incRptr(uint32_t value)
97 {
98 _rptr = (_rptr + value) % _size;
99 _global_rptr += value;
100 }
101
102 void
103 rptr(Addr value)
104 {
105 _rptr = value;
106 _global_rptr = value;
107 }
108
109 void
111 {
112 _wptr = value % _size;
113 }
114
115 void wptr(Addr value) { _wptr = value; }
116
117 void size(Addr value) { _size = value; }
118 void rptrWbAddr(Addr value) { _rptr_wb_addr = value; }
119 void valid(bool v) { _valid = v; }
120 void processing(bool value) { _processing = value; }
121 void parent(SDMAQueue* q) { _parent = q; }
122 void ib(SDMAQueue* ib) { _ib = ib; }
124 void setMQD(SDMAQueueDesc *mqd) { _mqd = mqd; }
125 void setMQDAddr(Addr mqdAddr) { _mqd_addr = mqdAddr; }
126 void setPriv(bool priv) { _priv = priv; }
127 };
128
129 /* SDMA Engine ID */
130 int id;
140
141 /* Gfx ring buffer registers */
142 uint64_t gfxBase;
143 uint64_t gfxRptr;
144 uint64_t gfxDoorbell;
146 uint64_t gfxWptr;
147 /* Page ring buffer registers */
148 uint64_t pageBase;
149 uint64_t pageRptr;
150 uint64_t pageDoorbell;
152 uint64_t pageWptr;
153
156
157 /* processRLC will select the correct queue for the doorbell */
158 std::array<Addr, 2> rlcInfo{};
159 void processRLC0(Addr wptrOffset);
160 void processRLC1(Addr wptrOffset);
161
164
165 public:
166 SDMAEngine(const SDMAEngineParams &p);
167
168 void setGPUDevice(AMDGPUDevice *gpu_device);
169
170 void setId(int _id) { id = _id; }
171 int getId() const { return id; }
175 int getIHClientId(int _id);
176
180 Addr getGARTAddr(Addr addr) const;
181 TranslationGenPtr translate(Addr vaddr, Addr size) override;
182
188 Addr getDeviceAddress(Addr raw_addr);
189
193 Tick write(PacketPtr pkt) override { return 0; }
194 Tick read(PacketPtr pkt) override { return 0; }
195 AddrRangeList getAddrRanges() const override;
196 void serialize(CheckpointOut &cp) const override;
197 void unserialize(CheckpointIn &cp) override;
198
203 void processGfx(Addr wptrOffset);
204 void processPage(Addr wptrOffset);
205 void processRLC(Addr doorbellOffset, Addr wptrOffset);
206
215 void decodeNext(SDMAQueue *q);
216
222 void decodeHeader(SDMAQueue *q, uint32_t data);
223
227 void write(SDMAQueue *q, sdmaWrite *pkt);
228 void writeReadData(SDMAQueue *q, sdmaWrite *pkt, uint32_t *dmaBuffer);
229 void writeDone(SDMAQueue *q, sdmaWrite *pkt, uint32_t *dmaBuffer);
230 void copy(SDMAQueue *q, sdmaCopy *pkt);
231 void copyReadData(SDMAQueue *q, sdmaCopy *pkt, uint8_t *dmaBuffer);
232 void copyDone(SDMAQueue *q, sdmaCopy *pkt, uint8_t *dmaBuffer);
233 void indirectBuffer(SDMAQueue *q, sdmaIndirectBuffer *pkt);
234 void fence(SDMAQueue *q, sdmaFence *pkt);
235 void fenceDone(SDMAQueue *q, sdmaFence *pkt);
236 void trap(SDMAQueue *q, sdmaTrap *pkt);
237 void srbmWrite(SDMAQueue *q, sdmaSRBMWriteHeader *header,
238 sdmaSRBMWrite *pkt);
239 void pollRegMem(SDMAQueue *q, sdmaPollRegMemHeader *header,
240 sdmaPollRegMem *pkt);
242 sdmaPollRegMem *pkt, uint32_t dma_buffer, int count);
243 bool pollRegMemFunc(uint32_t value, uint32_t reference, uint32_t func);
244 void ptePde(SDMAQueue *q, sdmaPtePde *pkt);
245 void ptePdeDone(SDMAQueue *q, sdmaPtePde *pkt, uint64_t *dmaBuffer);
246 void atomic(SDMAQueue *q, sdmaAtomicHeader *header, sdmaAtomic *pkt);
247 void atomicData(SDMAQueue *q, sdmaAtomicHeader *header, sdmaAtomic *pkt,
248 uint64_t *dmaBuffer);
249 void atomicDone(SDMAQueue *q, sdmaAtomicHeader *header, sdmaAtomic *pkt,
250 uint64_t *dmaBuffer);
251 void constFill(SDMAQueue *q, sdmaConstFill *pkt, uint32_t header);
252 void constFillDone(SDMAQueue *q, sdmaConstFill *pkt, uint8_t *fill_data);
253
261
265 uint64_t getGfxBase() { return gfxBase; }
266 uint64_t getGfxRptr() { return gfxRptr; }
267 uint64_t getGfxDoorbell() { return gfxDoorbell; }
269 uint64_t getGfxWptr() { return gfxWptr; }
270 uint64_t getPageBase() { return pageBase; }
271 uint64_t getPageRptr() { return pageRptr; }
272 uint64_t getPageDoorbell() { return pageDoorbell; }
274 uint64_t getPageWptr() { return pageWptr; }
275
279 void writeMMIO(PacketPtr pkt, Addr mmio_offset);
280
281 void setGfxBaseLo(uint32_t data);
282 void setGfxBaseHi(uint32_t data);
283 void setGfxRptrLo(uint32_t data);
284 void setGfxRptrHi(uint32_t data);
285 void setGfxDoorbellLo(uint32_t data);
286 void setGfxDoorbellHi(uint32_t data);
287 void setGfxDoorbellOffsetLo(uint32_t data);
288 void setGfxDoorbellOffsetHi(uint32_t data);
289 void setGfxSize(uint32_t data);
290 void setGfxWptrLo(uint32_t data);
291 void setGfxWptrHi(uint32_t data);
292 void setPageBaseLo(uint32_t data);
293 void setPageBaseHi(uint32_t data);
294 void setPageRptrLo(uint32_t data);
295 void setPageRptrHi(uint32_t data);
296 void setPageDoorbellLo(uint32_t data);
297 void setPageDoorbellHi(uint32_t data);
298 void setPageDoorbellOffsetLo(uint32_t data);
299 void setPageDoorbellOffsetHi(uint32_t data);
300 void setPageSize(uint32_t data);
301 void setPageWptrLo(uint32_t data);
302 void setPageWptrHi(uint32_t data);
303
307 void registerRLCQueue(Addr doorbell, Addr mqdAddr, SDMAQueueDesc *mqd);
308 void unregisterRLCQueue(Addr doorbell);
309 void deallocateRLCQueues();
310
311 int cur_vmid = 0;
312};
313
314} // namespace gem5
315
316#endif // __DEV_AMDGPU_SDMA_ENGINE_HH__
const char data[]
Device model for an AMD GPU.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition packet.hh:295
void setMQD(SDMAQueueDesc *mqd)
void setMQDAddr(Addr mqdAddr)
void processing(bool value)
SDMAQueueDesc * getMQD()
void ib(SDMAQueue *ib)
void rptrWbAddr(Addr value)
void incRptr(uint32_t value)
void parent(SDMAQueue *q)
void queueType(SDMAType type)
System DMA Engine class for AMD dGPU.
uint64_t pageDoorbell
void setPageRptrLo(uint32_t data)
void unserialize(CheckpointIn &cp) override
Unserialize an object.
uint64_t getPageDoorbellOffset()
SDMAQueue gfx
Each SDMAEngine processes four queues: paging, gfx, rlc0, and rlc1, where RLC stands for Run List Con...
void ptePde(SDMAQueue *q, sdmaPtePde *pkt)
void setGfxRptrLo(uint32_t data)
void setGfxWptrLo(uint32_t data)
uint64_t getGfxDoorbellOffset()
void setPageDoorbellHi(uint32_t data)
VegaISA::Walker * walker
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
void setGfxRptrHi(uint32_t data)
void writeDone(SDMAQueue *q, sdmaWrite *pkt, uint32_t *dmaBuffer)
Addr getMmioBase()
Methods for getting SDMA MMIO base address and size.
void processRLC(Addr doorbellOffset, Addr wptrOffset)
uint64_t getPageRptr()
void copy(SDMAQueue *q, sdmaCopy *pkt)
Tick write(PacketPtr pkt) override
Inherited methods.
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
Methods for setting the values of SDMA MMIO registers.
void setGfxSize(uint32_t data)
void fenceDone(SDMAQueue *q, sdmaFence *pkt)
void writeReadData(SDMAQueue *q, sdmaWrite *pkt, uint32_t *dmaBuffer)
void setId(int _id)
void unregisterRLCQueue(Addr doorbell)
void setGfxBaseLo(uint32_t data)
void processRLC0(Addr wptrOffset)
void processGfx(Addr wptrOffset)
Given a new write ptr offset, communicated to the GPU through a doorbell write, the SDMA engine proce...
void setGfxDoorbellOffsetHi(uint32_t data)
void constFill(SDMAQueue *q, sdmaConstFill *pkt, uint32_t header)
void deallocateRLCQueues()
AMDGPUDevice * gpuDevice
Addr getGARTAddr(Addr addr) const
Methods for translation.
void setPageDoorbellOffsetHi(uint32_t data)
void processRLC1(Addr wptrOffset)
void setGfxWptrHi(uint32_t data)
void setGfxDoorbellOffsetLo(uint32_t data)
void processPage(Addr wptrOffset)
uint64_t getGfxDoorbell()
void decodeHeader(SDMAQueue *q, uint32_t data)
Reads the first DW (32 bits) (i.e., header) of an SDMA packet, which encodes the opcode and sub-opcod...
uint64_t getGfxBase()
Methods for getting the values of SDMA MMIO registers.
void setPageDoorbellOffsetLo(uint32_t data)
int getIHClientId(int _id)
Returns the client id for the Interrupt Handler.
uint64_t getPageDoorbell()
SDMAEngine(const SDMAEngineParams &p)
void setGPUDevice(AMDGPUDevice *gpu_device)
Addr getDeviceAddress(Addr raw_addr)
Translate an address in an SDMA packet.
void constFillDone(SDMAQueue *q, sdmaConstFill *pkt, uint8_t *fill_data)
uint64_t pageDoorbellOffset
uint64_t getPageWptr()
void setPageBaseHi(uint32_t data)
uint64_t gfxDoorbellOffset
void registerRLCQueue(Addr doorbell, Addr mqdAddr, SDMAQueueDesc *mqd)
Methods for RLC queues.
uint64_t getGfxWptr()
uint64_t getPageBase()
bool pollRegMemFunc(uint32_t value, uint32_t reference, uint32_t func)
void setPageWptrHi(uint32_t data)
void setPageWptrLo(uint32_t data)
void pollRegMemRead(SDMAQueue *q, sdmaPollRegMemHeader *header, sdmaPollRegMem *pkt, uint32_t dma_buffer, int count)
void setGfxDoorbellLo(uint32_t data)
void copyReadData(SDMAQueue *q, sdmaCopy *pkt, uint8_t *dmaBuffer)
void indirectBuffer(SDMAQueue *q, sdmaIndirectBuffer *pkt)
void srbmWrite(SDMAQueue *q, sdmaSRBMWriteHeader *header, sdmaSRBMWrite *pkt)
void atomicData(SDMAQueue *q, sdmaAtomicHeader *header, sdmaAtomic *pkt, uint64_t *dmaBuffer)
void trap(SDMAQueue *q, sdmaTrap *pkt)
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
void setPageDoorbellLo(uint32_t data)
void setGfxDoorbellHi(uint32_t data)
void setPageSize(uint32_t data)
void setPageBaseLo(uint32_t data)
void copyDone(SDMAQueue *q, sdmaCopy *pkt, uint8_t *dmaBuffer)
void setGfxBaseHi(uint32_t data)
void ptePdeDone(SDMAQueue *q, sdmaPtePde *pkt, uint64_t *dmaBuffer)
TranslationGenPtr translate(Addr vaddr, Addr size) override
GPUController will perform DMA operations on VAs, and because page faults are not currently supported...
void setPageRptrHi(uint32_t data)
int getId() const
uint64_t getGfxRptr()
void decodeNext(SDMAQueue *q)
This method checks read and write pointers and starts decoding packets if the read pointer is less th...
void fence(SDMAQueue *q, sdmaFence *pkt)
void atomicDone(SDMAQueue *q, sdmaAtomicHeader *header, sdmaAtomic *pkt, uint64_t *dmaBuffer)
void serialize(CheckpointOut &cp) const override
Serialize an object.
std::array< Addr, 2 > rlcInfo
void pollRegMem(SDMAQueue *q, sdmaPollRegMemHeader *header, sdmaPollRegMem *pkt)
Implements a poll reg/mem packet that polls an SRBM register or a memory location,...
Bitfield< 23, 20 > atomic
Bitfield< 28 > v
Definition misc_types.hh:54
Bitfield< 27 > q
Definition misc_types.hh:55
Bitfield< 0 > p
Bitfield< 3 > addr
Definition types.hh:84
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36
std::ostream CheckpointOut
Definition serialize.hh:66
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition types.hh:147
uint64_t Tick
Tick count type.
Definition types.hh:58
std::unique_ptr< TranslationGen > TranslationGenPtr
output header
Definition nop.cc:36
PM4 packets.

Generated on Tue Jun 18 2024 16:24:02 for gem5 by doxygen 1.11.0