@@ -842,6 +842,11 @@ struct kfd_process *kfd_create_process(struct file *filep);
struct kfd_process *kfd_get_process(const struct task_struct *);
struct kfd_process *kfd_lookup_process_by_pasid(u32 pasid);
struct kfd_process *kfd_lookup_process_by_mm(const struct mm_struct *mm);
+int kfd_process_gpuid_from_gpuidx(struct kfd_process *p,
+ uint32_t gpu_idx, uint32_t *gpuid);
+int kfd_process_gpuidx_from_gpuid(struct kfd_process *p, uint32_t gpu_id);
+int kfd_process_device_from_gpuidx(struct kfd_process *p,
+ uint32_t gpu_idx, struct kfd_dev **gpu);
void kfd_unref_process(struct kfd_process *p);
int kfd_process_evict_queues(struct kfd_process *p);
int kfd_process_restore_queues(struct kfd_process *p);
@@ -1607,6 +1607,36 @@ int kfd_process_restore_queues(struct kfd_process *p)
return ret;
}
+int kfd_process_gpuid_from_gpuidx(struct kfd_process *p,
+ uint32_t gpu_idx, uint32_t *gpuid)
+{
+ if (gpu_idx < p->n_pdds) {
+ *gpuid = p->pdds[gpu_idx]->dev->id;
+ return 0;
+ }
+ return -EINVAL;
+}
+
+int kfd_process_gpuidx_from_gpuid(struct kfd_process *p, uint32_t gpu_id)
+{
+ int i;
+
+ for (i = 0; i < p->n_pdds; i++)
+ if (p->pdds[i] && gpu_id == p->pdds[i]->dev->id)
+ return i;
+ return -EINVAL;
+}
+
+int kfd_process_device_from_gpuidx(struct kfd_process *p,
+ uint32_t gpu_idx, struct kfd_dev **gpu)
+{
+ if (gpu_idx < p->n_pdds) {
+ *gpu = p->pdds[gpu_idx]->dev;
+ return 0;
+ }
+ return -EINVAL;
+}
+
static void evict_process_worker(struct work_struct *work)
{
int ret;