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 | #ifndef KFD_PRIV_H_INCLUDED |
| 24 | #define KFD_PRIV_H_INCLUDED |
| 25 | |
| 26 | #include <linux/hashtable.h> |
| 27 | #include <linux/mmu_notifier.h> |
| 28 | #include <linux/mutex.h> |
| 29 | #include <linux/types.h> |
| 30 | #include <linux/atomic.h> |
| 31 | #include <linux/workqueue.h> |
| 32 | #include <linux/spinlock.h> |
| 33 | #include <kgd_kfd_interface.h> |
| 34 | |
Evgeny Pinchuk | 5b5c4e4 | 2014-07-16 21:22:32 +0300 | [diff] [blame^] | 35 | #define KFD_SYSFS_FILE_MODE 0444 |
| 36 | |
| 37 | /* GPU ID hash width in bits */ |
| 38 | #define KFD_GPU_ID_HASH_WIDTH 16 |
| 39 | |
| 40 | /* Macro for allocating structures */ |
| 41 | #define kfd_alloc_struct(ptr_to_struct) \ |
| 42 | ((typeof(ptr_to_struct)) kzalloc(sizeof(*ptr_to_struct), GFP_KERNEL)) |
| 43 | |
Oded Gabbay | 4a488a7 | 2014-07-16 21:08:55 +0300 | [diff] [blame] | 44 | struct kfd_device_info { |
| 45 | unsigned int max_pasid_bits; |
| 46 | size_t ih_ring_entry_size; |
| 47 | }; |
| 48 | |
| 49 | struct kfd_dev { |
| 50 | struct kgd_dev *kgd; |
| 51 | |
| 52 | const struct kfd_device_info *device_info; |
| 53 | struct pci_dev *pdev; |
| 54 | |
| 55 | unsigned int id; /* topology stub index */ |
| 56 | |
| 57 | struct kgd2kfd_shared_resources shared_resources; |
| 58 | |
| 59 | bool init_complete; |
| 60 | |
| 61 | }; |
| 62 | |
| 63 | /* KGD2KFD callbacks */ |
| 64 | void kgd2kfd_exit(void); |
| 65 | struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev); |
| 66 | bool kgd2kfd_device_init(struct kfd_dev *kfd, |
| 67 | const struct kgd2kfd_shared_resources *gpu_resources); |
| 68 | void kgd2kfd_device_exit(struct kfd_dev *kfd); |
| 69 | |
| 70 | extern const struct kfd2kgd_calls *kfd2kgd; |
| 71 | |
| 72 | /* Character device interface */ |
| 73 | int kfd_chardev_init(void); |
| 74 | void kfd_chardev_exit(void); |
| 75 | struct device *kfd_chardev(void); |
| 76 | |
| 77 | /* Process data */ |
| 78 | struct kfd_process { |
| 79 | }; |
| 80 | |
| 81 | extern struct device *kfd_device; |
| 82 | |
Evgeny Pinchuk | 5b5c4e4 | 2014-07-16 21:22:32 +0300 | [diff] [blame^] | 83 | /* Topology */ |
| 84 | int kfd_topology_init(void); |
| 85 | void kfd_topology_shutdown(void); |
| 86 | int kfd_topology_add_device(struct kfd_dev *gpu); |
| 87 | int kfd_topology_remove_device(struct kfd_dev *gpu); |
| 88 | struct kfd_dev *kfd_device_by_id(uint32_t gpu_id); |
| 89 | struct kfd_dev *kfd_device_by_pci_dev(const struct pci_dev *pdev); |
| 90 | struct kfd_dev *kfd_topology_enum_kfd_devices(uint8_t idx); |
| 91 | |
Oded Gabbay | 4a488a7 | 2014-07-16 21:08:55 +0300 | [diff] [blame] | 92 | /* Interrupts */ |
| 93 | void kgd2kfd_interrupt(struct kfd_dev *dev, const void *ih_ring_entry); |
| 94 | |
| 95 | /* Power Management */ |
| 96 | void kgd2kfd_suspend(struct kfd_dev *dev); |
| 97 | int kgd2kfd_resume(struct kfd_dev *dev); |
| 98 | |
| 99 | #endif |