Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdgpu: Add reserved region ids

Add reserved regions and helper functions to memory manager.

Signed-off-by: Lijo Lazar <lijo.lazar@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Lijo Lazar and committed by
Alex Deucher
c9042a4d 8d45d88e

+89
+58
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 1671 1671 .access_memory = &amdgpu_ttm_access_memory, 1672 1672 }; 1673 1673 1674 + void amdgpu_ttm_init_vram_resv(struct amdgpu_device *adev, 1675 + enum amdgpu_resv_region_id id, 1676 + uint64_t offset, uint64_t size, 1677 + bool needs_cpu_map) 1678 + { 1679 + struct amdgpu_vram_resv *resv; 1680 + 1681 + if (id >= AMDGPU_RESV_MAX) 1682 + return; 1683 + 1684 + resv = &adev->mman.resv_region[id]; 1685 + resv->offset = offset; 1686 + resv->size = size; 1687 + resv->needs_cpu_map = needs_cpu_map; 1688 + } 1689 + 1690 + int amdgpu_ttm_mark_vram_reserved(struct amdgpu_device *adev, 1691 + enum amdgpu_resv_region_id id) 1692 + { 1693 + struct amdgpu_vram_resv *resv; 1694 + int ret; 1695 + 1696 + if (id >= AMDGPU_RESV_MAX) 1697 + return -EINVAL; 1698 + 1699 + resv = &adev->mman.resv_region[id]; 1700 + if (!resv->size) 1701 + return 0; 1702 + 1703 + ret = amdgpu_bo_create_kernel_at(adev, resv->offset, resv->size, 1704 + &resv->bo, 1705 + resv->needs_cpu_map ? &resv->cpu_ptr : NULL); 1706 + if (ret) { 1707 + dev_dbg(adev->dev, "reserve vram failed: id=%d offset=0x%llx size=0x%llx ret=%d\n", 1708 + id, resv->offset, resv->size, ret); 1709 + memset(resv, 0, sizeof(*resv)); 1710 + } 1711 + 1712 + return ret; 1713 + } 1714 + 1715 + void amdgpu_ttm_unmark_vram_reserved(struct amdgpu_device *adev, 1716 + enum amdgpu_resv_region_id id) 1717 + { 1718 + struct amdgpu_vram_resv *resv; 1719 + 1720 + if (id >= AMDGPU_RESV_MAX) 1721 + return; 1722 + 1723 + resv = &adev->mman.resv_region[id]; 1724 + if (!resv->bo) 1725 + return; 1726 + 1727 + amdgpu_bo_free_kernel(&resv->bo, NULL, 1728 + resv->needs_cpu_map ? &resv->cpu_ptr : NULL); 1729 + memset(resv, 0, sizeof(*resv)); 1730 + } 1731 + 1674 1732 /* 1675 1733 * Firmware Reservation functions 1676 1734 */
+31
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h
··· 59 59 u64 gart_window_offs[2]; 60 60 }; 61 61 62 + enum amdgpu_resv_region_id { 63 + AMDGPU_RESV_STOLEN_VGA, 64 + AMDGPU_RESV_STOLEN_EXTENDED, 65 + AMDGPU_RESV_STOLEN_RESERVED, 66 + AMDGPU_RESV_FW, 67 + AMDGPU_RESV_FW_EXTEND, 68 + AMDGPU_RESV_FW_VRAM_USAGE, 69 + AMDGPU_RESV_DRV_VRAM_USAGE, 70 + AMDGPU_RESV_MEM_TRAIN, 71 + AMDGPU_RESV_MAX 72 + }; 73 + 74 + struct amdgpu_vram_resv { 75 + uint64_t offset; 76 + uint64_t size; 77 + struct amdgpu_bo *bo; 78 + void *cpu_ptr; 79 + bool needs_cpu_map; 80 + }; 81 + 62 82 struct amdgpu_mman { 63 83 struct ttm_device bdev; 64 84 struct ttm_pool *ttm_pools; ··· 128 108 u64 drv_vram_usage_size; 129 109 struct amdgpu_bo *drv_vram_usage_reserved_bo; 130 110 void *drv_vram_usage_va; 111 + 112 + struct amdgpu_vram_resv resv_region[AMDGPU_RESV_MAX]; 131 113 132 114 /* PAGE_SIZE'd BO for process memory r/w over SDMA. */ 133 115 struct amdgpu_bo *sdma_access_bo; ··· 196 174 197 175 bool amdgpu_res_cpu_visible(struct amdgpu_device *adev, 198 176 struct ttm_resource *res); 177 + 178 + void amdgpu_ttm_init_vram_resv(struct amdgpu_device *adev, 179 + enum amdgpu_resv_region_id id, 180 + uint64_t offset, uint64_t size, 181 + bool needs_cpu_map); 182 + int amdgpu_ttm_mark_vram_reserved(struct amdgpu_device *adev, 183 + enum amdgpu_resv_region_id id); 184 + void amdgpu_ttm_unmark_vram_reserved(struct amdgpu_device *adev, 185 + enum amdgpu_resv_region_id id); 199 186 200 187 int amdgpu_ttm_init(struct amdgpu_device *adev); 201 188 void amdgpu_ttm_fini(struct amdgpu_device *adev);