Lines Matching refs:gt

146 static int psb_gtt_attach_pages(struct gtt_range *gt)  in psb_gtt_attach_pages()  argument
150 WARN_ON(gt->pages); in psb_gtt_attach_pages()
152 pages = drm_gem_get_pages(&gt->gem); in psb_gtt_attach_pages()
156 gt->npage = gt->gem.size / PAGE_SIZE; in psb_gtt_attach_pages()
157 gt->pages = pages; in psb_gtt_attach_pages()
171 static void psb_gtt_detach_pages(struct gtt_range *gt) in psb_gtt_detach_pages() argument
173 drm_gem_put_pages(&gt->gem, gt->pages, true, false); in psb_gtt_detach_pages()
174 gt->pages = NULL; in psb_gtt_detach_pages()
187 int psb_gtt_pin(struct gtt_range *gt) in psb_gtt_pin() argument
190 struct drm_device *dev = gt->gem.dev; in psb_gtt_pin()
196 if (gt->in_gart == 0 && gt->stolen == 0) { in psb_gtt_pin()
197 ret = psb_gtt_attach_pages(gt); in psb_gtt_pin()
200 ret = psb_gtt_insert(dev, gt, 0); in psb_gtt_pin()
202 psb_gtt_detach_pages(gt); in psb_gtt_pin()
206 gt->pages, (gpu_base + gt->offset), in psb_gtt_pin()
207 gt->npage, 0, 0, PSB_MMU_CACHED_MEMORY); in psb_gtt_pin()
209 gt->in_gart++; in psb_gtt_pin()
226 void psb_gtt_unpin(struct gtt_range *gt) in psb_gtt_unpin() argument
228 struct drm_device *dev = gt->gem.dev; in psb_gtt_unpin()
234 WARN_ON(!gt->in_gart); in psb_gtt_unpin()
236 gt->in_gart--; in psb_gtt_unpin()
237 if (gt->in_gart == 0 && gt->stolen == 0) { in psb_gtt_unpin()
239 (gpu_base + gt->offset), gt->npage, 0, 0); in psb_gtt_unpin()
240 psb_gtt_remove(dev, gt); in psb_gtt_unpin()
241 psb_gtt_detach_pages(gt); in psb_gtt_unpin()
270 struct gtt_range *gt; in psb_gtt_alloc_range() local
285 gt = kzalloc(sizeof(struct gtt_range), GFP_KERNEL); in psb_gtt_alloc_range()
286 if (gt == NULL) in psb_gtt_alloc_range()
288 gt->resource.name = name; in psb_gtt_alloc_range()
289 gt->stolen = backed; in psb_gtt_alloc_range()
290 gt->in_gart = backed; in psb_gtt_alloc_range()
292 gt->gem.dev = dev; in psb_gtt_alloc_range()
293 ret = allocate_resource(dev_priv->gtt_mem, &gt->resource, in psb_gtt_alloc_range()
296 gt->offset = gt->resource.start - r->start; in psb_gtt_alloc_range()
297 return gt; in psb_gtt_alloc_range()
299 kfree(gt); in psb_gtt_alloc_range()
311 void psb_gtt_free_range(struct drm_device *dev, struct gtt_range *gt) in psb_gtt_free_range() argument
314 if (gt->mmapping) { in psb_gtt_free_range()
315 psb_gtt_unpin(gt); in psb_gtt_free_range()
316 gt->mmapping = 0; in psb_gtt_free_range()
318 WARN_ON(gt->in_gart && !gt->stolen); in psb_gtt_free_range()
319 release_resource(&gt->resource); in psb_gtt_free_range()
320 kfree(gt); in psb_gtt_free_range()