Lines Matching full:gart
39 * GART
40 * The GART (Graphics Aperture Remapping Table) is an aperture
46 * Radeon GPUs support both an internal GART, as described above,
47 * and AGP. AGP works similarly, but the GART table is configured
52 * Both AGP and internal GART can be used at the same time, however
55 * This file handles the common internal GART management.
59 * Common GART table functions.
62 * radeon_gart_table_ram_alloc - allocate system ram for gart page table
66 * Allocate system memory for GART page table
68 * gart table to be in system memory.
75 ptr = dma_alloc_coherent(&rdev->pdev->dev, rdev->gart.table_size, in radeon_gart_table_ram_alloc()
76 &rdev->gart.table_addr, GFP_KERNEL); in radeon_gart_table_ram_alloc()
84 rdev->gart.table_size >> PAGE_SHIFT); in radeon_gart_table_ram_alloc()
87 rdev->gart.ptr = ptr; in radeon_gart_table_ram_alloc()
92 * radeon_gart_table_ram_free - free system ram for gart page table
96 * Free system memory for GART page table
98 * gart table to be in system memory.
102 if (!rdev->gart.ptr) in radeon_gart_table_ram_free()
108 set_memory_wb((unsigned long)rdev->gart.ptr, in radeon_gart_table_ram_free()
109 rdev->gart.table_size >> PAGE_SHIFT); in radeon_gart_table_ram_free()
112 dma_free_coherent(&rdev->pdev->dev, rdev->gart.table_size, in radeon_gart_table_ram_free()
113 (void *)rdev->gart.ptr, rdev->gart.table_addr); in radeon_gart_table_ram_free()
114 rdev->gart.ptr = NULL; in radeon_gart_table_ram_free()
115 rdev->gart.table_addr = 0; in radeon_gart_table_ram_free()
119 * radeon_gart_table_vram_alloc - allocate vram for gart page table
123 * Allocate video memory for GART page table
125 * gart table to be in video memory.
132 if (rdev->gart.robj == NULL) { in radeon_gart_table_vram_alloc()
133 r = radeon_bo_create(rdev, rdev->gart.table_size, in radeon_gart_table_vram_alloc()
135 0, NULL, NULL, &rdev->gart.robj); in radeon_gart_table_vram_alloc()
143 * radeon_gart_table_vram_pin - pin gart page table in vram
147 * Pin the GART page table in vram so it will not be moved
149 * gart table to be in video memory.
157 r = radeon_bo_reserve(rdev->gart.robj, false); in radeon_gart_table_vram_pin()
160 r = radeon_bo_pin(rdev->gart.robj, in radeon_gart_table_vram_pin()
163 radeon_bo_unreserve(rdev->gart.robj); in radeon_gart_table_vram_pin()
166 r = radeon_bo_kmap(rdev->gart.robj, &rdev->gart.ptr); in radeon_gart_table_vram_pin()
168 radeon_bo_unpin(rdev->gart.robj); in radeon_gart_table_vram_pin()
169 radeon_bo_unreserve(rdev->gart.robj); in radeon_gart_table_vram_pin()
170 rdev->gart.table_addr = gpu_addr; in radeon_gart_table_vram_pin()
175 /* We might have dropped some GART table updates while it wasn't in radeon_gart_table_vram_pin()
178 for (i = 0; i < rdev->gart.num_gpu_pages; i++) in radeon_gart_table_vram_pin()
179 radeon_gart_set_page(rdev, i, rdev->gart.pages_entry[i]); in radeon_gart_table_vram_pin()
188 * radeon_gart_table_vram_unpin - unpin gart page table in vram
192 * Unpin the GART page table in vram (pcie r4xx, r5xx+).
193 * These asics require the gart table to be in video memory.
199 if (!rdev->gart.robj) in radeon_gart_table_vram_unpin()
202 r = radeon_bo_reserve(rdev->gart.robj, false); in radeon_gart_table_vram_unpin()
204 radeon_bo_kunmap(rdev->gart.robj); in radeon_gart_table_vram_unpin()
205 radeon_bo_unpin(rdev->gart.robj); in radeon_gart_table_vram_unpin()
206 radeon_bo_unreserve(rdev->gart.robj); in radeon_gart_table_vram_unpin()
207 rdev->gart.ptr = NULL; in radeon_gart_table_vram_unpin()
212 * radeon_gart_table_vram_free - free gart page table vram
216 * Free the video memory used for the GART page table
217 * (pcie r4xx, r5xx+). These asics require the gart table to
222 if (!rdev->gart.robj) in radeon_gart_table_vram_free()
225 radeon_bo_unref(&rdev->gart.robj); in radeon_gart_table_vram_free()
229 * Common gart functions.
232 * radeon_gart_unbind - unbind pages from the gart page table
235 * @offset: offset into the GPU's gart aperture
238 * Unbinds the requested pages from the gart page table and
247 if (!rdev->gart.ready) { in radeon_gart_unbind()
248 WARN(1, "trying to unbind memory from uninitialized GART !\n"); in radeon_gart_unbind()
254 if (rdev->gart.pages[p]) { in radeon_gart_unbind()
255 rdev->gart.pages[p] = NULL; in radeon_gart_unbind()
257 rdev->gart.pages_entry[t] = rdev->dummy_page.entry; in radeon_gart_unbind()
258 if (rdev->gart.ptr) { in radeon_gart_unbind()
265 if (rdev->gart.ptr) { in radeon_gart_unbind()
272 * radeon_gart_bind - bind pages into the gart page table
275 * @offset: offset into the GPU's gart aperture
281 * Binds the requested pages to the gart page table
293 if (!rdev->gart.ready) { in radeon_gart_bind()
294 WARN(1, "trying to bind memory to uninitialized GART !\n"); in radeon_gart_bind()
301 rdev->gart.pages[p] = pagelist ? pagelist[i] : in radeon_gart_bind()
306 rdev->gart.pages_entry[t] = page_entry; in radeon_gart_bind()
307 if (rdev->gart.ptr) in radeon_gart_bind()
313 if (rdev->gart.ptr) { in radeon_gart_bind()
321 * radeon_gart_init - init the driver info for managing the gart
325 * Allocate the dummy page and init the gart driver info (all asics).
332 if (rdev->gart.pages) in radeon_gart_init()
344 rdev->gart.num_cpu_pages = rdev->mc.gtt_size / PAGE_SIZE; in radeon_gart_init()
345 rdev->gart.num_gpu_pages = rdev->mc.gtt_size / RADEON_GPU_PAGE_SIZE; in radeon_gart_init()
346 DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n", in radeon_gart_init()
347 rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages); in radeon_gart_init()
349 rdev->gart.pages = vzalloc(array_size(sizeof(void *), in radeon_gart_init()
350 rdev->gart.num_cpu_pages)); in radeon_gart_init()
351 if (rdev->gart.pages == NULL) { in radeon_gart_init()
355 rdev->gart.pages_entry = vmalloc(array_size(sizeof(uint64_t), in radeon_gart_init()
356 rdev->gart.num_gpu_pages)); in radeon_gart_init()
357 if (rdev->gart.pages_entry == NULL) { in radeon_gart_init()
361 /* set GART entry to point to the dummy page by default */ in radeon_gart_init()
362 for (i = 0; i < rdev->gart.num_gpu_pages; i++) in radeon_gart_init()
363 rdev->gart.pages_entry[i] = rdev->dummy_page.entry; in radeon_gart_init()
368 * radeon_gart_fini - tear down the driver info for managing the gart
372 * Tear down the gart driver info and free the dummy page (all asics).
376 if (rdev->gart.ready) { in radeon_gart_fini()
378 radeon_gart_unbind(rdev, 0, rdev->gart.num_cpu_pages); in radeon_gart_fini()
380 rdev->gart.ready = false; in radeon_gart_fini()
381 vfree(rdev->gart.pages); in radeon_gart_fini()
382 vfree(rdev->gart.pages_entry); in radeon_gart_fini()
383 rdev->gart.pages = NULL; in radeon_gart_fini()
384 rdev->gart.pages_entry = NULL; in radeon_gart_fini()