aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_syncobj.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_syncobj.c')
-rw-r--r--drivers/gpu/drm/drm_syncobj.c52
1 files changed, 15 insertions, 37 deletions
diff --git a/drivers/gpu/drm/drm_syncobj.c b/drivers/gpu/drm/drm_syncobj.c
index 497729202bfe..5bcb3ef9b256 100644
--- a/drivers/gpu/drm/drm_syncobj.c
+++ b/drivers/gpu/drm/drm_syncobj.c
@@ -66,20 +66,9 @@ static const char *drm_syncobj_stub_fence_get_name(struct dma_fence *fence)
66 return "syncobjstub"; 66 return "syncobjstub";
67} 67}
68 68
69static bool drm_syncobj_stub_fence_enable_signaling(struct dma_fence *fence)
70{
71 return !dma_fence_is_signaled(fence);
72}
73
74static void drm_syncobj_stub_fence_release(struct dma_fence *f)
75{
76 kfree(f);
77}
78static const struct dma_fence_ops drm_syncobj_stub_fence_ops = { 69static const struct dma_fence_ops drm_syncobj_stub_fence_ops = {
79 .get_driver_name = drm_syncobj_stub_fence_get_name, 70 .get_driver_name = drm_syncobj_stub_fence_get_name,
80 .get_timeline_name = drm_syncobj_stub_fence_get_name, 71 .get_timeline_name = drm_syncobj_stub_fence_get_name,
81 .enable_signaling = drm_syncobj_stub_fence_enable_signaling,
82 .release = drm_syncobj_stub_fence_release,
83}; 72};
84 73
85 74
@@ -683,7 +672,6 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
683{ 672{
684 struct syncobj_wait_entry *entries; 673 struct syncobj_wait_entry *entries;
685 struct dma_fence *fence; 674 struct dma_fence *fence;
686 signed long ret;
687 uint32_t signaled_count, i; 675 uint32_t signaled_count, i;
688 676
689 entries = kcalloc(count, sizeof(*entries), GFP_KERNEL); 677 entries = kcalloc(count, sizeof(*entries), GFP_KERNEL);
@@ -703,7 +691,7 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
703 if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) { 691 if (flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT) {
704 continue; 692 continue;
705 } else { 693 } else {
706 ret = -EINVAL; 694 timeout = -EINVAL;
707 goto cleanup_entries; 695 goto cleanup_entries;
708 } 696 }
709 } 697 }
@@ -715,12 +703,6 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
715 } 703 }
716 } 704 }
717 705
718 /* Initialize ret to the max of timeout and 1. That way, the
719 * default return value indicates a successful wait and not a
720 * timeout.
721 */
722 ret = max_t(signed long, timeout, 1);
723
724 if (signaled_count == count || 706 if (signaled_count == count ||
725 (signaled_count > 0 && 707 (signaled_count > 0 &&
726 !(flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL))) 708 !(flags & DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL)))
@@ -771,18 +753,17 @@ static signed long drm_syncobj_array_wait_timeout(struct drm_syncobj **syncobjs,
771 goto done_waiting; 753 goto done_waiting;
772 754
773 if (timeout == 0) { 755 if (timeout == 0) {
774 /* If we are doing a 0 timeout wait and we got 756 timeout = -ETIME;
775 * here, then we just timed out.
776 */
777 ret = 0;
778 goto done_waiting; 757 goto done_waiting;
779 } 758 }
780 759
781 ret = schedule_timeout(ret); 760 if (signal_pending(current)) {
761 timeout = -ERESTARTSYS;
762 goto done_waiting;
763 }
782 764
783 if (ret > 0 && signal_pending(current)) 765 timeout = schedule_timeout(timeout);
784 ret = -ERESTARTSYS; 766 } while (1);
785 } while (ret > 0);
786 767
787done_waiting: 768done_waiting:
788 __set_current_state(TASK_RUNNING); 769 __set_current_state(TASK_RUNNING);
@@ -799,7 +780,7 @@ cleanup_entries:
799 } 780 }
800 kfree(entries); 781 kfree(entries);
801 782
802 return ret; 783 return timeout;
803} 784}
804 785
805/** 786/**
@@ -840,19 +821,16 @@ static int drm_syncobj_array_wait(struct drm_device *dev,
840 struct drm_syncobj **syncobjs) 821 struct drm_syncobj **syncobjs)
841{ 822{
842 signed long timeout = drm_timeout_abs_to_jiffies(wait->timeout_nsec); 823 signed long timeout = drm_timeout_abs_to_jiffies(wait->timeout_nsec);
843 signed long ret = 0;
844 uint32_t first = ~0; 824 uint32_t first = ~0;
845 825
846 ret = drm_syncobj_array_wait_timeout(syncobjs, 826 timeout = drm_syncobj_array_wait_timeout(syncobjs,
847 wait->count_handles, 827 wait->count_handles,
848 wait->flags, 828 wait->flags,
849 timeout, &first); 829 timeout, &first);
850 if (ret < 0) 830 if (timeout < 0)
851 return ret; 831 return timeout;
852 832
853 wait->first_signaled = first; 833 wait->first_signaled = first;
854 if (ret == 0)
855 return -ETIME;
856 return 0; 834 return 0;
857} 835}
858 836