diff options
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 11 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 44 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | 4 |
3 files changed, 16 insertions, 43 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index c6812f2e198e..b66938dbb5cf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -440,12 +440,11 @@ int amdgpu_fence_wait_next(struct amdgpu_ring *ring); | |||
440 | int amdgpu_fence_wait_empty(struct amdgpu_ring *ring); | 440 | int amdgpu_fence_wait_empty(struct amdgpu_ring *ring); |
441 | unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring); | 441 | unsigned amdgpu_fence_count_emitted(struct amdgpu_ring *ring); |
442 | 442 | ||
443 | signed long amdgpu_fence_wait_multiple(struct amdgpu_device *adev, | 443 | signed long amdgpu_fence_wait_any(struct amdgpu_device *adev, |
444 | struct fence **array, | 444 | struct fence **array, |
445 | uint32_t count, | 445 | uint32_t count, |
446 | bool wait_all, | 446 | bool intr, |
447 | bool intr, | 447 | signed long t); |
448 | signed long t); | ||
449 | struct amdgpu_fence *amdgpu_fence_ref(struct amdgpu_fence *fence); | 448 | struct amdgpu_fence *amdgpu_fence_ref(struct amdgpu_fence *fence); |
450 | void amdgpu_fence_unref(struct amdgpu_fence **fence); | 449 | void amdgpu_fence_unref(struct amdgpu_fence **fence); |
451 | 450 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c index f446bf2fedc9..1be2bd6d07ea 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | |||
@@ -851,22 +851,6 @@ static bool amdgpu_test_signaled_any(struct fence **fences, uint32_t count) | |||
851 | return false; | 851 | return false; |
852 | } | 852 | } |
853 | 853 | ||
854 | static bool amdgpu_test_signaled_all(struct fence **fences, uint32_t count) | ||
855 | { | ||
856 | int idx; | ||
857 | struct fence *fence; | ||
858 | |||
859 | for (idx = 0; idx < count; ++idx) { | ||
860 | fence = fences[idx]; | ||
861 | if (fence) { | ||
862 | if (!test_bit(FENCE_FLAG_SIGNALED_BIT, &fence->flags)) | ||
863 | return false; | ||
864 | } | ||
865 | } | ||
866 | |||
867 | return true; | ||
868 | } | ||
869 | |||
870 | struct amdgpu_wait_cb { | 854 | struct amdgpu_wait_cb { |
871 | struct fence_cb base; | 855 | struct fence_cb base; |
872 | struct task_struct *task; | 856 | struct task_struct *task; |
@@ -885,7 +869,7 @@ static signed long amdgpu_fence_default_wait(struct fence *f, bool intr, | |||
885 | struct amdgpu_fence *fence = to_amdgpu_fence(f); | 869 | struct amdgpu_fence *fence = to_amdgpu_fence(f); |
886 | struct amdgpu_device *adev = fence->ring->adev; | 870 | struct amdgpu_device *adev = fence->ring->adev; |
887 | 871 | ||
888 | return amdgpu_fence_wait_multiple(adev, &f, 1, false, intr, t); | 872 | return amdgpu_fence_wait_any(adev, &f, 1, intr, t); |
889 | } | 873 | } |
890 | 874 | ||
891 | /** | 875 | /** |
@@ -894,23 +878,18 @@ static signed long amdgpu_fence_default_wait(struct fence *f, bool intr, | |||
894 | * @adev: amdgpu device | 878 | * @adev: amdgpu device |
895 | * @array: the fence array with amdgpu fence pointer | 879 | * @array: the fence array with amdgpu fence pointer |
896 | * @count: the number of the fence array | 880 | * @count: the number of the fence array |
897 | * @wait_all: the flag of wait all(true) or wait any(false) | ||
898 | * @intr: when sleep, set the current task interruptable or not | 881 | * @intr: when sleep, set the current task interruptable or not |
899 | * @t: timeout to wait | 882 | * @t: timeout to wait |
900 | * | 883 | * |
901 | * If wait_all is true, it will return when all fences are signaled or timeout. | 884 | * It will return when any fence is signaled or timeout. |
902 | * If wait_all is false, it will return when any fence is signaled or timeout. | ||
903 | */ | 885 | */ |
904 | signed long amdgpu_fence_wait_multiple(struct amdgpu_device *adev, | 886 | signed long amdgpu_fence_wait_any(struct amdgpu_device *adev, |
905 | struct fence **array, | 887 | struct fence **array, uint32_t count, |
906 | uint32_t count, | 888 | bool intr, signed long t) |
907 | bool wait_all, | 889 | { |
908 | bool intr, | ||
909 | signed long t) | ||
910 | { | ||
911 | long idx = 0; | ||
912 | struct amdgpu_wait_cb *cb; | 890 | struct amdgpu_wait_cb *cb; |
913 | struct fence *fence; | 891 | struct fence *fence; |
892 | unsigned idx; | ||
914 | 893 | ||
915 | BUG_ON(!array); | 894 | BUG_ON(!array); |
916 | 895 | ||
@@ -927,10 +906,7 @@ signed long amdgpu_fence_wait_multiple(struct amdgpu_device *adev, | |||
927 | if (fence_add_callback(fence, | 906 | if (fence_add_callback(fence, |
928 | &cb[idx].base, amdgpu_fence_wait_cb)) { | 907 | &cb[idx].base, amdgpu_fence_wait_cb)) { |
929 | /* The fence is already signaled */ | 908 | /* The fence is already signaled */ |
930 | if (wait_all) | 909 | goto fence_rm_cb; |
931 | continue; | ||
932 | else | ||
933 | goto fence_rm_cb; | ||
934 | } | 910 | } |
935 | } | 911 | } |
936 | } | 912 | } |
@@ -945,9 +921,7 @@ signed long amdgpu_fence_wait_multiple(struct amdgpu_device *adev, | |||
945 | * amdgpu_test_signaled_any must be called after | 921 | * amdgpu_test_signaled_any must be called after |
946 | * set_current_state to prevent a race with wake_up_process | 922 | * set_current_state to prevent a race with wake_up_process |
947 | */ | 923 | */ |
948 | if (!wait_all && amdgpu_test_signaled_any(array, count)) | 924 | if (amdgpu_test_signaled_any(array, count)) |
949 | break; | ||
950 | if (wait_all && amdgpu_test_signaled_all(array, count)) | ||
951 | break; | 925 | break; |
952 | 926 | ||
953 | if (adev->needs_reset) { | 927 | if (adev->needs_reset) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c index b92525329d6c..74dad270362c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_sa.c | |||
@@ -367,8 +367,8 @@ int amdgpu_sa_bo_new(struct amdgpu_device *adev, | |||
367 | } while (amdgpu_sa_bo_next_hole(sa_manager, fences, tries)); | 367 | } while (amdgpu_sa_bo_next_hole(sa_manager, fences, tries)); |
368 | 368 | ||
369 | spin_unlock(&sa_manager->wq.lock); | 369 | spin_unlock(&sa_manager->wq.lock); |
370 | t = amdgpu_fence_wait_multiple(adev, fences, AMDGPU_MAX_RINGS, false, false, | 370 | t = amdgpu_fence_wait_any(adev, fences, AMDGPU_MAX_RINGS, |
371 | MAX_SCHEDULE_TIMEOUT); | 371 | false, MAX_SCHEDULE_TIMEOUT); |
372 | r = (t > 0) ? 0 : t; | 372 | r = (t > 0) ? 0 : t; |
373 | spin_lock(&sa_manager->wq.lock); | 373 | spin_lock(&sa_manager->wq.lock); |
374 | /* if we have nothing to wait for block */ | 374 | /* if we have nothing to wait for block */ |