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)
{
struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM];
man->func = &amdgpu_vram_mgr_func;
man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
man->default_caching = TTM_PL_FLAG_WC;
return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_VRAM,
adev->gmc.real_vram_size >> PAGE_SHIFT);
}
static int amdgpu_ttm_init_gtt(struct amdgpu_device *adev, uint64_t gtt_size)
{
struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT];
switch (type) {
case TTM_PL_SYSTEM:
/* System memory */
break;
case TTM_PL_TT:
/* GTT memory */
man->use_tt = true; man->use_tt = true;
man->func = &amdgpu_gtt_mgr_func; man->func = &amdgpu_gtt_mgr_func;
man->available_caching = TTM_PL_MASK_CACHING; man->available_caching = TTM_PL_MASK_CACHING;
man->default_caching = TTM_PL_FLAG_CACHED; man->default_caching = TTM_PL_FLAG_CACHED;
break;
case TTM_PL_VRAM: return ttm_bo_init_mm(&adev->mman.bdev, TTM_PL_TT,
/* "On-card" video ram */ gtt_size >> PAGE_SHIFT);
man->func = &amdgpu_vram_mgr_func; }
man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
man->default_caching = TTM_PL_FLAG_WC; static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev,
break; unsigned int type,
case AMDGPU_PL_GDS: uint64_t size)
case AMDGPU_PL_GWS: {
case AMDGPU_PL_OA: struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type];
/* On-chip GDS memory*/
man->func = &ttm_bo_manager_func; man->func = &ttm_bo_manager_func;
man->available_caching = TTM_PL_FLAG_UNCACHED; man->available_caching = TTM_PL_FLAG_UNCACHED;
man->default_caching = TTM_PL_FLAG_UNCACHED; man->default_caching = TTM_PL_FLAG_UNCACHED;
break;
default: return ttm_bo_init_mm(&adev->mman.bdev, type, size);
DRM_ERROR("Unsupported memory type %u\n", (unsigned)type);
return -EINVAL;
}
return 0;
} }
/** /**
...@@ -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