diff options
author | Dave Airlie <airlied@redhat.com> | 2020-08-04 05:56:20 +0300 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2020-08-06 06:12:39 +0300 |
commit | 3a1fc38edac75d19dffa5d5b0f1ffc872f8798d9 (patch) | |
tree | 29a9f67280556f7bd71dbc0b45f6119096ba8089 /drivers/gpu/drm/ttm | |
parent | 37205891d84f9269de61d6e85c24607209478a85 (diff) | |
download | linux-3a1fc38edac75d19dffa5d5b0f1ffc872f8798d9.tar.xz |
drm/ttm: move range manager to subclassed driver allocation
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200804025632.3868079-48-airlied@gmail.com
Diffstat (limited to 'drivers/gpu/drm/ttm')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_bo_manager.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c index d83cb967a107..01d41c6f2f7b 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_manager.c +++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c @@ -44,16 +44,22 @@ */ struct ttm_range_manager { + struct ttm_mem_type_manager manager; struct drm_mm mm; spinlock_t lock; }; +static inline struct ttm_range_manager *to_range_manager(struct ttm_mem_type_manager *man) +{ + return container_of(man, struct ttm_range_manager, manager); +} + static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo, const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); struct drm_mm *mm = &rman->mm; struct drm_mm_node *node; enum drm_mm_insert_mode mode; @@ -92,7 +98,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man, static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) { - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); if (mem->mm_node) { spin_lock(&rman->lock); @@ -113,25 +119,26 @@ int ttm_range_man_init(struct ttm_bo_device *bdev, bool use_tt, unsigned long p_size) { - struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type); + struct ttm_mem_type_manager *man; struct ttm_range_manager *rman; - man->available_caching = available_caching; - man->default_caching = default_caching; - man->use_tt = use_tt; - rman = kzalloc(sizeof(*rman), GFP_KERNEL); if (!rman) return -ENOMEM; + man = &rman->manager; + man->available_caching = available_caching; + man->default_caching = default_caching; + man->use_tt = use_tt; + man->func = &ttm_bo_manager_func; ttm_mem_type_manager_init(bdev, man, p_size); drm_mm_init(&rman->mm, 0, p_size); spin_lock_init(&rman->lock); - man->priv = rman; + ttm_set_driver_manager(bdev, type, &rman->manager); ttm_mem_type_manager_set_used(man, true); return 0; } @@ -141,7 +148,7 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev, unsigned type) { struct ttm_mem_type_manager *man = ttm_manager_type(bdev, type); - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); struct drm_mm *mm = &rman->mm; int ret; @@ -155,10 +162,10 @@ int ttm_range_man_fini(struct ttm_bo_device *bdev, drm_mm_clean(mm); drm_mm_takedown(mm); spin_unlock(&rman->lock); - kfree(rman); - man->priv = NULL; ttm_mem_type_manager_cleanup(man); + ttm_set_driver_manager(bdev, type, NULL); + kfree(rman); return 0; } EXPORT_SYMBOL(ttm_range_man_fini); @@ -166,7 +173,7 @@ EXPORT_SYMBOL(ttm_range_man_fini); static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, struct drm_printer *printer) { - struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; + struct ttm_range_manager *rman = to_range_manager(man); spin_lock(&rman->lock); drm_mm_print(&rman->mm, printer); |