summaryrefslogtreecommitdiffstats
path: root/include/drm/ttm
diff options
context:
space:
mode:
authorRoger He <Hongbo.He@amd.com>2017-12-18 06:50:08 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-27 11:38:11 -0500
commita6c26af8a4348a0ba2eb146b08f4d4d908cd9222 (patch)
treea4c7f906baf50094c998479a974c3127e551b053 /include/drm/ttm
parent44835a86276ac2c90661267d3a3738aa1fa159ef (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.h1
-rw-r--r--include/drm/ttm/ttm_bo_driver.h1
-rw-r--r--include/drm/ttm/ttm_memory.h69
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
755int ttm_bo_swapout(struct ttm_bo_global *glob);
755void ttm_bo_swapout_all(struct ttm_bo_device *bdev); 756void ttm_bo_swapout_all(struct ttm_bo_device *bdev);
756int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo); 757int 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
49struct 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 {
76struct ttm_mem_zone; 62struct ttm_mem_zone;
77struct ttm_mem_global { 63struct 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
100static 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
116static 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
137static 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
146extern int ttm_mem_global_init(struct ttm_mem_global *glob); 79extern int ttm_mem_global_init(struct ttm_mem_global *glob);
147extern void ttm_mem_global_release(struct ttm_mem_global *glob); 80extern void ttm_mem_global_release(struct ttm_mem_global *glob);
148extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, 81extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,