Commit 4f297b9c authored by Dave Airlie's avatar Dave Airlie

drm/amdgpu/ttm: move vram/gtt mgr allocations to mman.

Christian suggested this and it makes sense.
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200806233459.4057784-2-airlied@gmail.com
parent 87154ff8
...@@ -24,13 +24,6 @@ ...@@ -24,13 +24,6 @@
#include "amdgpu.h" #include "amdgpu.h"
struct amdgpu_gtt_mgr {
struct ttm_resource_manager manager;
struct drm_mm mm;
spinlock_t lock;
atomic64_t available;
};
static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_resource_manager *man) static inline struct amdgpu_gtt_mgr *to_gtt_mgr(struct ttm_resource_manager *man)
{ {
return container_of(man, struct amdgpu_gtt_mgr, manager); return container_of(man, struct amdgpu_gtt_mgr, manager);
...@@ -93,16 +86,11 @@ static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func; ...@@ -93,16 +86,11 @@ static const struct ttm_resource_manager_func amdgpu_gtt_mgr_func;
*/ */
int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
{ {
struct ttm_resource_manager *man; struct amdgpu_gtt_mgr *mgr = &adev->mman.gtt_mgr;
struct amdgpu_gtt_mgr *mgr; struct ttm_resource_manager *man = &mgr->manager;
uint64_t start, size; uint64_t start, size;
int ret; int ret;
mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
if (!mgr)
return -ENOMEM;
man = &mgr->manager;
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;
...@@ -142,8 +130,8 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) ...@@ -142,8 +130,8 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
*/ */
void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
{ {
struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_TT); struct amdgpu_gtt_mgr *mgr = &adev->mman.gtt_mgr;
struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man); struct ttm_resource_manager *man = &mgr->manager;
int ret; int ret;
ttm_resource_manager_set_used(man, false); ttm_resource_manager_set_used(man, false);
...@@ -161,7 +149,6 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev) ...@@ -161,7 +149,6 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)
ttm_resource_manager_cleanup(man); ttm_resource_manager_cleanup(man);
ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL); ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_TT, NULL);
kfree(mgr);
} }
/** /**
......
...@@ -41,6 +41,22 @@ ...@@ -41,6 +41,22 @@
#define AMDGPU_POISON 0xd0bed0be #define AMDGPU_POISON 0xd0bed0be
struct amdgpu_vram_mgr {
struct ttm_resource_manager manager;
struct drm_mm mm;
spinlock_t lock;
atomic64_t usage;
atomic64_t vis_usage;
struct amdgpu_device *adev;
};
struct amdgpu_gtt_mgr {
struct ttm_resource_manager manager;
struct drm_mm mm;
spinlock_t lock;
atomic64_t available;
};
struct amdgpu_mman { struct amdgpu_mman {
struct ttm_bo_device bdev; struct ttm_bo_device bdev;
bool mem_global_referenced; bool mem_global_referenced;
...@@ -59,6 +75,9 @@ struct amdgpu_mman { ...@@ -59,6 +75,9 @@ struct amdgpu_mman {
struct mutex gtt_window_lock; struct mutex gtt_window_lock;
/* Scheduler entity for buffer moves */ /* Scheduler entity for buffer moves */
struct drm_sched_entity entity; struct drm_sched_entity entity;
struct amdgpu_vram_mgr vram_mgr;
struct amdgpu_gtt_mgr gtt_mgr;
}; };
struct amdgpu_copy_mem { struct amdgpu_copy_mem {
......
...@@ -28,15 +28,6 @@ ...@@ -28,15 +28,6 @@
#include "amdgpu_atomfirmware.h" #include "amdgpu_atomfirmware.h"
#include "atom.h" #include "atom.h"
struct amdgpu_vram_mgr {
struct ttm_resource_manager manager;
struct drm_mm mm;
spinlock_t lock;
atomic64_t usage;
atomic64_t vis_usage;
struct amdgpu_device *adev;
};
static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_resource_manager *man) static inline struct amdgpu_vram_mgr *to_vram_mgr(struct ttm_resource_manager *man)
{ {
return container_of(man, struct amdgpu_vram_mgr, manager); return container_of(man, struct amdgpu_vram_mgr, manager);
...@@ -177,16 +168,10 @@ static const struct ttm_resource_manager_func amdgpu_vram_mgr_func; ...@@ -177,16 +168,10 @@ static const struct ttm_resource_manager_func amdgpu_vram_mgr_func;
*/ */
int amdgpu_vram_mgr_init(struct amdgpu_device *adev) int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
{ {
struct ttm_resource_manager *man; struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr;
struct amdgpu_vram_mgr *mgr; struct ttm_resource_manager *man = &mgr->manager;
int ret; int ret;
mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
if (!mgr)
return -ENOMEM;
man = &mgr->manager;
man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC; man->available_caching = TTM_PL_FLAG_UNCACHED | TTM_PL_FLAG_WC;
man->default_caching = TTM_PL_FLAG_WC; man->default_caching = TTM_PL_FLAG_WC;
...@@ -219,8 +204,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) ...@@ -219,8 +204,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)
*/ */
void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
{ {
struct ttm_resource_manager *man = ttm_manager_type(&adev->mman.bdev, TTM_PL_VRAM); struct amdgpu_vram_mgr *mgr = &adev->mman.vram_mgr;
struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); struct ttm_resource_manager *man = &mgr->manager;
int ret; int ret;
ttm_resource_manager_set_used(man, false); ttm_resource_manager_set_used(man, false);
...@@ -237,7 +222,6 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev) ...@@ -237,7 +222,6 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)
ttm_resource_manager_cleanup(man); ttm_resource_manager_cleanup(man);
ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL); ttm_set_driver_manager(&adev->mman.bdev, TTM_PL_VRAM, NULL);
kfree(mgr);
} }
/** /**
......
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