1 // SPDX-License-Identifier: GPL-2.0 OR MIT
3 * Copyright 2014-2022 Advanced Micro Devices, Inc.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
24 #include <linux/sched.h>
25 #include <linux/device.h>
27 #include "amdgpu_amdkfd.h"
29 static int kfd_init(void)
33 /* Verify module parameters */
34 if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
35 (sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
36 pr_err("sched_policy has invalid value\n");
40 /* Verify module parameters */
41 if ((max_num_of_queues_per_device < 1) ||
42 (max_num_of_queues_per_device >
43 KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
44 pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
48 err = kfd_chardev_init();
52 err = kfd_topology_init();
56 err = kfd_process_create_wq();
60 /* Ignore the return value, so that we can continue
61 * to init the KFD, even if procfs isn't craated
70 kfd_topology_shutdown();
74 pr_err("KFD is disabled due to module initialization failure\n");
78 static void kfd_exit(void)
80 kfd_cleanup_processes();
82 kfd_process_destroy_wq();
83 kfd_procfs_shutdown();
84 kfd_topology_shutdown();
88 int kgd2kfd_init(void)
93 void kgd2kfd_exit(void)