0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include <linux/sched.h>
0025 #include <linux/device.h>
0026 #include "kfd_priv.h"
0027 #include "amdgpu_amdkfd.h"
0028
0029 static int kfd_init(void)
0030 {
0031 int err;
0032
0033
0034 if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
0035 (sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
0036 pr_err("sched_policy has invalid value\n");
0037 return -EINVAL;
0038 }
0039
0040
0041 if ((max_num_of_queues_per_device < 1) ||
0042 (max_num_of_queues_per_device >
0043 KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
0044 pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
0045 return -EINVAL;
0046 }
0047
0048 err = kfd_chardev_init();
0049 if (err < 0)
0050 goto err_ioctl;
0051
0052 err = kfd_topology_init();
0053 if (err < 0)
0054 goto err_topology;
0055
0056 err = kfd_process_create_wq();
0057 if (err < 0)
0058 goto err_create_wq;
0059
0060
0061
0062
0063 kfd_procfs_init();
0064
0065 kfd_debugfs_init();
0066
0067 return 0;
0068
0069 err_create_wq:
0070 kfd_topology_shutdown();
0071 err_topology:
0072 kfd_chardev_exit();
0073 err_ioctl:
0074 pr_err("KFD is disabled due to module initialization failure\n");
0075 return err;
0076 }
0077
0078 static void kfd_exit(void)
0079 {
0080 kfd_debugfs_fini();
0081 kfd_process_destroy_wq();
0082 kfd_procfs_shutdown();
0083 kfd_topology_shutdown();
0084 kfd_chardev_exit();
0085 }
0086
0087 int kgd2kfd_init(void)
0088 {
0089 return kfd_init();
0090 }
0091
0092 void kgd2kfd_exit(void)
0093 {
0094 kfd_exit();
0095 }