Path: blob/master/drivers/gpu/drm/amd/amdkfd/kfd_module.c
26516 views
// SPDX-License-Identifier: GPL-2.0 OR MIT1/*2* Copyright 2014-2022 Advanced Micro Devices, Inc.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* the rights to use, copy, modify, merge, publish, distribute, sublicense,8* and/or sell copies of the Software, and to permit persons to whom the9* Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR18* 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 OR20* OTHER DEALINGS IN THE SOFTWARE.21*/2223#include <linux/sched.h>24#include <linux/device.h>25#include "kfd_priv.h"26#include "amdgpu_amdkfd.h"2728static int kfd_init(void)29{30int err;3132/* Verify module parameters */33if ((sched_policy < KFD_SCHED_POLICY_HWS) ||34(sched_policy > KFD_SCHED_POLICY_NO_HWS)) {35pr_err("sched_policy has invalid value\n");36return -EINVAL;37}3839/* Verify module parameters */40if ((max_num_of_queues_per_device < 1) ||41(max_num_of_queues_per_device >42KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {43pr_err("max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");44return -EINVAL;45}4647err = kfd_chardev_init();48if (err < 0)49goto err_ioctl;5051err = kfd_topology_init();52if (err < 0)53goto err_topology;5455err = kfd_process_create_wq();56if (err < 0)57goto err_create_wq;5859/* Ignore the return value, so that we can continue60* to init the KFD, even if procfs isn't craated61*/62kfd_procfs_init();6364kfd_debugfs_init();6566return 0;6768err_create_wq:69kfd_topology_shutdown();70err_topology:71kfd_chardev_exit();72err_ioctl:73pr_err("KFD is disabled due to module initialization failure\n");74return err;75}7677static void kfd_exit(void)78{79kfd_cleanup_processes();80kfd_process_destroy_wq();81kfd_debugfs_fini();82kfd_procfs_shutdown();83kfd_topology_shutdown();84kfd_chardev_exit();85}8687int kgd2kfd_init(void)88{89return kfd_init();90}9192void kgd2kfd_exit(void)93{94kfd_exit();95}969798