Skip to contentSkip to conversation

drm/amdgpu:fix race condition

PATCH In review Monk Liu 3 participants 3 messages Apr 10, 2017 – Apr 11, 2017 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm/amdgpu:fix race condition

sequence is protected by spinlock so don't access sequence in paramter seq when invoking this function.

~0 means to get the latest sequence number and 0 means none to get.

Change-Id Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1ad
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
 include/uapi/drm/amdgpu_drm.h           | 5 ++++-
 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
index 6d86eae..b4bbbb3 100644
@@ -277,6 +277,9 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
 
 	spin_lock(&ctx->ring_lock);
 
+	if (seq == ~0ull)
+		seq = ctx->rings[ring->idx].sequence - 1;
+
 	if (seq >= cring->sequence) {
 		spin_unlock(&ctx->ring_lock);
 		return ERR_PTR(-EINVAL);
include/uapi/drm/amdgpu_drm.h +4 -1
index 34e5f93..3243409 100644
@@ -297,7 +297,10 @@ union drm_amdgpu_gem_wait_idle {
 };
 
 struct drm_amdgpu_wait_cs_in {
-	/** Command submission handle */
+	/* Command submission handle
+         * handle equals 0 means none to wait for
+         * handle equal ~0ull meanas wait for the latest sequence number
+         */
 	__u64 handle;
 	/** Absolute timeout to wait */
 	__u64 timeout;
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): 1491819882-19868-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

Reviewed-by
#2 lore raw

Am 10.04.2017 um 12:24 schrieb Monk Liu:

Quoted 8 lines

sequence is protected by spinlock so don't access sequence in paramter seq when invoking this function.

~0 means to get the latest sequence number and 0 means none to get.

Change-Id Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1ad
Quoted 25 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
  include/uapi/drm/amdgpu_drm.h           | 5 ++++-
  2 files changed, 7 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
index 6d86eae..b4bbbb3 100644
@@ -277,6 +277,9 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,
 
  	spin_lock(&ctx->ring_lock);
 
+	if (seq == ~0ull)
+		seq = ctx->rings[ring->idx].sequence - 1;
+
  	if (seq >= cring->sequence) {
  		spin_unlock(&ctx->ring_lock);
  		return ERR_PTR(-EINVAL);
include/uapi/drm/amdgpu_drm.h +0 -0
index 34e5f93..3243409 100644
@@ -297,7 +297,10 @@ union drm_amdgpu_gem_wait_idle {
  };

include/uapi/drm/amdgpu_drm.h union drm_amdgpu_gem_wait_idle { · line 306

Quoted 10 lines
include/uapi/drm/amdgpu_drm.h +4 -1
 
  struct drm_amdgpu_wait_cs_in {
-	/** Command submission handle */
+	/* Command submission handle
+         * handle equals 0 means none to wait for
+         * handle equal ~0ull meanas wait for the latest sequence number
+         */
  	__u64 handle;
  	/** Absolute timeout to wait */
  	__u64 timeout;

_______________________________________________
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

include/uapi/drm/amdgpu_drm.h union drm_amdgpu_gem_wait_idle { · line 300

Quoted 4 lines · Monk Liu

struct drm_amdgpu_wait_cs_in {

include/uapi/drm/amdgpu_drm.h +1 -1
-	/** Command submission handle */
+	/* Command submission handle

Any particular reason for dropping the /** comment opening?

Quoted 1 line

+ * handle equals 0 means none to wait for

This line and the following lines are indented incorrectly (9 spaces, should be 1 tab + 1 space).

include/uapi/drm/amdgpu_drm.h union drm_amdgpu_gem_wait_idle { · line 303

Quoted 2 lines
include/uapi/drm/amdgpu_drm.h +2 -0
+         * handle equal ~0ull meanas wait for the latest sequence number
+         */

Typo: "meanas" (vi(m) accident? :)

Signature · 6 lines
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx