Oded Gabbay | 4a488a7 | 2014-07-16 21:08:55 +0300 | [diff] [blame] | 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> |
| 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 | |
| 38 | const struct kfd2kgd_calls *kfd2kgd; |
| 39 | static 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 | |
| 49 | bool 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 | } |
| 65 | EXPORT_SYMBOL(kgd2kfd_init); |
| 66 | |
| 67 | void kgd2kfd_exit(void) |
| 68 | { |
| 69 | } |
| 70 | |
| 71 | static 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 Pinchuk | 5b5c4e4 | 2014-07-16 21:22:32 +0300 | [diff] [blame^] | 79 | err = kfd_topology_init(); |
| 80 | if (err < 0) |
| 81 | goto err_topology; |
| 82 | |
Oded Gabbay | 4a488a7 | 2014-07-16 21:08:55 +0300 | [diff] [blame] | 83 | dev_info(kfd_device, "Initialized module\n"); |
| 84 | |
| 85 | return 0; |
| 86 | |
Evgeny Pinchuk | 5b5c4e4 | 2014-07-16 21:22:32 +0300 | [diff] [blame^] | 87 | err_topology: |
| 88 | kfd_chardev_exit(); |
Oded Gabbay | 4a488a7 | 2014-07-16 21:08:55 +0300 | [diff] [blame] | 89 | err_ioctl: |
| 90 | return err; |
| 91 | } |
| 92 | |
| 93 | static void __exit kfd_module_exit(void) |
| 94 | { |
Evgeny Pinchuk | 5b5c4e4 | 2014-07-16 21:22:32 +0300 | [diff] [blame^] | 95 | kfd_topology_shutdown(); |
Oded Gabbay | 4a488a7 | 2014-07-16 21:08:55 +0300 | [diff] [blame] | 96 | kfd_chardev_exit(); |
| 97 | dev_info(kfd_device, "Removed module\n"); |
| 98 | } |
| 99 | |
| 100 | module_init(kfd_module_init); |
| 101 | module_exit(kfd_module_exit); |
| 102 | |
| 103 | MODULE_AUTHOR(KFD_DRIVER_AUTHOR); |
| 104 | MODULE_DESCRIPTION(KFD_DRIVER_DESC); |
| 105 | MODULE_LICENSE("GPL and additional rights"); |
| 106 | MODULE_VERSION(__stringify(KFD_DRIVER_MAJOR) "." |
| 107 | __stringify(KFD_DRIVER_MINOR) "." |
| 108 | __stringify(KFD_DRIVER_PATCHLEVEL)); |