Commit 47363354 authored by Christian König's avatar Christian König

drm/amdgpu: stop implementing init_mem_type

Instead just initialize the memory type parameters
before calling ttm_bo_init_mm.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/382084/
parent b0691b34
...@@ -62,55 +62,49 @@ ...@@ -62,55 +62,49 @@
#define AMDGPU_TTM_VRAM_MAX_DW_READ (size_t)128 #define AMDGPU_TTM_VRAM_MAX_DW_READ (size_t)128
/**
* amdgpu_init_mem_type - Initialize a memory manager for a specific type of
* memory request.
*
* @bdev: The TTM BO device object (contains a reference to amdgpu_device)
* @type: The type of memory requested
* @man: The memory type manager for each domain
*
* This is called by ttm_bo_init_mm() when a buffer object is being
* initialized.
*/
static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type, static int amdgpu_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
struct ttm_mem_type_manager *man) struct ttm_mem_type_manager *man)
{ {
struct amdgpu_device *adev; return 0;
}
adev = amdgpu_ttm_adev(bdev); static int amdgpu_ttm_init_vram(struct amdgpu_device *adev)
{
switch (type) { struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
case TTM_PL_SYSTEM:
/* System memory */ man->func = &amdgpu_vram_mgr_func;
break; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
case TTM_PL_TT: man->default_caching = TTM_PL_FLAG_WC;
/* GTT memory */
man->use_tt = true; return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
man->func = &amdgpu_gtt_mgr_func; adev->gmc.real_vram_size >> PAGE_SHIFT);
man->available_caching = TTM_PL_MASK_CACHING; }
man->default_caching = TTM_PL_FLAG_CACHED;
break; static int amdgpu_ttm_init_gtt(struct amdgpu_device *adev, uint64_t gtt_size)
case TTM_PL_VRAM: {
/* "On-card" video ram */ struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
man->func = &amdgpu_vram_mgr_func;
man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->use_tt = true;
man->default_caching = TTM_PL_FLAG_WC; man->func = &amdgpu_gtt_mgr_func;
break; man->available_caching = TTM_PL_MASK_CACHING;
case AMDGPU_PL_GDS: man->default_caching = TTM_PL_FLAG_CACHED;
case AMDGPU_PL_GWS:
case AMDGPU_PL_OA: return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT,
/* On-chip GDS memory*/ gtt_size >> PAGE_SHIFT);
man->func = &ttm_bo_manager_func; }
man->available_caching = TTM_PL_FLAG_UNCACHED;
man->default_caching = TTM_PL_FLAG_UNCACHED; static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
break; unsigned int type,
default: uint64_t size)
DRM_ERROR("Unsupported memory type %u\n", (unsigned)type); {
return -EINVAL; struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
}
return 0; man->func = &ttm_bo_manager_func;
man->available_caching = TTM_PL_FLAG_UNCACHED;
man->default_caching = TTM_PL_FLAG_UNCACHED;
return ttm_bo_init_mm(&adev->mman.bdev, type, size);
} }
/** /**
...@@ -1896,8 +1890,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -1896,8 +1890,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
adev->mman.bdev.no_retry = true; adev->mman.bdev.no_retry = true;
/* Initialize VRAM pool with all of VRAM divided into pages */ /* Initialize VRAM pool with all of VRAM divided into pages */
r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM, r = amdgpu_ttm_init_vram(adev);
adev->gmc.real_vram_size >> PAGE_SHIFT);
if (r) { if (r) {
DRM_ERROR("Failed initializing VRAM heap.\n"); DRM_ERROR("Failed initializing VRAM heap.\n");
return r; return r;
...@@ -1978,7 +1971,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -1978,7 +1971,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
gtt_size = (uint64_t)amdgpu_gtt_size << 20; gtt_size = (uint64_t)amdgpu_gtt_size << 20;
/* Initialize GTT memory pool */ /* Initialize GTT memory pool */
r = ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT, gtt_size >> PAGE_SHIFT); r = amdgpu_ttm_init_gtt(adev, gtt_size);
if (r) { if (r) {
DRM_ERROR("Failed initializing GTT heap.\n"); DRM_ERROR("Failed initializing GTT heap.\n");
return r; return r;
...@@ -1987,22 +1980,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) ...@@ -1987,22 +1980,19 @@ int amdgpu_ttm_init(struct amdgpu_device *adev)
(unsigned)(gtt_size / (1024 * 1024))); (unsigned)(gtt_size / (1024 * 1024)));
/* Initialize various on-chip memory pools */ /* Initialize various on-chip memory pools */
r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GDS, r = amdgpu_ttm_init_on_chip(adev, AMDGPU_PL_GDS, adev->gds.gds_size);
adev->gds.gds_size);
if (r) { if (r) {
DRM_ERROR("Failed initializing GDS heap.\n"); DRM_ERROR("Failed initializing GDS heap.\n");
return r; return r;
} }
r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_GWS, r = amdgpu_ttm_init_on_chip(adev, AMDGPU_PL_GWS, adev->gds.gws_size);
adev->gds.gws_size);
if (r) { if (r) {
DRM_ERROR("Failed initializing gws heap.\n"); DRM_ERROR("Failed initializing gws heap.\n");
return r; return r;
} }
r = ttm_bo_init_mm(&adev->mman.bdev, AMDGPU_PL_OA, r = amdgpu_ttm_init_on_chip(adev, AMDGPU_PL_OA, adev->gds.oa_size);
adev->gds.oa_size);
if (r) { if (r) {
DRM_ERROR("Failed initializing oa heap.\n"); DRM_ERROR("Failed initializing oa heap.\n");
return r; return r;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment