diff options
author | Roger He <Hongbo.He@amd.com> | 2017-12-18 06:50:08 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2017-12-27 11:38:11 -0500 |
commit | a6c26af8a4348a0ba2eb146b08f4d4d908cd9222 (patch) | |
tree | a4c7f906baf50094c998479a974c3127e551b053 /include/drm/ttm | |
parent | 44835a86276ac2c90661267d3a3738aa1fa159ef (diff) |
drm/ttm: call ttm_bo_swapout directly when ttm shrink
remove the extra indirection because we have only one implementation anyway
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Roger He <Hongbo.He@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'include/drm/ttm')
-rw-r--r-- | include/drm/ttm/ttm_bo_api.h | 1 | ||||
-rw-r--r-- | include/drm/ttm/ttm_bo_driver.h | 1 | ||||
-rw-r--r-- | include/drm/ttm/ttm_memory.h | 69 |
3 files changed, 2 insertions, 69 deletions
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h index c1263308145a..24a8db7bebb1 100644 --- a/include/drm/ttm/ttm_bo_api.h +++ b/include/drm/ttm/ttm_bo_api.h | |||
@@ -752,6 +752,7 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file *filp, | |||
752 | const char __user *wbuf, char __user *rbuf, | 752 | const char __user *wbuf, char __user *rbuf, |
753 | size_t count, loff_t *f_pos, bool write); | 753 | size_t count, loff_t *f_pos, bool write); |
754 | 754 | ||
755 | int ttm_bo_swapout(struct ttm_bo_global *glob); | ||
755 | void ttm_bo_swapout_all(struct ttm_bo_device *bdev); | 756 | void ttm_bo_swapout_all(struct ttm_bo_device *bdev); |
756 | int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); | 757 | int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); |
757 | #endif | 758 | #endif |
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h index 5115718ca607..934fecfa7b07 100644 --- a/include/drm/ttm/ttm_bo_driver.h +++ b/include/drm/ttm/ttm_bo_driver.h | |||
@@ -522,7 +522,6 @@ struct ttm_bo_global { | |||
522 | struct kobject kobj; | 522 | struct kobject kobj; |
523 | struct ttm_mem_global *mem_glob; | 523 | struct ttm_mem_global *mem_glob; |
524 | struct page *dummy_read_page; | 524 | struct page *dummy_read_page; |
525 | struct ttm_mem_shrink shrink; | ||
526 | struct mutex device_list_mutex; | 525 | struct mutex device_list_mutex; |
527 | spinlock_t lru_lock; | 526 | spinlock_t lru_lock; |
528 | 527 | ||
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h index 2c1e3598effe..85f3ad6f1348 100644 --- a/include/drm/ttm/ttm_memory.h +++ b/include/drm/ttm/ttm_memory.h | |||
@@ -37,20 +37,6 @@ | |||
37 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
38 | 38 | ||
39 | /** | 39 | /** |
40 | * struct ttm_mem_shrink - callback to shrink TTM memory usage. | ||
41 | * | ||
42 | * @do_shrink: The callback function. | ||
43 | * | ||
44 | * Arguments to the do_shrink functions are intended to be passed using | ||
45 | * inheritance. That is, the argument class derives from struct ttm_mem_shrink, | ||
46 | * and can be accessed using container_of(). | ||
47 | */ | ||
48 | |||
49 | struct ttm_mem_shrink { | ||
50 | int (*do_shrink) (struct ttm_mem_shrink *); | ||
51 | }; | ||
52 | |||
53 | /** | ||
54 | * struct ttm_mem_global - Global memory accounting structure. | 40 | * struct ttm_mem_global - Global memory accounting structure. |
55 | * | 41 | * |
56 | * @shrink: A single callback to shrink TTM memory usage. Extend this | 42 | * @shrink: A single callback to shrink TTM memory usage. Extend this |
@@ -76,7 +62,7 @@ struct ttm_mem_shrink { | |||
76 | struct ttm_mem_zone; | 62 | struct ttm_mem_zone; |
77 | struct ttm_mem_global { | 63 | struct ttm_mem_global { |
78 | struct kobject kobj; | 64 | struct kobject kobj; |
79 | struct ttm_mem_shrink *shrink; | 65 | struct ttm_bo_global *bo_glob; |
80 | struct workqueue_struct *swap_queue; | 66 | struct workqueue_struct *swap_queue; |
81 | struct work_struct work; | 67 | struct work_struct work; |
82 | spinlock_t lock; | 68 | spinlock_t lock; |
@@ -90,59 +76,6 @@ struct ttm_mem_global { | |||
90 | #endif | 76 | #endif |
91 | }; | 77 | }; |
92 | 78 | ||
93 | /** | ||
94 | * ttm_mem_init_shrink - initialize a struct ttm_mem_shrink object | ||
95 | * | ||
96 | * @shrink: The object to initialize. | ||
97 | * @func: The callback function. | ||
98 | */ | ||
99 | |||
100 | static inline void ttm_mem_init_shrink(struct ttm_mem_shrink *shrink, | ||
101 | int (*func) (struct ttm_mem_shrink *)) | ||
102 | { | ||
103 | shrink->do_shrink = func; | ||
104 | } | ||
105 | |||
106 | /** | ||
107 | * ttm_mem_register_shrink - register a struct ttm_mem_shrink object. | ||
108 | * | ||
109 | * @glob: The struct ttm_mem_global object to register with. | ||
110 | * @shrink: An initialized struct ttm_mem_shrink object to register. | ||
111 | * | ||
112 | * Returns: | ||
113 | * -EBUSY: There's already a callback registered. (May change). | ||
114 | */ | ||
115 | |||
116 | static inline int ttm_mem_register_shrink(struct ttm_mem_global *glob, | ||
117 | struct ttm_mem_shrink *shrink) | ||
118 | { | ||
119 | spin_lock(&glob->lock); | ||
120 | if (glob->shrink != NULL) { | ||
121 | spin_unlock(&glob->lock); | ||
122 | return -EBUSY; | ||
123 | } | ||
124 | glob->shrink = shrink; | ||
125 | spin_unlock(&glob->lock); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | /** | ||
130 | * ttm_mem_unregister_shrink - unregister a struct ttm_mem_shrink object. | ||
131 | * | ||
132 | * @glob: The struct ttm_mem_global object to unregister from. | ||
133 | * @shrink: A previously registert struct ttm_mem_shrink object. | ||
134 | * | ||
135 | */ | ||
136 | |||
137 | static inline void ttm_mem_unregister_shrink(struct ttm_mem_global *glob, | ||
138 | struct ttm_mem_shrink *shrink) | ||
139 | { | ||
140 | spin_lock(&glob->lock); | ||
141 | BUG_ON(glob->shrink != shrink); | ||
142 | glob->shrink = NULL; | ||
143 | spin_unlock(&glob->lock); | ||
144 | } | ||
145 | |||
146 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); | 79 | extern int ttm_mem_global_init(struct ttm_mem_global *glob); |
147 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); | 80 | extern void ttm_mem_global_release(struct ttm_mem_global *glob); |
148 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, | 81 | extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, |