13490bdb5SChristian König /* 23490bdb5SChristian König * Copyright 2017 Advanced Micro Devices, Inc. 33490bdb5SChristian König * 43490bdb5SChristian König * Permission is hereby granted, free of charge, to any person obtaining a 53490bdb5SChristian König * copy of this software and associated documentation files (the "Software"), 63490bdb5SChristian König * to deal in the Software without restriction, including without limitation 73490bdb5SChristian König * the rights to use, copy, modify, merge, publish, distribute, sublicense, 83490bdb5SChristian König * and/or sell copies of the Software, and to permit persons to whom the 93490bdb5SChristian König * Software is furnished to do so, subject to the following conditions: 103490bdb5SChristian König * 113490bdb5SChristian König * The above copyright notice and this permission notice shall be included in 123490bdb5SChristian König * all copies or substantial portions of the Software. 133490bdb5SChristian König * 143490bdb5SChristian König * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 153490bdb5SChristian König * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 163490bdb5SChristian König * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 173490bdb5SChristian König * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 183490bdb5SChristian König * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 193490bdb5SChristian König * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 203490bdb5SChristian König * OTHER DEALINGS IN THE SOFTWARE. 213490bdb5SChristian König * 223490bdb5SChristian König */ 233490bdb5SChristian König 243490bdb5SChristian König #ifndef __AMDGPU_GART_H__ 253490bdb5SChristian König #define __AMDGPU_GART_H__ 263490bdb5SChristian König 273490bdb5SChristian König #include <linux/types.h> 283490bdb5SChristian König 293490bdb5SChristian König /* 303490bdb5SChristian König * GART structures, functions & helpers 313490bdb5SChristian König */ 323490bdb5SChristian König struct amdgpu_device; 333490bdb5SChristian König struct amdgpu_bo; 343490bdb5SChristian König 353490bdb5SChristian König #define AMDGPU_GPU_PAGE_SIZE 4096 363490bdb5SChristian König #define AMDGPU_GPU_PAGE_MASK (AMDGPU_GPU_PAGE_SIZE - 1) 373490bdb5SChristian König #define AMDGPU_GPU_PAGE_SHIFT 12 383490bdb5SChristian König #define AMDGPU_GPU_PAGE_ALIGN(a) (((a) + AMDGPU_GPU_PAGE_MASK) & ~AMDGPU_GPU_PAGE_MASK) 393490bdb5SChristian König 40463d2fe8SMichel Dänzer #define AMDGPU_GPU_PAGES_IN_CPU_PAGE (PAGE_SIZE / AMDGPU_GPU_PAGE_SIZE) 41463d2fe8SMichel Dänzer 423490bdb5SChristian König struct amdgpu_gart { 431123b989SChristian König struct amdgpu_bo *bo; 445dcb668dSOak Zeng /* CPU kmapped address of gart table */ 453490bdb5SChristian König void *ptr; 463490bdb5SChristian König unsigned num_gpu_pages; 473490bdb5SChristian König unsigned num_cpu_pages; 483490bdb5SChristian König unsigned table_size; 493490bdb5SChristian König 503490bdb5SChristian König /* Asic default pte flags */ 513490bdb5SChristian König uint64_t gart_pte_flags; 523490bdb5SChristian König }; 533490bdb5SChristian König 54*c9a502e9SFelix Kuehling int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev); 55*c9a502e9SFelix Kuehling void amdgpu_gart_table_ram_free(struct amdgpu_device *adev); 563490bdb5SChristian König int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev); 573490bdb5SChristian König void amdgpu_gart_table_vram_free(struct amdgpu_device *adev); 583490bdb5SChristian König int amdgpu_gart_init(struct amdgpu_device *adev); 59d10d0daaSAndrey Grodzovsky void amdgpu_gart_dummy_page_fini(struct amdgpu_device *adev); 601b08dfb8SChristian König void amdgpu_gart_unbind(struct amdgpu_device *adev, uint64_t offset, 613490bdb5SChristian König int pages); 621b08dfb8SChristian König void amdgpu_gart_map(struct amdgpu_device *adev, uint64_t offset, 633490bdb5SChristian König int pages, dma_addr_t *dma_addr, uint64_t flags, 643490bdb5SChristian König void *dst); 651b08dfb8SChristian König void amdgpu_gart_bind(struct amdgpu_device *adev, uint64_t offset, 66942ab769SYifan Zhang int pages, dma_addr_t *dma_addr, uint64_t flags); 6719a1d935SNirmoy Das void amdgpu_gart_invalidate_tlb(struct amdgpu_device *adev); 683490bdb5SChristian König #endif 69