[PATCH v4 08/24] drm/amdkfd: enable pc sampling destroy
James Zhu
James.Zhu at amd.com
Tue Feb 6 15:59:04 UTC 2024
Enable pc sampling destroy.
Signed-off-by: James Zhu <James.Zhu at amd.com>
---
drivers/gpu/drm/amd/amdkfd/kfd_pc_sampling.c | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_pc_sampling.c b/drivers/gpu/drm/amd/amdkfd/kfd_pc_sampling.c
index 72c66d4bd24f..b46caa52fbe8 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_pc_sampling.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_pc_sampling.c
@@ -186,10 +186,24 @@ static int kfd_pc_sample_create(struct kfd_process_device *pdd,
return 0;
}
-static int kfd_pc_sample_destroy(struct kfd_process_device *pdd, uint32_t trace_id)
+static int kfd_pc_sample_destroy(struct kfd_process_device *pdd, uint32_t trace_id,
+ struct pc_sampling_entry *pcs_entry)
{
- return -EINVAL;
+ pr_debug("free pcs_entry = %p, trace_id = 0x%x on gpu 0x%x",
+ pcs_entry, trace_id, pdd->dev->id);
+
+ mutex_lock(&pdd->dev->pcs_data.mutex);
+ pdd->dev->pcs_data.hosttrap_entry.base.use_count--;
+ idr_remove(&pdd->dev->pcs_data.hosttrap_entry.base.pc_sampling_idr, trace_id);
+ if (!pdd->dev->pcs_data.hosttrap_entry.base.use_count)
+ memset(&pdd->dev->pcs_data.hosttrap_entry.base.pc_sample_info, 0x0,
+ sizeof(struct kfd_pc_sample_info));
+ mutex_unlock(&pdd->dev->pcs_data.mutex);
+
+ kfree(pcs_entry);
+
+ return 0;
}
int kfd_pc_sample(struct kfd_process_device *pdd,
@@ -224,7 +238,7 @@ int kfd_pc_sample(struct kfd_process_device *pdd,
if (pcs_entry->enabled)
return -EBUSY;
else
- return kfd_pc_sample_destroy(pdd, args->trace_id);
+ return kfd_pc_sample_destroy(pdd, args->trace_id, pcs_entry);
case KFD_IOCTL_PCS_OP_START:
if (pcs_entry->enabled)
--
2.25.1
More information about the amd-gfx
mailing list