<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif;" dir="ltr">
<p>Hi Christian,</p>
<p><br>
</p>
<p>Please review this v2 patch. It is slightly faster.</p>
<br>
<p>Thanks,</p>
<p>Alex Bin<br>
</p>
<div style="color: rgb(0, 0, 0);">
<div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Xie, AlexBin<br>
<b>Sent:</b> Wednesday, May 31, 2017 7:08 PM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org<br>
<b>Cc:</b> Xie, AlexBin<br>
<b>Subject:</b> [PATCH] drm/amdgpu: Move compute vm bug logic to amdgpu_vm.c</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText"> In review, Christian would like to keep the logic<br>
inside amdgpu_vm.c with a cost of slightly slower.<br>
The loop is still optimized out with this patch.<br>
<br>
v2: remove the if statement. Now it is not slower.<br>
<br>
Signed-off-by: Alex Xie <AlexBin.Xie@amd.com><br>
---<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c | 32 -------------------------<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 5 ----<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 38 ++++++++++++++++++++++++++++--<br>
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h | 1 +<br>
5 files changed, 39 insertions(+), 39 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
index 89bc34a..2f1a4e9 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c<br>
@@ -2227,6 +2227,8 @@ int amdgpu_device_init(struct amdgpu_device *adev,<br>
<br>
adev->accel_working = true;<br>
<br>
+ amdgpu_vm_check_compute_bug(adev);<br>
+<br>
/* Initialize the buffer migration limit. */<br>
if (amdgpu_moverate >= 0)<br>
max_MBps = amdgpu_moverate;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
index 7d95435..31aa51d 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.c<br>
@@ -153,36 +153,6 @@ void amdgpu_ring_undo(struct amdgpu_ring *ring)<br>
}<br>
<br>
/**<br>
- * amdgpu_ring_check_compute_vm_bug - check whether this ring has compute vm bug<br>
- *<br>
- * @adev: amdgpu_device pointer<br>
- * @ring: amdgpu_ring structure holding ring information<br>
- */<br>
-static void amdgpu_ring_check_compute_vm_bug(struct amdgpu_device *adev,<br>
- struct amdgpu_ring *ring)<br>
-{<br>
- const struct amdgpu_ip_block *ip_block;<br>
-<br>
- ring->has_compute_vm_bug = false;<br>
-<br>
- if (ring->funcs->type != AMDGPU_RING_TYPE_COMPUTE)<br>
- /* only compute rings */<br>
- return;<br>
-<br>
- ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);<br>
- if (!ip_block)<br>
- return;<br>
-<br>
- /* Compute ring has a VM bug for GFX version < 7.<br>
- And compute ring has a VM bug for GFX 8 MEC firmware version < 673.*/<br>
- if (ip_block->version->major <= 7) {<br>
- ring->has_compute_vm_bug = true;<br>
- } else if (ip_block->version->major == 8)<br>
- if (adev->gfx.mec_fw_version < 673)<br>
- ring->has_compute_vm_bug = true;<br>
-}<br>
-<br>
-/**<br>
* amdgpu_ring_init - init driver ring struct.<br>
*<br>
* @adev: amdgpu_device pointer<br>
@@ -288,8 +258,6 @@ int amdgpu_ring_init(struct amdgpu_device *adev, struct amdgpu_ring *ring,<br>
DRM_ERROR("Failed to register debugfs file for rings !\n");<br>
}<br>
<br>
- amdgpu_ring_check_compute_vm_bug(adev, ring);<br>
-<br>
return 0;<br>
}<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
index 334307e..ad399c8 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h<br>
@@ -208,9 +208,4 @@ static inline void amdgpu_ring_clear_ring(struct amdgpu_ring *ring)<br>
<br>
}<br>
<br>
-static inline bool amdgpu_ring_has_compute_vm_bug(struct amdgpu_ring *ring)<br>
-{<br>
- return ring->has_compute_vm_bug;<br>
-}<br>
-<br>
#endif<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
index d4d05a8..6e32748 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
@@ -656,6 +656,41 @@ static int amdgpu_vm_alloc_reserved_vmid(struct amdgpu_device *adev,<br>
return r;<br>
}<br>
<br>
+/**<br>
+ * amdgpu_vm_check_compute_bug - check whether asic has compute vm bug<br>
+ *<br>
+ * @adev: amdgpu_device pointer<br>
+ */<br>
+void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev)<br>
+{<br>
+ const struct amdgpu_ip_block *ip_block;<br>
+ bool has_compute_vm_bug;<br>
+ struct amdgpu_ring *ring;<br>
+ int i;<br>
+<br>
+ has_compute_vm_bug = false;<br>
+<br>
+ ip_block = amdgpu_get_ip_block(adev, AMD_IP_BLOCK_TYPE_GFX);<br>
+ if (ip_block) {<br>
+ /* Compute has a VM bug for GFX version < 7.<br>
+ Compute has a VM bug for GFX 8 MEC firmware version < 673.*/<br>
+ if (ip_block->version->major <= 7)<br>
+ has_compute_vm_bug = true;<br>
+ else if (ip_block->version->major == 8)<br>
+ if (adev->gfx.mec_fw_version < 673)<br>
+ has_compute_vm_bug = true;<br>
+ }<br>
+<br>
+ for (i = 0; i < adev->num_rings; i++) {<br>
+ ring = adev->rings[i];<br>
+ if (ring->funcs->type == AMDGPU_RING_TYPE_COMPUTE)<br>
+ /* only compute rings */<br>
+ ring->has_compute_vm_bug = has_compute_vm_bug;<br>
+ else<br>
+ ring->has_compute_vm_bug = false;<br>
+ }<br>
+}<br>
+<br>
bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,<br>
struct amdgpu_job *job)<br>
{<br>
@@ -664,8 +699,7 @@ bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,<br>
struct amdgpu_vm_id_manager *id_mgr = &adev->vm_manager.id_mgr[vmhub];<br>
struct amdgpu_vm_id *id;<br>
bool gds_switch_needed;<br>
- bool vm_flush_needed = job->vm_needs_flush ||<br>
- amdgpu_ring_has_compute_vm_bug(ring);<br>
+ bool vm_flush_needed = job->vm_needs_flush || ring->has_compute_vm_bug;<br>
<br>
if (job->vm_id == 0)<br>
return false;<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
index 8309bc7..f5dba9c 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.h<br>
@@ -245,5 +245,6 @@ void amdgpu_vm_adjust_size(struct amdgpu_device *adev, uint64_t vm_size);<br>
int amdgpu_vm_ioctl(struct drm_device *dev, void *data, struct drm_file *filp);<br>
bool amdgpu_vm_need_pipeline_sync(struct amdgpu_ring *ring,<br>
struct amdgpu_job *job);<br>
+void amdgpu_vm_check_compute_bug(struct amdgpu_device *adev);<br>
<br>
#endif<br>
-- <br>
2.7.4<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>