diff options
author | Maarten Lankhorst <m.b.lankhorst@gmail.com> | 2013-06-27 07:48:17 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-06-27 22:02:20 -0400 |
commit | ecff665f5e3f1c6909353e00b9420e45ae23d995 (patch) | |
tree | 8fed7d4570ec707427e954c6d2695d1549e08364 /include | |
parent | 786d7257e537da0674c02e16e3b30a44665d1cee (diff) |
drm/ttm: make ttm reservation calls behave like reservation calls
This commit converts the source of the val_seq counter to
the ww_mutex api. The reservation objects are converted later,
because there is still a lockdep splat in nouveau that has to
resolved first.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 2 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 32 | ||||
-rw-r--r-- | include/drm/ttm/ttm_execbuf_util.h | 13 |
3 files changed, 34 insertions, 13 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index 3cb5d848fb66..0a992b016fe9 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -234,7 +234,7 @@ struct ttm_buffer_object { | |||
234 | struct list_head ddestroy; | 234 | struct list_head ddestroy; |
235 | struct list_head swap; | 235 | struct list_head swap; |
236 | struct list_head io_reserve_lru; | 236 | struct list_head io_reserve_lru; |
237 | uint32_t val_seq; | 237 | unsigned long val_seq; |
238 | bool seq_valid; | 238 | bool seq_valid; |
239 | 239 | ||
240 | /** | 240 | /** |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 9c8dca79808e..ec18c5f3e6e9 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -38,6 +38,7 @@ | |||
38 | #include <linux/workqueue.h> | 38 | #include <linux/workqueue.h> |
39 | #include <linux/fs.h> | 39 | #include <linux/fs.h> |
40 | #include <linux/spinlock.h> | 40 | #include <linux/spinlock.h> |
41 | #include <linux/reservation.h> | ||
41 | 42 | ||
42 | struct ttm_backend_func { | 43 | struct ttm_backend_func { |
43 | /** | 44 | /** |
@@ -778,7 +779,7 @@ extern void ttm_mem_io_unlock(struct ttm_mem_type_manager *man); | |||
778 | * @bo: A pointer to a struct ttm_buffer_object. | 779 | * @bo: A pointer to a struct ttm_buffer_object. |
779 | * @interruptible: Sleep interruptible if waiting. | 780 | * @interruptible: Sleep interruptible if waiting. |
780 | * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY. | 781 | * @no_wait: Don't sleep while trying to reserve, rather return -EBUSY. |
781 | * @use_sequence: If @bo is already reserved, Only sleep waiting for | 782 | * @use_ticket: If @bo is already reserved, Only sleep waiting for |
782 | * it to become unreserved if @sequence < (@bo)->sequence. | 783 | * it to become unreserved if @sequence < (@bo)->sequence. |
783 | * | 784 | * |
784 | * Locks a buffer object for validation. (Or prevents other processes from | 785 | * Locks a buffer object for validation. (Or prevents other processes from |
@@ -819,7 +820,8 @@ extern void ttm_mem_io_unlock(struct ttm_mem_type_manager *man); | |||
819 | */ | 820 | */ |
820 | extern int ttm_bo_reserve(struct ttm_buffer_object *bo, | 821 | extern int ttm_bo_reserve(struct ttm_buffer_object *bo, |
821 | bool interruptible, | 822 | bool interruptible, |
822 | bool no_wait, bool use_sequence, uint32_t sequence); | 823 | bool no_wait, bool use_ticket, |
824 | struct ww_acquire_ctx *ticket); | ||
823 | 825 | ||
824 | /** | 826 | /** |
825 | * ttm_bo_reserve_slowpath_nolru: | 827 | * ttm_bo_reserve_slowpath_nolru: |
@@ -836,7 +838,7 @@ extern int ttm_bo_reserve(struct ttm_buffer_object *bo, | |||
836 | */ | 838 | */ |
837 | extern int ttm_bo_reserve_slowpath_nolru(struct ttm_buffer_object *bo, | 839 | extern int ttm_bo_reserve_slowpath_nolru(struct ttm_buffer_object *bo, |
838 | bool interruptible, | 840 | bool interruptible, |
839 | uint32_t sequence); | 841 | struct ww_acquire_ctx *ticket); |
840 | 842 | ||
841 | 843 | ||
842 | /** | 844 | /** |
@@ -850,7 +852,8 @@ extern int ttm_bo_reserve_slowpath_nolru(struct ttm_buffer_object *bo, | |||
850 | * held by us, this function cannot deadlock any more. | 852 | * held by us, this function cannot deadlock any more. |
851 | */ | 853 | */ |
852 | extern int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, | 854 | extern int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, |
853 | bool interruptible, uint32_t sequence); | 855 | bool interruptible, |
856 | struct ww_acquire_ctx *ticket); | ||
854 | 857 | ||
855 | /** | 858 | /** |
856 | * ttm_bo_reserve_nolru: | 859 | * ttm_bo_reserve_nolru: |
@@ -876,8 +879,8 @@ extern int ttm_bo_reserve_slowpath(struct ttm_buffer_object *bo, | |||
876 | */ | 879 | */ |
877 | extern int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo, | 880 | extern int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo, |
878 | bool interruptible, | 881 | bool interruptible, |
879 | bool no_wait, bool use_sequence, | 882 | bool no_wait, bool use_ticket, |
880 | uint32_t sequence); | 883 | struct ww_acquire_ctx *ticket); |
881 | 884 | ||
882 | /** | 885 | /** |
883 | * ttm_bo_unreserve | 886 | * ttm_bo_unreserve |
@@ -889,14 +892,25 @@ extern int ttm_bo_reserve_nolru(struct ttm_buffer_object *bo, | |||
889 | extern void ttm_bo_unreserve(struct ttm_buffer_object *bo); | 892 | extern void ttm_bo_unreserve(struct ttm_buffer_object *bo); |
890 | 893 | ||
891 | /** | 894 | /** |
892 | * ttm_bo_unreserve_locked | 895 | * ttm_bo_unreserve_ticket |
896 | * @bo: A pointer to a struct ttm_buffer_object. | ||
897 | * @ticket: ww_acquire_ctx used for reserving | ||
893 | * | 898 | * |
899 | * Unreserve a previous reservation of @bo made with @ticket. | ||
900 | */ | ||
901 | extern void ttm_bo_unreserve_ticket(struct ttm_buffer_object *bo, | ||
902 | struct ww_acquire_ctx *ticket); | ||
903 | |||
904 | /** | ||
905 | * ttm_bo_unreserve_locked | ||
894 | * @bo: A pointer to a struct ttm_buffer_object. | 906 | * @bo: A pointer to a struct ttm_buffer_object. |
907 | * @ticket: ww_acquire_ctx used for reserving, or NULL | ||
895 | * | 908 | * |
896 | * Unreserve a previous reservation of @bo. | 909 | * Unreserve a previous reservation of @bo made with @ticket. |
897 | * Needs to be called with struct ttm_bo_global::lru_lock held. | 910 | * Needs to be called with struct ttm_bo_global::lru_lock held. |
898 | */ | 911 | */ |
899 | extern void ttm_bo_unreserve_locked(struct ttm_buffer_object *bo); | 912 | extern void ttm_bo_unreserve_ticket_locked(struct ttm_buffer_object *bo, |
913 | struct ww_acquire_ctx *ticket); | ||
900 | 914 | ||
901 | /* | 915 | /* |
902 | * ttm_bo_util.c | 916 | * ttm_bo_util.c |
diff --git a/include/drm/ttm/ttm_execbuf_util.h b/include/drm/ttm/ttm_execbuf_util.h index 547e19f06e57..ba71ef91f4d5 100644 --- a/include/drm/ttm/ttm_execbuf_util.h +++ b/include/drm/ttm/ttm_execbuf_util.h | |||
@@ -33,6 +33,7 @@ | |||
33 | 33 | ||
34 | #include <ttm/ttm_bo_api.h> | 34 | #include <ttm/ttm_bo_api.h> |
35 | #include <linux/list.h> | 35 | #include <linux/list.h> |
36 | #include <linux/reservation.h> | ||
36 | 37 | ||
37 | /** | 38 | /** |
38 | * struct ttm_validate_buffer | 39 | * struct ttm_validate_buffer |
@@ -57,17 +58,20 @@ struct ttm_validate_buffer { | |||
57 | /** | 58 | /** |
58 | * function ttm_eu_backoff_reservation | 59 | * function ttm_eu_backoff_reservation |
59 | * | 60 | * |
61 | * @ticket: ww_acquire_ctx from reserve call | ||
60 | * @list: thread private list of ttm_validate_buffer structs. | 62 | * @list: thread private list of ttm_validate_buffer structs. |
61 | * | 63 | * |
62 | * Undoes all buffer validation reservations for bos pointed to by | 64 | * Undoes all buffer validation reservations for bos pointed to by |
63 | * the list entries. | 65 | * the list entries. |
64 | */ | 66 | */ |
65 | 67 | ||
66 | extern void ttm_eu_backoff_reservation(struct list_head *list); | 68 | extern void ttm_eu_backoff_reservation(struct ww_acquire_ctx *ticket, |
69 | struct list_head *list); | ||
67 | 70 | ||
68 | /** | 71 | /** |
69 | * function ttm_eu_reserve_buffers | 72 | * function ttm_eu_reserve_buffers |
70 | * | 73 | * |
74 | * @ticket: [out] ww_acquire_ctx returned by call. | ||
71 | * @list: thread private list of ttm_validate_buffer structs. | 75 | * @list: thread private list of ttm_validate_buffer structs. |
72 | * | 76 | * |
73 | * Tries to reserve bos pointed to by the list entries for validation. | 77 | * Tries to reserve bos pointed to by the list entries for validation. |
@@ -90,11 +94,13 @@ extern void ttm_eu_backoff_reservation(struct list_head *list); | |||
90 | * has failed. | 94 | * has failed. |
91 | */ | 95 | */ |
92 | 96 | ||
93 | extern int ttm_eu_reserve_buffers(struct list_head *list); | 97 | extern int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket, |
98 | struct list_head *list); | ||
94 | 99 | ||
95 | /** | 100 | /** |
96 | * function ttm_eu_fence_buffer_objects. | 101 | * function ttm_eu_fence_buffer_objects. |
97 | * | 102 | * |
103 | * @ticket: ww_acquire_ctx from reserve call | ||
98 | * @list: thread private list of ttm_validate_buffer structs. | 104 | * @list: thread private list of ttm_validate_buffer structs. |
99 | * @sync_obj: The new sync object for the buffers. | 105 | * @sync_obj: The new sync object for the buffers. |
100 | * | 106 | * |
@@ -104,6 +110,7 @@ extern int ttm_eu_reserve_buffers(struct list_head *list); | |||
104 | * | 110 | * |
105 | */ | 111 | */ |
106 | 112 | ||
107 | extern void ttm_eu_fence_buffer_objects(struct list_head *list, void *sync_obj); | 113 | extern void ttm_eu_fence_buffer_objects(struct ww_acquire_ctx *ticket, |
114 | struct list_head *list, void *sync_obj); | ||
108 | 115 | ||
109 | #endif | 116 | #endif |