drm/amdgpu: Merge amdkfd into amdgpu
authorAmber Lin <Amber.Lin@amd.com>
Wed, 22 Aug 2018 20:48:50 +0000 (16:48 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Aug 2018 16:22:42 +0000 (11:22 -0500)
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>
drivers/gpu/drm/Kconfig
drivers/gpu/drm/amd/amdgpu/Kconfig
drivers/gpu/drm/amd/amdgpu/Makefile
drivers/gpu/drm/amd/amdkfd/Kconfig
drivers/gpu/drm/amd/amdkfd/Makefile
drivers/gpu/drm/amd/amdkfd/kfd_module.c

index cb88528e7b10c0aff35dc17f3996a451a064e85a..736b7e67e4ec7068bfc2ce261f073a8874d09e8d 100644 (file)
@@ -285,8 +285,6 @@ source "drivers/gpu/drm/bridge/Kconfig"
 
 source "drivers/gpu/drm/sti/Kconfig"
 
-source "drivers/gpu/drm/amd/amdkfd/Kconfig"
-
 source "drivers/gpu/drm/imx/Kconfig"
 
 source "drivers/gpu/drm/v3d/Kconfig"
index e8af1f5e8a7981bdac82c4262c3c8c979cf13799..9221e5489069adb5227510852c7a72718903896f 100644 (file)
@@ -42,3 +42,4 @@ config DRM_AMDGPU_GART_DEBUGFS
 
 source "drivers/gpu/drm/amd/acp/Kconfig"
 source "drivers/gpu/drm/amd/display/Kconfig"
+source "drivers/gpu/drm/amd/amdkfd/Kconfig"
index d2bafabe585d6821e5c088caac8f199698bbf8c1..847536b55f46d9f8e4a2756513ed266216c625a6 100644 (file)
@@ -35,7 +35,8 @@ ccflags-y := -I$(FULL_AMD_PATH)/include/asic_reg \
        -I$(FULL_AMD_DISPLAY_PATH) \
        -I$(FULL_AMD_DISPLAY_PATH)/include \
        -I$(FULL_AMD_DISPLAY_PATH)/dc \
-       -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm
+       -I$(FULL_AMD_DISPLAY_PATH)/amdgpu_dm \
+       -I$(FULL_AMD_PATH)/amdkfd
 
 amdgpu-y := amdgpu_drv.o
 
@@ -136,6 +137,9 @@ amdgpu-y += \
 amdgpu-y += amdgpu_amdkfd.o
 
 ifneq ($(CONFIG_HSA_AMD),)
+AMDKFD_PATH := ../amdkfd
+include $(FULL_AMD_PATH)/amdkfd/Makefile
+amdgpu-y += $(AMDKFD_FILES)
 amdgpu-y += \
         amdgpu_amdkfd_fence.o \
         amdgpu_amdkfd_gpuvm.o \
index 3858820a0055d31fb30621f55efa9067d8eebfd8..fbf0ee5201c370b1a09f51d6b2dfd6557b89b496 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 config HSA_AMD
-       tristate "HSA kernel driver for AMD GPU devices"
+       bool "HSA kernel driver for AMD GPU devices"
        depends on DRM_AMDGPU && X86_64
        imply AMD_IOMMU_V2
        select MMU_NOTIFIER
index ffd096fffc1c2dde32389d3fad25411bc3eb7cd7..69ec96998bb97be0c9be2cc452cea5013017157e 100644 (file)
 # Makefile for Heterogenous System Architecture support for AMD GPU devices
 #
 
-ccflags-y := -Idrivers/gpu/drm/amd/include/  \
-               -Idrivers/gpu/drm/amd/include/asic_reg
-
-amdkfd-y       := kfd_module.o kfd_device.o kfd_chardev.o kfd_topology.o \
-               kfd_pasid.o kfd_doorbell.o kfd_flat_memory.o \
-               kfd_process.o kfd_queue.o kfd_mqd_manager.o \
-               kfd_mqd_manager_cik.o kfd_mqd_manager_vi.o \
-               kfd_mqd_manager_v9.o \
-               kfd_kernel_queue.o kfd_kernel_queue_cik.o \
-               kfd_kernel_queue_vi.o kfd_kernel_queue_v9.o \
-               kfd_packet_manager.o kfd_process_queue_manager.o \
-               kfd_device_queue_manager.o kfd_device_queue_manager_cik.o \
-               kfd_device_queue_manager_vi.o kfd_device_queue_manager_v9.o \
-               kfd_interrupt.o kfd_events.o cik_event_interrupt.o \
-               kfd_int_process_v9.o kfd_dbgdev.o kfd_dbgmgr.o kfd_crat.o
+AMDKFD_FILES   := $(AMDKFD_PATH)/kfd_module.o \
+               $(AMDKFD_PATH)/kfd_device.o \
+               $(AMDKFD_PATH)/kfd_chardev.o \
+               $(AMDKFD_PATH)/kfd_topology.o \
+               $(AMDKFD_PATH)/kfd_pasid.o \
+               $(AMDKFD_PATH)/kfd_doorbell.o \
+               $(AMDKFD_PATH)/kfd_flat_memory.o \
+               $(AMDKFD_PATH)/kfd_process.o \
+               $(AMDKFD_PATH)/kfd_queue.o \
+               $(AMDKFD_PATH)/kfd_mqd_manager.o \
+               $(AMDKFD_PATH)/kfd_mqd_manager_cik.o \
+               $(AMDKFD_PATH)/kfd_mqd_manager_vi.o \
+               $(AMDKFD_PATH)/kfd_mqd_manager_v9.o \
+               $(AMDKFD_PATH)/kfd_kernel_queue.o \
+               $(AMDKFD_PATH)/kfd_kernel_queue_cik.o \
+               $(AMDKFD_PATH)/kfd_kernel_queue_vi.o \
+               $(AMDKFD_PATH)/kfd_kernel_queue_v9.o \
+               $(AMDKFD_PATH)/kfd_packet_manager.o \
+               $(AMDKFD_PATH)/kfd_process_queue_manager.o \
+               $(AMDKFD_PATH)/kfd_device_queue_manager.o \
+               $(AMDKFD_PATH)/kfd_device_queue_manager_cik.o \
+               $(AMDKFD_PATH)/kfd_device_queue_manager_vi.o \
+               $(AMDKFD_PATH)/kfd_device_queue_manager_v9.o \
+               $(AMDKFD_PATH)/kfd_interrupt.o \
+               $(AMDKFD_PATH)/kfd_events.o \
+               $(AMDKFD_PATH)/cik_event_interrupt.o \
+               $(AMDKFD_PATH)/kfd_int_process_v9.o \
+               $(AMDKFD_PATH)/kfd_dbgdev.o \
+               $(AMDKFD_PATH)/kfd_dbgmgr.o \
+               $(AMDKFD_PATH)/kfd_crat.o
 
 ifneq ($(CONFIG_AMD_IOMMU_V2),)
-amdkfd-y += kfd_iommu.o
+AMDKFD_FILES += $(AMDKFD_PATH)/kfd_iommu.o
 endif
 
-amdkfd-$(CONFIG_DEBUG_FS) += kfd_debugfs.o
-
-obj-$(CONFIG_HSA_AMD)  += amdkfd.o
+ifneq ($(CONFIG_DEBUG_FS),)
+AMDKFD_FILES += $(AMDKFD_PATH)/kfd_debugfs.o
+endif
index 6e1f5c7c2d4be6131d1ed38cb18b38d59dc3383c..b445674bba9ae282b980d422924476e0810aee12 100644 (file)
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#include <linux/module.h>
 #include <linux/sched.h>
 #include <linux/moduleparam.h>
 #include <linux/device.h>
-#include <linux/printk.h>
 #include "kfd_priv.h"
 
-#define KFD_DRIVER_AUTHOR      "AMD Inc. and others"
-
-#define KFD_DRIVER_DESC                "Standalone HSA driver for AMD's GPUs"
-#define KFD_DRIVER_DATE                "20150421"
-#define KFD_DRIVER_MAJOR       0
-#define KFD_DRIVER_MINOR       7
-#define KFD_DRIVER_PATCHLEVEL  2
-
 static const struct kgd2kfd_calls kgd2kfd = {
        .exit           = kgd2kfd_exit,
        .probe          = kgd2kfd_probe,
@@ -95,33 +85,7 @@ module_param(halt_if_hws_hang, int, 0644);
 MODULE_PARM_DESC(halt_if_hws_hang, "Halt if HWS hang is detected (0 = off (default), 1 = on)");
 
 
-static int amdkfd_init_completed;
-
-
-int kgd2kfd_init(unsigned int interface_version,
-               const struct kgd2kfd_calls **g2f)
-{
-       if (!amdkfd_init_completed)
-               return -EPROBE_DEFER;
-
-       /*
-        * Only one interface version is supported,
-        * no kfd/kgd version skew allowed.
-        */
-       if (interface_version != KFD_INTERFACE_VERSION)
-               return -EINVAL;
-
-       *g2f = &kgd2kfd;
-
-       return 0;
-}
-EXPORT_SYMBOL(kgd2kfd_init);
-
-void kgd2kfd_exit(void)
-{
-}
-
-static int __init kfd_module_init(void)
+static int kfd_init(void)
 {
        int err;
 
@@ -129,7 +93,7 @@ static int __init kfd_module_init(void)
        if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
                (sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
                pr_err("sched_policy has invalid value\n");
-               return -1;
+               return -EINVAL;
        }
 
        /* Verify module parameters */
@@ -137,7 +101,7 @@ static int __init kfd_module_init(void)
                (max_num_of_queues_per_device >
                        KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
                pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
-               return -1;
+               return -EINVAL;
        }
 
        err = kfd_chardev_init();
@@ -154,10 +118,6 @@ static int __init kfd_module_init(void)
 
        kfd_debugfs_init();
 
-       amdkfd_init_completed = 1;
-
-       dev_info(kfd_device, "Initialized module\n");
-
        return 0;
 
 err_create_wq:
@@ -168,23 +128,30 @@ err_ioctl:
        return err;
 }
 
-static void __exit kfd_module_exit(void)
+static void kfd_exit(void)
 {
-       amdkfd_init_completed = 0;
-
        kfd_debugfs_fini();
        kfd_process_destroy_wq();
        kfd_topology_shutdown();
        kfd_chardev_exit();
-       pr_info("amdkfd: Removed module\n");
 }
 
-module_init(kfd_module_init);
-module_exit(kfd_module_exit);
+int kgd2kfd_init(unsigned int interface_version,
+               const struct kgd2kfd_calls **g2f)
+{
+       int err;
+
+       err = kfd_init();
+       if (err)
+               return err;
 
-MODULE_AUTHOR(KFD_DRIVER_AUTHOR);
-MODULE_DESCRIPTION(KFD_DRIVER_DESC);
-MODULE_LICENSE("GPL and additional rights");
-MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "."
-              __stringify(KFD_DRIVER_MINOR) "."
-              __stringify(KFD_DRIVER_PATCHLEVEL));
+       *g2f = &kgd2kfd;
+
+       return 0;
+}
+EXPORT_SYMBOL(kgd2kfd_init);
+
+void kgd2kfd_exit(void)
+{
+       kfd_exit();
+}