aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAmber Lin <Amber.Lin@amd.com>2018-08-22 16:48:50 -0400
committerAlex Deucher <alexander.deucher@amd.com>2018-08-28 12:22:42 -0400
commit04d5e2765802241b54ee93d1e655123c39fa7385 (patch)
tree018d3e2901170e95127f73b6d54eba9aa061e0dd /drivers
parent7d0aa3765fa839c0047a8924807e5201f4d9e76d (diff)
drm/amdgpu: Merge amdkfd into amdgpu
Since KFD is only supported by single GPU driver, it makes sense to merge amdgpu and amdkfd into one module. This patch is the initial step: merge Kconfig and Makefile. v2: also remove kfd from drm Kconfig Signed-off-by: Amber Lin <Amber.Lin@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/Kconfig2
-rw-r--r--drivers/gpu/drm/amd/amdgpu/Kconfig1
-rw-r--r--drivers/gpu/drm/amd/amdgpu/Makefile6
-rw-r--r--drivers/gpu/drm/amd/amdkfd/Kconfig2
-rw-r--r--drivers/gpu/drm/amd/amdkfd/Makefile53
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_module.c77
6 files changed, 63 insertions, 78 deletions
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index cb88528e7b10..736b7e67e4ec 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -285,8 +285,6 @@ source "drivers/gpu/drm/bridge/Kconfig"
285 285
286source "drivers/gpu/drm/sti/Kconfig" 286source "drivers/gpu/drm/sti/Kconfig"
287 287
288source "drivers/gpu/drm/amd/amdkfd/Kconfig"
289
290source "drivers/gpu/drm/imx/Kconfig" 288source "drivers/gpu/drm/imx/Kconfig"
291 289
292source "drivers/gpu/drm/v3d/Kconfig" 290source "drivers/gpu/drm/v3d/Kconfig"
diff --git a/drivers/gpu/drm/amd/amdgpu/Kconfig b/drivers/gpu/drm/amd/amdgpu/Kconfig
index e8af1f5e8a79..9221e5489069 100644
--- a/drivers/gpu/drm/amd/amdgpu/Kconfig
+++ b/drivers/gpu/drm/amd/amdgpu/Kconfig
@@ -42,3 +42,4 @@ config DRM_AMDGPU_GART_DEBUGFS
42 42
43source "drivers/gpu/drm/amd/acp/Kconfig" 43source "drivers/gpu/drm/amd/acp/Kconfig"
44source "drivers/gpu/drm/amd/display/Kconfig" 44source "drivers/gpu/drm/amd/display/Kconfig"
45source "drivers/gpu/drm/amd/amdkfd/Kconfig"
diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile
index d2bafabe585d..847536b55f46 100644
--- a/drivers/gpu/drm/amd/amdgpu/Makefile
+++ b/drivers/gpu/drm/amd/amdgpu/Makefile
@@ -35,7 +35,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
35 -I$(FULL_AMD_DISPLAY_PATH) \ 35 -I$(FULL_AMD_DISPLAY_PATH) \
36 -I$(FULL_AMD_DISPLAY_PATH)/include \ 36 -I$(FULL_AMD_DISPLAY_PATH)/include \
37 -I$(FULL_AMD_DISPLAY_PATH)/dc \ 37 -I$(FULL_AMD_DISPLAY_PATH)/dc \
38 -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm 38 -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
39 -I$(FULL_AMD_PATH)/amdkfd
39 40
40amdgpu-y := amdgpu_drv.o 41amdgpu-y := amdgpu_drv.o
41 42
@@ -136,6 +137,9 @@ amdgpu-y += \
136amdgpu-y += amdgpu_amdkfd.o 137amdgpu-y += amdgpu_amdkfd.o
137 138
138ifneq ($(CONFIG_HSA_AMD),) 139ifneq ($(CONFIG_HSA_AMD),)
140AMDKFD_PATH := ../amdkfd
141include $(FULL_AMD_PATH)/amdkfd/Makefile
142amdgpu-y += $(AMDKFD_FILES)
139amdgpu-y += \ 143amdgpu-y += \
140 amdgpu_amdkfd_fence.o \ 144 amdgpu_amdkfd_fence.o \
141 amdgpu_amdkfd_gpuvm.o \ 145 amdgpu_amdkfd_gpuvm.o \
diff --git a/drivers/gpu/drm/amd/amdkfd/Kconfig b/drivers/gpu/drm/amd/amdkfd/Kconfig
index 3858820a0055..fbf0ee5201c3 100644
--- a/drivers/gpu/drm/amd/amdkfd/Kconfig
+++ b/drivers/gpu/drm/amd/amdkfd/Kconfig
@@ -3,7 +3,7 @@
3# 3#
4 4
5config HSA_AMD 5config HSA_AMD
6 tristate "HSA kernel driver for AMD GPU devices" 6 bool "HSA kernel driver for AMD GPU devices"
7 depends on DRM_AMDGPU && X86_64 7 depends on DRM_AMDGPU && X86_64
8 imply AMD_IOMMU_V2 8 imply AMD_IOMMU_V2
9 select MMU_NOTIFIER 9 select MMU_NOTIFIER
diff --git a/drivers/gpu/drm/amd/amdkfd/Makefile b/drivers/gpu/drm/amd/amdkfd/Makefile
index ffd096fffc1c..69ec96998bb9 100644
--- a/drivers/gpu/drm/amd/amdkfd/Makefile
+++ b/drivers/gpu/drm/amd/amdkfd/Makefile
@@ -23,26 +23,41 @@
23# Makefile for Heterogenous System Architecture support for AMD GPU devices 23# Makefile for Heterogenous System Architecture support for AMD GPU devices
24# 24#
25 25
26ccflags-y := -Idrivers/gpu/drm/amd/include/ \ 26AMDKFD_FILES := $(AMDKFD_PATH)/kfd_module.o \
27 -Idrivers/gpu/drm/amd/include/asic_reg 27 $(AMDKFD_PATH)/kfd_device.o \
28 28 $(AMDKFD_PATH)/kfd_chardev.o \
29amdkfd-y := kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \ 29 $(AMDKFD_PATH)/kfd_topology.o \
30 kfd_pasid.o kfd_doorbell.o kfd_flat_memory.o \ 30 $(AMDKFD_PATH)/kfd_pasid.o \
31 kfd_process.o kfd_queue.o kfd_mqd_manager.o \ 31 $(AMDKFD_PATH)/kfd_doorbell.o \
32 kfd_mqd_manager_cik.o kfd_mqd_manager_vi.o \ 32 $(AMDKFD_PATH)/kfd_flat_memory.o \
33 kfd_mqd_manager_v9.o \ 33 $(AMDKFD_PATH)/kfd_process.o \
34 kfd_kernel_queue.o kfd_kernel_queue_cik.o \ 34 $(AMDKFD_PATH)/kfd_queue.o \
35 kfd_kernel_queue_vi.o kfd_kernel_queue_v9.o \ 35 $(AMDKFD_PATH)/kfd_mqd_manager.o \
36 kfd_packet_manager.o kfd_process_queue_manager.o \ 36 $(AMDKFD_PATH)/kfd_mqd_manager_cik.o \
37 kfd_device_queue_manager.o kfd_device_queue_manager_cik.o \ 37 $(AMDKFD_PATH)/kfd_mqd_manager_vi.o \
38 kfd_device_queue_manager_vi.o kfd_device_queue_manager_v9.o \ 38 $(AMDKFD_PATH)/kfd_mqd_manager_v9.o \
39 kfd_interrupt.o kfd_events.o cik_event_interrupt.o \ 39 $(AMDKFD_PATH)/kfd_kernel_queue.o \
40 kfd_int_process_v9.o kfd_dbgdev.o kfd_dbgmgr.o kfd_crat.o 40 $(AMDKFD_PATH)/kfd_kernel_queue_cik.o \
41 $(AMDKFD_PATH)/kfd_kernel_queue_vi.o \
42 $(AMDKFD_PATH)/kfd_kernel_queue_v9.o \
43 $(AMDKFD_PATH)/kfd_packet_manager.o \
44 $(AMDKFD_PATH)/kfd_process_queue_manager.o \
45 $(AMDKFD_PATH)/kfd_device_queue_manager.o \
46 $(AMDKFD_PATH)/kfd_device_queue_manager_cik.o \
47 $(AMDKFD_PATH)/kfd_device_queue_manager_vi.o \
48 $(AMDKFD_PATH)/kfd_device_queue_manager_v9.o \
49 $(AMDKFD_PATH)/kfd_interrupt.o \
50 $(AMDKFD_PATH)/kfd_events.o \
51 $(AMDKFD_PATH)/cik_event_interrupt.o \
52 $(AMDKFD_PATH)/kfd_int_process_v9.o \
53 $(AMDKFD_PATH)/kfd_dbgdev.o \
54 $(AMDKFD_PATH)/kfd_dbgmgr.o \
55 $(AMDKFD_PATH)/kfd_crat.o
41 56
42ifneq ($(CONFIG_AMD_IOMMU_V2),) 57ifneq ($(CONFIG_AMD_IOMMU_V2),)
43amdkfd-y += kfd_iommu.o 58AMDKFD_FILES += $(AMDKFD_PATH)/kfd_iommu.o
44endif 59endif
45 60
46amdkfd-$(CONFIG_DEBUG_FS) += kfd_debugfs.o 61ifneq ($(CONFIG_DEBUG_FS),)
47 62AMDKFD_FILES += $(AMDKFD_PATH)/kfd_debugfs.o
48obj-$(CONFIG_HSA_AMD) += amdkfd.o 63endif
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_module.c b/drivers/gpu/drm/amd/amdkfd/kfd_module.c
index 6e1f5c7c2d4b..b445674bba9a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_module.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_module.c
@@ -20,21 +20,11 @@
20 * OTHER DEALINGS IN THE SOFTWARE. 20 * OTHER DEALINGS IN THE SOFTWARE.
21 */ 21 */
22 22
23#include <linux/module.h>
24#include <linux/sched.h> 23#include <linux/sched.h>
25#include <linux/moduleparam.h> 24#include <linux/moduleparam.h>
26#include <linux/device.h> 25#include <linux/device.h>
27#include <linux/printk.h>
28#include "kfd_priv.h" 26#include "kfd_priv.h"
29 27
30#define KFD_DRIVER_AUTHOR "AMD Inc. and others"
31
32#define KFD_DRIVER_DESC "Standalone HSA driver for AMD's GPUs"
33#define KFD_DRIVER_DATE "20150421"
34#define KFD_DRIVER_MAJOR 0
35#define KFD_DRIVER_MINOR 7
36#define KFD_DRIVER_PATCHLEVEL 2
37
38static const struct kgd2kfd_calls kgd2kfd = { 28static const struct kgd2kfd_calls kgd2kfd = {
39 .exit = kgd2kfd_exit, 29 .exit = kgd2kfd_exit,
40 .probe = kgd2kfd_probe, 30 .probe = kgd2kfd_probe,
@@ -95,33 +85,7 @@ module_param(halt_if_hws_hang, int, 0644);
95MODULE_PARM_DESC(halt_if_hws_hang, "Halt if HWS hang is detected (0 = off (default), 1 = on)"); 85MODULE_PARM_DESC(halt_if_hws_hang, "Halt if HWS hang is detected (0 = off (default), 1 = on)");
96 86
97 87
98static int amdkfd_init_completed; 88static int kfd_init(void)
99
100
101int kgd2kfd_init(unsigned int interface_version,
102 const struct kgd2kfd_calls **g2f)
103{
104 if (!amdkfd_init_completed)
105 return -EPROBE_DEFER;
106
107 /*
108 * Only one interface version is supported,
109 * no kfd/kgd version skew allowed.
110 */
111 if (interface_version != KFD_INTERFACE_VERSION)
112 return -EINVAL;
113
114 *g2f = &kgd2kfd;
115
116 return 0;
117}
118EXPORT_SYMBOL(kgd2kfd_init);
119
120void kgd2kfd_exit(void)
121{
122}
123
124static int __init kfd_module_init(void)
125{ 89{
126 int err; 90 int err;
127 91
@@ -129,7 +93,7 @@ static int __init kfd_module_init(void)
129 if ((sched_policy < KFD_SCHED_POLICY_HWS) || 93 if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
130 (sched_policy > KFD_SCHED_POLICY_NO_HWS)) { 94 (sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
131 pr_err("sched_policy has invalid value\n"); 95 pr_err("sched_policy has invalid value\n");
132 return -1; 96 return -EINVAL;
133 } 97 }
134 98
135 /* Verify module parameters */ 99 /* Verify module parameters */
@@ -137,7 +101,7 @@ static int __init kfd_module_init(void)
137 (max_num_of_queues_per_device > 101 (max_num_of_queues_per_device >
138 KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) { 102 KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
139 pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n"); 103 pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
140 return -1; 104 return -EINVAL;
141 } 105 }
142 106
143 err = kfd_chardev_init(); 107 err = kfd_chardev_init();
@@ -154,10 +118,6 @@ static int __init kfd_module_init(void)
154 118
155 kfd_debugfs_init(); 119 kfd_debugfs_init();
156 120
157 amdkfd_init_completed = 1;
158
159 dev_info(kfd_device, "Initialized module\n");
160
161 return 0; 121 return 0;
162 122
163err_create_wq: 123err_create_wq:
@@ -168,23 +128,30 @@ err_ioctl:
168 return err; 128 return err;
169} 129}
170 130
171static void __exit kfd_module_exit(void) 131static void kfd_exit(void)
172{ 132{
173 amdkfd_init_completed = 0;
174
175 kfd_debugfs_fini(); 133 kfd_debugfs_fini();
176 kfd_process_destroy_wq(); 134 kfd_process_destroy_wq();
177 kfd_topology_shutdown(); 135 kfd_topology_shutdown();
178 kfd_chardev_exit(); 136 kfd_chardev_exit();
179 pr_info("amdkfd: Removed module\n");
180} 137}
181 138
182module_init(kfd_module_init); 139int kgd2kfd_init(unsigned int interface_version,
183module_exit(kfd_module_exit); 140 const struct kgd2kfd_calls **g2f)
141{
142 int err;
143
144 err = kfd_init();
145 if (err)
146 return err;
184 147
185MODULE_AUTHOR(KFD_DRIVER_AUTHOR); 148 *g2f = &kgd2kfd;
186MODULE_DESCRIPTION(KFD_DRIVER_DESC); 149
187MODULE_LICENSE("GPL and additional rights"); 150 return 0;
188MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "." 151}
189 __stringify(KFD_DRIVER_MINOR) "." 152EXPORT_SYMBOL(kgd2kfd_init);
190 __stringify(KFD_DRIVER_PATCHLEVEL)); 153
154void kgd2kfd_exit(void)
155{
156 kfd_exit();
157}