gem5  v22.0.0.1
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
amdgpu_device.cc
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 
33 
34 #include <fstream>
35 
36 #include "debug/AMDGPUDevice.hh"
37 #include "dev/amdgpu/amdgpu_vm.hh"
41 #include "dev/hsa/hw_scheduler.hh"
43 #include "mem/abstract_mem.hh"
44 #include "mem/packet.hh"
45 #include "mem/packet_access.hh"
46 #include "params/AMDGPUDevice.hh"
47 #include "sim/byteswap.hh"
48 #include "sim/sim_exit.hh"
49 
50 namespace gem5
51 {
52 
53 AMDGPUDevice::AMDGPUDevice(const AMDGPUDeviceParams &p)
54  : PciDevice(p), gpuMemMgr(p.memory_manager), deviceIH(p.device_ih),
55  sdma0(p.sdma0), sdma1(p.sdma1), pm4PktProc(p.pm4_pkt_proc), cp(p.cp),
56  checkpoint_before_mmios(p.checkpoint_before_mmios),
57  init_interrupt_count(0), _lastVMID(0),
58  deviceMem(name() + ".deviceMem", p.memories, false, "", false)
59 {
60  // Loading the rom binary dumped from hardware.
61  std::ifstream romBin;
62  romBin.open(p.rom_binary, std::ios::binary);
63  romBin.read((char *)rom.data(), ROM_SIZE);
64  romBin.close();
65 
66  // System pointer needs to be explicitly set for device memory since
67  // DRAMCtrl uses it to get (1) cache line size and (2) the mem mode.
68  // Note this means the cache line size is system wide.
69  for (auto& m : p.memories) {
70  m->system(p.system);
71 
72  // Add to system's device memory map.
73  p.system->addDeviceMemory(gpuMemMgr->getRequestorID(), m);
74  }
75 
76  if (config.expansionROM) {
77  romRange = RangeSize(config.expansionROM, ROM_SIZE);
78  } else {
80  }
81 
82  if (p.trace_file != "") {
83  mmioReader.readMMIOTrace(p.trace_file);
84  }
85 
86  sdma0->setGPUDevice(this);
87  sdma0->setId(0);
88  sdma1->setGPUDevice(this);
89  sdma1->setId(1);
90  deviceIH->setGPUDevice(this);
91  pm4PktProc->setGPUDevice(this);
92  cp->hsaPacketProc().setGPUDevice(this);
93  cp->setGPUDevice(this);
94 }
95 
96 void
98 {
99  Addr rom_offset = pkt->getAddr() & (ROM_SIZE - 1);
100  uint64_t rom_data = 0;
101 
102  memcpy(&rom_data, rom.data() + rom_offset, pkt->getSize());
103  pkt->setUintX(rom_data, ByteOrder::little);
104 
105  DPRINTF(AMDGPUDevice, "Read from addr %#x on ROM offset %#x data: %#x\n",
106  pkt->getAddr(), rom_offset, rom_data);
107 }
108 
111 {
113  AddrRangeList ret_ranges;
114  ret_ranges.push_back(romRange);
115 
116  // If the range starts at zero assume OS hasn't assigned it yet. Do not
117  // return ranges starting with zero as they will surely overlap with
118  // another range causing the I/O crossbar to fatal.
119  for (auto & r : ranges) {
120  if (r.start() != 0) {
121  ret_ranges.push_back(r);
122  }
123  }
124 
125  return ret_ranges;
126 }
127 
128 Tick
130 {
131  [[maybe_unused]] int offset = pkt->getAddr() & PCI_CONFIG_SIZE;
132  DPRINTF(AMDGPUDevice, "Read Config: from offset: %#x size: %#x "
133  "data: %#x\n", offset, pkt->getSize(), config.data[offset]);
134 
135  Tick delay = PciDevice::readConfig(pkt);
136 
137  // Before sending MMIOs the driver sends three interrupts in a row.
138  // Use this to trigger creating a checkpoint to restore in timing mode.
139  // This is only necessary until we can create a "hole" in the KVM VM
140  // around the VGA ROM region such that KVM exits and sends requests to
141  // this device rather than the KVM VM.
143  if (offset == PCI0_INTERRUPT_PIN) {
144  if (++init_interrupt_count == 3) {
145  DPRINTF(AMDGPUDevice, "Checkpointing before first MMIO\n");
146  exitSimLoop("checkpoint", 0, curTick() + delay + 1);
147  }
148  } else {
150  }
151  }
152 
153  return delay;
154 }
155 
156 Tick
158 {
159  [[maybe_unused]] int offset = pkt->getAddr() & PCI_CONFIG_SIZE;
160  DPRINTF(AMDGPUDevice, "Write Config: from offset: %#x size: %#x "
161  "data: %#x\n", offset, pkt->getSize(),
162  pkt->getUintX(ByteOrder::little));
163 
164  return PciDevice::writeConfig(pkt);
165 }
166 
167 void
169 {
170  DPRINTF(AMDGPUDevice, "%s from addr %#x size: %#x data: %#x\n",
171  read ? "Read" : "Write", pkt->getAddr(), pkt->getSize(),
172  pkt->getUintX(ByteOrder::little));
173 
174  pkt->makeAtomicResponse();
175 }
176 
177 void
179 {
180  DPRINTF(AMDGPUDevice, "Read framebuffer address %#lx\n", offset);
181 
182  /* Try MMIO trace for frame writes first. */
184 
185  /* If the driver wrote something, use that value over the trace. */
186  if (frame_regs.find(offset) != frame_regs.end()) {
187  pkt->setUintX(frame_regs[offset], ByteOrder::little);
188  }
189 
190  /* Handle special counter addresses in framebuffer. */
191  if (offset == 0xa28000) {
192  /* Counter addresses expect the read to return previous value + 1. */
193  if (regs.find(pkt->getAddr()) == regs.end()) {
194  regs[pkt->getAddr()] = 1;
195  } else {
196  regs[pkt->getAddr()]++;
197  }
198 
199  pkt->setUintX(regs[pkt->getAddr()], ByteOrder::little);
200  }
201 }
202 
203 void
205 {
206  DPRINTF(AMDGPUDevice, "Read doorbell %#lx\n", offset);
208 }
209 
210 void
212 {
213  Addr aperture = gpuvm.getMmioAperture(offset);
214  Addr aperture_offset = offset - aperture;
215 
216  // By default read from MMIO trace. Overwrite the packet for a select
217  // few more dynamic MMIOs.
218  DPRINTF(AMDGPUDevice, "Read MMIO %#lx\n", offset);
220 
221  switch (aperture) {
222  case NBIO_BASE:
223  switch (aperture_offset) {
224  // This is a PCIe status register. At some point during driver init
225  // the driver checks that interrupts are enabled. This is only
226  // checked once, so if the MMIO trace does not exactly line up with
227  // what the driver is doing in gem5, this may still have the first
228  // bit zero causing driver to fail. Therefore, we always set this
229  // bit to one as there is no harm to do so.
230  case 0x3c: // mmPCIE_DATA2 << 2
231  uint32_t value = pkt->getLE<uint32_t>() | 0x1;
232  DPRINTF(AMDGPUDevice, "Marking interrupts enabled: %#lx\n", value);
233  pkt->setLE<uint32_t>(value);
234  break;
235  } break;
236  case GRBM_BASE:
237  gpuvm.readMMIO(pkt, aperture_offset >> GRBM_OFFSET_SHIFT);
238  break;
239  case MMHUB_BASE:
240  gpuvm.readMMIO(pkt, aperture_offset >> MMHUB_OFFSET_SHIFT);
241  break;
242  default:
243  break;
244  }
245 }
246 
247 void
249 {
250  DPRINTF(AMDGPUDevice, "Wrote framebuffer address %#lx\n", offset);
251 
252  Addr aperture = gpuvm.getFrameAperture(offset);
253  Addr aperture_offset = offset - aperture;
254 
255  // Record the value
256  frame_regs[offset] = pkt->getUintX(ByteOrder::little);
257  if (aperture == gpuvm.gartBase()) {
258  frame_regs[aperture_offset] = pkt->getLE<uint32_t>();
259  DPRINTF(AMDGPUDevice, "GART translation %p -> %p\n", aperture_offset,
260  bits(frame_regs[aperture_offset], 48, 12));
261  gpuvm.gartTable[aperture_offset] = pkt->getLE<uint32_t>();
262  }
263 }
264 
265 void
267 {
268  DPRINTF(AMDGPUDevice, "Wrote doorbell %#lx\n", offset);
269 
270  if (doorbells.find(offset) != doorbells.end()) {
271  QueueType q_type = doorbells[offset];
272  DPRINTF(AMDGPUDevice, "Doorbell offset %p queue: %d\n",
273  offset, q_type);
274  switch (q_type) {
275  case Compute:
277  pkt->getLE<uint64_t>());
278  break;
279  case Gfx:
281  pkt->getLE<uint64_t>());
282  break;
283  case SDMAGfx: {
284  SDMAEngine *sdmaEng = getSDMAEngine(offset);
285  sdmaEng->processGfx(pkt->getLE<uint64_t>());
286  } break;
287  case SDMAPage: {
288  SDMAEngine *sdmaEng = getSDMAEngine(offset);
289  sdmaEng->processPage(pkt->getLE<uint64_t>());
290  } break;
291  case ComputeAQL: {
293  pkt->getLE<uint64_t>() + 1);
294  pm4PktProc->updateReadIndex(offset, pkt->getLE<uint64_t>() + 1);
295  } break;
296  case InterruptHandler:
297  deviceIH->updateRptr(pkt->getLE<uint32_t>());
298  break;
299  case RLC: {
300  panic("RLC queues not yet supported. Run with the environment "
301  "variable HSA_ENABLE_SDMA set to False");
302  } break;
303  default:
304  panic("Write to unkown queue type!");
305  }
306  } else {
307  warn("Unknown doorbell offset: %lx\n", offset);
308  }
309 }
310 
311 void
313 {
314  Addr aperture = gpuvm.getMmioAperture(offset);
315  Addr aperture_offset = offset - aperture;
316 
317  DPRINTF(AMDGPUDevice, "Wrote MMIO %#lx\n", offset);
318 
319  switch (aperture) {
320  /* Write a register to the first System DMA. */
321  case SDMA0_BASE:
322  sdma0->writeMMIO(pkt, aperture_offset >> SDMA_OFFSET_SHIFT);
323  break;
324  /* Write a register to the second System DMA. */
325  case SDMA1_BASE:
326  sdma1->writeMMIO(pkt, aperture_offset >> SDMA_OFFSET_SHIFT);
327  break;
328  /* Write a general register to the graphics register bus manager. */
329  case GRBM_BASE:
330  gpuvm.writeMMIO(pkt, aperture_offset >> GRBM_OFFSET_SHIFT);
331  pm4PktProc->writeMMIO(pkt, aperture_offset >> GRBM_OFFSET_SHIFT);
332  break;
333  /* Write a register to the interrupt handler. */
334  case IH_BASE:
335  deviceIH->writeMMIO(pkt, aperture_offset >> IH_OFFSET_SHIFT);
336  break;
337  default:
338  DPRINTF(AMDGPUDevice, "Unknown MMIO aperture for %#x\n", offset);
339  break;
340  }
341 }
342 
343 Tick
345 {
346  if (isROM(pkt->getAddr())) {
347  readROM(pkt);
348  } else {
349  int barnum = -1;
350  Addr offset = 0;
351  getBAR(pkt->getAddr(), barnum, offset);
352 
353  switch (barnum) {
354  case FRAMEBUFFER_BAR:
355  readFrame(pkt, offset);
356  break;
357  case DOORBELL_BAR:
358  readDoorbell(pkt, offset);
359  break;
360  case MMIO_BAR:
361  readMMIO(pkt, offset);
362  break;
363  default:
364  panic("Request with address out of mapped range!");
365  }
366  }
367 
368  dispatchAccess(pkt, true);
369  return pioDelay;
370 }
371 
372 Tick
374 {
375  int barnum = -1;
376  Addr offset = 0;
377  getBAR(pkt->getAddr(), barnum, offset);
378 
379  switch (barnum) {
380  case FRAMEBUFFER_BAR:
381  gpuMemMgr->writeRequest(offset, pkt->getPtr<uint8_t>(),
382  pkt->getSize());
383  writeFrame(pkt, offset);
384  break;
385  case DOORBELL_BAR:
386  writeDoorbell(pkt, offset);
387  break;
388  case MMIO_BAR:
389  writeMMIO(pkt, offset);
390  break;
391  default:
392  panic("Request with address out of mapped range!");
393  }
394 
395  // Record only if there is non-zero value, or a value to be overwritten.
396  // Reads return 0 by default.
397  uint64_t data = pkt->getUintX(ByteOrder::little);
398 
399  DPRINTF(AMDGPUDevice, "PCI Write to %#lx data %#lx\n",
400  pkt->getAddr(), data);
401 
402  if (data || regs.find(pkt->getAddr()) != regs.end())
403  regs[pkt->getAddr()] = data;
404 
405  dispatchAccess(pkt, false);
406 
407  return pioDelay;
408 }
409 
410 uint32_t
412 {
413  return regs[addr];
414 }
415 void
416 AMDGPUDevice::setRegVal(uint32_t addr, uint32_t value)
417 {
418  DPRINTF(AMDGPUDevice, "Setting register 0x%lx to %x\n",
419  addr, value);
420  regs[addr] = value;
421 }
422 
423 void
425 {
426  DPRINTF(AMDGPUDevice, "Setting doorbell type for %x\n", offset);
427  doorbells[offset] = qt;
428 }
429 
430 void
432 {
433  sdmaEngs[offset] = eng;
434 }
435 
436 SDMAEngine*
438 {
443  switch (id) {
444  case 0:
445  return sdma0;
446  break;
447  case 1:
448  return sdma1;
449  break;
450  default:
451  panic("No SDMA with id %d\n", id);
452  break;
453  }
454 
455  return nullptr;
456 }
457 
458 SDMAEngine*
460 {
461  return sdmaEngs[offset];
462 }
463 
464 void
466 {
468 }
469 
470 void
472 {
473  // Serialize the PciDevice base class
475 
476  uint64_t regs_size = regs.size();
477  uint64_t doorbells_size = doorbells.size();
478  uint64_t sdma_engs_size = sdmaEngs.size();
479 
480  SERIALIZE_SCALAR(regs_size);
481  SERIALIZE_SCALAR(doorbells_size);
482  SERIALIZE_SCALAR(sdma_engs_size);
483 
484  // Make a c-style array of the regs to serialize
485  uint32_t reg_addrs[regs_size];
486  uint64_t reg_values[regs_size];
487  uint32_t doorbells_offset[doorbells_size];
488  QueueType doorbells_queues[doorbells_size];
489  uint32_t sdma_engs_offset[sdma_engs_size];
490  int sdma_engs[sdma_engs_size];
491 
492  int idx = 0;
493  for (auto & it : regs) {
494  reg_addrs[idx] = it.first;
495  reg_values[idx] = it.second;
496  ++idx;
497  }
498 
499  idx = 0;
500  for (auto & it : doorbells) {
501  doorbells_offset[idx] = it.first;
502  doorbells_queues[idx] = it.second;
503  ++idx;
504  }
505 
506  idx = 0;
507  for (auto & it : sdmaEngs) {
508  sdma_engs_offset[idx] = it.first;
509  sdma_engs[idx] = it.second == sdma0 ? 0 : 1;
510  ++idx;
511  }
512 
513  SERIALIZE_ARRAY(reg_addrs, sizeof(reg_addrs)/sizeof(reg_addrs[0]));
514  SERIALIZE_ARRAY(reg_values, sizeof(reg_values)/sizeof(reg_values[0]));
515  SERIALIZE_ARRAY(doorbells_offset, sizeof(doorbells_offset)/
516  sizeof(doorbells_offset[0]));
517  SERIALIZE_ARRAY(doorbells_queues, sizeof(doorbells_queues)/
518  sizeof(doorbells_queues[0]));
519  SERIALIZE_ARRAY(sdma_engs_offset, sizeof(sdma_engs_offset)/
520  sizeof(sdma_engs_offset[0]));
521  SERIALIZE_ARRAY(sdma_engs, sizeof(sdma_engs)/sizeof(sdma_engs[0]));
522 
523  // Serialize the device memory
524  deviceMem.serializeSection(cp, "deviceMem");
525 }
526 
527 void
529 {
530  // Unserialize the PciDevice base class
532 
533  uint64_t regs_size = 0;
534  uint64_t doorbells_size = 0;
535  uint64_t sdma_engs_size = 0;
536 
537  UNSERIALIZE_SCALAR(regs_size);
538  UNSERIALIZE_SCALAR(doorbells_size);
539  UNSERIALIZE_SCALAR(sdma_engs_size);
540 
541  if (regs_size > 0) {
542  uint32_t reg_addrs[regs_size];
543  uint64_t reg_values[regs_size];
544 
545  UNSERIALIZE_ARRAY(reg_addrs, sizeof(reg_addrs)/sizeof(reg_addrs[0]));
546  UNSERIALIZE_ARRAY(reg_values,
547  sizeof(reg_values)/sizeof(reg_values[0]));
548 
549  for (int idx = 0; idx < regs_size; ++idx) {
550  regs.insert(std::make_pair(reg_addrs[idx], reg_values[idx]));
551  }
552  }
553 
554  if (doorbells_size > 0) {
555  uint32_t doorbells_offset[doorbells_size];
556  QueueType doorbells_queues[doorbells_size];
557 
558  UNSERIALIZE_ARRAY(doorbells_offset, sizeof(doorbells_offset)/
559  sizeof(doorbells_offset[0]));
560  UNSERIALIZE_ARRAY(doorbells_queues, sizeof(doorbells_queues)/
561  sizeof(doorbells_queues[0]));
562 
563  for (int idx = 0; idx < doorbells_size; ++idx) {
564  regs.insert(std::make_pair(doorbells_offset[idx],
565  doorbells_queues[idx]));
566  doorbells[doorbells_offset[idx]] = doorbells_queues[idx];
567  }
568  }
569 
570  if (sdma_engs_size > 0) {
571  uint32_t sdma_engs_offset[sdma_engs_size];
572  int sdma_engs[sdma_engs_size];
573 
574  UNSERIALIZE_ARRAY(sdma_engs_offset, sizeof(sdma_engs_offset)/
575  sizeof(sdma_engs_offset[0]));
576  UNSERIALIZE_ARRAY(sdma_engs, sizeof(sdma_engs)/sizeof(sdma_engs[0]));
577 
578  for (int idx = 0; idx < sdma_engs_size; ++idx) {
579  SDMAEngine *sdma = sdma_engs[idx] == 0 ? sdma0 : sdma1;
580  sdmaEngs.insert(std::make_pair(sdma_engs_offset[idx], sdma));
581  }
582  }
583 
584  // Unserialize the device memory
585  deviceMem.unserializeSection(cp, "deviceMem");
586 }
587 
588 uint16_t
590 {
591  for (uint16_t vmid = 1; vmid < AMDGPU_VM_COUNT; vmid++) {
592  auto result = usedVMIDs.find(vmid);
593  if (result == usedVMIDs.end()) {
594  idMap.insert(std::make_pair(pasid, vmid));
595  usedVMIDs[vmid] = {};
596  _lastVMID = vmid;
597  return vmid;
598  }
599  }
600  panic("All VMIDs have been assigned");
601 }
602 
603 void
605 {
606  usedVMIDs.erase(vmid);
607 }
608 
609 void
611 {
612  auto result = idMap.find(pasid);
613  assert(result != idMap.end());
614  if (result == idMap.end()) return;
615  uint16_t vmid = result->second;
616 
617  idMap.erase(result);
618  usedVMIDs.erase(vmid);
619 }
620 
621 void
623 {
624  idMap.erase(idMap.begin(), idMap.end());
625  usedVMIDs.erase(usedVMIDs.begin(), usedVMIDs.end());
626 }
627 
628 void
629 AMDGPUDevice::mapDoorbellToVMID(Addr doorbell, uint16_t vmid)
630 {
631  doorbellVMIDMap[doorbell] = vmid;
632 }
633 
634 std::unordered_map<uint16_t, std::set<int>>&
636 {
637  return usedVMIDs;
638 }
639 
640 void
641 AMDGPUDevice::insertQId(uint16_t vmid, int id)
642 {
643  usedVMIDs[vmid].insert(id);
644 }
645 
646 } // namespace gem5
gem5::AMDGPUVM::readMMIO
void readMMIO(PacketPtr pkt, Addr offset)
Definition: amdgpu_vm.cc:69
gem5::curTick
Tick curTick()
The universal simulation clock.
Definition: cur_tick.hh:46
gem5::AMDGPUDevice::read
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: amdgpu_device.cc:344
gem5::AMDGPUDevice::isROM
bool isROM(Addr addr) const
Definition: amdgpu_device.hh:96
gem5::HSAPacketProcessor::setGPUDevice
void setGPUDevice(AMDGPUDevice *gpu_device)
Definition: hsa_packet_processor.cc:97
warn
#define warn(...)
Definition: logging.hh:246
gem5::AMDGPUDevice::_lastVMID
uint16_t _lastVMID
Definition: amdgpu_device.hh:132
gem5::SDMAEngine::setId
void setId(int _id)
Definition: sdma_engine.hh:146
gem5::AMDGPUDevice::getAddrRanges
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
Definition: amdgpu_device.cc:110
gem5::PciDevice::config
PCIConfig config
The current config space.
Definition: device.hh:275
gem5::Packet::getUintX
uint64_t getUintX(ByteOrder endian) const
Get the data in the packet byte swapped from the specified endianness and zero-extended to 64 bits.
Definition: packet.cc:348
gem5::VegaISA::m
m
Definition: pagetable.hh:52
gem5::AMDGPUDevice::gpuMemMgr
AMDGPUMemoryManager * gpuMemMgr
Blocks of the GPU.
Definition: amdgpu_device.hh:109
data
const char data[]
Definition: circlebuf.test.cc:48
gem5::SDMA1_BASE
static constexpr uint32_t SDMA1_BASE
Definition: amdgpu_defines.hh:66
UNSERIALIZE_SCALAR
#define UNSERIALIZE_SCALAR(scalar)
Definition: serialize.hh:575
gem5::PciDevice::serialize
void serialize(CheckpointOut &cp) const override
Serialize this object to the given output stream.
Definition: device.cc:401
gem5::AMDGPUDevice::setDoorbellType
void setDoorbellType(uint32_t offset, QueueType qt)
Set handles to GPU blocks.
Definition: amdgpu_device.cc:424
gem5::AMDGPUDevice::frame_regs
GPURegMap frame_regs
Definition: amdgpu_device.hh:88
gem5::NBIO_BASE
static constexpr uint32_t NBIO_BASE
Definition: amdgpu_defines.hh:91
gem5::RangeSize
AddrRange RangeSize(Addr start, Addr size)
Definition: addr_range.hh:815
abstract_mem.hh
gem5::AMDGPUDevice::getSDMAEngine
SDMAEngine * getSDMAEngine(Addr offset)
Definition: amdgpu_device.cc:459
gem5::PciDevice::unserialize
void unserialize(CheckpointIn &cp) override
Reconstruct the state of this object from a checkpoint.
Definition: device.cc:464
gem5::IH_OFFSET_SHIFT
static constexpr uint32_t IH_OFFSET_SHIFT
Definition: amdgpu_defines.hh:73
gem5::AMDGPUVM::gartTable
std::unordered_map< uint64_t, uint32_t > gartTable
Copy of GART table.
Definition: amdgpu_vm.hh:168
gem5::AMDGPUVM::getMmioAperture
Addr getMmioAperture(Addr addr)
Definition: amdgpu_vm.hh:216
gem5::AMDGPUDevice::getSDMAById
SDMAEngine * getSDMAById(int id)
Definition: amdgpu_device.cc:437
gem5::MMHUB_OFFSET_SHIFT
static constexpr uint32_t MMHUB_OFFSET_SHIFT
Definition: amdgpu_defines.hh:88
gem5::Gfx
@ Gfx
Definition: amdgpu_defines.hh:44
gem5::AMDGPUInterruptHandler::writeMMIO
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
Methods for setting the values of interrupt handler MMIO registers.
Definition: interrupt_handler.cc:145
gem5::PM4PacketProcessor::writeMMIO
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
Definition: pm4_packet_processor.cc:731
gem5::AMDGPUDevice::deallocateAllQueues
void deallocateAllQueues()
Definition: amdgpu_device.cc:622
gem5::AMDGPUDevice::intrPost
void intrPost()
Methods inherited from PciDevice.
Definition: amdgpu_device.cc:465
gem5::CheckpointIn
Definition: serialize.hh:68
gem5::PciDevice::pioDelay
Tick pioDelay
Definition: device.hh:354
gem5::Serializable::serializeSection
void serializeSection(CheckpointOut &cp, const char *name) const
Serialize an object into a new section.
Definition: serialize.cc:74
sdma_engine.hh
gem5::DOORBELL_BAR
constexpr int DOORBELL_BAR
Definition: amdgpu_defines.hh:57
gem5::RLC
@ RLC
Definition: amdgpu_defines.hh:49
gem5::AMDGPUDevice::sdma1
SDMAEngine * sdma1
Definition: amdgpu_device.hh:113
gem5::AMDGPUDevice::idMap
std::unordered_map< uint16_t, uint16_t > idMap
Definition: amdgpu_device.hh:126
gem5::AMDGPUDevice::doorbellVMIDMap
std::unordered_map< Addr, uint16_t > doorbellVMIDMap
Definition: amdgpu_device.hh:128
gem5::AMDGPUVM::gartBase
Addr gartBase()
Return base address of GART table in framebuffer.
Definition: amdgpu_vm.cc:57
gem5::FRAMEBUFFER_BAR
constexpr int FRAMEBUFFER_BAR
Definition: amdgpu_defines.hh:56
gem5::AMDGPUDevice::unserialize
void unserialize(CheckpointIn &cp) override
Unserialize an object.
Definition: amdgpu_device.cc:528
gem5::AMDGPUInterruptHandler::setGPUDevice
void setGPUDevice(AMDGPUDevice *gpu_device)
Definition: interrupt_handler.hh:164
gem5::GPUCommandProcessor::hsaPacketProc
HSAPacketProcessor & hsaPacketProc()
Definition: gpu_command_processor.cc:65
gem5::AMDMMIOReader::readMMIOTrace
void readMMIOTrace(std::string trace_file)
Read an MMIO trace gathered from a real system and place the MMIO values read and written into the MM...
Definition: mmio_reader.cc:44
gem5::Packet::makeAtomicResponse
void makeAtomicResponse()
Definition: packet.hh:1056
gem5::VegaISA::r
Bitfield< 5 > r
Definition: pagetable.hh:60
gem5::AMDGPUVM::getFrameAperture
Addr getFrameAperture(Addr addr)
Definition: amdgpu_vm.hh:248
gem5::PM4PacketProcessor::process
void process(PM4Queue *q, Addr wptrOffset)
This method start processing a PM4Queue from the current read pointer to the newly communicated write...
Definition: pm4_packet_processor.cc:152
gem5::AMDGPUDevice::readConfig
Tick readConfig(PacketPtr pkt) override
Read from the PCI config space data that is stored locally.
Definition: amdgpu_device.cc:129
interrupt_handler.hh
hw_scheduler.hh
sim_exit.hh
gem5::SDMAPage
@ SDMAPage
Definition: amdgpu_defines.hh:46
gem5::AMDGPUDevice::mapDoorbellToVMID
void mapDoorbellToVMID(Addr doorbell, uint16_t vmid)
Definition: amdgpu_device.cc:629
gem5::AMDGPUDevice::writeMMIO
void writeMMIO(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:312
gem5::exitSimLoop
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
Definition: sim_events.cc:88
gem5::AMDGPUDevice::gpuvm
AMDGPUVM gpuvm
Definition: amdgpu_device.hh:111
packet.hh
gem5::AMDGPUDevice::cp
GPUCommandProcessor * cp
Definition: amdgpu_device.hh:116
gem5::AMDGPUDevice::sdmaEngs
std::unordered_map< uint32_t, SDMAEngine * > sdmaEngs
Definition: amdgpu_device.hh:114
gem5::PciDevice::writeConfig
virtual Tick writeConfig(PacketPtr pkt)
Write to the PCI config space data that is stored locally.
Definition: device.cc:283
gem5::AMDGPUDevice::AMDGPUDevice
AMDGPUDevice(const AMDGPUDeviceParams &p)
Definition: amdgpu_device.cc:53
gem5::GRBM_OFFSET_SHIFT
static constexpr uint32_t GRBM_OFFSET_SHIFT
Definition: amdgpu_defines.hh:78
gem5::AMDGPUInterruptHandler::updateRptr
void updateRptr(const uint32_t &data)
Definition: interrupt_handler.cc:235
gem5::SDMAEngine::processPage
void processPage(Addr wptrOffset)
Definition: sdma_engine.cc:181
gem5::AMDGPUDevice::writeConfig
Tick writeConfig(PacketPtr pkt) override
Write to the PCI config space data that is stored locally.
Definition: amdgpu_device.cc:157
gem5::Serializable::unserializeSection
void unserializeSection(CheckpointIn &cp, const char *name)
Unserialize an a child object.
Definition: serialize.cc:81
gem5::VegaISA::p
Bitfield< 54 > p
Definition: pagetable.hh:70
gem5::PM4PacketProcessor::setGPUDevice
void setGPUDevice(AMDGPUDevice *gpu_device)
Definition: pm4_packet_processor.cc:84
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
amdgpu_device.hh
gem5::Packet
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:291
gem5::Tick
uint64_t Tick
Tick count type.
Definition: types.hh:58
gem5::AMDGPUDevice::setRegVal
void setRegVal(uint32_t addr, uint32_t value)
Definition: amdgpu_device.cc:416
gem5::AMDGPUDevice::allocateVMID
uint16_t allocateVMID(uint16_t pasid)
Definition: amdgpu_device.cc:589
gem5::AMDGPUDevice::regs
GPURegMap regs
Definition: amdgpu_device.hh:89
gem5::AMDGPUDevice::mmioReader
AMDMMIOReader mmioReader
MMIO reader to populate device registers map.
Definition: amdgpu_device.hh:104
gem5::PciDevice
PCI device, base implementation is only config space.
Definition: device.hh:269
gem5::AMDGPUDevice::checkpoint_before_mmios
bool checkpoint_before_mmios
Initial checkpoint support variables.
Definition: amdgpu_device.hh:121
gem5::MMIO_BAR
constexpr int MMIO_BAR
Definition: amdgpu_defines.hh:58
gem5::AMDGPUDevice::readROM
void readROM(PacketPtr pkt)
Definition: amdgpu_device.cc:97
gem5::PciDevice::getBAR
bool getBAR(Addr addr, int &num, Addr &offs)
Which base address register (if any) maps the given address?
Definition: device.hh:320
pm4_packet_processor.hh
gem5::ArmISA::offset
Bitfield< 23, 0 > offset
Definition: types.hh:144
gem5::AMDGPUDevice
Device model for an AMD GPU.
Definition: amdgpu_device.hh:60
gem5::AMDGPUDevice::serialize
void serialize(CheckpointOut &cp) const override
Checkpoint support.
Definition: amdgpu_device.cc:471
gem5::bits
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
gem5::AMDGPUDevice::dispatchAccess
void dispatchAccess(PacketPtr pkt, bool read)
Convert a PCI packet into a response.
Definition: amdgpu_device.cc:168
gpu_command_processor.hh
gem5::SDMA_OFFSET_SHIFT
static constexpr uint32_t SDMA_OFFSET_SHIFT
Definition: amdgpu_defines.hh:68
SERIALIZE_ARRAY
#define SERIALIZE_ARRAY(member, size)
Definition: serialize.hh:610
gem5::AMDGPUDevice::readFrame
void readFrame(PacketPtr pkt, Addr offset)
Helper methods to handle specific BAR read/writes.
Definition: amdgpu_device.cc:178
gem5::AMDGPUDevice::readDoorbell
void readDoorbell(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:204
gem5::SDMAEngine
System DMA Engine class for AMD dGPU.
Definition: sdma_engine.hh:48
gem5::GPUCommandProcessor::setGPUDevice
void setGPUDevice(AMDGPUDevice *gpu_device)
Definition: gpu_command_processor.cc:432
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
gem5::ROM_SIZE
constexpr uint32_t ROM_SIZE
Definition: amdgpu_defines.hh:62
gem5::SDMAGfx
@ SDMAGfx
Definition: amdgpu_defines.hh:45
name
const std::string & name()
Definition: trace.cc:49
SERIALIZE_SCALAR
#define SERIALIZE_SCALAR(scalar)
Definition: serialize.hh:568
gem5::AMDGPUDevice::write
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
Definition: amdgpu_device.cc:373
gem5::VGA_ROM_DEFAULT
constexpr uint32_t VGA_ROM_DEFAULT
Definition: amdgpu_defines.hh:61
gem5::Compute
@ Compute
Definition: amdgpu_defines.hh:43
packet_access.hh
gem5::AMDGPUDevice::getUsedVMIDs
std::unordered_map< uint16_t, std::set< int > > & getUsedVMIDs()
Definition: amdgpu_device.cc:635
gem5::AMDMMIOReader::readFromTrace
void readFromTrace(PacketPtr pkt, int barnum, Addr offset)
Get the next MMIO read from the trace file to an offset in a BAR and write the value to the packet pr...
Definition: mmio_reader.cc:76
gem5::IH_BASE
static constexpr uint32_t IH_BASE
Definition: amdgpu_defines.hh:71
gem5::AMDGPUMemoryManager::getRequestorID
RequestorID getRequestorID() const
Get the requestorID for the memory manager.
Definition: memory_manager.hh:98
gem5::AMDGPUVM::writeMMIO
void writeMMIO(PacketPtr pkt, Addr offset)
Definition: amdgpu_vm.cc:105
gem5::PciDevice::readConfig
virtual Tick readConfig(PacketPtr pkt)
Read from the PCI config space data that is stored locally.
Definition: device.cc:212
gem5::AMDGPUDevice::readMMIO
void readMMIO(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:211
gem5::AMDGPUMemoryManager::writeRequest
void writeRequest(Addr addr, uint8_t *data, int size, Request::Flags flag=0, Event *callback=nullptr)
Write size amount of data to device memory at addr using flags and callback.
Definition: memory_manager.cc:53
UNSERIALIZE_ARRAY
#define UNSERIALIZE_ARRAY(member, size)
Definition: serialize.hh:618
gem5::PM4PacketProcessor::getQueue
PM4Queue * getQueue(Addr offset, bool gfx=false)
Based on an offset communicated through doorbell write, the PM4PacketProcessor identifies which queue...
Definition: pm4_packet_processor.cc:100
gem5::AMDGPUDevice::init_interrupt_count
int init_interrupt_count
Definition: amdgpu_device.hh:122
gem5::HSAPacketProcessor::hwScheduler
HWScheduler * hwScheduler()
Definition: hsa_packet_processor.hh:366
gem5::AMDGPUDevice::romRange
AddrRange romRange
VGA ROM methods.
Definition: amdgpu_device.hh:95
gem5::MMHUB_BASE
static constexpr uint32_t MMHUB_BASE
Definition: amdgpu_defines.hh:86
gem5::AMDGPUDevice::usedVMIDs
std::unordered_map< uint16_t, std::set< int > > usedVMIDs
Definition: amdgpu_device.hh:130
gem5::PM4PacketProcessor::updateReadIndex
void updateReadIndex(Addr offset, uint64_t rd_idx)
Update read index on doorbell rings.
Definition: pm4_packet_processor.cc:508
gem5::AMDGPUDevice::insertQId
void insertQId(uint16_t vmid, int id)
Definition: amdgpu_device.cc:641
gem5::Packet::getLE
T getLE() const
Get the data in the packet byte swapped from little endian to host endian.
Definition: packet_access.hh:78
gem5::SDMAEngine::setGPUDevice
void setGPUDevice(AMDGPUDevice *gpu_device)
Definition: sdma_engine.cc:70
gem5::AMDGPUDevice::deallocateVmid
void deallocateVmid(uint16_t vmid)
Definition: amdgpu_device.cc:604
gem5::PioDevice::read
virtual Tick read(PacketPtr pkt)=0
Pure virtual function that the device must implement.
gem5::AMDGPUDevice::deallocatePasid
void deallocatePasid(uint16_t pasid)
Definition: amdgpu_device.cc:610
gem5::AMDGPUDevice::rom
std::array< uint8_t, ROM_SIZE > rom
Definition: amdgpu_device.hh:99
gem5::CheckpointOut
std::ostream CheckpointOut
Definition: serialize.hh:66
gem5::AMDGPU_VM_COUNT
static constexpr int AMDGPU_VM_COUNT
Definition: amdgpu_defines.hh:53
gem5::AMDGPUDevice::deviceMem
memory::PhysicalMemory deviceMem
Definition: amdgpu_device.hh:137
gem5::Packet::setLE
void setLE(T v)
Set the value in the data pointer to v as little endian.
Definition: packet_access.hh:108
gem5::AMDGPUDevice::getRegVal
uint32_t getRegVal(uint32_t addr)
Register value getter/setter.
Definition: amdgpu_device.cc:411
gem5::HWScheduler::write
void write(Addr db_addr, uint64_t doorbell_reg)
Definition: hw_scheduler.cc:329
gem5::InterruptHandler
@ InterruptHandler
Definition: amdgpu_defines.hh:48
gem5::AMDGPUDevice::writeFrame
void writeFrame(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:248
std::list< AddrRange >
amdgpu_vm.hh
gem5::Packet::getAddr
Addr getAddr() const
Definition: packet.hh:790
gem5::SDMAEngine::processGfx
void processGfx(Addr wptrOffset)
Given a new write ptr offset, communicated to the GPU through a doorbell write, the SDMA engine proce...
Definition: sdma_engine.cc:170
PCI_CONFIG_SIZE
#define PCI_CONFIG_SIZE
Definition: pcireg.h:165
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: gpu_translation_state.hh:37
gem5::PciDevice::intrPost
void intrPost()
Definition: device.hh:364
gem5::QueueType
QueueType
Definition: amdgpu_defines.hh:41
gem5::AMDGPUDevice::pm4PktProc
PM4PacketProcessor * pm4PktProc
Definition: amdgpu_device.hh:115
gem5::AMDGPUDevice::setSDMAEngine
void setSDMAEngine(Addr offset, SDMAEngine *eng)
Definition: amdgpu_device.cc:431
gem5::AMDGPUDevice::sdma0
SDMAEngine * sdma0
Definition: amdgpu_device.hh:112
gem5::Packet::setUintX
void setUintX(uint64_t w, ByteOrder endian)
Set the value in the word w after truncating it to the length of the packet and then byteswapping it ...
Definition: packet.cc:357
gem5::PciDevice::getAddrRanges
AddrRangeList getAddrRanges() const override
Determine the address ranges that this device responds to.
Definition: device.cc:269
gem5::AMDGPUDevice::doorbells
std::unordered_map< uint32_t, QueueType > doorbells
Definition: amdgpu_device.hh:90
gem5::GRBM_BASE
static constexpr uint32_t GRBM_BASE
Definition: amdgpu_defines.hh:76
gem5::SDMA0_BASE
static constexpr uint32_t SDMA0_BASE
Definition: amdgpu_defines.hh:65
gem5::AMDGPUDevice::deviceIH
AMDGPUInterruptHandler * deviceIH
Definition: amdgpu_device.hh:110
gem5::Packet::getSize
unsigned getSize() const
Definition: packet.hh:800
byteswap.hh
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
gem5::X86ISA::addr
Bitfield< 3 > addr
Definition: types.hh:84
gem5::Packet::getPtr
T * getPtr()
get a pointer to the data ptr.
Definition: packet.hh:1197
PCI0_INTERRUPT_PIN
#define PCI0_INTERRUPT_PIN
Definition: pcireg.h:135
gem5::SDMAEngine::writeMMIO
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
Methods for setting the values of SDMA MMIO registers.
Definition: sdma_engine.cc:925
gem5::AMDGPUDevice::writeDoorbell
void writeDoorbell(PacketPtr pkt, Addr offset)
Definition: amdgpu_device.cc:266
gem5::ComputeAQL
@ ComputeAQL
Definition: amdgpu_defines.hh:47

Generated on Wed Jul 13 2022 10:39:18 for gem5 by doxygen 1.8.17