drm/amdgpu: add condition check for trace_amdgpu_cs()
authorKevin Wang <kevin1.wang@amd.com>
Mon, 17 Aug 2020 08:57:20 +0000 (16:57 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 17 Aug 2020 18:06:37 +0000 (14:06 -0400)
v1:
add trace event enabled check to avoid nop loop when submit multi ibs
in amdgpu_cs_ioctl() function.

v2:
add a new wrapper function to trace all amdgpu cs ibs.

Signed-off-by: Kevin Wang <kevin1.wang@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index a512ccb..10c0779 100644 (file)
@@ -1275,13 +1275,24 @@ error_unlock:
        return r;
 }
 
+static void trace_amdgpu_cs_ibs(struct amdgpu_cs_parser *parser)
+{
+       int i;
+
+       if (!trace_amdgpu_cs_enabled())
+               return;
+
+       for (i = 0; i < parser->job->num_ibs; i++)
+               trace_amdgpu_cs(parser, i);
+}
+
 int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 {
        struct amdgpu_device *adev = dev->dev_private;
        union drm_amdgpu_cs *cs = data;
        struct amdgpu_cs_parser parser = {};
        bool reserved_buffers = false;
-       int i, r;
+       int r;
 
        if (amdgpu_ras_intr_triggered())
                return -EHWPOISON;
@@ -1319,8 +1330,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 
        reserved_buffers = true;
 
-       for (i = 0; i < parser.job->num_ibs; i++)
-               trace_amdgpu_cs(&parser, i);
+       trace_amdgpu_cs_ibs(&parser);
 
        r = amdgpu_cs_vm_handling(&parser);
        if (r)