forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/ttm/ttm_agp_backend.c
....@@ -48,14 +48,17 @@
4848 struct agp_bridge_data *bridge;
4949 };
5050
51
-static int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
51
+int ttm_agp_bind(struct ttm_tt *ttm, struct ttm_resource *bo_mem)
5252 {
5353 struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
54
- struct page *dummy_read_page = ttm->bdev->glob->dummy_read_page;
54
+ struct page *dummy_read_page = ttm_bo_glob.dummy_read_page;
5555 struct drm_mm_node *node = bo_mem->mm_node;
5656 struct agp_memory *mem;
5757 int ret, cached = (bo_mem->placement & TTM_PL_FLAG_CACHED);
5858 unsigned i;
59
+
60
+ if (agp_be->mem)
61
+ return 0;
5962
6063 mem = agp_allocate_memory(agp_be->bridge, ttm->num_pages, AGP_USER_MEMORY);
6164 if (unlikely(mem == NULL))
....@@ -81,21 +84,35 @@
8184
8285 return ret;
8386 }
87
+EXPORT_SYMBOL(ttm_agp_bind);
8488
85
-static int ttm_agp_unbind(struct ttm_tt *ttm)
89
+void ttm_agp_unbind(struct ttm_tt *ttm)
8690 {
8791 struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
8892
8993 if (agp_be->mem) {
90
- if (agp_be->mem->is_bound)
91
- return agp_unbind_memory(agp_be->mem);
94
+ if (agp_be->mem->is_bound) {
95
+ agp_unbind_memory(agp_be->mem);
96
+ return;
97
+ }
9298 agp_free_memory(agp_be->mem);
9399 agp_be->mem = NULL;
94100 }
95
- return 0;
96101 }
102
+EXPORT_SYMBOL(ttm_agp_unbind);
97103
98
-static void ttm_agp_destroy(struct ttm_tt *ttm)
104
+bool ttm_agp_is_bound(struct ttm_tt *ttm)
105
+{
106
+ struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
107
+
108
+ if (!ttm)
109
+ return false;
110
+
111
+ return (agp_be->mem != NULL);
112
+}
113
+EXPORT_SYMBOL(ttm_agp_is_bound);
114
+
115
+void ttm_agp_destroy(struct ttm_tt *ttm)
99116 {
100117 struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm);
101118
....@@ -104,12 +121,7 @@
104121 ttm_tt_fini(ttm);
105122 kfree(agp_be);
106123 }
107
-
108
-static struct ttm_backend_func ttm_agp_func = {
109
- .bind = ttm_agp_bind,
110
- .unbind = ttm_agp_unbind,
111
- .destroy = ttm_agp_destroy,
112
-};
124
+EXPORT_SYMBOL(ttm_agp_destroy);
113125
114126 struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo,
115127 struct agp_bridge_data *bridge,
....@@ -123,7 +135,6 @@
123135
124136 agp_be->mem = NULL;
125137 agp_be->bridge = bridge;
126
- agp_be->ttm.func = &ttm_agp_func;
127138
128139 if (ttm_tt_init(&agp_be->ttm, bo, page_flags)) {
129140 kfree(agp_be);
....@@ -133,18 +144,3 @@
133144 return &agp_be->ttm;
134145 }
135146 EXPORT_SYMBOL(ttm_agp_tt_create);
136
-
137
-int ttm_agp_tt_populate(struct ttm_tt *ttm, struct ttm_operation_ctx *ctx)
138
-{
139
- if (ttm->state != tt_unpopulated)
140
- return 0;
141
-
142
- return ttm_pool_populate(ttm, ctx);
143
-}
144
-EXPORT_SYMBOL(ttm_agp_tt_populate);
145
-
146
-void ttm_agp_tt_unpopulate(struct ttm_tt *ttm)
147
-{
148
- ttm_pool_unpopulate(ttm);
149
-}
150
-EXPORT_SYMBOL(ttm_agp_tt_unpopulate);