drm/amdgpu:fix race condition
Subsystems (2)
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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3 -0
@@ -277,6 +277,9 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,spin_lock (&ctx->ring_lock); +if (seq == ~0 ) + seq = ctx->rings[ring->idx].sequence -1 ; +if (seq >= cring->sequence) {spin_unlock (&ctx->ring_lock);return ERR_PTR (-EINVAL );
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): 1491809988-26981-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org
Am 10.04.2017 um 09:39 schrieb Monk Liu:
Quoted 5 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.
Well you are still not using ~0ull as I said. Using ~0 here will cause 0xffffffff to be used instead of 0xffffffffffffffff.
Additional to that please add a define into amdgpu_drm.h to document this interface change.
Christian.
Quoted 12 lines
Change-Id Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1adSigned-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0
-0
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx, · line 285
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3
-0@@ -277,6 +277,9 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,spin_lock (&ctx->ring_lock); +if (seq == ~0 ) + seq = ctx->rings[ring->idx].sequence -1 ; +if (seq >= cring->sequence) {spin_unlock (&ctx->ring_lock);return ERR_PTR (-EINVAL );
_______________________________________________
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): 7761bfd7-c34f-f21a-650e-fcc41d722245-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org
Is that so ?
Seq is already type of "uint64_t", GCC still compiles ~0 as 0xffffffff, but not 0xffffffffffffffff ? I'll change to use ~0ull anyway,
BR Monk
-----邮件原件-----
发件人: Christian König [mailto:[email protected]] 发送时间: Monday, April 10, 2017 4:10 PM
收件人: Liu, Monk <[email protected]>; [email protected] 主题: Re: [PATCH] drm/amdgpu:fix race condition
Am 10.04.2017 um 09:39 schrieb Monk Liu:
Quoted 4 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.
Well you are still not using ~0ull as I said. Using ~0 here will cause 0xffffffff to be used instead of 0xffffffffffffffff.
Additional to that please add a define into amdgpu_drm.h to document this interface change.
Christian.
Quoted 22 lines
Change-Id Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1adSigned-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3
-0@@ -277,6 +277,9 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,spin_lock (&ctx->ring_lock); +if (seq == ~0 ) + seq = ctx->rings[ring->idx].sequence -1 ; +if (seq >= cring->sequence) {spin_unlock (&ctx->ring_lock);
Quoted 1 line
return ERR_PTR(-EINVAL);
_______________________________________________
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): DM5PR12MB1610C70F02FD5904AEF06DD684010-2J9CzHegvk++jCVTvoAFKAdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org
Am 10.04.2017 um 12:16 schrieb Liu, Monk:
Quoted 3 lines
Is that so ?
Seq is already type of "
uint64_t", GCC still compiles ~0 as0xffffffff, but not0xffffffffffffffff?
You mean that it sign extend the value? Good point, that could be as well.
Quoted 1 line
I'll change to use ~0ull anyway,
Yeah, that should make it a bit more clear what happens here.
Christian.
Quoted 37 lines
BR Monk
-----邮件原件-----
发件人: Christian König [mailto:[email protected]] 发送时间: Monday, April 10, 2017 4:10 PM
收件人: Liu, Monk <[email protected]>; [email protected] 主题: Re: [PATCH] drm/amdgpu:fix race conditionAm 10.04.2017 um 09:39 schrieb Monk Liu:
Quoted 4 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.
Well you are still not using ~0ull as I said. Using ~0 here will cause
0xffffffffto be used instead of0xffffffffffffffff.Additional to that please add a define into
amdgpu_drm.hto document this interface change.Christian.
Quoted 16 lines
Change-Id Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1adSigned-off-by Monk Liu <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +0
-0@@ -277,6 +277,9 @@ struct fence *amdgpu_ctx_get_fence(struct amdgpu_ctx *ctx,spin_lock (&ctx->ring_lock);
Quoted 11 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +3
-0+if (seq == ~0 ) + seq = ctx->rings[ring->idx].sequence -1 ; +if (seq >= cring->sequence) {spin_unlock (&ctx->ring_lock);return ERR_PTR(-EINVAL);_______________________________________________
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