1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#include "kfd_priv.h"
24#include "kfd_events.h"
25#include "soc15_int.h"
26#include "kfd_device_queue_manager.h"
27#include "kfd_smi_events.h"
28
29static bool event_interrupt_isr_v9(struct kfd_dev *dev,
30 const uint32_t *ih_ring_entry,
31 uint32_t *patched_ihre,
32 bool *patched_flag)
33{
34 uint16_t source_id, client_id, pasid, vmid;
35 const uint32_t *data = ih_ring_entry;
36
37
38 vmid = SOC15_VMID_FROM_IH_ENTRY(ih_ring_entry);
39 if (vmid < dev->vm_info.first_vmid_kfd ||
40 vmid > dev->vm_info.last_vmid_kfd)
41 return false;
42
43 source_id = SOC15_SOURCE_ID_FROM_IH_ENTRY(ih_ring_entry);
44 client_id = SOC15_CLIENT_ID_FROM_IH_ENTRY(ih_ring_entry);
45 pasid = SOC15_PASID_FROM_IH_ENTRY(ih_ring_entry);
46
47
48
49
50
51 if (!pasid && dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) {
52 const uint32_t pasid_mask = 0xffff;
53
54 *patched_flag = true;
55 memcpy(patched_ihre, ih_ring_entry,
56 dev->device_info->ih_ring_entry_size);
57
58 pasid = dev->dqm->vmid_pasid[vmid];
59
60
61 patched_ihre[3] = cpu_to_le32((le32_to_cpu(patched_ihre[3])
62 & ~pasid_mask) | pasid);
63 }
64
65 pr_debug("client id 0x%x, source id %d, vmid %d, pasid 0x%x. raw data:\n",
66 client_id, source_id, vmid, pasid);
67 pr_debug("%8X, %8X, %8X, %8X, %8X, %8X, %8X, %8X.\n",
68 data[0], data[1], data[2], data[3],
69 data[4], data[5], data[6], data[7]);
70
71
72 if (WARN_ONCE(pasid == 0, "Bug: No PASID in KFD interrupt"))
73 return false;
74
75
76
77
78 return source_id == SOC15_INTSRC_CP_END_OF_PIPE ||
79 source_id == SOC15_INTSRC_SDMA_TRAP ||
80 source_id == SOC15_INTSRC_SQ_INTERRUPT_MSG ||
81 source_id == SOC15_INTSRC_CP_BAD_OPCODE ||
82 client_id == SOC15_IH_CLIENTID_VMC ||
83 client_id == SOC15_IH_CLIENTID_VMC1 ||
84 client_id == SOC15_IH_CLIENTID_UTCL2;
85}
86
87static void event_interrupt_wq_v9(struct kfd_dev *dev,
88 const uint32_t *ih_ring_entry)
89{
90 uint16_t source_id, client_id, pasid, vmid;
91 uint32_t context_id;
92
93 source_id = SOC15_SOURCE_ID_FROM_IH_ENTRY(ih_ring_entry);
94 client_id = SOC15_CLIENT_ID_FROM_IH_ENTRY(ih_ring_entry);
95 pasid = SOC15_PASID_FROM_IH_ENTRY(ih_ring_entry);
96 vmid = SOC15_VMID_FROM_IH_ENTRY(ih_ring_entry);
97 context_id = SOC15_CONTEXT_ID0_FROM_IH_ENTRY(ih_ring_entry);
98
99 if (source_id == SOC15_INTSRC_CP_END_OF_PIPE)
100 kfd_signal_event_interrupt(pasid, context_id, 32);
101 else if (source_id == SOC15_INTSRC_SDMA_TRAP)
102 kfd_signal_event_interrupt(pasid, context_id & 0xfffffff, 28);
103 else if (source_id == SOC15_INTSRC_SQ_INTERRUPT_MSG)
104 kfd_signal_event_interrupt(pasid, context_id & 0xffffff, 24);
105 else if (source_id == SOC15_INTSRC_CP_BAD_OPCODE)
106 kfd_signal_hw_exception_event(pasid);
107 else if (client_id == SOC15_IH_CLIENTID_VMC ||
108 client_id == SOC15_IH_CLIENTID_VMC1 ||
109 client_id == SOC15_IH_CLIENTID_UTCL2) {
110 struct kfd_vm_fault_info info = {0};
111 uint16_t ring_id = SOC15_RING_ID_FROM_IH_ENTRY(ih_ring_entry);
112
113 info.vmid = vmid;
114 info.mc_id = client_id;
115 info.page_addr = ih_ring_entry[4] |
116 (uint64_t)(ih_ring_entry[5] & 0xf) << 32;
117 info.prot_valid = ring_id & 0x08;
118 info.prot_read = ring_id & 0x10;
119 info.prot_write = ring_id & 0x20;
120
121 kfd_smi_event_update_vmfault(dev, pasid);
122 kfd_process_vm_fault(dev->dqm, pasid);
123 kfd_signal_vm_fault_event(dev, pasid, &info);
124 }
125}
126
127const struct kfd_event_interrupt_class event_interrupt_class_v9 = {
128 .interrupt_isr = event_interrupt_isr_v9,
129 .interrupt_wq = event_interrupt_wq_v9,
130};
131