Re: 答复: [PATCH] drm/amdgpu:fix race condition

Christian König deathsimple at vodafone.de
Mon Apr 10 10:17:43 UTC 2017


Am 10.04.2017 um 12:16 schrieb Liu, Monk:
> Is that so ?
>
> Seq is already type of "uint64_t", GCC still compiles ~0 as 0xffffffff, but not 0xffffffffffffffff ?

You mean that it sign extend the value? Good point, that could be as well.

> I'll change to use ~0ull anyway,

Yeah, that should make it a bit more clear what happens here.

Christian.

>
> BR Monk
>
>
> -----邮件原件-----
> 发件人: Christian König [mailto:deathsimple at vodafone.de]
> 发送时间: Monday, April 10, 2017 4:10 PM
> 收件人: Liu, Monk <Monk.Liu at amd.com>; amd-gfx at lists.freedesktop.org
> 主题: Re: [PATCH] drm/amdgpu:fix race condition
>
> Am 10.04.2017 um 09:39 schrieb Monk Liu:
>> 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.
>
>> Change-Id: Ib7a03f3cf5594deeb4ad333cc59b47a6bddfd1ad
>> Signed-off-by: Monk Liu <Monk.Liu at amd.com>
>> ---
>>    drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 3 +++
>>    1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> index 6d86eae..c24bb90 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> @@ -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
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx




More information about the amd-gfx mailing list