drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c
authorAlex Xie <AlexBin.Xie@amd.com>
Thu, 1 Jun 2017 13:42:59 +0000 (09:42 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 1 Jun 2017 20:00:20 +0000 (16:00 -0400)
  In review, Christian would like to keep the logic
  inside amdgpu_vm.c with a cost of slightly slower.
  The loop is still optimized out with this patch.

v2: remove the if statement. Now it is not slower.

Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
Reviewed-by: Christian König <christian.koeng@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

index cce94d836221c47ae888a37f90815db726470b77..01ee69b37a2b96c913f3088b2f3eed4756325857 100644 (file)
@@ -2190,6 +2190,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,
 
        adev->accel_working = true;
 
+       amdgpu_vm_check_compute_bug(adev);
+
        /* Initialize the buffer migration limit. */
        if (amdgpu_moverate >= 0)
                max_MBps = amdgpu_moverate;
index cef135ef733430f3b3b13be7950540428c3b5d9d..75165e07b1cd8807831d4dd602a9c1a2037d8ad6 100644 (file)
@@ -154,36 +154,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring)
                ring->funcs->end_use(ring);
 }
 
-/**
- * amdgpu_ring_check_compute_vm_bug - check whether this ring has compute vm bug
- *
- * @adev: amdgpu_device pointer
- * @ring: amdgpu_ring structure holding ring information
- */
-static void amdgpu_ring_check_compute_vm_bug(struct amdgpu_device *adev,
-                                       struct amdgpu_ring *ring)
-{
-       const struct amdgpu_ip_block *ip_block;
-
-       ring->has_compute_vm_bug = false;
-
-       if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE)
-               /* only compute rings */
-               return;
-
-       ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);
-       if (!ip_block)
-               return;
-
-       /* Compute ring has a VM bug for GFX version < 7.
-           And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/
-       if (ip_block->version->major <= 7) {
-               ring->has_compute_vm_bug = true;
-       } else if (ip_block->version->major == 8)
-               if (adev->gfx.mec_fw_version < 673)
-                       ring->has_compute_vm_bug = true;
-}
-
 /**
  * amdgpu_ring_init - init driver ring struct.
  *
@@ -292,8 +262,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,
                DRM_ERROR("Failed to register debugfs file for rings !\n");
        }
 
-       amdgpu_ring_check_compute_vm_bug(adev, ring);
-
        return 0;
 }
 
index a1dd9077c064e3c0ae11df9e670abe49cab2b941..bc8dec992f73d5da7a4d8742fd3d7bc110cd0312 100644 (file)
@@ -212,9 +212,4 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring)
 
 }
 
-static inline bool amdgpu_ring_has_compute_vm_bug(struct amdgpu_ring *ring)
-{
-       return ring->has_compute_vm_bug;
-}
-
 #endif
index d4d05a81960354276b5dc8cd49397a52dfedfe5d..6e32748d224e015d863bf3690d56fdeb59e109fc 100644 (file)
@@ -656,6 +656,41 @@ unlock:
        return r;
 }
 
+/**
+ * amdgpu_vm_check_compute_bug - check whether asic has compute vm bug
+ *
+ * @adev: amdgpu_device pointer
+ */
+void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev)
+{
+       const struct amdgpu_ip_block *ip_block;
+       bool has_compute_vm_bug;
+       struct amdgpu_ring *ring;
+       int i;
+
+       has_compute_vm_bug = false;
+
+       ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);
+       if (ip_block) {
+               /* Compute has a VM bug for GFX version < 7.
+                  Compute has a VM bug for GFX 8 MEC firmware version < 673.*/
+               if (ip_block->version->major <= 7)
+                       has_compute_vm_bug = true;
+               else if (ip_block->version->major == 8)
+                       if (adev->gfx.mec_fw_version < 673)
+                               has_compute_vm_bug = true;
+       }
+
+       for (i = 0; i < adev->num_rings; i++) {
+               ring = adev->rings[i];
+               if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE)
+                       /* only compute rings */
+                       ring->has_compute_vm_bug = has_compute_vm_bug;
+               else
+                       ring->has_compute_vm_bug = false;
+       }
+}
+
 bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job)
 {
@@ -664,8 +699,7 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
        struct amdgpu_vm_id_manager *id_mgr = &adev->vm_manager.id_mgr[vmhub];
        struct amdgpu_vm_id *id;
        bool gds_switch_needed;
-       bool vm_flush_needed = job->vm_needs_flush ||
-               amdgpu_ring_has_compute_vm_bug(ring);
+       bool vm_flush_needed = job->vm_needs_flush || ring->has_compute_vm_bug;
 
        if (job->vm_id == 0)
                return false;
index 8309bc7ffd71fc087c0f8475075ff7693368f356..f5dba9cea5878d132bcda1908490867c2d5280b9 100644 (file)
@@ -245,5 +245,6 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size);
 int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);
 bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,
                                  struct amdgpu_job *job);
+void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev);
 
 #endif