From 8c398abee7bbece2a44d3c1a45ac3f3eb3c5e3b3 Mon Sep 17 00:00:00 2001 From: Yong Zhao Date: Tue, 2 Jan 2018 14:55:08 -0500 Subject: [PATCH 3051/4131] drm/amdkfd: Simplify tlb invalidation for non-HWS case For non-HWS case, we can not use KIQ to invalidate tlbs. Because we already know the vmid that is associated with pasid on each device, we do not need to get VMID through querying pasid. Change-Id: I02fc13b0703dfc099a20f372adbf06152d967189 Signed-off-by: Yong Zhao --- drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 6 +++--- drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c | 7 ------- drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 3 ++- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 17 +++++++++++++++++ 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c index aba0291..afc4ce2 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c @@ -1374,10 +1374,10 @@ static int kfd_ioctl_map_memory_to_gpu(struct file *filep, peer = kfd_device_by_id(devices_arr[i]); if (WARN_ON_ONCE(!peer)) continue; - kfd_flush_tlb(peer, p->pasid); + kfd_flush_tlb(peer, p); } } else { - kfd_flush_tlb(dev, p->pasid); + kfd_flush_tlb(dev, p); } if (args->device_ids_array_size > 0 && devices_arr) @@ -1408,7 +1408,7 @@ int kfd_unmap_memory_from_gpu(void *mem, struct kfd_process_device *pdd) if (err != 0) return err; - kfd_flush_tlb(dev, pdd->process->pasid); + kfd_flush_tlb(dev, pdd->process); return 0; } diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c index 0b1454c..a628a0d 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c @@ -198,7 +198,7 @@ static int allocate_vmid(struct device_queue_manager *dqm, qpd->vmid, qpd->page_table_base); /*invalidate the VM context after pasid and vmid mapping is set up*/ - kfd_flush_tlb(dqm->dev, qpd->pqm->process->pasid); + kfd_flush_tlb(dqm->dev, qpd->pqm->process); return 0; } @@ -229,7 +229,7 @@ static void deallocate_vmid(struct device_queue_manager *dqm, if (flush_texture_cache_nocpsch(q->device, qpd)) pr_err("Failed to flush TC\n"); - kfd_flush_tlb(dqm->dev, qpd->pqm->process->pasid); + kfd_flush_tlb(dqm->dev, qpd->pqm->process); /* Release the vmid mapping */ set_pasid_vmid_mapping(dqm, 0, qpd->vmid); @@ -661,7 +661,7 @@ int process_restore_queues(struct device_queue_manager *dqm, qpd->vmid, qpd->page_table_base); - kfd_flush_tlb(dqm->dev, pdd->process->pasid); + kfd_flush_tlb(dqm->dev, pdd->process); } /* activate all active queues on the qpd */ diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c index be2d072..499efa1 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_flat_memory.c @@ -416,10 +416,3 @@ int kfd_init_apertures(struct kfd_process *process) return 0; } - -void kfd_flush_tlb(struct kfd_dev *dev, uint32_t pasid) -{ - const struct kfd2kgd_calls *f2g = dev->kfd2kgd; - - f2g->invalidate_tlbs(dev->kgd, pasid); -} diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h index 5914f93..6b2e1e6 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h @@ -556,6 +556,7 @@ struct qcm_process_device { struct list_head priv_queue_list; unsigned int queue_count; + /* a data field only meaningful for non-HWS case */ unsigned int vmid; bool is_debug; unsigned int evicted; /* eviction counter, 0=active */ @@ -1080,7 +1081,7 @@ int kfd_event_destroy(struct kfd_process *p, uint32_t event_id); void kfd_signal_vm_fault_event(struct kfd_dev *dev, unsigned int pasid, struct kfd_vm_fault_info *info); -void kfd_flush_tlb(struct kfd_dev *dev, uint32_t pasid); +void kfd_flush_tlb(struct kfd_dev *dev, struct kfd_process *p); int dbgdev_wave_reset_wavefronts(struct kfd_dev *dev, struct kfd_process *p); diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c index e178dda..3d663d31 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c @@ -1171,3 +1171,20 @@ int kfd_debugfs_mqds_by_process(struct seq_file *m, void *data) } #endif + +void kfd_flush_tlb(struct kfd_dev *dev, struct kfd_process *p) +{ + const struct kfd2kgd_calls *f2g = dev->kfd2kgd; + + if (dev->dqm->sched_policy == KFD_SCHED_POLICY_NO_HWS) { + struct kfd_process_device *pdd = + kfd_get_process_device_data(dev, p); + if (!pdd) { + pr_err("could not find pdd for pasid %d\n", p->pasid); + return; + } + + f2g->invalidate_tlbs_vmid(dev->kgd, pdd->qpd.vmid); + } else + f2g->invalidate_tlbs(dev->kgd, p->pasid); +} -- 2.7.4