Skip to contentSkip to conversation

drm/amdgpu: check ring being ready before using

PATCH In review Pixel Ding 3 participants 3 messages Jan 18, 2017 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Pixel Ding

author
#0 lore raw

PATCH 1/1 drm/amdgpu: check ring being ready before using

From: Ding Pixel <[email protected]>

Return success when the ring is properly initialized, otherwise return failure.

Tonga SRIOV VF doesn't have UVD and VCE engines, the initialization of these IPs is bypassed. The system crashes if application submit IB to their rings which are not ready to use. It could be a common issue if IP having ring buffer is disabled for some reason on specific ASIC, so it should check the ring being ready to use.

Bug: amdgpu_test crashes system on Tonga VF.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +6 -0
index 08dd97b..0a235b9 100644
@@ -83,6 +83,12 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type,
 		}
 		break;
 	}
+
+	if (!(*out_ring && (*out_ring)->ready)) {
+		DRM_ERROR("invalid ip type: %d\n", ip_type);
+		return -EINVAL;
+	}
+
 	return 0;
 }
 
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): 1484735840-28171-1-git-send-email-pding-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 18.01.2017 um 11:37 schrieb Pixel Ding:

Quoted 5 lines

From: Ding Pixel <[email protected]>

Return success when the ring is properly initialized, otherwise return failure.

Quoted 7 lines

Tonga SRIOV VF doesn't have UVD and VCE engines, the initialization of these IPs is bypassed. The system crashes if application submit IB to their rings which are not ready to use. It could be a common issue if IP having ring buffer is disabled for some reason on specific ASIC, so it should check the ring being ready to use.

Bug: amdgpu_test crashes system on Tonga VF.

Good catch, we probably have problem using the second VCE ring as well.

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 08dd97b..0a235b9 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · line 87

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -83,6 +83,12 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type,
  		}
  		break;
  	}
+
+	if (!(*out_ring && (*out_ring)->ready)) {

Don't check ring->ready here, that member is used during GPU reset to test if we have successfully restarted the ring.

Instead check if ring->adev is set, that is used in ring_init() to check if a ring is initialized or not.

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · line 88

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -0
+		DRM_ERROR("invalid ip type: %d\n", ip_type);

Please adjust the error message to something like "ring %d not initialized on IP %d\".

Regards,
Christian.

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · line 94

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -0
+		return -EINVAL;
+	}
+
  	return 0;
  }
 

_______________________________________________
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): e51bdd89-eb3d-ed58-fbbb-db68a420dfff-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#4 lore raw

Christian,

Thank you for the quick comments. The revision is coming soon.

—
Sincerely Yours,
Pixel

Quoted 47 lines · Christian König

Am 18.01.2017 um 11:37 schrieb Pixel Ding:

Quoted 5 lines

From: Ding Pixel <[email protected]>

Return success when the ring is properly initialized, otherwise return failure.

Quoted 7 lines

Tonga SRIOV VF doesn't have UVD and VCE engines, the initialization of these IPs is bypassed. The system crashes if application submit IB to their rings which are not ready to use. It could be a common issue if IP having ring buffer is disabled for some reason on specific ASIC, so it should check the ring being ready to use.

Bug: amdgpu_test crashes system on Tonga VF.

Good catch, we probably have problem using the second VCE ring as well.

Quoted 11 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 ++++++
  1 file changed, 6 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 08dd97b..0a235b9 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · line 87

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -0
@@ -83,6 +83,12 @@ int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type,
  		}
  		break;
  	}
+
+	if (!(*out_ring && (*out_ring)->ready)) {

Don't check ring->ready here, that member is used during GPU reset to test if we have successfully restarted the ring.

Instead check if ring->adev is set, that is used in ring_init() to check if a ring is initialized or not.

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · line 88

Quoted 1 line
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +1 -0
+		DRM_ERROR("invalid ip type: %d\n", ip_type);

Please adjust the error message to something like "ring %d not initialized on IP %d\".

Regards,
Christian.

Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_get_ring(struct amdgpu_device *adev, u32 ip_type, · line 94

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -0
+		return -EINVAL;
+	}
+
  	return 0;
  }
 

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