gem5  v22.1.0.0
interrupt_handler.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 
33 #ifndef __DEV_AMDGPU_INTERRUPT_HANDLER__
34 #define __DEV_AMDGPU_INTERRUPT_HANDLER__
35 
36 #include <bitset>
37 #include <iostream>
38 #include <queue>
39 #include <vector>
40 
41 #include "base/addr_range.hh"
42 #include "base/flags.hh"
43 #include "base/types.hh"
45 #include "dev/dma_device.hh"
46 #include "params/AMDGPUInterruptHandler.hh"
47 
48 namespace gem5
49 {
50 
57 {
62 };
63 
65 {
66  CP_EOP = 181,
67  TRAP_ID = 224
68 };
69 
83 constexpr uint32_t INTR_COOKIE_SIZE = 32; // in bytes
84 
85 typedef struct
86 {
87  uint32_t clientId : 8;
88  uint32_t sourceId : 8;
89  uint32_t ringId : 8;
90  uint32_t vmId : 4;
91  uint32_t reserved1 : 3;
92  uint32_t vmid_type : 1;
93  uint32_t timestamp_Lo;
94  uint32_t timestamp_Hi : 16;
95  uint32_t reserved2 : 15;
96  uint32_t timestamp_src : 1;
97  uint32_t pasid : 16;
98  uint32_t reserved3 : 15;
99  uint32_t pasid_src : 1;
100  uint32_t source_data_dw1;
101  uint32_t source_data_dw2;
102  uint32_t source_data_dw3;
103  uint32_t source_data_dw4;
105 static_assert(sizeof(AMDGPUInterruptCookie) == INTR_COOKIE_SIZE);
106 
110 typedef struct
111 {
112  uint32_t IH_Cntl;
113  uint32_t IH_Base;
114  uint32_t IH_Base_Hi;
116  uint32_t IH_Rptr;
117  uint32_t IH_Wptr;
118  uint32_t IH_Wptr_Addr_Lo;
119  uint32_t IH_Wptr_Addr_Hi;
121  uint32_t IH_Doorbell;
122 } AMDGPUIHRegs;
123 
125 {
126  public:
127  class DmaEvent : public Event
128  {
129  private:
131  uint32_t data;
132 
133  public:
136  {
138  }
139  void process();
140  const char *description() const {
141  return "AMDGPUInterruptHandler Dma";
142  }
143 
144  void setData(uint32_t _data) { data = _data; }
145  uint32_t getData() { return data; }
146  };
147 
149  {
151  : saved(sender_state), _addr(addr)
152  {
153  }
156  };
157 
158  AMDGPUInterruptHandler(const AMDGPUInterruptHandlerParams &p);
159 
160  Tick write(PacketPtr pkt) override { return 0; }
161  Tick read(PacketPtr pkt) override { return 0; }
162  AddrRangeList getAddrRanges() const override;
163  void serialize(CheckpointOut &cp) const override;
164  void unserialize(CheckpointIn &cp) override;
165 
166  void setGPUDevice(AMDGPUDevice *gpu_device) { gpuDevice = gpu_device; }
167  void prepareInterruptCookie(ContextID cntxtId, uint32_t ring_id,
168  uint32_t client_id, uint32_t source_id);
169  void submitInterruptCookie();
170  void submitWritePointer();
171  void intrPost();
172 
176  void writeMMIO(PacketPtr pkt, Addr mmio_offset);
177 
178  uint32_t getDoorbellOffset() const { return regs.IH_Doorbell; }
179  void setCntl(const uint32_t &data);
180  void setBase(const uint32_t &data);
181  void setBaseHi(const uint32_t &data);
182  void setRptr(const uint32_t &data);
183  void setWptr(const uint32_t &data);
184  void setWptrAddrLo(const uint32_t &data);
185  void setWptrAddrHi(const uint32_t &data);
186  void setDoorbellOffset(const uint32_t &data);
187  void updateRptr(const uint32_t &data);
188 
189  private:
192  std::queue<AMDGPUInterruptCookie*> interruptQueue;
194 };
195 
196 } // namespace gem5
197 
198 #endif // __DEV_AMDGPU_INTERRUPT_HANDLER__
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,...
const char data[]
Device model for an AMD GPU.
DmaEvent(AMDGPUInterruptHandler *deviceIh, uint32_t data)
const char * description() const
Return a C string describing the event.
void setGPUDevice(AMDGPUDevice *gpu_device)
void prepareInterruptCookie(ContextID cntxtId, uint32_t ring_id, uint32_t client_id, uint32_t source_id)
void setCntl(const uint32_t &data)
void setRptr(const uint32_t &data)
void setWptrAddrLo(const uint32_t &data)
AMDGPUInterruptHandler::DmaEvent * dmaEvent
Tick read(PacketPtr pkt) override
Pure virtual function that the device must implement.
AMDGPUInterruptHandler(const AMDGPUInterruptHandlerParams &p)
AddrRangeList getAddrRanges() const override
Every PIO device is obliged to provide an implementation that returns the address ranges the device r...
void unserialize(CheckpointIn &cp) override
Unserialize an object.
void setWptrAddrHi(const uint32_t &data)
void setBase(const uint32_t &data)
void serialize(CheckpointOut &cp) const override
Serialize an object.
void setDoorbellOffset(const uint32_t &data)
void updateRptr(const uint32_t &data)
void setBaseHi(const uint32_t &data)
void setWptr(const uint32_t &data)
Tick write(PacketPtr pkt) override
Pure virtual function that the device must implement.
std::queue< AMDGPUInterruptCookie * > interruptQueue
void writeMMIO(PacketPtr pkt, Addr mmio_offset)
Methods for setting the values of interrupt handler MMIO registers.
static const FlagsType AutoDelete
Definition: eventq.hh:107
void setFlags(Flags _flags)
Definition: eventq.hh:328
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
Definition: packet.hh:294
Bitfield< 54 > p
Definition: pagetable.hh:70
Bitfield< 3 > addr
Definition: types.hh:84
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
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
soc15_ih_clientid
Defines from driver code.
@ SOC15_IH_CLIENTID_SDMA0
@ SOC15_IH_CLIENTID_GRBM_CP
@ SOC15_IH_CLIENTID_SDMA1
@ SOC15_IH_CLIENTID_RLC
uint64_t Tick
Tick count type.
Definition: types.hh:58
constexpr uint32_t INTR_COOKIE_SIZE
MSI-style interrupts.
int ContextID
Globally unique thread context ID.
Definition: types.hh:239
Struct to contain all interrupt handler related registers.
SenderState(Packet::SenderState *sender_state, Addr addr)
A virtual base opaque structure used to hold state associated with the packet (e.g....
Definition: packet.hh:468

Generated on Wed Dec 21 2022 10:22:32 for gem5 by doxygen 1.9.1