.. | .. |
---|
48 | 48 | struct agp_bridge_data *bridge; |
---|
49 | 49 | }; |
---|
50 | 50 | |
---|
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) |
---|
52 | 52 | { |
---|
53 | 53 | 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; |
---|
55 | 55 | struct drm_mm_node *node = bo_mem->mm_node; |
---|
56 | 56 | struct agp_memory *mem; |
---|
57 | 57 | int ret, cached = (bo_mem->placement & TTM_PL_FLAG_CACHED); |
---|
58 | 58 | unsigned i; |
---|
| 59 | + |
---|
| 60 | + if (agp_be->mem) |
---|
| 61 | + return 0; |
---|
59 | 62 | |
---|
60 | 63 | mem = agp_allocate_memory(agp_be->bridge, ttm->num_pages, AGP_USER_MEMORY); |
---|
61 | 64 | if (unlikely(mem == NULL)) |
---|
.. | .. |
---|
81 | 84 | |
---|
82 | 85 | return ret; |
---|
83 | 86 | } |
---|
| 87 | +EXPORT_SYMBOL(ttm_agp_bind); |
---|
84 | 88 | |
---|
85 | | -static int ttm_agp_unbind(struct ttm_tt *ttm) |
---|
| 89 | +void ttm_agp_unbind(struct ttm_tt *ttm) |
---|
86 | 90 | { |
---|
87 | 91 | struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm); |
---|
88 | 92 | |
---|
89 | 93 | 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 | + } |
---|
92 | 98 | agp_free_memory(agp_be->mem); |
---|
93 | 99 | agp_be->mem = NULL; |
---|
94 | 100 | } |
---|
95 | | - return 0; |
---|
96 | 101 | } |
---|
| 102 | +EXPORT_SYMBOL(ttm_agp_unbind); |
---|
97 | 103 | |
---|
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) |
---|
99 | 116 | { |
---|
100 | 117 | struct ttm_agp_backend *agp_be = container_of(ttm, struct ttm_agp_backend, ttm); |
---|
101 | 118 | |
---|
.. | .. |
---|
104 | 121 | ttm_tt_fini(ttm); |
---|
105 | 122 | kfree(agp_be); |
---|
106 | 123 | } |
---|
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); |
---|
113 | 125 | |
---|
114 | 126 | struct ttm_tt *ttm_agp_tt_create(struct ttm_buffer_object *bo, |
---|
115 | 127 | struct agp_bridge_data *bridge, |
---|
.. | .. |
---|
123 | 135 | |
---|
124 | 136 | agp_be->mem = NULL; |
---|
125 | 137 | agp_be->bridge = bridge; |
---|
126 | | - agp_be->ttm.func = &ttm_agp_func; |
---|
127 | 138 | |
---|
128 | 139 | if (ttm_tt_init(&agp_be->ttm, bo, page_flags)) { |
---|
129 | 140 | kfree(agp_be); |
---|
.. | .. |
---|
133 | 144 | return &agp_be->ttm; |
---|
134 | 145 | } |
---|
135 | 146 | 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); |
---|