blob: 45654be039ff22209c7e51b5409f817b10d9a38a [file] [log] [blame]
Oded Gabbay4a488a72014-07-16 21:08:55 +03001/*
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>
25#include <linux/notifier.h>
26#include <linux/moduleparam.h>
27#include <linux/device.h>
28#include "kfd_priv.h"
29
30#define KFD_DRIVER_AUTHOR "AMD Inc. and others"
31
32#define KFD_DRIVER_DESC "Standalone HSA driver for AMD's GPUs"
33#define KFD_DRIVER_DATE "20141113"
34#define KFD_DRIVER_MAJOR 0
35#define KFD_DRIVER_MINOR 7
36#define KFD_DRIVER_PATCHLEVEL 0
37
38const struct kfd2kgd_calls *kfd2kgd;
39static const struct kgd2kfd_calls kgd2kfd = {
40 .exit = kgd2kfd_exit,
41 .probe = kgd2kfd_probe,
42 .device_init = kgd2kfd_device_init,
43 .device_exit = kgd2kfd_device_exit,
44 .interrupt = kgd2kfd_interrupt,
45 .suspend = kgd2kfd_suspend,
46 .resume = kgd2kfd_resume,
47};
48
49bool kgd2kfd_init(unsigned interface_version,
50 const struct kfd2kgd_calls *f2g,
51 const struct kgd2kfd_calls **g2f)
52{
53 /*
54 * Only one interface version is supported,
55 * no kfd/kgd version skew allowed.
56 */
57 if (interface_version != KFD_INTERFACE_VERSION)
58 return false;
59
60 kfd2kgd = f2g;
61 *g2f = &kgd2kfd;
62
63 return true;
64}
65EXPORT_SYMBOL(kgd2kfd_init);
66
67void kgd2kfd_exit(void)
68{
69}
70
71static int __init kfd_module_init(void)
72{
73 int err;
74
75 err = kfd_chardev_init();
76 if (err < 0)
77 goto err_ioctl;
78
Evgeny Pinchuk5b5c4e42014-07-16 21:22:32 +030079 err = kfd_topology_init();
80 if (err < 0)
81 goto err_topology;
82
Oded Gabbay4a488a72014-07-16 21:08:55 +030083 dev_info(kfd_device, "Initialized module\n");
84
85 return 0;
86
Evgeny Pinchuk5b5c4e42014-07-16 21:22:32 +030087err_topology:
88 kfd_chardev_exit();
Oded Gabbay4a488a72014-07-16 21:08:55 +030089err_ioctl:
90 return err;
91}
92
93static void __exit kfd_module_exit(void)
94{
Evgeny Pinchuk5b5c4e42014-07-16 21:22:32 +030095 kfd_topology_shutdown();
Oded Gabbay4a488a72014-07-16 21:08:55 +030096 kfd_chardev_exit();
97 dev_info(kfd_device, "Removed module\n");
98}
99
100module_init(kfd_module_init);
101module_exit(kfd_module_exit);
102
103MODULE_AUTHOR(KFD_DRIVER_AUTHOR);
104MODULE_DESCRIPTION(KFD_DRIVER_DESC);
105MODULE_LICENSE("GPL and additional rights");
106MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "."
107 __stringify(KFD_DRIVER_MINOR) "."
108 __stringify(KFD_DRIVER_PATCHLEVEL));