Skip to contentSkip to conversation

drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

PATCH In review Christian König 3 participants 8 messages Sep 5, 2017 – Sep 6, 2017 6 messages not in the archive

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

PATCH 1/1 drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

From: Christian König <[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -4
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
 	cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
 	job->uf_sequence = cs->out.handle;
 	amdgpu_job_free_resources(job);
-	amdgpu_cs_parser_fini(p, 0, true);
 
 	trace_amdgpu_cs_ioctl(job);
 	amd_sched_entity_push_job(&job->base);
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
 		goto out;
 
 	r = amdgpu_cs_submit(&parser, cs);
-	if (r)
-		goto out;
 
-	return 0;
 out:
 	amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
 	return r;
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): 1504617263-7210-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#2 lore raw

+Monk.

Moving push_job out of reservation lock indeed not a good idea.

Hi Monk,

How about Christian's revert?

Regards,
David Zhou

Quoted 31 lines · Christian König

From: Christian König <[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
  1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -1
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
  	cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
  	job->uf_sequence = cs->out.handle;
  	amdgpu_job_free_resources(job);
-	amdgpu_cs_parser_fini(p, 0, true);
 
  	trace_amdgpu_cs_ioctl(job);
  	amd_sched_entity_push_job(&job->base);

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1125

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -3
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
  		goto out;
 
  	r = amdgpu_cs_submit(&parser, cs);
-	if (r)
-		goto out;
 
-	return 0;
  out:
  	amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
  	return r;

_______________________________________________
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): 97ae6951-c278-4d6f-82e2-d6716cebf12c-5C7GfCeVMHo@public.gmane.org

#4 lore raw

BTW: I'm working of fixing the underlying issue in general.

But this is going to need some more time.

Regards,
Christian.

Am 06.09.2017 um 05:08 schrieb zhoucm1:

Quoted 49 lines

+Monk.

Moving push_job out of reservation lock indeed not a good idea.

Hi Monk,

How about Christian's revert?

Regards,
David Zhou

Quoted 37 lines · Christian König

From: Christian König <[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
  1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -3
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct 
 amdgpu_cs_parser *p,
      cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
      job->uf_sequence = cs->out.handle;
      amdgpu_job_free_resources(job);
-    amdgpu_cs_parser_fini(p, 0, true);
        trace_amdgpu_cs_ioctl(job);
      amd_sched_entity_push_job(&job->base);
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, 
 void *data, struct drm_file *filp)
          goto out;
        r = amdgpu_cs_submit(&parser, cs);
-    if (r)
-        goto out;
  -    return 0;
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp) · line 1125

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -0
  out:
      amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
      return r;

_______________________________________________
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

#5 lore raw
In reply to a message not in the archive
Quoted 1 line

The patch doesn't work at all:

1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

I suddenly found that the parser->job is really a wild pointer:

    amdgpu_cs_parser_fini(p, 0, true);

    trace_amdgpu_cs_ioctl(job);
    amd_sched_entity_push_job(&job->base);

so "cs_parser_fini" cannot be called before "entity_push_job", that part is correct

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

BR Monk

________________________________
From: amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]>
Sent: Tuesday, September 5, 2017 9:14:23 PM
To: [email protected]; Zhou, David(ChunMing)
Subject: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

From: Christian König <[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -4
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
         cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
         job->uf_sequence = cs->out.handle;
         amdgpu_job_free_resources(job);
-       amdgpu_cs_parser_fini(p, 0, true);
 
         trace_amdgpu_cs_ioctl(job);
         amd_sched_entity_push_job(&job->base);
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
                 goto out;
 
         r = amdgpu_cs_submit(&parser, cs);
-       if (r)
-               goto out;
 
-       return 0;
 out:
         amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
         return r;

--
2.7.4

_______________________________________________
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): BLUPR12MB044977C621578CDB0427B52584970-7LeqcoF/[email protected]

#7 lore raw
Quoted 3 lines

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

See amdgpu_ctx_add_fence(), it can block for previous command submissions just like entity_push_job(). So only moving entity_push_job() out of locking the PD doesn't help at all.

Quoted 3 lines

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

The problem isn't parser->job, but rather that the job is referencing the entity which is part of the context and we already called amdgpu_ctx_put() on that one.

Regards,
Christian.

Am 06.09.2017 um 10:04 schrieb Liu, Monk:

Quoted 78 lines
Quoted 2 lines

The patch doesn't work at all:

1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

I suddenly found that the parser->job is really a wild pointer:

amdgpu_cs_parser_fini(p, 0, true);
trace_amdgpu_cs_ioctl(job);
amd_sched_entity_push_job(&job->base);

so "cs_parser_fini" cannot be called before "entity_push_job", that part is correct

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

BR Monk

------------------------------------------------------------------------
*From:* amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]> *Sent:* Tuesday, September 5, 2017 9:14:23 PM
*To:* [email protected]; Zhou, David(ChunMing)
*Subject:* [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"
From: Christian König <[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -1
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct 
 amdgpu_cs_parser *p,
         cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
         job->uf_sequence = cs->out.handle;
         amdgpu_job_free_resources(job);
-       amdgpu_cs_parser_fini(p, 0, true);
 
         trace_amdgpu_cs_ioctl(job);
         amd_sched_entity_push_job(&job->base);
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -3
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, 
 void *data, struct drm_file *filp)
                 goto out;
 
         r = amdgpu_cs_submit(&parser, cs);
-       if (r)
-               goto out;
 
-       return 0;
 out:
         amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
Quoted 14 lines
         return r;
Signature · 12 lines
2.7.4

_______________________________________________
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

_______________________________________________
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): cd51ddcb-c27b-93fa-a10a-d41c4a0b8014-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

#9 lore raw

Yeah, you are right, although it has 32 slots (compared with entit_push_job which only waits for two slots in gpu scheduler) but still have chance to wait and meanwhile one job could under processing by gpu reset

What’s you plan ?

Revert this patch is correct since it have potential dirty reference, but how we need another patch to walk around this PD reservation dead lock

BR Monk

From: Christian König [mailto:[email protected]]
Sent: 2017年9月6日 16:20
To: Liu, Monk <[email protected]>; [email protected]; Zhou, David(ChunMing) <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."
See amdgpu_ctx_add_fence(), it can block for previous command submissions just like entity_push_job(). So only moving entity_push_job() out of locking the PD doesn't help at all.

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...
The problem isn't parser->job, but rather that the job is referencing the entity which is part of the context and we already called amdgpu_ctx_put() on that one.

Regards,
Christian.

Am 06.09.2017 um 10:04 schrieb Liu, Monk:

Quoted 1 line

The patch doesn't work at all:

1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

I suddenly found that the parser->job is really a wild pointer:

amdgpu_cs_parser_fini(p,
0, true);

    trace_amdgpu_cs_ioctl(job);

    amd_sched_entity_push_job(&job->base);

so "cs_parser_fini" cannot be called before "entity_push_job", that part is correct

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

BR Monk

________________________________
From: amd-gfx <[email protected]><mailto:[email protected]> on behalf of Christian König <[email protected]><mailto:[email protected]>
Sent: Tuesday, September 5, 2017 9:14:23 PM
To: [email protected]<mailto:[email protected]>; Zhou, David(ChunMing)
Subject: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

From: Christian König <[email protected]><mailto:[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -4
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
         cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
         job->uf_sequence = cs->out.handle;
         amdgpu_job_free_resources(job);
-       amdgpu_cs_parser_fini(p, 0, true);
 
         trace_amdgpu_cs_ioctl(job);
         amd_sched_entity_push_job(&job->base);
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
                 goto out;
 
         r = amdgpu_cs_submit(&parser, cs);
-       if (r)
-               goto out;
 
-       return 0;
 out:
         amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
         return r;

--
2.7.4

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

_______________________________________________

amd-gfx mailing list

[email protected]<mailto:[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): BLUPR12MB04494AA6CEDAB5CC5CDF286D84970-7LeqcoF/[email protected]

#11 lore raw
Quoted 1 line

What’s you plan ?

Not 100% sure yet. I need to move the fencing around to fix userptrs anyway.

When I'm done with that and when the UVD/VCE stuff is fixed then I'm going to tackle this next.

Regards,
Christian.

Am 06.09.2017 um 11:25 schrieb Liu, Monk:

Quoted 143 lines

Yeah, you are right, although it has 32 slots (compared with entit_push_job which only waits for two slots in gpu scheduler) but still have chance to wait and meanwhile one job could under processing by gpu reset

What’s you plan ?

Revert this patch is correct since it have potential dirty reference, but how we need another patch to walk around this PD reservation dead lock

BR Monk

*From:*Christian König [mailto:[email protected]]
*Sent:* 2017年9月6日16:20
*To:* Liu, Monk <[email protected]>; [email protected]; Zhou, David(ChunMing) <[email protected]> *Subject:* Re: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

See amdgpu_ctx_add_fence(), it can block for previous command submissions just like entity_push_job(). So only moving entity_push_job() out of locking the PD doesn't help at all.

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

The problem isn't parser->job, but rather that the job is referencing the entity which is part of the context and we already called amdgpu_ctx_put() on that one.

Regards,
Christian.

Am 06.09.2017 um 10:04 schrieb Liu, Monk:

Quoted 1 line

The patch doesn't work at all:

1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

I suddenly found that the parser->job is really a wild pointer:

amdgpu_cs_parser_fini(p,

0, true);

trace_amdgpu_cs_ioctl(job);

amd_sched_entity_push_job(&job->base);

so "cs_parser_fini" cannot be called before "entity_push_job", that part is correct

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

BR Monk

------------------------------------------------------------------------

*From:*amd-gfx <amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> <mailto:amd-gfx-bounces-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org> on behalf of Christian König <[email protected]> <mailto:[email protected]>
*Sent:* Tuesday, September 5, 2017 9:14:23 PM
*To:* [email protected] <mailto:[email protected]>; Zhou, David(ChunMing) *Subject:* [PATCH] drm/amdgpu: revert "fix deadlock of reservation
between cs and gpu reset v2"

From: Christian König <[email protected]> <mailto:[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO
handling, but this is a larger task just avoid the obvious crashes for now.

<mailto:[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ---- 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
index b96776c..2db4010 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring,
p->fence);
job->uf_sequence = cs->out.handle; amdgpu_job_free_resources(job);
- amdgpu_cs_parser_fini(p, 0, true);

trace_amdgpu_cs_ioctl(job); amd_sched_entity_push_job(&job->base);
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
goto out;

r = amdgpu_cs_submit(&parser, cs);
- if (r)
- goto out;

- return 0;
out:
amdgpu_cs_parser_fini(&parser, r, reserved_buffers); return r;
--
2.7.4

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

_______________________________________________

amd-gfx mailing list

[email protected] <mailto:[email protected]>

Quoted 8 lines

https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
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): 8797925e-0533-846e-2e46-55293b1b05c1-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org

Reviewed-by Monk Liu [email protected]
#13 lore raw

I’m thinking of directly call “ttm_eu_fence_buffer_object” before ctx_ad_fence(), and right after “fence_get(&job->base.s_fence->finished);” Since that time we already have parser->ticket/validated/fence,

BR Monk

From: Christian König [mailto:[email protected]]
Sent: 2017年9月6日 17:33
To: Liu, Monk <[email protected]>; [email protected]; Zhou, David(ChunMing) <[email protected]>
Subject: Re: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

What’s you plan ?
Not 100% sure yet. I need to move the fencing around to fix userptrs anyway.

When I'm done with that and when the UVD/VCE stuff is fixed then I'm going to tackle this next.

Regards,
Christian.

Am 06.09.2017 um 11:25 schrieb Liu, Monk:
Yeah, you are right, although it has 32 slots (compared with entit_push_job which only waits for two slots in gpu scheduler) but still have chance to wait and meanwhile one job could under processing by gpu reset

What’s you plan ?

Revert this patch is correct since it have potential dirty reference, but how we need another patch to walk around this PD reservation dead lock

BR Monk

From: Christian König [mailto:[email protected]]
Sent: 2017年9月6日 16:20
To: Liu, Monk <[email protected]><mailto:[email protected]>; [email protected]<mailto:[email protected]>; Zhou, David(ChunMing) <[email protected]><mailto:[email protected]>
Subject: Re: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."
See amdgpu_ctx_add_fence(), it can block for previous command submissions just like entity_push_job(). So only moving entity_push_job() out of locking the PD doesn't help at all.

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...
The problem isn't parser->job, but rather that the job is referencing the entity which is part of the context and we already called amdgpu_ctx_put() on that one.

Regards,
Christian.

Am 06.09.2017 um 10:04 schrieb Liu, Monk:

Quoted 1 line

The patch doesn't work at all:

1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

I suddenly found that the parser->job is really a wild pointer:

amdgpu_cs_parser_fini(p,
0, true);

    trace_amdgpu_cs_ioctl(job);

    amd_sched_entity_push_job(&job->base);

so "cs_parser_fini" cannot be called before "entity_push_job", that part is correct

but how to understand 1)

what do you mean "The CS can still be blocked because of amdgpu_ctx_add_fence()."

for 2)The order of submission isn't correct any more.

I think since the pointer "job" is already a dirty pointer, meaningless that we talking about it if the order is correct ...

BR Monk

________________________________
From: amd-gfx <[email protected]><mailto:[email protected]> on behalf of Christian König <[email protected]><mailto:[email protected]>
Sent: Tuesday, September 5, 2017 9:14:23 PM
To: [email protected]<mailto:[email protected]>; Zhou, David(ChunMing)
Subject: [PATCH] drm/amdgpu: revert "fix deadlock of reservation between cs and gpu reset v2"

From: Christian König <[email protected]><mailto:[email protected]>

This reverts commit 10e709cb296c98424c03408d23e3addeddcd4088.

The patch doesn't work at all:
1. The CS can still be blocked because of amdgpu_ctx_add_fence().
2. The order of submission isn't correct any more.
3. We could end up using freed up memory because we now drop the ctx reference to early.

This needs to be fixed cleanly by doing the context handling after the BO handling, but this is a larger task just avoid the obvious crashes for now.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +0 -4
index b96776c..2db4010 100644
@@ -1061,7 +1061,6 @@ static int amdgpu_cs_submit(struct amdgpu_cs_parser *p,
         cs->out.handle = amdgpu_ctx_add_fence(p->ctx, ring, p->fence);
         job->uf_sequence = cs->out.handle;
         amdgpu_job_free_resources(job);
-       amdgpu_cs_parser_fini(p, 0, true);
 
         trace_amdgpu_cs_ioctl(job);
         amd_sched_entity_push_job(&job->base);
@@ -1120,10 +1119,7 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
                 goto out;
 
         r = amdgpu_cs_submit(&parser, cs);
-       if (r)
-               goto out;
 
-       return 0;
 out:
         amdgpu_cs_parser_fini(&parser, r, reserved_buffers);
         return r;

--
2.7.4

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

_______________________________________________

amd-gfx mailing list

[email protected]<mailto:[email protected]>

https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________

amd-gfx mailing list

[email protected]<mailto:[email protected]>

https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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