Commit a82918f1 authored by Ben Goz's avatar Ben Goz Committed by Oded Gabbay

drm/amdkfd: make reset wavefronts per process per device

This commit moves the reset wavefront flag to per process per device
data structure, so we can support multiple devices.
Signed-off-by: default avatarBen Goz <ben.goz@amd.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent 6235e15e
...@@ -946,7 +946,7 @@ static int destroy_queues_cpsch(struct device_queue_manager *dqm, ...@@ -946,7 +946,7 @@ static int destroy_queues_cpsch(struct device_queue_manager *dqm,
{ {
int retval; int retval;
enum kfd_preempt_type_filter preempt_type; enum kfd_preempt_type_filter preempt_type;
struct kfd_process *p; struct kfd_process_device *pdd;
BUG_ON(!dqm); BUG_ON(!dqm);
...@@ -981,8 +981,9 @@ static int destroy_queues_cpsch(struct device_queue_manager *dqm, ...@@ -981,8 +981,9 @@ static int destroy_queues_cpsch(struct device_queue_manager *dqm,
retval = amdkfd_fence_wait_timeout(dqm->fence_addr, KFD_FENCE_COMPLETED, retval = amdkfd_fence_wait_timeout(dqm->fence_addr, KFD_FENCE_COMPLETED,
QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS); QUEUE_PREEMPT_DEFAULT_TIMEOUT_MS);
if (retval != 0) { if (retval != 0) {
p = kfd_get_process(current); pdd = kfd_get_process_device_data(dqm->dev,
p->reset_wavefronts = true; kfd_get_process(current));
pdd->reset_wavefronts = true;
goto out; goto out;
} }
pm_release_ib(&dqm->packets); pm_release_ib(&dqm->packets);
......
...@@ -463,6 +463,11 @@ struct kfd_process_device { ...@@ -463,6 +463,11 @@ struct kfd_process_device {
/* Is this process/pasid bound to this device? (amd_iommu_bind_pasid) */ /* Is this process/pasid bound to this device? (amd_iommu_bind_pasid) */
bool bound; bool bound;
/* This flag tells if we should reset all
* wavefronts on process termination
*/
bool reset_wavefronts;
}; };
#define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd) #define qpd_to_pdd(x) container_of(x, struct kfd_process_device, qpd)
...@@ -519,11 +524,6 @@ struct kfd_process { ...@@ -519,11 +524,6 @@ struct kfd_process {
event_pages */ event_pages */
u32 next_nonsignal_event_id; u32 next_nonsignal_event_id;
size_t signal_event_count; size_t signal_event_count;
/*
* This flag tells if we should reset all wavefronts on
* process termination
*/
bool reset_wavefronts;
}; };
/** /**
......
...@@ -173,7 +173,7 @@ static void kfd_process_wq_release(struct work_struct *work) ...@@ -173,7 +173,7 @@ static void kfd_process_wq_release(struct work_struct *work)
pr_debug("Releasing pdd (topology id %d) for process (pasid %d) in workqueue\n", pr_debug("Releasing pdd (topology id %d) for process (pasid %d) in workqueue\n",
pdd->dev->id, p->pasid); pdd->dev->id, p->pasid);
if (p->reset_wavefronts) if (pdd->reset_wavefronts)
dbgdev_wave_reset_wavefronts(pdd->dev, p); dbgdev_wave_reset_wavefronts(pdd->dev, p);
amd_iommu_unbind_pasid(pdd->dev->pdev, p->pasid); amd_iommu_unbind_pasid(pdd->dev->pdev, p->pasid);
...@@ -222,6 +222,7 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn, ...@@ -222,6 +222,7 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
struct mm_struct *mm) struct mm_struct *mm)
{ {
struct kfd_process *p; struct kfd_process *p;
struct kfd_process_device *pdd = NULL;
/* /*
* The kfd_process structure can not be free because the * The kfd_process structure can not be free because the
...@@ -240,6 +241,15 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn, ...@@ -240,6 +241,15 @@ static void kfd_process_notifier_release(struct mmu_notifier *mn,
/* In case our notifier is called before IOMMU notifier */ /* In case our notifier is called before IOMMU notifier */
pqm_uninit(&p->pqm); pqm_uninit(&p->pqm);
/* Iterate over all process device data structure and check
* if we should reset all wavefronts */
list_for_each_entry(pdd, &p->per_device_data, per_device_list)
if (pdd->reset_wavefronts) {
pr_warn("amdkfd: Resetting all wave fronts\n");
dbgdev_wave_reset_wavefronts(pdd->dev, p);
pdd->reset_wavefronts = false;
}
mutex_unlock(&p->mutex); mutex_unlock(&p->mutex);
/* /*
...@@ -305,8 +315,6 @@ static struct kfd_process *create_process(const struct task_struct *thread) ...@@ -305,8 +315,6 @@ static struct kfd_process *create_process(const struct task_struct *thread)
if (kfd_init_apertures(process) != 0) if (kfd_init_apertures(process) != 0)
goto err_init_apretures; goto err_init_apretures;
process->reset_wavefronts = false;
return process; return process;
err_init_apretures: err_init_apretures:
...@@ -348,6 +356,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev, ...@@ -348,6 +356,7 @@ struct kfd_process_device *kfd_create_process_device_data(struct kfd_dev *dev,
INIT_LIST_HEAD(&pdd->qpd.queues_list); INIT_LIST_HEAD(&pdd->qpd.queues_list);
INIT_LIST_HEAD(&pdd->qpd.priv_queue_list); INIT_LIST_HEAD(&pdd->qpd.priv_queue_list);
pdd->qpd.dqm = dev->dqm; pdd->qpd.dqm = dev->dqm;
pdd->reset_wavefronts = false;
list_add(&pdd->per_device_list, &p->per_device_data); list_add(&pdd->per_device_list, &p->per_device_data);
} }
...@@ -409,10 +418,12 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid) ...@@ -409,10 +418,12 @@ void kfd_unbind_process_from_device(struct kfd_dev *dev, unsigned int pasid)
kfd_dbgmgr_destroy(dev->dbgmgr); kfd_dbgmgr_destroy(dev->dbgmgr);
pqm_uninit(&p->pqm); pqm_uninit(&p->pqm);
if (p->reset_wavefronts)
dbgdev_wave_reset_wavefronts(dev, p);
pdd = kfd_get_process_device_data(dev, p); pdd = kfd_get_process_device_data(dev, p);
if (pdd->reset_wavefronts) {
dbgdev_wave_reset_wavefronts(pdd->dev, p);
pdd->reset_wavefronts = false;
}
/* /*
* Just mark pdd as unbound, because we still need it to call * Just mark pdd as unbound, because we still need it to call
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment