| .. | .. |
|---|
| 22 | 22 | |
|---|
| 23 | 23 | #include <linux/types.h> |
|---|
| 24 | 24 | #include "kfd_priv.h" |
|---|
| 25 | +#include "amdgpu_ids.h" |
|---|
| 25 | 26 | |
|---|
| 26 | 27 | static unsigned int pasid_bits = 16; |
|---|
| 27 | | -static const struct kfd2kgd_calls *kfd2kgd; |
|---|
| 28 | +static bool pasids_allocated; /* = false */ |
|---|
| 28 | 29 | |
|---|
| 29 | 30 | bool kfd_set_pasid_limit(unsigned int new_limit) |
|---|
| 30 | 31 | { |
|---|
| .. | .. |
|---|
| 32 | 33 | return false; |
|---|
| 33 | 34 | |
|---|
| 34 | 35 | if (new_limit < (1U << pasid_bits)) { |
|---|
| 35 | | - if (kfd2kgd) |
|---|
| 36 | + if (pasids_allocated) |
|---|
| 36 | 37 | /* We've already allocated user PASIDs, too late to |
|---|
| 37 | 38 | * change the limit |
|---|
| 38 | 39 | */ |
|---|
| .. | .. |
|---|
| 50 | 51 | return 1U << pasid_bits; |
|---|
| 51 | 52 | } |
|---|
| 52 | 53 | |
|---|
| 53 | | -unsigned int kfd_pasid_alloc(void) |
|---|
| 54 | +u32 kfd_pasid_alloc(void) |
|---|
| 54 | 55 | { |
|---|
| 55 | | - int r; |
|---|
| 56 | + int r = amdgpu_pasid_alloc(pasid_bits); |
|---|
| 56 | 57 | |
|---|
| 57 | | - /* Find the first best KFD device for calling KGD */ |
|---|
| 58 | | - if (!kfd2kgd) { |
|---|
| 59 | | - struct kfd_dev *dev = NULL; |
|---|
| 60 | | - unsigned int i = 0; |
|---|
| 61 | | - |
|---|
| 62 | | - while ((kfd_topology_enum_kfd_devices(i, &dev)) == 0) { |
|---|
| 63 | | - if (dev && dev->kfd2kgd) { |
|---|
| 64 | | - kfd2kgd = dev->kfd2kgd; |
|---|
| 65 | | - break; |
|---|
| 66 | | - } |
|---|
| 67 | | - i++; |
|---|
| 68 | | - } |
|---|
| 69 | | - |
|---|
| 70 | | - if (!kfd2kgd) |
|---|
| 71 | | - return false; |
|---|
| 58 | + if (r > 0) { |
|---|
| 59 | + pasids_allocated = true; |
|---|
| 60 | + return r; |
|---|
| 72 | 61 | } |
|---|
| 73 | 62 | |
|---|
| 74 | | - r = kfd2kgd->alloc_pasid(pasid_bits); |
|---|
| 75 | | - |
|---|
| 76 | | - return r > 0 ? r : 0; |
|---|
| 63 | + return 0; |
|---|
| 77 | 64 | } |
|---|
| 78 | 65 | |
|---|
| 79 | | -void kfd_pasid_free(unsigned int pasid) |
|---|
| 66 | +void kfd_pasid_free(u32 pasid) |
|---|
| 80 | 67 | { |
|---|
| 81 | | - if (kfd2kgd) |
|---|
| 82 | | - kfd2kgd->free_pasid(pasid); |
|---|
| 68 | + amdgpu_pasid_free(pasid); |
|---|
| 83 | 69 | } |
|---|