From e96746cfcd843797f2a02a7c712324424b63b10c Mon Sep 17 00:00:00 2001 From: Antony Clince Alex Date: Tue, 1 Feb 2022 08:17:53 +0000 Subject: [PATCH] gpu: nvgpu: profiler: update PMA stream free policy Update PMA stream free policy to implicitly unbind any resources already bound to the profiler object. Bug 3480919 Change-Id: I71ed4b73be295a86046a1384800e7ed0f2430f64 Signed-off-by: Antony Clince Alex Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2662361 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/ioctl_prof.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_prof.c b/drivers/gpu/nvgpu/os/linux/ioctl_prof.c index e97875c3e..e47dde640 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_prof.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_prof.c @@ -521,6 +521,7 @@ static int nvgpu_prof_ioctl_free_pma_stream(struct nvgpu_profiler_object_priv *p { struct nvgpu_profiler_object *prof = priv->prof; struct gk20a *g = prof->g; + int err; nvgpu_log(g, gpu_dbg_prof, "Request to free PMA stream for handle %u", prof->prof_handle); @@ -531,8 +532,15 @@ static int nvgpu_prof_ioctl_free_pma_stream(struct nvgpu_profiler_object_priv *p } if (prof->bound) { - nvgpu_err(g, "PM resources are bound, cannot free PMA"); - return -EINVAL; + nvgpu_log(g, gpu_dbg_prof, "PM resources already bound with" + " profiler handle %u, implicity unbinding for" + " freeing PMA stream", prof->prof_handle); + err = nvgpu_profiler_unbind_pm_resources(prof); + if (err != 0) { + nvgpu_err(g, "Profiler handle %u failed to unbind," + " err %d", prof->prof_handle, err); + return err; + } } nvgpu_prof_free_pma_stream_priv_data(priv);