Lines Matching +full:sg +full:- +full:micro

2  * Copyright 2008 Advanced Micro Devices, Inc.
66 * amdgpu_gart_dummy_page_init - init dummy page used by the driver
73 * Returns 0 on sucess, -ENOMEM on failure.
79 if (adev->dummy_page_addr) in amdgpu_gart_dummy_page_init()
81 adev->dummy_page_addr = dma_map_page(&adev->pdev->dev, dummy_page, 0, in amdgpu_gart_dummy_page_init()
83 if (dma_mapping_error(&adev->pdev->dev, adev->dummy_page_addr)) { in amdgpu_gart_dummy_page_init()
84 dev_err(&adev->pdev->dev, "Failed to DMA MAP the dummy page\n"); in amdgpu_gart_dummy_page_init()
85 adev->dummy_page_addr = 0; in amdgpu_gart_dummy_page_init()
86 return -ENOMEM; in amdgpu_gart_dummy_page_init()
92 * amdgpu_gart_dummy_page_fini - free dummy page used by the driver
100 if (!adev->dummy_page_addr) in amdgpu_gart_dummy_page_fini()
102 dma_unmap_page(&adev->pdev->dev, adev->dummy_page_addr, PAGE_SIZE, in amdgpu_gart_dummy_page_fini()
104 adev->dummy_page_addr = 0; in amdgpu_gart_dummy_page_fini()
108 * amdgpu_gart_table_ram_alloc - allocate system ram for gart page table
118 unsigned int order = get_order(adev->gart.table_size); in amdgpu_gart_table_ram_alloc()
121 struct sg_table *sg = NULL; in amdgpu_gart_table_ram_alloc() local
128 if (adev->gart.bo != NULL) in amdgpu_gart_table_ram_alloc()
133 return -ENOMEM; in amdgpu_gart_table_ram_alloc()
137 p[x].mapping = adev->mman.bdev.dev_mapping; in amdgpu_gart_table_ram_alloc()
143 dma_addr = dma_map_page(&adev->pdev->dev, p, 0, adev->gart.table_size, in amdgpu_gart_table_ram_alloc()
145 if (dma_mapping_error(&adev->pdev->dev, dma_addr)) { in amdgpu_gart_table_ram_alloc()
146 dev_err(&adev->pdev->dev, "Failed to DMA MAP the GART BO page\n"); in amdgpu_gart_table_ram_alloc()
149 return -EFAULT; in amdgpu_gart_table_ram_alloc()
152 dev_info(adev->dev, "%s dma_addr:%pad\n", __func__, &dma_addr); in amdgpu_gart_table_ram_alloc()
153 /* Create SG table */ in amdgpu_gart_table_ram_alloc()
154 sg = kmalloc(sizeof(*sg), GFP_KERNEL); in amdgpu_gart_table_ram_alloc()
155 if (!sg) { in amdgpu_gart_table_ram_alloc()
156 ret = -ENOMEM; in amdgpu_gart_table_ram_alloc()
159 ret = sg_alloc_table(sg, 1, GFP_KERNEL); in amdgpu_gart_table_ram_alloc()
163 sg_dma_address(sg->sgl) = dma_addr; in amdgpu_gart_table_ram_alloc()
164 sg->sgl->length = adev->gart.table_size; in amdgpu_gart_table_ram_alloc()
166 sg->sgl->dma_length = adev->gart.table_size; in amdgpu_gart_table_ram_alloc()
168 /* Create SG BO */ in amdgpu_gart_table_ram_alloc()
170 bp.size = adev->gart.table_size; in amdgpu_gart_table_ram_alloc()
181 bo->tbo.sg = sg; in amdgpu_gart_table_ram_alloc()
182 bo->tbo.ttm->sg = sg; in amdgpu_gart_table_ram_alloc()
183 bo->allowed_domains = AMDGPU_GEM_DOMAIN_GTT; in amdgpu_gart_table_ram_alloc()
184 bo->preferred_domains = AMDGPU_GEM_DOMAIN_GTT; in amdgpu_gart_table_ram_alloc()
188 dev_err(adev->dev, "(%d) failed to reserve bo for GART system bo\n", ret); in amdgpu_gart_table_ram_alloc()
197 adev->gart.bo = bo; in amdgpu_gart_table_ram_alloc()
198 adev->gart.ptr = page_to_virt(p); in amdgpu_gart_table_ram_alloc()
200 ret = amdgpu_ttm_alloc_gart(&adev->gart.bo->tbo); in amdgpu_gart_table_ram_alloc()
211 if (sg) { in amdgpu_gart_table_ram_alloc()
212 sg_free_table(sg); in amdgpu_gart_table_ram_alloc()
213 kfree(sg); in amdgpu_gart_table_ram_alloc()
220 * amdgpu_gart_table_ram_free - free gart page table system ram
229 unsigned int order = get_order(adev->gart.table_size); in amdgpu_gart_table_ram_free()
230 struct sg_table *sg = adev->gart.bo->tbo.sg; in amdgpu_gart_table_ram_free() local
235 ret = amdgpu_bo_reserve(adev->gart.bo, false); in amdgpu_gart_table_ram_free()
237 amdgpu_bo_unpin(adev->gart.bo); in amdgpu_gart_table_ram_free()
238 amdgpu_bo_unreserve(adev->gart.bo); in amdgpu_gart_table_ram_free()
240 amdgpu_bo_unref(&adev->gart.bo); in amdgpu_gart_table_ram_free()
241 sg_free_table(sg); in amdgpu_gart_table_ram_free()
242 kfree(sg); in amdgpu_gart_table_ram_free()
243 p = virt_to_page(adev->gart.ptr); in amdgpu_gart_table_ram_free()
248 adev->gart.ptr = NULL; in amdgpu_gart_table_ram_free()
252 * amdgpu_gart_table_vram_alloc - allocate vram for gart page table
263 if (adev->gart.bo != NULL) in amdgpu_gart_table_vram_alloc()
266 return amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE, in amdgpu_gart_table_vram_alloc()
267 AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.bo, in amdgpu_gart_table_vram_alloc()
268 NULL, (void *)&adev->gart.ptr); in amdgpu_gart_table_vram_alloc()
272 * amdgpu_gart_table_vram_free - free gart page table vram
282 amdgpu_bo_free_kernel(&adev->gart.bo, NULL, (void *)&adev->gart.ptr); in amdgpu_gart_table_vram_free()
289 * amdgpu_gart_unbind - unbind pages from the gart page table
297 * Returns 0 for success, -EINVAL for failure.
310 if (!adev->gart.ptr) in amdgpu_gart_unbind()
319 page_base = adev->dummy_page_addr; in amdgpu_gart_unbind()
320 if (!adev->gart.ptr) in amdgpu_gart_unbind()
324 amdgpu_gmc_set_pte_pde(adev, adev->gart.ptr, in amdgpu_gart_unbind()
335 * amdgpu_gart_map - map dma_addresses into GART entries
345 * Returns 0 for success, -EINVAL for failure.
371 * amdgpu_gart_bind - bind pages into the gart page table
381 * Returns 0 for success, -EINVAL for failure.
387 if (!adev->gart.ptr) in amdgpu_gart_bind()
390 amdgpu_gart_map(adev, offset, pages, dma_addr, flags, adev->gart.ptr); in amdgpu_gart_bind()
394 * amdgpu_gart_invalidate_tlb - invalidate gart TLB
405 if (!adev->gart.ptr) in amdgpu_gart_invalidate_tlb()
409 if (down_read_trylock(&adev->reset_domain->sem)) { in amdgpu_gart_invalidate_tlb()
411 up_read(&adev->reset_domain->sem); in amdgpu_gart_invalidate_tlb()
413 for_each_set_bit(i, adev->vmhubs_mask, AMDGPU_MAX_VMHUBS) in amdgpu_gart_invalidate_tlb()
418 * amdgpu_gart_init - init the driver info for managing the gart
429 if (adev->dummy_page_addr) in amdgpu_gart_init()
435 return -EINVAL; in amdgpu_gart_init()
441 adev->gart.num_cpu_pages = adev->gmc.gart_size / PAGE_SIZE; in amdgpu_gart_init()
442 adev->gart.num_gpu_pages = adev->gmc.gart_size / AMDGPU_GPU_PAGE_SIZE; in amdgpu_gart_init()
444 adev->gart.num_cpu_pages, adev->gart.num_gpu_pages); in amdgpu_gart_init()