Merge tag 'seccomp-4.5-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
[deliverable/linux.git] / drivers / gpu / drm / amd / amdkfd / kfd_module.c
CommitLineData
4a488a7a
OG
1/*
2 * Copyright 2014 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * 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 OR
20 * OTHER DEALINGS IN THE SOFTWARE.
21 */
22
23#include <linux/module.h>
24#include <linux/sched.h>
4a488a7a
OG
25#include <linux/moduleparam.h>
26#include <linux/device.h>
27#include "kfd_priv.h"
28
29#define KFD_DRIVER_AUTHOR "AMD Inc. and others"
30
31#define KFD_DRIVER_DESC "Standalone HSA driver for AMD's GPUs"
7591cd2c 32#define KFD_DRIVER_DATE "20150421"
4a488a7a
OG
33#define KFD_DRIVER_MAJOR 0
34#define KFD_DRIVER_MINOR 7
7591cd2c 35#define KFD_DRIVER_PATCHLEVEL 2
4a488a7a 36
4a488a7a
OG
37static const struct kgd2kfd_calls kgd2kfd = {
38 .exit = kgd2kfd_exit,
39 .probe = kgd2kfd_probe,
40 .device_init = kgd2kfd_device_init,
41 .device_exit = kgd2kfd_device_exit,
42 .interrupt = kgd2kfd_interrupt,
43 .suspend = kgd2kfd_suspend,
44 .resume = kgd2kfd_resume,
45};
46
31c21fec
BG
47int sched_policy = KFD_SCHED_POLICY_HWS;
48module_param(sched_policy, int, 0444);
49MODULE_PARM_DESC(sched_policy,
cb2ac441 50 "Scheduling policy (0 = HWS (Default), 1 = HWS without over-subscription, 2 = Non-HWS (Used for debugging only)");
31c21fec 51
b8cbab04
OG
52int max_num_of_queues_per_device = KFD_MAX_NUM_OF_QUEUES_PER_DEVICE_DEFAULT;
53module_param(max_num_of_queues_per_device, int, 0444);
54MODULE_PARM_DESC(max_num_of_queues_per_device,
55 "Maximum number of supported queues per device (1 = Minimum, 4096 = default)");
19f6d2a6 56
81663016
OG
57int send_sigterm;
58module_param(send_sigterm, int, 0444);
59MODULE_PARM_DESC(send_sigterm,
60 "Send sigterm to HSA process on unhandled exception (0 = disable, 1 = enable)");
61
cea405b1 62bool kgd2kfd_init(unsigned interface_version, const struct kgd2kfd_calls **g2f)
4a488a7a
OG
63{
64 /*
65 * Only one interface version is supported,
66 * no kfd/kgd version skew allowed.
67 */
68 if (interface_version != KFD_INTERFACE_VERSION)
69 return false;
70
4a488a7a
OG
71 *g2f = &kgd2kfd;
72
73 return true;
74}
75EXPORT_SYMBOL(kgd2kfd_init);
76
77void kgd2kfd_exit(void)
78{
79}
80
81static int __init kfd_module_init(void)
82{
83 int err;
84
31c21fec
BG
85 /* Verify module parameters */
86 if ((sched_policy < KFD_SCHED_POLICY_HWS) ||
87 (sched_policy > KFD_SCHED_POLICY_NO_HWS)) {
88 pr_err("kfd: sched_policy has invalid value\n");
89 return -1;
90 }
91
19f6d2a6 92 /* Verify module parameters */
ca400b2a 93 if ((max_num_of_queues_per_device < 1) ||
b8cbab04
OG
94 (max_num_of_queues_per_device >
95 KFD_MAX_NUM_OF_QUEUES_PER_DEVICE)) {
ca400b2a 96 pr_err("kfd: max_num_of_queues_per_device must be between 1 to KFD_MAX_NUM_OF_QUEUES_PER_DEVICE\n");
19f6d2a6
OG
97 return -1;
98 }
99
100 err = kfd_pasid_init();
101 if (err < 0)
102 goto err_pasid;
103
4a488a7a
OG
104 err = kfd_chardev_init();
105 if (err < 0)
106 goto err_ioctl;
107
5b5c4e40
EP
108 err = kfd_topology_init();
109 if (err < 0)
110 goto err_topology;
111
19f6d2a6
OG
112 kfd_process_create_wq();
113
4a488a7a
OG
114 dev_info(kfd_device, "Initialized module\n");
115
116 return 0;
117
5b5c4e40
EP
118err_topology:
119 kfd_chardev_exit();
4a488a7a 120err_ioctl:
19f6d2a6
OG
121 kfd_pasid_exit();
122err_pasid:
4a488a7a
OG
123 return err;
124}
125
126static void __exit kfd_module_exit(void)
127{
19f6d2a6 128 kfd_process_destroy_wq();
5b5c4e40 129 kfd_topology_shutdown();
4a488a7a 130 kfd_chardev_exit();
19f6d2a6 131 kfd_pasid_exit();
4a488a7a
OG
132 dev_info(kfd_device, "Removed module\n");
133}
134
135module_init(kfd_module_init);
136module_exit(kfd_module_exit);
137
138MODULE_AUTHOR(KFD_DRIVER_AUTHOR);
139MODULE_DESCRIPTION(KFD_DRIVER_DESC);
140MODULE_LICENSE("GPL and additional rights");
141MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "."
142 __stringify(KFD_DRIVER_MINOR) "."
143 __stringify(KFD_DRIVER_PATCHLEVEL));
This page took 0.089618 seconds and 5 git commands to generate.