Skip to contentSkip to conversation

drm/amdgpu: initialize the context reset_counter in amdgpu_ctx_init

PATCH In review Nicolai Hähnle 5 participants 7 messages Oct 4, 2016 – Oct 6, 2016 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: initialize the context reset_counter in amdgpu_ctx_init

From: Nicolai Hähnle <[email protected]>

Ensure that we really only report a GPU reset if one has happened since the creation of the context.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
index e203e55..a5e2fcb 100644
@@ -36,20 +36,23 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx)
 	spin_lock_init(&ctx->ring_lock);
 	ctx->fences = kcalloc(amdgpu_sched_jobs * AMDGPU_MAX_RINGS,
 			      sizeof(struct fence*), GFP_KERNEL);
 	if (!ctx->fences)
 		return -ENOMEM;
 
 	for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
 		ctx->rings[i].sequence = 1;
 		ctx->rings[i].fences = &ctx->fences[amdgpu_sched_jobs * i];
 	}
+
+	ctx->reset_counter = atomic_read(&adev->gpu_reset_counter);
+
 	/* create context entity for each ring */
 	for (i = 0; i < adev->num_rings; i++) {
 		struct amdgpu_ring *ring = adev->rings[i];
 		struct amd_sched_rq *rq;
 
 		rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL];
 		r = amd_sched_entity_init(&ring->sched, &ctx->rings[i].entity,
 					  rq, amdgpu_sched_jobs);
 		if (r)
 			break;
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): 1475567106-5818-1-git-send-email-nhaehnle-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

Reviewed-by
#2 lore raw

Am 04.10.2016 um 09:45 schrieb Nicolai Hähnle:

Quoted 6 lines

From: Nicolai Hähnle <[email protected]>

Ensure that we really only report a GPU reset if one has happened since the creation of the context.

Quoted 22 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
index e203e55..a5e2fcb 100644
@@ -36,20 +36,23 @@ static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx)
  	spin_lock_init(&ctx->ring_lock);
  	ctx->fences = kcalloc(amdgpu_sched_jobs * AMDGPU_MAX_RINGS,
  			      sizeof(struct fence*), GFP_KERNEL);
  	if (!ctx->fences)
  		return -ENOMEM;
 
  	for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
  		ctx->rings[i].sequence = 1;
  		ctx->rings[i].fences = &ctx->fences[amdgpu_sched_jobs * i];
  	}
+
+	ctx->reset_counter = atomic_read(&adev->gpu_reset_counter);
+

drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c static int amdgpu_ctx_init(struct amdgpu_device *adev, struct amdgpu_ctx *ctx) · line 58

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0 -0
  	/* create context entity for each ring */
  	for (i = 0; i < adev->num_rings; i++) {
  		struct amdgpu_ring *ring = adev->rings[i];
  		struct amd_sched_rq *rq;
 
  		rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL];
  		r = amd_sched_entity_init(&ring->sched, &ctx->rings[i].entity,
  					  rq, amdgpu_sched_jobs);
  		if (r)
  			break;

_______________________________________________
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): 2d749b1b-5d1b-f0bc-502b-358acf09e04a-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#4 lore raw

Do we need to bump the DRM version for this bug fix?

Marek

Quoted 46 lines · Christian König

Am 04.10.2016 um 09:45 schrieb Nicolai Hähnle:

Quoted 8 lines

From: Nicolai Hähnle <[email protected]>

Ensure that we really only report a GPU reset if one has happened since the
creation of the context.

---

Quoted 32 lines
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
index e203e55..a5e2fcb 100644
@@ -36,20 +36,23 @@ static int amdgpu_ctx_init(struct amdgpu_device
 *adev, struct amdgpu_ctx *ctx)
        spin_lock_init(&ctx->ring_lock);
        ctx->fences = kcalloc(amdgpu_sched_jobs * AMDGPU_MAX_RINGS,
                              sizeof(struct fence*), GFP_KERNEL);
        if (!ctx->fences)
                return -ENOMEM;
        for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
                ctx->rings[i].sequence = 1;
                ctx->rings[i].fences = &ctx->fences[amdgpu_sched_jobs *
 i];
        }
+
+       ctx->reset_counter = atomic_read(&adev->gpu_reset_counter);
+
        /* create context entity for each ring */
        for (i = 0; i < adev->num_rings; i++) {
                struct amdgpu_ring *ring = adev->rings[i];
                struct amd_sched_rq *rq;
                rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL];
                r = amd_sched_entity_init(&ring->sched,
 &ctx->rings[i].entity,
                                          rq, amdgpu_sched_jobs);
                if (r)
Quoted 9 lines
Quoted 2 lines
                        break;

_______________________________________________
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): CAAxE2A55JNWJ3hP5MtbHA=Jz_5bKQDnfvvTrwvW-g2LiDf8TrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw
Quoted 2 lines · Marek Olšák

Do we need to bump the DRM version for this bug fix?

Alternatively, we could just cc stable. Being that the whole reset handling is mesa is till kind of up in the air, I'm not sure how critical it is.

Alex

Quoted 61 lines

Marek

Quoted 47 lines · Christian König

Am 04.10.2016 um 09:45 schrieb Nicolai Hähnle:

Quoted 8 lines

From: Nicolai Hähnle <[email protected]>

Ensure that we really only report a GPU reset if one has happened since the
creation of the context.

Quoted 33 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
index e203e55..a5e2fcb 100644
@@ -36,20 +36,23 @@ static int amdgpu_ctx_init(struct amdgpu_device
 *adev, struct amdgpu_ctx *ctx)
        spin_lock_init(&ctx->ring_lock);
        ctx->fences = kcalloc(amdgpu_sched_jobs * AMDGPU_MAX_RINGS,
                              sizeof(struct fence*), GFP_KERNEL);
        if (!ctx->fences)
                return -ENOMEM;
        for (i = 0; i < AMDGPU_MAX_RINGS; ++i) {
                ctx->rings[i].sequence = 1;
                ctx->rings[i].fences = &ctx->fences[amdgpu_sched_jobs *
 i];
        }
+
+       ctx->reset_counter = atomic_read(&adev->gpu_reset_counter);
+
        /* create context entity for each ring */
        for (i = 0; i < adev->num_rings; i++) {
                struct amdgpu_ring *ring = adev->rings[i];
                struct amd_sched_rq *rq;
                rq = &ring->sched.sched_rq[AMD_SCHED_PRIORITY_NORMAL];
                r = amd_sched_entity_init(&ring->sched,
 &ctx->rings[i].entity,
                                          rq, amdgpu_sched_jobs);
                if (r)
Quoted 8 lines
Quoted 1 line
                        break;

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

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): CADnq5_O8-D7hS5riU-7izo-jxh7fLTMYfpevcbBJqJHbKmKXjQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#8 lore raw
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Marek Olšák

Do we need to bump the DRM version for this bug fix?

Alternatively, we could just cc stable. Being that the whole reset handling is mesa is till kind of up in the air, I'm not sure how critical it is.

The Mesa part is actually complete. The problem is that if an application requests the GL_LOSE_CONTEXT_ON_RESET strategy, an incorrect reset counter returned by the kernel will automatically kill the OpenGL context (by setting the no-op dispatch), so it's a pretty serious issue and the kernel should return correct values regardless of the state of GPU reset there. If the kernel returns an incorrect reset counter, we need a version bump for the fix.

Marek
_______________________________________________
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): CAAxE2A6FHmQhfzxAiq9-pMi+LkyJ6PAqvZi_-MV-xX1sZ_vv-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#10 lore raw
Quoted 9 lines · Marek Olšák
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Marek Olšák

Do we need to bump the DRM version for this bug fix?

Alternatively, we could just cc stable. Being that the whole reset handling is mesa is till kind of up in the air, I'm not sure how critical it is.

Quoted 7 lines

The Mesa part is actually complete. The problem is that if an application requests the GL_LOSE_CONTEXT_ON_RESET strategy, an incorrect reset counter returned by the kernel will automatically kill the OpenGL context (by setting the no-op dispatch), so it's a pretty serious issue and the kernel should return correct values regardless of the state of GPU reset there. If the kernel returns an incorrect reset counter, we need a version bump for the fix.

Yeah, that seems to be the safest solution.

Nicolai

Quoted 3 lines

Marek

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

#11 lore raw
In reply to a message not in the archive
Quoted 9 lines · Marek Olšák
Quoted 7 lines · Alex Deucher
Quoted 2 lines · Marek Olšák

Do we need to bump the DRM version for this bug fix?

Alternatively, we could just cc stable. Being that the whole reset handling is mesa is till kind of up in the air, I'm not sure how critical it is.

Quoted 7 lines

The Mesa part is actually complete. The problem is that if an application requests the GL_LOSE_CONTEXT_ON_RESET strategy, an incorrect reset counter returned by the kernel will automatically kill the OpenGL context (by setting the no-op dispatch), so it's a pretty serious issue and the kernel should return correct values regardless of the state of GPU reset there. If the kernel returns an incorrect reset counter, we need a version bump for the fix.

GPU reset is currently disabled by default so the counter should never change at this point.

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