diff options
| author | Dave Airlie <airlied@redhat.com> | 2014-11-19 23:32:32 -0500 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2014-11-19 23:32:32 -0500 |
| commit | cc5ac1ca79b4976ed3a779d7ea157f078207b56b (patch) | |
| tree | d377a52ab17c0a7c2403c23aa862f0c0e4432ed7 /include | |
| parent | 8975626ea35adcca561f8a81dedccfbc5dd8ec72 (diff) | |
| parent | ecd5c9821c39626fa7c03e9c397586b24cb11b79 (diff) | |
Merge branch 'amdkfd-v6' of git://people.freedesktop.org/~gabbayo/linux into drm-next
Merge AMDKFD it seems clean enough.
* 'amdkfd-v6' of git://people.freedesktop.org/~gabbayo/linux: (29 commits)
amdkfd: Implement the Get Version IOCTL
amdkfd: Implement the Get Process Aperture IOCTL
amdkfd: Implement the Get Clock Counters IOCTL
amdkfd: Implement the Set Memory Policy IOCTL
amdkfd: Implement the create/destroy/update queue IOCTLs
amdkfd: Add interrupt handling module
amdkfd: Add device queue manager module
amdkfd: Add process queue manager module
amdkfd: Add packet manager module
amdkfd: Add module parameter of scheduling policy
amdkfd: Add kernel queue module
amdkfd: Add mqd_manager module
amdkfd: Add queue module
amdkfd: Add binding/unbinding calls to amd_iommu driver
amdkfd: Add basic modules to amdkfd
amdkfd: Add topology module to amdkfd
amdkfd: Add amdkfd skeleton driver
amdkfd: Add IOCTL set definitions of amdkfd
Update MAINTAINERS and CREDITS files with amdkfd info
drm/radeon: Add radeon <--> amdkfd interface
...
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/mmu_notifier.h | 88 | ||||
| -rw-r--r-- | include/uapi/linux/kfd_ioctl.h | 154 |
2 files changed, 237 insertions, 5 deletions
diff --git a/include/linux/mmu_notifier.h b/include/linux/mmu_notifier.h index 88787bb4b3b9..94d19f64cecf 100644 --- a/include/linux/mmu_notifier.h +++ b/include/linux/mmu_notifier.h | |||
| @@ -98,11 +98,11 @@ struct mmu_notifier_ops { | |||
| 98 | /* | 98 | /* |
| 99 | * invalidate_range_start() and invalidate_range_end() must be | 99 | * invalidate_range_start() and invalidate_range_end() must be |
| 100 | * paired and are called only when the mmap_sem and/or the | 100 | * paired and are called only when the mmap_sem and/or the |
| 101 | * locks protecting the reverse maps are held. The subsystem | 101 | * locks protecting the reverse maps are held. If the subsystem |
| 102 | * must guarantee that no additional references are taken to | 102 | * can't guarantee that no additional references are taken to |
| 103 | * the pages in the range established between the call to | 103 | * the pages in the range, it has to implement the |
| 104 | * invalidate_range_start() and the matching call to | 104 | * invalidate_range() notifier to remove any references taken |
| 105 | * invalidate_range_end(). | 105 | * after invalidate_range_start(). |
| 106 | * | 106 | * |
| 107 | * Invalidation of multiple concurrent ranges may be | 107 | * Invalidation of multiple concurrent ranges may be |
| 108 | * optionally permitted by the driver. Either way the | 108 | * optionally permitted by the driver. Either way the |
| @@ -144,6 +144,29 @@ struct mmu_notifier_ops { | |||
| 144 | void (*invalidate_range_end)(struct mmu_notifier *mn, | 144 | void (*invalidate_range_end)(struct mmu_notifier *mn, |
| 145 | struct mm_struct *mm, | 145 | struct mm_struct *mm, |
| 146 | unsigned long start, unsigned long end); | 146 | unsigned long start, unsigned long end); |
| 147 | |||
| 148 | /* | ||
| 149 | * invalidate_range() is either called between | ||
| 150 | * invalidate_range_start() and invalidate_range_end() when the | ||
| 151 | * VM has to free pages that where unmapped, but before the | ||
| 152 | * pages are actually freed, or outside of _start()/_end() when | ||
| 153 | * a (remote) TLB is necessary. | ||
| 154 | * | ||
| 155 | * If invalidate_range() is used to manage a non-CPU TLB with | ||
| 156 | * shared page-tables, it not necessary to implement the | ||
| 157 | * invalidate_range_start()/end() notifiers, as | ||
| 158 | * invalidate_range() alread catches the points in time when an | ||
| 159 | * external TLB range needs to be flushed. | ||
| 160 | * | ||
| 161 | * The invalidate_range() function is called under the ptl | ||
| 162 | * spin-lock and not allowed to sleep. | ||
| 163 | * | ||
| 164 | * Note that this function might be called with just a sub-range | ||
| 165 | * of what was passed to invalidate_range_start()/end(), if | ||
| 166 | * called between those functions. | ||
| 167 | */ | ||
| 168 | void (*invalidate_range)(struct mmu_notifier *mn, struct mm_struct *mm, | ||
| 169 | unsigned long start, unsigned long end); | ||
| 147 | }; | 170 | }; |
| 148 | 171 | ||
| 149 | /* | 172 | /* |
| @@ -190,6 +213,8 @@ extern void __mmu_notifier_invalidate_range_start(struct mm_struct *mm, | |||
| 190 | unsigned long start, unsigned long end); | 213 | unsigned long start, unsigned long end); |
| 191 | extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm, | 214 | extern void __mmu_notifier_invalidate_range_end(struct mm_struct *mm, |
| 192 | unsigned long start, unsigned long end); | 215 | unsigned long start, unsigned long end); |
| 216 | extern void __mmu_notifier_invalidate_range(struct mm_struct *mm, | ||
| 217 | unsigned long start, unsigned long end); | ||
| 193 | 218 | ||
| 194 | static inline void mmu_notifier_release(struct mm_struct *mm) | 219 | static inline void mmu_notifier_release(struct mm_struct *mm) |
| 195 | { | 220 | { |
| @@ -242,6 +267,13 @@ static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm, | |||
| 242 | __mmu_notifier_invalidate_range_end(mm, start, end); | 267 | __mmu_notifier_invalidate_range_end(mm, start, end); |
| 243 | } | 268 | } |
| 244 | 269 | ||
| 270 | static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, | ||
| 271 | unsigned long start, unsigned long end) | ||
| 272 | { | ||
| 273 | if (mm_has_notifiers(mm)) | ||
| 274 | __mmu_notifier_invalidate_range(mm, start, end); | ||
| 275 | } | ||
| 276 | |||
| 245 | static inline void mmu_notifier_mm_init(struct mm_struct *mm) | 277 | static inline void mmu_notifier_mm_init(struct mm_struct *mm) |
| 246 | { | 278 | { |
| 247 | mm->mmu_notifier_mm = NULL; | 279 | mm->mmu_notifier_mm = NULL; |
| @@ -279,6 +311,44 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) | |||
| 279 | __young; \ | 311 | __young; \ |
| 280 | }) | 312 | }) |
| 281 | 313 | ||
| 314 | #define ptep_clear_flush_notify(__vma, __address, __ptep) \ | ||
| 315 | ({ \ | ||
| 316 | unsigned long ___addr = __address & PAGE_MASK; \ | ||
| 317 | struct mm_struct *___mm = (__vma)->vm_mm; \ | ||
| 318 | pte_t ___pte; \ | ||
| 319 | \ | ||
| 320 | ___pte = ptep_clear_flush(__vma, __address, __ptep); \ | ||
| 321 | mmu_notifier_invalidate_range(___mm, ___addr, \ | ||
| 322 | ___addr + PAGE_SIZE); \ | ||
| 323 | \ | ||
| 324 | ___pte; \ | ||
| 325 | }) | ||
| 326 | |||
| 327 | #define pmdp_clear_flush_notify(__vma, __haddr, __pmd) \ | ||
| 328 | ({ \ | ||
| 329 | unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \ | ||
| 330 | struct mm_struct *___mm = (__vma)->vm_mm; \ | ||
| 331 | pmd_t ___pmd; \ | ||
| 332 | \ | ||
| 333 | ___pmd = pmdp_clear_flush(__vma, __haddr, __pmd); \ | ||
| 334 | mmu_notifier_invalidate_range(___mm, ___haddr, \ | ||
| 335 | ___haddr + HPAGE_PMD_SIZE); \ | ||
| 336 | \ | ||
| 337 | ___pmd; \ | ||
| 338 | }) | ||
| 339 | |||
| 340 | #define pmdp_get_and_clear_notify(__mm, __haddr, __pmd) \ | ||
| 341 | ({ \ | ||
| 342 | unsigned long ___haddr = __haddr & HPAGE_PMD_MASK; \ | ||
| 343 | pmd_t ___pmd; \ | ||
| 344 | \ | ||
| 345 | ___pmd = pmdp_get_and_clear(__mm, __haddr, __pmd); \ | ||
| 346 | mmu_notifier_invalidate_range(__mm, ___haddr, \ | ||
| 347 | ___haddr + HPAGE_PMD_SIZE); \ | ||
| 348 | \ | ||
| 349 | ___pmd; \ | ||
| 350 | }) | ||
| 351 | |||
| 282 | /* | 352 | /* |
| 283 | * set_pte_at_notify() sets the pte _after_ running the notifier. | 353 | * set_pte_at_notify() sets the pte _after_ running the notifier. |
| 284 | * This is safe to start by updating the secondary MMUs, because the primary MMU | 354 | * This is safe to start by updating the secondary MMUs, because the primary MMU |
| @@ -342,6 +412,11 @@ static inline void mmu_notifier_invalidate_range_end(struct mm_struct *mm, | |||
| 342 | { | 412 | { |
| 343 | } | 413 | } |
| 344 | 414 | ||
| 415 | static inline void mmu_notifier_invalidate_range(struct mm_struct *mm, | ||
| 416 | unsigned long start, unsigned long end) | ||
| 417 | { | ||
| 418 | } | ||
| 419 | |||
| 345 | static inline void mmu_notifier_mm_init(struct mm_struct *mm) | 420 | static inline void mmu_notifier_mm_init(struct mm_struct *mm) |
| 346 | { | 421 | { |
| 347 | } | 422 | } |
| @@ -352,6 +427,9 @@ static inline void mmu_notifier_mm_destroy(struct mm_struct *mm) | |||
| 352 | 427 | ||
| 353 | #define ptep_clear_flush_young_notify ptep_clear_flush_young | 428 | #define ptep_clear_flush_young_notify ptep_clear_flush_young |
| 354 | #define pmdp_clear_flush_young_notify pmdp_clear_flush_young | 429 | #define pmdp_clear_flush_young_notify pmdp_clear_flush_young |
| 430 | #define ptep_clear_flush_notify ptep_clear_flush | ||
| 431 | #define pmdp_clear_flush_notify pmdp_clear_flush | ||
| 432 | #define pmdp_get_and_clear_notify pmdp_get_and_clear | ||
| 355 | #define set_pte_at_notify set_pte_at | 433 | #define set_pte_at_notify set_pte_at |
| 356 | 434 | ||
| 357 | #endif /* CONFIG_MMU_NOTIFIER */ | 435 | #endif /* CONFIG_MMU_NOTIFIER */ |
diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h new file mode 100644 index 000000000000..7acef41fc209 --- /dev/null +++ b/include/uapi/linux/kfd_ioctl.h | |||
| @@ -0,0 +1,154 @@ | |||
| 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_IOCTL_H_INCLUDED | ||
| 24 | #define KFD_IOCTL_H_INCLUDED | ||
| 25 | |||
| 26 | #include <linux/types.h> | ||
| 27 | #include <linux/ioctl.h> | ||
| 28 | |||
| 29 | #define KFD_IOCTL_MAJOR_VERSION 1 | ||
| 30 | #define KFD_IOCTL_MINOR_VERSION 0 | ||
| 31 | |||
| 32 | struct kfd_ioctl_get_version_args { | ||
| 33 | uint32_t major_version; /* from KFD */ | ||
| 34 | uint32_t minor_version; /* from KFD */ | ||
| 35 | }; | ||
| 36 | |||
| 37 | /* For kfd_ioctl_create_queue_args.queue_type. */ | ||
| 38 | #define KFD_IOC_QUEUE_TYPE_COMPUTE 0 | ||
| 39 | #define KFD_IOC_QUEUE_TYPE_SDMA 1 | ||
| 40 | #define KFD_IOC_QUEUE_TYPE_COMPUTE_AQL 2 | ||
| 41 | |||
| 42 | #define KFD_MAX_QUEUE_PERCENTAGE 100 | ||
| 43 | #define KFD_MAX_QUEUE_PRIORITY 15 | ||
| 44 | |||
| 45 | struct kfd_ioctl_create_queue_args { | ||
| 46 | uint64_t ring_base_address; /* to KFD */ | ||
| 47 | uint64_t write_pointer_address; /* from KFD */ | ||
| 48 | uint64_t read_pointer_address; /* from KFD */ | ||
| 49 | uint64_t doorbell_offset; /* from KFD */ | ||
| 50 | |||
| 51 | uint32_t ring_size; /* to KFD */ | ||
| 52 | uint32_t gpu_id; /* to KFD */ | ||
| 53 | uint32_t queue_type; /* to KFD */ | ||
| 54 | uint32_t queue_percentage; /* to KFD */ | ||
| 55 | uint32_t queue_priority; /* to KFD */ | ||
| 56 | uint32_t queue_id; /* from KFD */ | ||
| 57 | |||
| 58 | uint64_t eop_buffer_address; /* to KFD */ | ||
| 59 | uint64_t eop_buffer_size; /* to KFD */ | ||
| 60 | uint64_t ctx_save_restore_address; /* to KFD */ | ||
| 61 | uint64_t ctx_save_restore_size; /* to KFD */ | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct kfd_ioctl_destroy_queue_args { | ||
| 65 | uint32_t queue_id; /* to KFD */ | ||
| 66 | uint32_t pad; | ||
| 67 | }; | ||
| 68 | |||
| 69 | struct kfd_ioctl_update_queue_args { | ||
| 70 | uint64_t ring_base_address; /* to KFD */ | ||
| 71 | |||
| 72 | uint32_t queue_id; /* to KFD */ | ||
| 73 | uint32_t ring_size; /* to KFD */ | ||
| 74 | uint32_t queue_percentage; /* to KFD */ | ||
| 75 | uint32_t queue_priority; /* to KFD */ | ||
| 76 | }; | ||
| 77 | |||
| 78 | /* For kfd_ioctl_set_memory_policy_args.default_policy and alternate_policy */ | ||
| 79 | #define KFD_IOC_CACHE_POLICY_COHERENT 0 | ||
| 80 | #define KFD_IOC_CACHE_POLICY_NONCOHERENT 1 | ||
| 81 | |||
| 82 | struct kfd_ioctl_set_memory_policy_args { | ||
| 83 | uint64_t alternate_aperture_base; /* to KFD */ | ||
| 84 | uint64_t alternate_aperture_size; /* to KFD */ | ||
| 85 | |||
| 86 | uint32_t gpu_id; /* to KFD */ | ||
| 87 | uint32_t default_policy; /* to KFD */ | ||
| 88 | uint32_t alternate_policy; /* to KFD */ | ||
| 89 | uint32_t pad; | ||
| 90 | }; | ||
| 91 | |||
| 92 | /* | ||
| 93 | * All counters are monotonic. They are used for profiling of compute jobs. | ||
| 94 | * The profiling is done by userspace. | ||
| 95 | * | ||
| 96 | * In case of GPU reset, the counter should not be affected. | ||
| 97 | */ | ||
| 98 | |||
| 99 | struct kfd_ioctl_get_clock_counters_args { | ||
| 100 | uint64_t gpu_clock_counter; /* from KFD */ | ||
| 101 | uint64_t cpu_clock_counter; /* from KFD */ | ||
| 102 | uint64_t system_clock_counter; /* from KFD */ | ||
| 103 | uint64_t system_clock_freq; /* from KFD */ | ||
| 104 | |||
| 105 | uint32_t gpu_id; /* to KFD */ | ||
| 106 | uint32_t pad; | ||
| 107 | }; | ||
| 108 | |||
| 109 | #define NUM_OF_SUPPORTED_GPUS 7 | ||
| 110 | |||
| 111 | struct kfd_process_device_apertures { | ||
| 112 | uint64_t lds_base; /* from KFD */ | ||
| 113 | uint64_t lds_limit; /* from KFD */ | ||
| 114 | uint64_t scratch_base; /* from KFD */ | ||
| 115 | uint64_t scratch_limit; /* from KFD */ | ||
| 116 | uint64_t gpuvm_base; /* from KFD */ | ||
| 117 | uint64_t gpuvm_limit; /* from KFD */ | ||
| 118 | uint32_t gpu_id; /* from KFD */ | ||
| 119 | uint32_t pad; | ||
| 120 | }; | ||
| 121 | |||
| 122 | struct kfd_ioctl_get_process_apertures_args { | ||
| 123 | struct kfd_process_device_apertures | ||
| 124 | process_apertures[NUM_OF_SUPPORTED_GPUS];/* from KFD */ | ||
| 125 | |||
| 126 | /* from KFD, should be in the range [1 - NUM_OF_SUPPORTED_GPUS] */ | ||
| 127 | uint32_t num_of_nodes; | ||
| 128 | uint32_t pad; | ||
| 129 | }; | ||
| 130 | |||
| 131 | #define KFD_IOC_MAGIC 'K' | ||
| 132 | |||
| 133 | #define KFD_IOC_GET_VERSION \ | ||
| 134 | _IOR(KFD_IOC_MAGIC, 1, struct kfd_ioctl_get_version_args) | ||
| 135 | |||
| 136 | #define KFD_IOC_CREATE_QUEUE \ | ||
| 137 | _IOWR(KFD_IOC_MAGIC, 2, struct kfd_ioctl_create_queue_args) | ||
| 138 | |||
| 139 | #define KFD_IOC_DESTROY_QUEUE \ | ||
| 140 | _IOWR(KFD_IOC_MAGIC, 3, struct kfd_ioctl_destroy_queue_args) | ||
| 141 | |||
| 142 | #define KFD_IOC_SET_MEMORY_POLICY \ | ||
| 143 | _IOW(KFD_IOC_MAGIC, 4, struct kfd_ioctl_set_memory_policy_args) | ||
| 144 | |||
| 145 | #define KFD_IOC_GET_CLOCK_COUNTERS \ | ||
| 146 | _IOWR(KFD_IOC_MAGIC, 5, struct kfd_ioctl_get_clock_counters_args) | ||
| 147 | |||
| 148 | #define KFD_IOC_GET_PROCESS_APERTURES \ | ||
| 149 | _IOR(KFD_IOC_MAGIC, 6, struct kfd_ioctl_get_process_apertures_args) | ||
| 150 | |||
| 151 | #define KFD_IOC_UPDATE_QUEUE \ | ||
| 152 | _IOW(KFD_IOC_MAGIC, 7, struct kfd_ioctl_update_queue_args) | ||
| 153 | |||
| 154 | #endif | ||
