Skip to contentSkip to conversation

drm/amdgpu: Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES

PATCH Superseded Andrey Grodzovsky 2 participants 4 messages Feb 1, 2019 3 messages not in the archive

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES

New chunk for dependency on start of job's execution instead on the end. This is used for GPU deadlock prevention when userspace uses mid-IB fences to wait for mid-IB work on other rings.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 12 +++++++++++-
 include/uapi/drm/amdgpu_drm.h          |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +11 -1
index 1c49b82..3c374ec 100644
@@ -214,6 +214,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
 		case AMDGPU_CHUNK_ID_DEPENDENCIES:
 		case AMDGPU_CHUNK_ID_SYNCOBJ_IN:
 		case AMDGPU_CHUNK_ID_SYNCOBJ_OUT:
+		case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
 			break;
 
 		default:
@@ -1090,6 +1091,14 @@ static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p,
 
 		fence = amdgpu_ctx_get_fence(ctx, entity,
 					     deps[i].handle);
+
+		if (chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIESD) {
+			struct drm_sched_fence *s_fence = to_drm_sched_fence(fence);
+
+			dma_fence_put(fence);
+			fence = dma_fence_get(&s_fence->scheduled);
+		}
+
 		if (IS_ERR(fence)) {
 			r = PTR_ERR(fence);
 			amdgpu_ctx_put(ctx);
@@ -1177,7 +1186,8 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
 
 		chunk = &p->chunks[i];
 
-		if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES) {
+		if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES ||
+		    chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
 			r = amdgpu_cs_process_fence_dep(p, chunk);
 			if (r)
 				return r;
include/uapi/drm/amdgpu_drm.h +1 -0
index faaad04..43d03a2 100644
@@ -526,6 +526,7 @@ struct drm_amdgpu_gem_va {
 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
 #define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
+#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES	0x07
 
 struct drm_amdgpu_cs_chunk {
 	__u32		chunk_id;
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): 1549050670-18395-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH v2 1/1 drm/amdgpu: Add AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES

New chunk for dependency on start of job's execution instead on the end. This is used for GPU deadlock prevention when userspace uses mid-IB fences to wait for mid-IB work on other rings.

v2: Fix typo in AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 12 +++++++++++-
 include/uapi/drm/amdgpu_drm.h          |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +11 -1
index 1c49b82..3f21eca 100644
@@ -214,6 +214,7 @@ static int amdgpu_cs_parser_init(struct amdgpu_cs_parser *p, union drm_amdgpu_cs
 		case AMDGPU_CHUNK_ID_DEPENDENCIES:
 		case AMDGPU_CHUNK_ID_SYNCOBJ_IN:
 		case AMDGPU_CHUNK_ID_SYNCOBJ_OUT:
+		case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
 			break;
 
 		default:
@@ -1090,6 +1091,14 @@ static int amdgpu_cs_process_fence_dep(struct amdgpu_cs_parser *p,
 
 		fence = amdgpu_ctx_get_fence(ctx, entity,
 					     deps[i].handle);
+
+		if (chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
+			struct drm_sched_fence *s_fence = to_drm_sched_fence(fence);
+
+			dma_fence_put(fence);
+			fence = dma_fence_get(&s_fence->scheduled);
+		}
+
 		if (IS_ERR(fence)) {
 			r = PTR_ERR(fence);
 			amdgpu_ctx_put(ctx);
@@ -1177,7 +1186,8 @@ static int amdgpu_cs_dependencies(struct amdgpu_device *adev,
 
 		chunk = &p->chunks[i];
 
-		if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES) {
+		if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES ||
+		    chunk->chunk_id == AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
 			r = amdgpu_cs_process_fence_dep(p, chunk);
 			if (r)
 				return r;
include/uapi/drm/amdgpu_drm.h +1 -0
index faaad04..43d03a2 100644
@@ -526,6 +526,7 @@ struct drm_amdgpu_gem_va {
 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
 #define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
+#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES	0x07
 
 struct drm_amdgpu_cs_chunk {
 	__u32		chunk_id;
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): 1549051196-25609-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

Reviewed-by Tested-by
#4 lore raw
Quoted 72 lines · Andrey Grodzovsky

New chunk for dependency on start of job's execution instead on the end. This is used for GPU deadlock prevention when userspace uses mid-IB fences to wait for mid-IB work on other rings.

v2: Fix typo in AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 12 +++++++++++-
 include/uapi/drm/amdgpu_drm.h          |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 1c49b82..3f21eca 100644
@@ -214,6 +214,7 @@ static int amdgpu_cs_parser_init(struct

amdgpu_cs_parser *p, union drm_amdgpu_cs
case AMDGPU_CHUNK_ID_DEPENDENCIES:
case AMDGPU_CHUNK_ID_SYNCOBJ_IN:
case AMDGPU_CHUNK_ID_SYNCOBJ_OUT:

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9 -0
+               case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
                        break;
 
                default:
@@ -1090,6 +1091,14 @@ static int amdgpu_cs_process_fence_dep(struct
 amdgpu_cs_parser *p,
 
                fence = amdgpu_ctx_get_fence(ctx, entity,
                                             deps[i].handle);
+
+               if (chunk->chunk_id ==
 AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
+                       struct drm_sched_fence *s_fence =
 to_drm_sched_fence(fence);
+
+                       dma_fence_put(fence);
+                       fence = dma_fence_get(&s_fence->scheduled);
+               }
+
                if (IS_ERR(fence)) {
                        r = PTR_ERR(fence);
                        amdgpu_ctx_put(ctx);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -1
@@ -1177,7 +1186,8 @@ static int amdgpu_cs_dependencies(struct
 amdgpu_device *adev,
 
                chunk = &p->chunks[i];
 
-               if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES) {
+               if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES ||
+                   chunk->chunk_id ==
 AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
                        r = amdgpu_cs_process_fence_dep(p, chunk);
                        if (r)
                                return r;
include/uapi/drm/amdgpu_drm.h +1 -1
index faaad04..43d03a2 100644
@@ -526,6 +526,7 @@ struct drm_amdgpu_gem_va {
 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
 #define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
+#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
 
 struct drm_amdgpu_cs_chunk {
        __u32           chunk_id;
--

2.7.4

Quoted 5 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

A message that is not in the archive (sent off-list or not yet received): CAAxE2A6EnRR4OUJkspWqdhDqHiJuTevW+=G+YycyOrnxtLGiuw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Can you also bump the KMS version?

Thanks,
Marek

Quoted 78 lines · Marek Olšák
Quoted 72 lines · Andrey Grodzovsky

New chunk for dependency on start of job's execution instead on the end. This is used for GPU deadlock prevention when userspace uses mid-IB fences to wait for mid-IB work on other rings.

v2: Fix typo in AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 12 +++++++++++-
 include/uapi/drm/amdgpu_drm.h          |  1 +
 2 files changed, 12 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
index 1c49b82..3f21eca 100644
@@ -214,6 +214,7 @@ static int amdgpu_cs_parser_init(struct

amdgpu_cs_parser *p, union drm_amdgpu_cs
case AMDGPU_CHUNK_ID_DEPENDENCIES:
case AMDGPU_CHUNK_ID_SYNCOBJ_IN:
case AMDGPU_CHUNK_ID_SYNCOBJ_OUT:

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +9 -0
+               case AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES:
                        break;
 
                default:
@@ -1090,6 +1091,14 @@ static int amdgpu_cs_process_fence_dep(struct
 amdgpu_cs_parser *p,
 
                fence = amdgpu_ctx_get_fence(ctx, entity,
                                             deps[i].handle);
+
+               if (chunk->chunk_id ==
 AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
+                       struct drm_sched_fence *s_fence =
 to_drm_sched_fence(fence);
+
+                       dma_fence_put(fence);
+                       fence = dma_fence_get(&s_fence->scheduled);
+               }
+
                if (IS_ERR(fence)) {
                        r = PTR_ERR(fence);
                        amdgpu_ctx_put(ctx);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -1
@@ -1177,7 +1186,8 @@ static int amdgpu_cs_dependencies(struct
 amdgpu_device *adev,
 
                chunk = &p->chunks[i];
 
-               if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES) {
+               if (chunk->chunk_id == AMDGPU_CHUNK_ID_DEPENDENCIES ||
+                   chunk->chunk_id ==
 AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES) {
                        r = amdgpu_cs_process_fence_dep(p, chunk);
                        if (r)
                                return r;
include/uapi/drm/amdgpu_drm.h +1 -1
index faaad04..43d03a2 100644
@@ -526,6 +526,7 @@ struct drm_amdgpu_gem_va {
 #define AMDGPU_CHUNK_ID_SYNCOBJ_IN      0x04
 #define AMDGPU_CHUNK_ID_SYNCOBJ_OUT     0x05
 #define AMDGPU_CHUNK_ID_BO_HANDLES      0x06
+#define AMDGPU_CHUNK_ID_SCHEDULED_DEPENDENCIES 0x07
 
 struct drm_amdgpu_cs_chunk {
        __u32           chunk_id;
--

2.7.4

Quoted 6 lines
Quoted 5 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