RE: [PATCH] amdkfd: allow profiler process reenter

"Zhu, Lingshan" <[email protected]>
Newsgroups org.freedesktop.lists.amd-gfx
Message-ID <CH2PR12MB94573C6D5DD3480E33E6463F8CDC2@CH2PR12MB9457.namprd12.prod.outlook.com>
AMD General

Gentle Ping.

Thanks
Lingshan

-----Original Message-----
From: Zhu, Lingshan <[email protected]>
Sent: Thursday, August 6, 2026 4:43 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Kuehling, Felix <[email protected]>
Cc: Huang, Ray <[email protected]>; [email protected]; Zhu, Lingshan <[email protected]>
Subject: [PATCH] amdkfd: allow profiler process reenter

profile_lock_device() currently returns -EALREADY when the current profiler process requests to lock the device again. However any negtive values here are treated as failure, so this causes rejecting a profiler operation even though the caller still owns the device locking.

This commit fixes this problem by returning 0 when the current profiler process locking the device again.

This commit also changes profile_lock_device() to return an int value other than uint32_t, because it returns negative number when fail.

Signed-off-by: Zhu Lingshan <[email protected]>
---
 drivers/gpu/drm/amd/amdkfd/kfd_chardev.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
index 309510e23315..9acd5c91e51c 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -3329,8 +3329,8 @@ static int kfd_ioctl_create_process(struct file *filep, struct kfd_process *p, v
        return 0;
 }

-static inline uint32_t profile_lock_device(struct kfd_process *p,
-                                          uint32_t gpu_id, uint32_t op)
+static inline int profile_lock_device(struct kfd_process *p,
+                                     uint32_t gpu_id, uint32_t op)
 {
        struct kfd_process_device *pdd;
        struct kfd_dev *kfd;
@@ -3365,7 +3365,7 @@ static inline uint32_t profile_lock_device(struct kfd_process *p,
                        }
                        return status;
                } else if (kfd->profiler_process == p) {
-                       status = -EALREADY;
+                       status = 0;
                } else {
                        status = -EBUSY;
                }
--
2.53.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.