When the profiler is released it needs to enable PTL again to make sure
PTL state is restored to preivous state.

Signed-off-by: Perry Yuan <[email protected]>
Reviewed-by: Lijo Lazar <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 2 +-
 drivers/gpu/drm/amd/amdkfd/kfd_priv.h    | 3 +++
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 1 +
 3 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 1e619eda8433..285219781939 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1764,7 +1764,7 @@ static int kfd_ioctl_svm(struct file *filep, struct 
kfd_process *p, void *data)
 }
 #endif
 
-static int kfd_ptl_control(struct kfd_process_device *pdd, bool enable)
+int kfd_ptl_control(struct kfd_process_device *pdd, bool enable)
 {
        struct amdgpu_device *adev = pdd->dev->adev;
        enum amdgpu_ptl_fmt pref_format1 = adev->psp.ptl_fmt1;
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h 
b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
index 8983065645fa..164f69924a3d 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
@@ -1607,6 +1607,9 @@ static inline bool kfd_is_first_node(struct kfd_node 
*node)
        return (node == node->kfd->nodes[0]);
 }
 
+/* PTL support */
+int kfd_ptl_control(struct kfd_process_device *pdd, bool enable);
+
 /* Debugfs */
 #if defined(CONFIG_DEBUG_FS)
 
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c 
b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index deca19b478d0..5114ac4da5b9 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -1115,6 +1115,7 @@ static void kfd_process_profiler_release(struct 
kfd_process *p, struct kfd_proce
        mutex_lock(&pdd->dev->kfd->profiler_lock);
        if (pdd->dev->kfd->profiler_process == p) {
                pdd->qpd.dqm->ops.set_perfcount(pdd->qpd.dqm, 0);
+               kfd_ptl_control(pdd, true);
                pdd->dev->kfd->profiler_process = NULL;
        }
        mutex_unlock(&pdd->dev->kfd->profiler_lock);
-- 
2.34.1

Reply via email to