Skip to contentSkip to conversation

drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c

PATCH In review Alex Xie 3 participants 5 messages May 31, 2017 – Jun 1, 2017 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Alex Xie

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 32 -------------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  5 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 38 ++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |  1 +
 5 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 89bc34a..2f1a4e9 100644
@@ -2227,6 +2227,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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -32
index 7d95435..31aa51d 100644
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *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.
  *
  * @adev: amdgpu_device pointer
@@ -288,8 +258,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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -5
index 334307e..ad399c8 100644
@@ -208,9 +208,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
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +36 -2
index d4d05a8..6e32748 100644
@@ -656,6 +656,41 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,
 	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;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -0
index 8309bc7..f5dba9c 100644
@@ -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
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1496272081-21584-1-git-send-email-AlexBin.Xie-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Hi Christian,

Please review this v2 patch. It is slightly faster.

Thanks,

Alex Bin

________________________________
From: Xie, AlexBin
Sent: Wednesday, May 31, 2017 7:08 PM
To: [email protected]
Cc: Xie, AlexBin
Subject: [PATCH] drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c

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.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 32 -------------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  5 ----
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 38 ++++++++++++++++++++++++++++--
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |  1 +
 5 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 89bc34a..2f1a4e9 100644
@@ -2227,6 +2227,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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -32
index 7d95435..31aa51d 100644
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *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.
  *
  * @adev: amdgpu_device pointer
@@ -288,8 +258,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;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -5
index 334307e..ad399c8 100644
@@ -208,9 +208,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
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +36 -2
index d4d05a8..6e32748 100644
@@ -656,6 +656,41 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,
         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;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -0
index 8309bc7..f5dba9c 100644
@@ -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

--
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#3 lore raw
In reply to a message not in the archive

Am 01.06.2017 um 01:08 schrieb Alex Xie:

Quoted 7 lines

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.

When you create a v2 of a patch please note that in the subject line as well.

Either by using the "-v2" option with "git send-email" or by adding the v2 manually on the subject line.

I sometimes get mails twice because they are send to multiple lists I'm registered on and that helps allot seeing that a patch changed and is not just a duplicated mail.

Anyway this version is Reviewed-by: Christian König <[email protected]> as well.

Regards,
Christian.

Quoted 146 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 32 -------------------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  5 ----
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 38 ++++++++++++++++++++++++++++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |  1 +
  5 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 89bc34a..2f1a4e9 100644
@@ -2227,6 +2227,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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -32
index 7d95435..31aa51d 100644
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *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.
   *
   * @adev: amdgpu_device pointer
@@ -288,8 +258,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;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -5
index 334307e..ad399c8 100644
@@ -208,9 +208,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
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +36 -2
index d4d05a8..6e32748 100644
@@ -656,6 +656,41 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,
  	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;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -0
index 8309bc7..f5dba9c 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size); · line 250

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -0
@@ -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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 183887cb-17a0-e457-0c92-c04cc4b7fb53-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#5 lore raw

Ok. I will add the v2 next time. I did not add the v2 in case this email list does not put the two patches under same thread...

-Alex Bin

________________________________
From: Christian König <[email protected]>
Sent: Thursday, June 1, 2017 9:26 AM
To: Xie, AlexBin; [email protected]
Subject: Re: [PATCH] drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c

Am 01.06.2017 um 01:08 schrieb Alex Xie:

Quoted 7 lines

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.

When you create a v2 of a patch please note that in the subject line as well.

Either by using the "-v2" option with "git send-email" or by adding the v2 manually on the subject line.

I sometimes get mails twice because they are send to multiple lists I'm registered on and that helps allot seeing that a patch changed and is not just a duplicated mail.

Anyway this version is Reviewed-by: Christian König <[email protected]> as well.

Regards,
Christian.

Quoted 146 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 32 -------------------------
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  5 ----
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 38 ++++++++++++++++++++++++++++--
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |  1 +
  5 files changed, 39 insertions(+), 39 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
index 89bc34a..2f1a4e9 100644
@@ -2227,6 +2227,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;
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -32
index 7d95435..31aa51d 100644
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *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.
   *
   * @adev: amdgpu_device pointer
@@ -288,8 +258,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;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -5
index 334307e..ad399c8 100644
@@ -208,9 +208,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
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +36 -2
index d4d05a8..6e32748 100644
@@ -656,6 +656,41 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,
       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;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -0
index 8309bc7..f5dba9c 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size); · line 250

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -0
@@ -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

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): MWHPR1201MB0045729996FF89B47DCD29A3F2F60-3iK1xFAIwjq45V35fqe+hGrFom/aUZj6nBOFsp37pqbUKgpGm//BTAC/[email protected]

#7 lore raw

When you git email-send first time, there is a message-id, when you would send follow up patches, using --in-reply-to="message-id" in your comment line, then that will be in the same thread.

Cheers,

Leo

Quoted 213 lines · AlexBin

Ok. I will add the v2 next time. I did not add the v2 in case this email list does not put the two patches under same thread...

-Alex Bin

------------------------------------------------------------------------
*From:* Christian König <[email protected]> *Sent:* Thursday, June 1, 2017 9:26 AM
*To:* Xie, AlexBin; [email protected] *Subject:* Re: [PATCH] drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c Am 01.06.2017 um 01:08 schrieb Alex Xie:

Quoted 7 lines

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.

When you create a v2 of a patch please note that in the subject line as well.

Either by using the "-v2" option with "git send-email" or by adding the v2 manually on the subject line.

I sometimes get mails twice because they are send to multiple lists I'm registered on and that helps allot seeing that a patch changed and is not just a duplicated mail.

Anyway this version is Reviewed-by: Christian König <[email protected]> as well.

Regards,
Christian.

Quoted 3 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c |  2 ++
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c   | 32 

-------------------------

Quoted 2 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h   |  5 ----
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c     | 38 

++++++++++++++++++++++++++++--

Review

Quoted 4 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h     |  1 +
  5 files changed, 39 insertions(+), 39 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c

Review

Quoted 13 lines

index 89bc34a..2f1a4e9 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -0
@@ -2227,6 +2227,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;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c void amdgpu_ring_undo(struct amdgpu_ring *ring) · line 156

Quoted 8 lines

index 7d95435..31aa51d 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -1
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring)
  }
 
  /**
- * amdgpu_ring_check_compute_vm_bug - check whether this ring has 

compute vm bug

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c void amdgpu_ring_undo(struct amdgpu_ring *ring)

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -5
- *
- * @adev: amdgpu_device pointer
- * @ring: amdgpu_ring structure holding ring information
- */
-static void amdgpu_ring_check_compute_vm_bug(struct amdgpu_device 

*adev,

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -6
-                                     struct amdgpu_ring *ring)
-{
-     const struct amdgpu_ip_block *ip_block;
-
-     ring->has_compute_vm_bug = false;
-

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c void amdgpu_ring_undo(struct amdgpu_ring *ring)

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -10
-     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.*/

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c int amdgpu_ring_init(struct amdgpu_device *adev,

Quoted 12 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -8
-     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.
   *
   * @adev: amdgpu_device pointer
@@ -288,8 +258,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, 

struct amdgpu_ring *ring,

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c int amdgpu_ring_init(struct amdgpu_device *adev, · line 258

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -0
               DRM_ERROR("Failed to register debugfs file for rings 

!\n");

Review

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c +0 -2
       }
 
-     amdgpu_ring_check_compute_vm_bug(adev, ring);
-
       return 0;
  }
 
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h static inline void amdgpu_ring_clear_ring(struct

Quoted 4 lines

index 334307e..ad399c8 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -0
@@ -208,9 +208,4 @@ static inline void amdgpu_ring_clear_ring(struct 

amdgpu_ring *ring)

drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h static inline void amdgpu_ring_clear_ring(struct · line 210

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -1
  }
 
-static inline bool amdgpu_ring_has_compute_vm_bug(struct 

amdgpu_ring *ring)

Review

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +0 -4
-{
-     return ring->has_compute_vm_bug;
-}
-
  #endif
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_alloc_reserved_vmid(struct

Quoted 4 lines

index d4d05a8..6e32748 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
@@ -656,6 +656,41 @@ static int amdgpu_vm_alloc_reserved_vmid(struct 

amdgpu_device *adev,

Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +8 -0
       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;

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +10 -0
+     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.*/

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_need_pipeline_sync(struct

Quoted 21 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +17 -0
+             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,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_need_pipeline_sync(struct · line 699

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
       struct amdgpu_vm_id_manager *id_mgr = 

&adev->vm_manager.id_mgr[vmhub];

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -2
       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;

Review

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
       if (job->vm_id == 0)
               return false;
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h void amdgpu_vm_adjust_size(struct amdgpu_device

Quoted 4 lines

index 8309bc7..f5dba9c 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -0
@@ -245,5 +245,6 @@ void amdgpu_vm_adjust_size(struct amdgpu_device 

*adev, uint64_t vm_size);

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h void amdgpu_vm_adjust_size(struct amdgpu_device · line 245

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +0 -0
  int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct 

drm_file *filp);

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size); · line 250

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h +1 -0
  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
Quoted 4 lines

_______________________________________________
amd-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx