drm/amdgpu: fix type mismatch error
authormonk.liu <monk.liu@amd.com>
Wed, 12 Aug 2015 09:56:52 +0000 (17:56 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 17 Aug 2015 20:51:18 +0000 (16:51 -0400)
remaining timeout returned by amdgpu_fence_wait_any can be larger than
max int value, thus the truncated 32 bit value in r ends up being
negative while its original long value is positive.

Signed-off-by: monk.liu <monk.liu@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Jammy Zhou <jammy.zhou@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c

index c5b17262529d45b37a0c3f5e34232416ba95b4b3..d6398cf45f2400d1c24ed54ac0f5168fdbdc1662 100644 (file)
@@ -318,6 +318,7 @@ int amdgpu_sa_bo_new(struct amdgpu_device *adev,
        struct amdgpu_fence *fences[AMDGPU_MAX_RINGS];
        unsigned tries[AMDGPU_MAX_RINGS];
        int i, r;
+       signed long t;
 
        BUG_ON(align > sa_manager->align);
        BUG_ON(size > sa_manager->size);
@@ -351,8 +352,8 @@ int amdgpu_sa_bo_new(struct amdgpu_device *adev,
                } while (amdgpu_sa_bo_next_hole(sa_manager, fences, tries));
 
                spin_unlock(&sa_manager->wq.lock);
-               r = amdgpu_fence_wait_any(adev, fences, false, MAX_SCHEDULE_TIMEOUT);
-               r = (r > 0) ? 0 : r;
+               t = amdgpu_fence_wait_any(adev, fences, false, MAX_SCHEDULE_TIMEOUT);
+               r = (t > 0) ? 0 : t;
                spin_lock(&sa_manager->wq.lock);
                /* if we have nothing to wait for block */
                if (r == -ENOENT) {