aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Kuehling <Felix.Kuehling@amd.com>2018-04-10 17:33:10 -0400
committerOded Gabbay <oded.gabbay@gmail.com>2018-04-10 17:33:10 -0400
commitca750681bc4a897ffa7eed71a1e05762fb1f0a34 (patch)
tree5ee1466f07b85cc3d611de95dbdabb234ec2b675
parentbed4f110251b4f9041e5e797e035bc40c34d60ea (diff)
drm/amdkfd: Add SOC15 interrupt processing support
Signed-off-by: Shaoyun Liu <Shaoyun.Liu@amd.com> Signed-off-by: Oak Zeng <Oak.Zeng@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/Makefile2
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c84
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_priv.h2
-rw-r--r--drivers/gpu/drm/amd/amdkfd/soc15_int.h47
4 files changed, 134 insertions, 1 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/Makefile b/drivers/gpu/drm/amd/amdkfd/Makefile
index ff8b5aa11f4e..ffd096fffc1c 100644
--- a/drivers/gpu/drm/amd/amdkfd/Makefile
+++ b/drivers/gpu/drm/amd/amdkfd/Makefile
@@ -37,7 +37,7 @@ amdkfd-y := kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \
37 kfd_device_queue_manager.o kfd_device_queue_manager_cik.o \ 37 kfd_device_queue_manager.o kfd_device_queue_manager_cik.o \
38 kfd_device_queue_manager_vi.o kfd_device_queue_manager_v9.o \ 38 kfd_device_queue_manager_vi.o kfd_device_queue_manager_v9.o \
39 kfd_interrupt.o kfd_events.o cik_event_interrupt.o \ 39 kfd_interrupt.o kfd_events.o cik_event_interrupt.o \
40 kfd_dbgdev.o kfd_dbgmgr.o kfd_crat.o 40 kfd_int_process_v9.o kfd_dbgdev.o kfd_dbgmgr.o kfd_crat.o
41 41
42ifneq ($(CONFIG_AMD_IOMMU_V2),) 42ifneq ($(CONFIG_AMD_IOMMU_V2),)
43amdkfd-y += kfd_iommu.o 43amdkfd-y += kfd_iommu.o
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c
new file mode 100644
index 000000000000..39d41155581f
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v9.c
@@ -0,0 +1,84 @@
1/*
2 * Copyright 2016-2018 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#include "kfd_priv.h"
24#include "kfd_events.h"
25#include "soc15_int.h"
26
27
28static bool event_interrupt_isr_v9(struct kfd_dev *dev,
29 const uint32_t *ih_ring_entry)
30{
31 uint16_t source_id, client_id, pasid, vmid;
32
33 source_id = SOC15_SOURCE_ID_FROM_IH_ENTRY(ih_ring_entry);
34 client_id = SOC15_CLIENT_ID_FROM_IH_ENTRY(ih_ring_entry);
35 pasid = SOC15_PASID_FROM_IH_ENTRY(ih_ring_entry);
36 vmid = SOC15_VMID_FROM_IH_ENTRY(ih_ring_entry);
37
38 if (pasid) {
39 const uint32_t *data = ih_ring_entry;
40
41 pr_debug("client id 0x%x, source id %d, pasid 0x%x. raw data:\n",
42 client_id, source_id, pasid);
43 pr_debug("%8X, %8X, %8X, %8X, %8X, %8X, %8X, %8X.\n",
44 data[0], data[1], data[2], data[3],
45 data[4], data[5], data[6], data[7]);
46 }
47
48 return (pasid != 0) &&
49 (source_id == SOC15_INTSRC_CP_END_OF_PIPE ||
50 source_id == SOC15_INTSRC_SDMA_TRAP ||
51 source_id == SOC15_INTSRC_SQ_INTERRUPT_MSG ||
52 source_id == SOC15_INTSRC_CP_BAD_OPCODE);
53}
54
55static void event_interrupt_wq_v9(struct kfd_dev *dev,
56 const uint32_t *ih_ring_entry)
57{
58 uint16_t source_id, client_id, pasid, vmid;
59 uint32_t context_id;
60
61 source_id = SOC15_SOURCE_ID_FROM_IH_ENTRY(ih_ring_entry);
62 client_id = SOC15_CLIENT_ID_FROM_IH_ENTRY(ih_ring_entry);
63 pasid = SOC15_PASID_FROM_IH_ENTRY(ih_ring_entry);
64 vmid = SOC15_VMID_FROM_IH_ENTRY(ih_ring_entry);
65 context_id = SOC15_CONTEXT_ID0_FROM_IH_ENTRY(ih_ring_entry);
66
67 if (source_id == SOC15_INTSRC_CP_END_OF_PIPE)
68 kfd_signal_event_interrupt(pasid, context_id, 32);
69 else if (source_id == SOC15_INTSRC_SDMA_TRAP)
70 kfd_signal_event_interrupt(pasid, context_id & 0xfffffff, 28);
71 else if (source_id == SOC15_INTSRC_SQ_INTERRUPT_MSG)
72 kfd_signal_event_interrupt(pasid, context_id & 0xffffff, 24);
73 else if (source_id == SOC15_INTSRC_CP_BAD_OPCODE)
74 kfd_signal_hw_exception_event(pasid);
75 else if (client_id == SOC15_IH_CLIENTID_VMC ||
76 client_id == SOC15_IH_CLIENTID_UTCL2) {
77 /* TODO */
78 }
79}
80
81const struct kfd_event_interrupt_class event_interrupt_class_v9 = {
82 .interrupt_isr = event_interrupt_isr_v9,
83 .interrupt_wq = event_interrupt_wq_v9,
84};
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index d5cdb5db4983..06b210b33dda 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -934,6 +934,8 @@ uint64_t kfd_get_number_elems(struct kfd_dev *kfd);
934 934
935/* Events */ 935/* Events */
936extern const struct kfd_event_interrupt_class event_interrupt_class_cik; 936extern const struct kfd_event_interrupt_class event_interrupt_class_cik;
937extern const struct kfd_event_interrupt_class event_interrupt_class_v9;
938
937extern const struct kfd_device_global_init_class device_global_init_class_cik; 939extern const struct kfd_device_global_init_class device_global_init_class_cik;
938 940
939void kfd_event_init_process(struct kfd_process *p); 941void kfd_event_init_process(struct kfd_process *p);
diff --git a/drivers/gpu/drm/amd/amdkfd/soc15_int.h b/drivers/gpu/drm/amd/amdkfd/soc15_int.h
new file mode 100644
index 000000000000..0bc0b25cb410
--- /dev/null
+++ b/drivers/gpu/drm/amd/amdkfd/soc15_int.h
@@ -0,0 +1,47 @@
1/*
2 * Copyright 2016-2018 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#ifndef HSA_SOC15_INT_H_INCLUDED
24#define HSA_SOC15_INT_H_INCLUDED
25
26#include "soc15_ih_clientid.h"
27
28#define SOC15_INTSRC_CP_END_OF_PIPE 181
29#define SOC15_INTSRC_CP_BAD_OPCODE 183
30#define SOC15_INTSRC_SQ_INTERRUPT_MSG 239
31#define SOC15_INTSRC_VMC_FAULT 0
32#define SOC15_INTSRC_SDMA_TRAP 224
33
34
35#define SOC15_CLIENT_ID_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[0]) & 0xff)
36#define SOC15_SOURCE_ID_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[0]) >> 8 & 0xff)
37#define SOC15_RING_ID_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[0]) >> 16 & 0xff)
38#define SOC15_VMID_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[0]) >> 24 & 0xf)
39#define SOC15_VMID_TYPE_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[0]) >> 31 & 0x1)
40#define SOC15_PASID_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[3]) & 0xffff)
41#define SOC15_CONTEXT_ID0_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[4]))
42#define SOC15_CONTEXT_ID1_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[5]))
43#define SOC15_CONTEXT_ID2_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[6]))
44#define SOC15_CONTEXT_ID3_FROM_IH_ENTRY(entry) (le32_to_cpu(entry[7]))
45
46#endif
47