ttm mem manager refactoring.
Subsystems (8)
Dave Airlie
maintainercover ttm mem manager refactoring.
I started pulling on a thread, and it led me down a hole.
This series refactors the ttm ttm_mem_type_manager object into a driver owned, allocated, subclassaed object.
It starts with two minor fixes for some bad assumptions in two drivers.
Enables a new init path, ports all the drivers to the new init path, and cleans up the old init path.
Enables a new takedown path, ports all the drivers to the new takedown path, and cleans up the old takedown path
Wraps all access to the memory managers in the bo_device in a wrapper across all drivers.
Make debug callback optional
Enables driver to provide their own mem manager objects Subclasses the objects in all drivers and makes them into driver owned object Drops the bo_device arrays of pointers, and some unneeded links and struct members
Cleans up one api.
I think I'd probably want to merge all this via drm-misc, so if I can collect acks/r-b from driver maintainers that would be good.
This is also based on Chrisitan's work to remove init_mem_type, so it won't apply until he's finished getting all of that into drm-misc.
https://cgit.freedesktop.org/~airlied/linux/log/?h=ttm-refactor-mem-manager
is the tree I've built this on top off, so it's probably going to get rebased but the code should stay mostly the same.
I've done some boot testing on nouveau, and I hope to test it on vmwgfx and amdgpu soon.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 2/49 drm/vram-helper: call the ttm manager debug function
From: Dave Airlie <[email protected]>
This code was assuming there was a drm_mm here, don't do that call the correct API.
--- drivers/gpu/drm/drm_gem_vram_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +2 -4
@@ -1075,12 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data) {struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_vram_mm *vmm = node->minor->dev->vram_mm; -struct drm_mm *mm = vmm->bdev.man[TTM_PL_VRAM ].priv; +struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM ];struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&ttm_bo_glob.lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&ttm_bo_glob.lru_lock); + man->func->debug (man, &p);return 0 ; }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 1/49 drm/qxl/ttm: call ttm manager debug
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This code was poking inside a struct and assuming it was a drm_mm at the start. Call the proper API.
--- drivers/gpu/drm/qxl/qxl_ttm.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +4 -6
@@ -279,12 +279,10 @@ void qxl_ttm_fini(struct qxl_device *qdev)static int qxl_mm_dump_table (struct seq_file *m,void *data) {struct drm_info_node *node = (struct drm_info_node *)m->private; -struct drm_mm *mm = (struct drm_mm *)node->info_ent->data; +struct ttm_mem_type_manager *man = (struct ttm_mem_type_manager *)node->info_ent->data;struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&ttm_bo_glob.lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&ttm_bo_glob.lru_lock); + man->func->debug (man, &p);return 0 ; }#endif
@@ -305,9 +303,9 @@ void qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table; qxl_mem_types_list[i].driver_features =0 ;if (i ==0 ) - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM ];else - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV ].priv; + qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV ]; }qxl_debugfs_add_files (qdev, qxl_mem_types_list, i);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 3/49 drm/ttm: split the mm manager init code
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This will allow the driver to control the ordering here better.
Eventually the old path will be removed.
--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +20 -14
@@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) { -int ret; -struct ttm_mem_type_manager *man;unsigned i; -BUG_ON (type >=TTM_NUM_MEM_TYPES ); - man = &bdev->man[type];BUG_ON (man->has_type); man->use_io_reserve_lru = false;mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);INIT_LIST_HEAD (&man->io_reserve_lru); man->bdev = bdev; - -if (type !=TTM_PL_SYSTEM ) { - ret = (*man->func->init)(man, p_size); -if (ret) -return ret; - } - man->has_type = true; - man->use_type = true; man->size = p_size;for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i)INIT_LIST_HEAD (&man->lru[i]); man->move =NULL ; +} +EXPORT_SYMBOL (ttm_bo_init_mm_base); +int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, +unsigned long p_size) +{ +int ret; +struct ttm_mem_type_manager *man; + +BUG_ON (type >=TTM_NUM_MEM_TYPES ); +ttm_bo_init_mm_base (bdev, &bdev->man[type], p_size); + +if (type !=TTM_PL_SYSTEM ) { + ret = (*man->func->init)(man, p_size); +if (ret) +return ret; + } +ttm_bo_use_mm (man);return 0 ; }EXPORT_SYMBOL (ttm_bo_init_mm);
include/drm/ttm/ttm_bo_api.h +4 -0
@@ -546,6 +546,10 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,* -ENOMEM: Not enough memory. * May also return driver-specified errors. */ +struct ttm_mem_type_manager ; +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type,unsigned long p_size);
include/drm/ttm/ttm_bo_driver.h +6 -0
@@ -678,6 +678,12 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)dma_resv_unlock (bo->base.resv); } +static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) +{ + man->has_type = true; + man->use_type = true; +} +/* * ttm_bo_util.c */
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 5/49 drm/amdgpu/ttm: init managers from the driver side.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Use new init calls to unwrap manager init
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 19 ++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 37 +++----------------- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 4 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 19 ++++++---- 4 files changed, 33 insertions(+), 46 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +13 -6
@@ -76,6 +76,7 @@ static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO, static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO, amdgpu_mem_info_gtt_used_show, NULL); +static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;/** * amdgpu_gtt_mgr_init - init GTT manager and DRM MM *
@@ -84,14 +85,20 @@ static DEVICE_ATTR(mem_info_gtt_used, S_IRUGO,* * Allocate and initialize the GTT manager. */ -static int amdgpu_gtt_mgr_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT ];struct amdgpu_gtt_mgr *mgr;uint64_t start, size;int ret; + man->use_tt = true; + man->func = &amdgpu_gtt_mgr_func; + man->available_caching =TTM_PL_MASK_CACHING ; + man->default_caching =TTM_PL_FLAG_CACHED ; + +ttm_bo_init_mm_base (&adev->mman.bdev, man, gtt_size >>PAGE_SHIFT ); + mgr =kzalloc (sizeof (*mgr),GFP_KERNEL );if (!mgr)return -ENOMEM ;
@@ -100,7 +107,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man, size = (adev->gmc.gart_size >>PAGE_SHIFT ) - start;drm_mm_init (&mgr->mm, start, size);spin_lock_init (&mgr->lock); -atomic64_set (&mgr->available, p_size); +atomic64_set (&mgr->available, gtt_size >>PAGE_SHIFT ); man->priv = mgr; ret =device_create_file (adev->dev, &dev_attr_mem_info_gtt_total);
@@ -114,6 +121,7 @@ static int amdgpu_gtt_mgr_init(struct ttm_mem_type_manager *man,return ret; } +ttm_bo_use_mm (man);return 0 ; }
@@ -298,8 +306,7 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, amdgpu_gtt_mgr_usage(man) >> 20); } -const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { - .init = amdgpu_gtt_mgr_init, +static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { .takedown = amdgpu_gtt_mgr_fini, .get_node = amdgpu_gtt_mgr_new, .put_node = amdgpu_gtt_mgr_del,
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -32
@@ -63,43 +63,16 @@#define AMDGPU_TTM_VRAM_MAX_DW_READ (size_t)128 -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 ]; - - man->use_tt = true; - man->func = &amdgpu_gtt_mgr_func; - man->available_caching =TTM_PL_MASK_CACHING ; - man->default_caching =TTM_PL_FLAG_CACHED ; - -return ttm_bo_init_mm (&adev->mman.bdev,TTM_PL_TT , - gtt_size >>PAGE_SHIFT ); -} -static int amdgpu_ttm_init_on_chip (struct amdgpu_device *adev, -unsigned int type, -uint64_t size) +unsigned int type, +uint64_t size) {struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type]; - 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); +return ttm_bo_man_init (&adev->mman.bdev, man, size >>PAGE_SHIFT ); }/**
@@ -1915,7 +1888,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) adev->mman.bdev.no_retry = true;/* Initialize VRAM pool with all of VRAM divided into pages */ - r =amdgpu_ttm_init_vram (adev); + r =amdgpu_vram_mgr_init (adev);if (r) {DRM_ERROR ("Failed initializing VRAM heap.\n" );return r;
@@ -1982,7 +1955,7 @@ int amdgpu_ttm_init(struct amdgpu_device *adev) gtt_size = (uint64_t )amdgpu_gtt_size <<20 ;/* Initialize GTT memory pool */ - r =amdgpu_ttm_init_gtt (adev, gtt_size); + r =amdgpu_gtt_mgr_init (adev, gtt_size);if (r) {DRM_ERROR ("Failed initializing GTT heap.\n" );return r;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -2
@@ -67,8 +67,8 @@ struct amdgpu_copy_mem {unsigned long offset; }; -extern const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func; -extern const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; +int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size); +int amdgpu_vram_mgr_init (struct amdgpu_device *adev);bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man);
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +13 -6
@@ -158,6 +158,8 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = { NULL }; +static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func; +/** * amdgpu_vram_mgr_init - init VRAM manager and DRM MM *
@@ -166,18 +168,23 @@ static const struct attribute *amdgpu_vram_mgr_attributes[] = {* * Allocate and initialize the VRAM manager. */ -static int amdgpu_vram_mgr_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +int amdgpu_vram_mgr_init (struct amdgpu_device *adev) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM ];struct amdgpu_vram_mgr *mgr;int ret; + man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; + man->default_caching =TTM_PL_FLAG_WC ; + +ttm_bo_init_mm_base (&adev->mman.bdev, man, adev->gmc.real_vram_size >>PAGE_SHIFT ); + + man->func = &amdgpu_vram_mgr_func; mgr =kzalloc (sizeof (*mgr),GFP_KERNEL );if (!mgr)return -ENOMEM ; -drm_mm_init (&mgr->mm,0 , p_size); +drm_mm_init (&mgr->mm,0 , man->size);spin_lock_init (&mgr->lock); man->priv = mgr;
@@ -186,6 +193,7 @@ static int amdgpu_vram_mgr_init(struct ttm_mem_type_manager *man,if (ret)DRM_ERROR ("Failed to register sysfs\n" ); +ttm_bo_use_mm (man);return 0 ; }
@@ -587,8 +595,7 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, amdgpu_vram_mgr_vis_usage(man) >> 20); } -const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { - .init = amdgpu_vram_mgr_init, +static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { .takedown = amdgpu_vram_mgr_fini, .get_node = amdgpu_vram_mgr_new, .put_node = amdgpu_vram_mgr_del,
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 4/49 drm/ttm: provide a driver-led init path for generic mm manager.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This lets the generic mm manager be initialised by the driver.
--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++--- include/drm/ttm/ttm_bo_driver.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_manager.c +20 -3
@@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +unsigned long p_size) {struct ttm_range_manager *rman;
@@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,return 0 ; } +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) +{ +int ret; + + man->func = &ttm_bo_manager_func; + +ttm_bo_init_mm_base (bdev, man, p_size); + ret =ttm_bo_man_init_private (man, p_size); +if (ret) +return ret; +ttm_bo_use_mm (man); +return 0 ; +} +EXPORT_SYMBOL (ttm_bo_man_init); +static int ttm_bo_man_takedown (struct ttm_mem_type_manager *man) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
@@ -147,7 +164,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init, + .init = ttm_bo_man_init_private, .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node,
include/drm/ttm/ttm_bo_driver.h +3 -0
@@ -799,6 +799,9 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);*/ pgprot_t ttm_io_prot (uint32_t caching_flags,pgprot_t tmp); +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;#endif
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 6/49 drm/radeon: use new ttm man init path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Use the new common manager init path.
--- drivers/gpu/drm/radeon/radeon_ttm.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +3 -5
@@ -70,19 +70,17 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev) {struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM ]; - man->func = &ttm_bo_manager_func; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; -return ttm_bo_init_mm (&rdev->mman.bdev,TTM_PL_VRAM , - rdev->mc.real_vram_size >>PAGE_SHIFT ); +return ttm_bo_man_init (&rdev->mman.bdev, man, + rdev->mc.real_vram_size >>PAGE_SHIFT ); }static int radeon_ttm_init_gtt (struct radeon_device *rdev) {struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT ]; - man->func = &ttm_bo_manager_func; man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; man->use_tt = true;
@@ -98,7 +96,7 @@ static int radeon_ttm_init_gtt(struct radeon_device *rdev) }#endif -return ttm_bo_init_mm (&rdev->mman.bdev,TTM_PL_TT , +return ttm_bo_man_init (&rdev->mman.bdev, man, rdev->mc.gtt_size >>PAGE_SHIFT ); }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 7/49 drm/qxl/ttm: use new init path for manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/qxl/qxl_ttm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +1 -2
@@ -221,11 +221,10 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, {struct ttm_mem_type_manager *man = &qdev->mman.bdev.man[type]; - man->func = &ttm_bo_manager_func; man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; -return ttm_bo_init_mm (&qdev->mman.bdev, type, size); +return ttm_bo_man_init (&qdev->mman.bdev, man, size); }int qxl_ttm_init (struct qxl_device *qdev)
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 8/49 drm/vram_helper: use new ttm manager init function
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/drm_gem_vram_helper.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +1 -2
@@ -1116,10 +1116,9 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,if (ret)return ret; - man->func = &ttm_bo_manager_func; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; - ret =ttm_bo_init_mm (&vmm->bdev,TTM_PL_VRAM , vram_size >>PAGE_SHIFT ); + ret =ttm_bo_man_init (&vmm->bdev, man, vram_size >>PAGE_SHIFT );if (ret)return ret;
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 10/49 drm/vmwgfx/ttm: convert vram mm init to new code paths
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Split out the vram thp init path vs the range manager init.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 25 +++++++++++++++++++------ drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 4 +--- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 12 ++++++++---- 3 files changed, 28 insertions(+), 13 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +19 -6
@@ -620,6 +620,23 @@ static int vmw_dma_masks(struct vmw_private *dev_priv)return ret; } +static int vmw_init_vram_manager (struct vmw_private *dev_priv) +{ +int ret; +#ifdef CONFIG_TRANSPARENT_HUGEPAGE + ret =vmw_thp_init (dev_priv); +#else +struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ]; + + man->available_caching =TTM_PL_FLAG_CACHED ; + man->default_caching =TTM_PL_FLAG_CACHED ; + + ret =ttm_bo_man_init (&dev_priv->bdev, man, + dev_priv->vram_size >>PAGE_SHIFT ); +#endif + dev_priv->bdev.man[TTM_PL_VRAM ].use_type = false; +return ret; +}static int vmw_driver_load (struct drm_device *dev,unsigned long chipset) {struct vmw_private *dev_priv;
@@ -864,16 +881,12 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)* Enable VRAM, but initially don't use it until SVGA is enabled and * unhidden. */ - dev_priv->bdev.man[TTM_PL_VRAM ].func = &vmw_thp_func; - dev_priv->bdev.man[TTM_PL_VRAM ].available_caching =TTM_PL_FLAG_CACHED ; - dev_priv->bdev.man[TTM_PL_VRAM ].default_caching =TTM_PL_FLAG_CACHED ; - ret =ttm_bo_init_mm (&dev_priv->bdev,TTM_PL_VRAM , - (dev_priv->vram_size >>PAGE_SHIFT )); + + ret =vmw_init_vram_manager (dev_priv);if (unlikely (ret !=0 )) {DRM_ERROR ("Failed initializing memory manager for VRAM.\n" ); goto out_no_vram; } - dev_priv->bdev.man[TTM_PL_VRAM ].use_type = false;/* * "Guest Memory Regions" is an aperture like feature with
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -3
@@ -1520,9 +1520,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,/* Transparent hugepage support - vmwgfx_thp.c */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE -extern const struct ttm_mem_type_manager_func vmw_thp_func; -#else -#define vmw_thp_func ttm_bo_manager_func +extern int vmw_thp_init (struct vmw_private *dev_priv);#endif /**
drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +8 -4
@@ -115,18 +115,23 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man, } } -static int vmw_thp_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +int vmw_thp_init (struct vmw_private *dev_priv) { +struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ];struct vmw_thp_manager *rman; + man->available_caching =TTM_PL_FLAG_CACHED ; + man->default_caching =TTM_PL_FLAG_CACHED ; +ttm_bo_init_mm_base (&dev_priv->bdev, man, + dev_priv->vram_size >>PAGE_SHIFT ); rman =kzalloc (sizeof (*rman),GFP_KERNEL );if (!rman)return -ENOMEM ; -drm_mm_init (&rman->mm,0 , p_size); +drm_mm_init (&rman->mm,0 , man->size);spin_lock_init (&rman->lock); man->priv = rman; +ttm_bo_use_mm (man);return 0 ; }
@@ -158,7 +163,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func vmw_thp_func = { - .init = vmw_thp_init, .takedown = vmw_thp_takedown, .get_node = vmw_thp_get_node, .put_node = vmw_thp_put_node,
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 11/49 drm/vmwgfx/ttm: switch gmrid allocator to new init paths.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 17 ++++------------- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 19 ++++++++++++------- 3 files changed, 17 insertions(+), 21 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4 -13
@@ -894,14 +894,10 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)* slots as well as the bo size. */ dev_priv->has_gmr = true; - dev_priv->bdev.man[VMW_PL_GMR ].func = &vmw_gmrid_manager_func; - dev_priv->bdev.man[VMW_PL_GMR ].available_caching =TTM_PL_FLAG_CACHED ; - dev_priv->bdev.man[VMW_PL_GMR ].default_caching =TTM_PL_FLAG_CACHED ;/* TODO: This is most likely not correct */ - dev_priv->bdev.man[VMW_PL_GMR ].use_tt = true;if (((dev_priv->capabilities & (SVGA_CAP_GMR |SVGA_CAP_GMR2 )) ==0 ) || - refuse_dma ||ttm_bo_init_mm (&dev_priv->bdev,VMW_PL_GMR , -VMW_PL_GMR ) !=0 ) { + refuse_dma || +vmw_gmrid_man_init (dev_priv,VMW_PL_GMR ) !=0 ) {DRM_INFO ("No GMR memory available. " "Graphics memory resources are very limited.\n" ); dev_priv->has_gmr = false;
@@ -909,13 +905,8 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)if (dev_priv->capabilities &SVGA_CAP_GBOBJECTS && !refuse_dma) { dev_priv->has_mob = true; - dev_priv->bdev.man[VMW_PL_MOB ].func = &vmw_gmrid_manager_func; - dev_priv->bdev.man[VMW_PL_MOB ].available_caching =TTM_PL_FLAG_CACHED ; - dev_priv->bdev.man[VMW_PL_MOB ].default_caching =TTM_PL_FLAG_CACHED ; -/* TODO: This is most likely not correct */ - dev_priv->bdev.man[VMW_PL_MOB ].use_tt = true; -if (ttm_bo_init_mm (&dev_priv->bdev,VMW_PL_MOB , -VMW_PL_MOB ) !=0 ) { + +if (vmw_gmrid_man_init (dev_priv,VMW_PL_MOB ) !=0 ) {DRM_INFO ("No MOB memory available. " "3D will be disabled.\n" ); dev_priv->has_mob = false;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -1
@@ -1221,7 +1221,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);* GMR Id manager */ -extern const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; +int vmw_gmrid_man_init (struct vmw_private *dev_priv,int type);/** * Prime - vmwgfx_prime.c
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +12 -7
@@ -94,22 +94,28 @@ static void vmw_gmrid_man_put_node(struct ttm_mem_type_manager *man, } } -static int vmw_gmrid_man_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func; + +int vmw_gmrid_man_init (struct vmw_private *dev_priv,int type) { -struct vmw_private *dev_priv = - container_of(man->bdev, struct vmw_private, bdev); +struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];struct vmwgfx_gmrid_man *gman =kzalloc (sizeof (*gman),GFP_KERNEL );if (unlikely (!gman))return -ENOMEM ; + man->func = &vmw_gmrid_manager_func; + man->available_caching =TTM_PL_FLAG_CACHED ; + man->default_caching =TTM_PL_FLAG_CACHED ; +/* TODO: This is most likely not correct */ + man->use_tt = true; +ttm_bo_init_mm_base (&dev_priv->bdev, man,0 );spin_lock_init (&gman->lock); gman->used_gmr_pages =0 ;ida_init (&gman->gmr_ida); -switch (p_size) { +switch (type) {case VMW_PL_GMR : gman->max_gmr_ids = dev_priv->max_gmr_ids; gman->max_gmr_pages = dev_priv->max_gmr_pages;
@@ -143,8 +149,7 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,drm_printf (printer,"No debug info available for the GMR id manager\n" ); } -const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { - .init = vmw_gmrid_man_init, +static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { .takedown = vmw_gmrid_man_takedown, .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node,
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 12/49 drm/ttm: convert system manager init to new code.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Remove the exit path, since this can't fail now.
--- drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +17 -13
@@ -1644,6 +1644,22 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) }EXPORT_SYMBOL (ttm_bo_device_release); +static void ttm_bo_init_sysman (struct ttm_bo_device *bdev) +{ +struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM ]; + +/* +* Initialize the system memory buffer type. +* Other types need to be driver / IOCTL initialized. +*/ + man->use_tt = true; + man->available_caching =TTM_PL_MASK_CACHING ; + man->default_caching =TTM_PL_FLAG_CACHED ; + +ttm_bo_init_mm_base (bdev, man,0 ); +ttm_bo_use_mm (man); +} + int ttm_bo_device_init(struct ttm_bo_device *bdev, struct ttm_bo_driver *driver, struct address_space *mapping,
@@ -1664,16 +1680,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,memset (bdev->man,0 ,sizeof (bdev->man)); -/* -* Initialize the system memory buffer type. -* Other types need to be driver / IOCTL initialized. -*/ - bdev->man[TTM_PL_SYSTEM ].use_tt = true; - bdev->man[TTM_PL_SYSTEM ].available_caching =TTM_PL_MASK_CACHING ; - bdev->man[TTM_PL_SYSTEM ].default_caching =TTM_PL_FLAG_CACHED ; - ret =ttm_bo_init_mm (bdev,TTM_PL_SYSTEM ,0 ); -if (unlikely (ret !=0 )) - goto out_no_sys; +ttm_bo_init_sysman (bdev); bdev->vma_manager = vma_manager;INIT_DELAYED_WORK (&bdev->wq, ttm_bo_delayed_workqueue);
@@ -1685,9 +1692,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,mutex_unlock (&ttm_global_mutex);return 0 ; -out_no_sys: -ttm_bo_global_release (); -return ret; }EXPORT_SYMBOL (ttm_bo_device_init);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 14/49 drm/ttm: pass man around instead of mem_type in some places
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This makes it easier to cleanup things
--- drivers/gpu/drm/ttm/ttm_bo.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +6 -8
@@ -763,13 +763,12 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, }static int ttm_mem_evict_first (struct ttm_bo_device *bdev, -uint32_t mem_type, +struct ttm_mem_type_manager *man,const struct ttm_place *place,struct ttm_operation_ctx *ctx,struct ww_acquire_ctx *ticket) {struct ttm_buffer_object *bo =NULL , *busy_bo =NULL ; -struct ttm_mem_type_manager *man = &bdev->man[mem_type];bool locked = false;unsigned i;int ret;
@@ -918,7 +917,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,break ;if (unlikely (ret != -ENOSPC ))return ret; - ret =ttm_mem_evict_first (bdev, mem->mem_type, place, ctx, + ret =ttm_mem_evict_first (bdev, man, place, ctx, ticket);if (unlikely (ret !=0 ))return ret;
@@ -1403,14 +1402,13 @@ int ttm_bo_create(struct ttm_bo_device *bdev,EXPORT_SYMBOL (ttm_bo_create);static int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, -unsigned mem_type) +struct ttm_mem_type_manager *man) {struct ttm_operation_ctx ctx = { .interruptible = false, .no_wait_gpu = false, .flags =TTM_OPT_FLAG_FORCE_ALLOC }; -struct ttm_mem_type_manager *man = &bdev->man[mem_type];struct ttm_bo_global *glob = &ttm_bo_glob;struct dma_fence *fence;int ret;
@@ -1424,7 +1422,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i) {while (!list_empty (&man->lru[i])) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type,NULL , &ctx, + ret =ttm_mem_evict_first (bdev, man,NULL , &ctx,NULL );if (ret)return ret;
@@ -1469,7 +1467,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret =0 ;if (mem_type >0 ) { - ret =ttm_bo_force_list_clean (bdev, mem_type); + ret =ttm_bo_force_list_clean (bdev, man);if (ret) {pr_err ("Cleanup eviction failed\n" );return ret;
@@ -1499,7 +1497,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)return 0 ; } -return ttm_bo_force_list_clean (bdev, mem_type); +return ttm_bo_force_list_clean (bdev, man); }EXPORT_SYMBOL (ttm_bo_evict_mm);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 13/49 drm/ttm: purge old manager init path.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/ttm/ttm_bo.c | 19 ------------------- drivers/gpu/drm/ttm/ttm_bo_manager.c | 27 +++++++++------------------ include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 14 -------------- 4 files changed, 9 insertions(+), 53 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -19
@@ -1523,25 +1523,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_init_mm_base); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) -{ -int ret; -struct ttm_mem_type_manager *man; - -BUG_ON (type >=TTM_NUM_MEM_TYPES ); -ttm_bo_init_mm_base (bdev, &bdev->man[type], p_size); - -if (type !=TTM_PL_SYSTEM ) { - ret = (*man->func->init)(man, p_size); -if (ret) -return ret; - } -ttm_bo_use_mm (man); -return 0 ; -} -EXPORT_SYMBOL (ttm_bo_init_mm); -static void ttm_bo_global_kobj_release (struct kobject *kobj) { struct ttm_bo_global *glob =
drivers/gpu/drm/ttm/ttm_bo_manager.c +9 -18
@@ -104,11 +104,18 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +static const struct ttm_mem_type_manager_func ttm_bo_manager_func; + +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man,unsigned long p_size) {struct ttm_range_manager *rman; + man->func = &ttm_bo_manager_func; + +ttm_bo_init_mm_base (bdev, man, p_size); + rman =kzalloc (sizeof (*rman),GFP_KERNEL );if (!rman)return -ENOMEM ;
@@ -116,21 +123,7 @@ static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,drm_mm_init (&rman->mm,0 , p_size);spin_lock_init (&rman->lock); man->priv = rman; -return 0 ; -} -int ttm_bo_man_init (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, -unsigned long p_size) -{ -int ret; - - man->func = &ttm_bo_manager_func; - -ttm_bo_init_mm_base (bdev, man, p_size); - ret =ttm_bo_man_init_private (man, p_size); -if (ret) -return ret;ttm_bo_use_mm (man);return 0 ; }
@@ -163,11 +156,9 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,spin_unlock (&rman->lock); } -const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init_private, +static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug }; -EXPORT_SYMBOL (ttm_bo_manager_func);
include/drm/ttm/ttm_bo_api.h +0 -2
@@ -550,8 +550,6 @@ struct ttm_mem_type_manager;void ttm_bo_init_mm_base (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man,unsigned long p_size); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size);/** * ttm_bo_clean_mm
include/drm/ttm/ttm_bo_driver.h +0 -14
@@ -48,19 +48,6 @@struct ttm_mem_type_manager ;struct ttm_mem_type_manager_func { -/** -* struct ttm_mem_type_manager member init -* -* @man: Pointer to a memory type manager. -* @p_size: Implementation dependent, but typically the size of the -* range to be managed in pages. -* -* Called to initialize a private range manager. The function is -* expected to initialize the man::priv member. -* Returns 0 on success, negative error code on failure. -*/ -int (*init)(struct ttm_mem_type_manager *man,unsigned long p_size); -/** * struct ttm_mem_type_manager member takedown *
@@ -802,6 +789,5 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);int ttm_bo_man_init (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man,unsigned long p_size); -extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;#endif
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 15/49 drm/ttm: make some inline helper functions for cleanup paths.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- include/drm/ttm/ttm_bo_driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -4
@@ -1462,8 +1462,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)return ret; } - man->use_type = false; - man->has_type = false; +ttm_bo_disable_mm (man); ret =0 ;if (mem_type >0 ) {
@@ -1476,8 +1475,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = (*man->func->takedown)(man); } -dma_fence_put (man->move); - man->move =NULL ; +ttm_bo_man_cleanup (man);return ret; }
include/drm/ttm/ttm_bo_driver.h +12 -0
@@ -671,6 +671,18 @@ static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) man->use_type = true; } +static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) +{ + man->has_type = false; + man->use_type = false; +} + +static inline void ttm_bo_man_cleanup (struct ttm_mem_type_manager *man) +{ +dma_fence_put (man->move); + man->move =NULL ; +} +/* * ttm_bo_util.c */
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 9/49 drm/nouveau: use new memory manager init paths
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_ttm.c | 43 ++++++++++++--------------- 1 file changed, 19 insertions(+), 24 deletions(-)
drivers/gpu/drm/nouveau/nouveau_ttm.c +19 -24
@@ -31,12 +31,6 @@#include <core/tegra.h> -static int -nouveau_manager_init (struct ttm_mem_type_manager *man,unsigned long psize) -{ -return 0 ; -} -static int nouveau_manager_fini (struct ttm_mem_type_manager *man) {
@@ -82,7 +76,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func nouveau_vram_manager = { - .init = nouveau_manager_init, .takedown = nouveau_manager_fini, .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del,
@@ -108,7 +101,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func nouveau_gart_manager = { - .init = nouveau_manager_init, .takedown = nouveau_manager_fini, .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del,
@@ -143,7 +135,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func nv04_gart_manager = { - .init = nouveau_manager_init, .takedown = nouveau_manager_fini, .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del,
@@ -200,27 +191,21 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->func = &nouveau_vram_manager; man->use_io_reserve_lru = true; +ttm_bo_init_mm_base (&drm->ttm.bdev, man, + drm->gem.vram_available >>PAGE_SHIFT ); +ttm_bo_use_mm (man); +return 0 ; }else { - man->func = &ttm_bo_manager_func; +return ttm_bo_man_init (&drm->ttm.bdev, man, + drm->gem.vram_available >>PAGE_SHIFT ); } - -return ttm_bo_init_mm (&drm->ttm.bdev,TTM_PL_VRAM , - drm->gem.vram_available >>PAGE_SHIFT ); }static int nouveau_ttm_init_gtt (struct nouveau_drm *drm) {struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT ]; - -if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) - man->func = &nouveau_gart_manager; -else -if (!drm->agp.bridge) - man->func = &nv04_gart_manager; -else - man->func = &ttm_bo_manager_func; - +unsigned long size_pages = drm->gem.gart_available >>PAGE_SHIFT ; man->use_tt = true;if (drm->agp.bridge) { man->available_caching = TTM_PL_FLAG_UNCACHED |
@@ -231,8 +216,18 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->default_caching =TTM_PL_FLAG_CACHED ; } -return ttm_bo_init_mm (&drm->ttm.bdev,TTM_PL_TT , - drm->gem.gart_available >>PAGE_SHIFT ); +if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) + man->func = &nouveau_gart_manager; +else if (!drm->agp.bridge) + man->func = &nv04_gart_manager; +else +return ttm_bo_man_init (&drm->ttm.bdev, man, + size_pages); + +ttm_bo_init_mm_base (&drm->ttm.bdev, man, + size_pages); +ttm_bo_use_mm (man); +return 0 ; }int
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 17/49 drm/amdgpu/ttm: use new takedown path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 15 +++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 15 +++++++++++---- 4 files changed, 29 insertions(+), 13 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +11 -4
@@ -133,10 +133,18 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)* Destroy and free the GTT manager, returns -EBUSY if ranges are still * allocated inside it. */ -static int amdgpu_gtt_mgr_fini (struct ttm_mem_type_manager *man) +void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT ];struct amdgpu_gtt_mgr *mgr = man->priv; +int ret; + +ttm_bo_disable_mm (man); + + ret =ttm_bo_force_list_clean (&adev->mman.bdev, man); +if (ret) +return ; +spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);spin_unlock (&mgr->lock);
@@ -146,7 +154,7 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)device_remove_file (adev->dev, &dev_attr_mem_info_gtt_total);device_remove_file (adev->dev, &dev_attr_mem_info_gtt_used); -return 0 ; +ttm_bo_man_cleanup (man); }/**
@@ -307,7 +315,6 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { - .takedown = amdgpu_gtt_mgr_fini, .get_node = amdgpu_gtt_mgr_new, .put_node = amdgpu_gtt_mgr_del, .debug = amdgpu_gtt_mgr_debug
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5 -5
@@ -2012,11 +2012,11 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)iounmap (adev->mman.aper_base_kaddr); adev->mman.aper_base_kaddr =NULL ; -ttm_bo_clean_mm (&adev->mman.bdev,TTM_PL_VRAM ); -ttm_bo_clean_mm (&adev->mman.bdev,TTM_PL_TT ); -ttm_bo_clean_mm (&adev->mman.bdev,AMDGPU_PL_GDS ); -ttm_bo_clean_mm (&adev->mman.bdev,AMDGPU_PL_GWS ); -ttm_bo_clean_mm (&adev->mman.bdev,AMDGPU_PL_OA ); +amdgpu_vram_mgr_fini (adev); +amdgpu_gtt_mgr_fini (adev); +ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS ]); +ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS ]); +ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA ]);ttm_bo_device_release (&adev->mman.bdev); adev->mman.initialized = false;DRM_INFO ("amdgpu: ttm finalized\n" );
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2 -0
@@ -68,7 +68,9 @@ struct amdgpu_copy_mem { };int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size); +void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev);int amdgpu_vram_mgr_init (struct amdgpu_device *adev); +void amdgpu_vram_mgr_fini (struct amdgpu_device *adev);bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man);
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +11 -4
@@ -205,10 +205,17 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)* Destroy and free the VRAM manager, returns -EBUSY if ranges are still * allocated inside it. */ -static int amdgpu_vram_mgr_fini (struct ttm_mem_type_manager *man) +void amdgpu_vram_mgr_fini (struct amdgpu_device *adev) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM ];struct amdgpu_vram_mgr *mgr = man->priv; +int ret; + +ttm_bo_disable_mm (man); + + ret =ttm_bo_force_list_clean (&adev->mman.bdev, man); +if (ret) +return ;spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);
@@ -216,7 +223,8 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)kfree (mgr); man->priv =NULL ;sysfs_remove_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes); -return 0 ; + +ttm_bo_man_cleanup (man); }/**
@@ -596,7 +604,6 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { - .takedown = amdgpu_vram_mgr_fini, .get_node = amdgpu_vram_mgr_new, .put_node = amdgpu_vram_mgr_del, .debug = amdgpu_vram_mgr_debug
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 18/49 drm/vmwgfx: takedown vram manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Don't bother returning EBUSY, nobody cares enough, if the driver has a problem, it should deal with it.
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 ++++++++++++- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 23 +++++++++++++---------- 3 files changed, 26 insertions(+), 11 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +12 -1
@@ -637,6 +637,17 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv) dev_priv->bdev.man[TTM_PL_VRAM ].use_type = false;return ret; } + +static void vmw_takedown_vram_manager (struct vmw_private *dev_priv) +{ +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +vmw_thp_takedown (dev_priv); +#else +ttm_bo_man_takedown (&dev_priv->bdev, + &dev_priv->bdev.man[TTM_PL_VRAM ]); +#endif +} +static int vmw_driver_load (struct drm_device *dev,unsigned long chipset) {struct vmw_private *dev_priv;
@@ -986,7 +997,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset) (void )ttm_bo_clean_mm (&dev_priv->bdev,VMW_PL_MOB );if (dev_priv->has_gmr) (void )ttm_bo_clean_mm (&dev_priv->bdev,VMW_PL_GMR ); - (void )ttm_bo_clean_mm (&dev_priv->bdev,TTM_PL_VRAM ); +vmw_takedown_vram_manager (dev_priv); out_no_vram: (void )ttm_bo_device_release (&dev_priv->bdev); out_no_bdev:
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -0
@@ -1521,6 +1521,7 @@ vm_fault_t vmw_bo_vm_huge_fault(struct vm_fault *vmf,/* Transparent hugepage support - vmwgfx_thp.c */ #ifdef CONFIG_TRANSPARENT_HUGEPAGE extern int vmw_thp_init (struct vmw_private *dev_priv); +void vmw_thp_takedown (struct vmw_private *dev_priv);#endif /**
drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +13 -10
@@ -135,21 +135,25 @@ int vmw_thp_init(struct vmw_private *dev_priv)return 0 ; } -static int vmw_thp_takedown (struct ttm_mem_type_manager *man) +void vmw_thp_takedown (struct vmw_private *dev_priv) { +struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ];struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;struct drm_mm *mm = &rman->mm; +int ret; + +ttm_bo_disable_mm (man); + ret =ttm_bo_force_list_clean (&dev_priv->bdev, man); +if (ret) +return ;spin_lock (&rman->lock); -if (drm_mm_clean (mm)) { -drm_mm_takedown (mm); -spin_unlock (&rman->lock); -kfree (rman); - man->priv =NULL ; -return 0 ; - } +drm_mm_clean (mm); +drm_mm_takedown (mm);spin_unlock (&rman->lock); -return -EBUSY ; +kfree (rman); + man->priv =NULL ; +ttm_bo_man_cleanup (man); } static void vmw_thp_debug(struct ttm_mem_type_manager *man,
@@ -163,7 +167,6 @@ static void vmw_thp_debug(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func vmw_thp_func = { - .takedown = vmw_thp_takedown, .get_node = vmw_thp_get_node, .put_node = vmw_thp_put_node, .debug = vmw_thp_debug
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 20/49 drm/nouveau: use new cleanup paths
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_ttm.c | 41 ++++++++++++++++++++------- 1 file changed, 30 insertions(+), 11 deletions(-)
drivers/gpu/drm/nouveau/nouveau_ttm.c +30 -11
@@ -31,12 +31,6 @@#include <core/tegra.h> -static int -nouveau_manager_fini (struct ttm_mem_type_manager *man) -{ -return 0 ; -} -static void nouveau_manager_del (struct ttm_mem_type_manager *man,struct ttm_mem_reg *reg) {
@@ -76,7 +70,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func nouveau_vram_manager = { - .takedown = nouveau_manager_fini, .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del, .debug = nouveau_manager_debug,
@@ -101,7 +94,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func nouveau_gart_manager = { - .takedown = nouveau_manager_fini, .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del, .debug = nouveau_manager_debug
@@ -135,7 +127,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func nv04_gart_manager = { - .takedown = nouveau_manager_fini, .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del, .debug = nouveau_manager_debug
@@ -201,6 +192,19 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) } } +static void +nouveau_ttm_fini_vram (struct nouveau_drm *drm) +{ +struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM ]; + +if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { +ttm_bo_disable_mm (man); +ttm_bo_force_list_clean (&drm->ttm.bdev, man); +ttm_bo_man_cleanup (man); + }else +ttm_bo_man_takedown (&drm->ttm.bdev, man); +} +static int nouveau_ttm_init_gtt (struct nouveau_drm *drm) {
@@ -230,6 +234,21 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)return 0 ; } +static void +nouveau_ttm_fini_gtt (struct nouveau_drm *drm) +{ +struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT ]; + +if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA && + drm->agp.bridge) +ttm_bo_man_takedown (&drm->ttm.bdev, man); +else { +ttm_bo_disable_mm (man); +ttm_bo_force_list_clean (&drm->ttm.bdev, man); +ttm_bo_man_cleanup (man); + } +} +int nouveau_ttm_init (struct nouveau_drm *drm) {
@@ -319,8 +338,8 @@ nouveau_ttm_fini(struct nouveau_drm *drm) {struct nvkm_device *device =nvxx_device (&drm->client.device); -ttm_bo_clean_mm (&drm->ttm.bdev,TTM_PL_VRAM ); -ttm_bo_clean_mm (&drm->ttm.bdev,TTM_PL_TT ); +nouveau_ttm_fini_vram (drm); +nouveau_ttm_fini_gtt (drm);ttm_bo_device_release (&drm->ttm.bdev);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 21/49 drm/radeon/ttm: use new takedown paths
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/radeon_ttm.c +2 -2
@@ -826,8 +826,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) }radeon_bo_unref (&rdev->stolen_vga_memory); } -ttm_bo_clean_mm (&rdev->mman.bdev,TTM_PL_VRAM ); -ttm_bo_clean_mm (&rdev->mman.bdev,TTM_PL_TT ); +ttm_bo_man_takedown (&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM ]); +ttm_bo_man_takedown (&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT ]);ttm_bo_device_release (&rdev->mman.bdev);radeon_gart_fini (rdev); rdev->mman.initialized = false;
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 24/49 drm/ttm: remove range manager legacy takedown path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Now no drivers have been converted, drop the non-driver path.
--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_manager.c +9 -19
@@ -129,26 +129,11 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_man_init); -static int ttm_bo_man_takedown_private (struct ttm_mem_type_manager *man) -{ -struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; -struct drm_mm *mm = &rman->mm; - -spin_lock (&rman->lock); -if (drm_mm_clean (mm)) { -drm_mm_takedown (mm); -spin_unlock (&rman->lock); -kfree (rman); - man->priv =NULL ; -return 0 ; - } -spin_unlock (&rman->lock); -return -EBUSY ; -} -int ttm_bo_man_takedown (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man) { +struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; +struct drm_mm *mm = &rman->mm;int ret;ttm_bo_disable_mm (man);
@@ -157,7 +142,13 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,if (ret)return ret; -ttm_bo_man_takedown_private (man); +spin_lock (&rman->lock); +drm_mm_clean (mm); +drm_mm_takedown (mm); +spin_unlock (&rman->lock); +kfree (rman); + man->priv =NULL ; +ttm_bo_man_cleanup (man);return 0 ; }
@@ -174,7 +165,6 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .takedown = ttm_bo_man_takedown_private, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 19/49 drm/vram_helper: call explicit mm takedown
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/drm_gem_vram_helper.c | 1 + 1 file changed, 1 insertion(+)
drivers/gpu/drm/drm_gem_vram_helper.c +1 -0
@@ -1127,6 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,static void drm_vram_mm_cleanup (struct drm_vram_mm *vmm) { +ttm_bo_man_takedown (&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM ]);ttm_bo_device_release (&vmm->bdev); }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 22/49 drm/qxl/ttm: use new takedown path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/qxl/qxl_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +2 -2
@@ -266,8 +266,8 @@ int qxl_ttm_init(struct qxl_device *qdev)void qxl_ttm_fini (struct qxl_device *qdev) { -ttm_bo_clean_mm (&qdev->mman.bdev,TTM_PL_VRAM ); -ttm_bo_clean_mm (&qdev->mman.bdev,TTM_PL_PRIV ); +ttm_bo_man_takedown (&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_VRAM ]); +ttm_bo_man_takedown (&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_PRIV ]);ttm_bo_device_release (&qdev->mman.bdev);DRM_INFO ("qxl: ttm finalized\n" ); }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 25/49 drm/ttm: make TTM responsible for cleaning system only.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
drivers should all be cleaning up their memory managers themselves now, so let the core just clean the system one up.
Remove the legacy cleaning interface.
--- drivers/gpu/drm/ttm/ttm_bo.c | 55 +++------------------------------ include/drm/ttm/ttm_bo_api.h | 28 ----------------- include/drm/ttm/ttm_bo_driver.h | 10 ------ 3 files changed, 4 insertions(+), 89 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +4 -51
@@ -1446,43 +1446,6 @@ int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_force_list_clean); -int ttm_bo_clean_mm (struct ttm_bo_device *bdev,unsigned mem_type) -{ -struct ttm_mem_type_manager *man; -int ret = -EINVAL ; - -if (mem_type >=TTM_NUM_MEM_TYPES ) { -pr_err ("Illegal memory type %d\n" , mem_type); -return ret; - } - man = &bdev->man[mem_type]; - -if (!man->has_type) { -pr_err ("Trying to take down uninitialized memory manager type %u\n" , - mem_type); -return ret; - } - -ttm_bo_disable_mm (man); - - ret =0 ; -if (mem_type >0 ) { - ret =ttm_bo_force_list_clean (bdev, man); -if (ret) { -pr_err ("Cleanup eviction failed\n" ); -return ret; - } - -if (man->func->takedown) - ret = (*man->func->takedown)(man); - } - -ttm_bo_man_cleanup (man); - -return ret; -} -EXPORT_SYMBOL (ttm_bo_clean_mm); -int ttm_bo_evict_mm (struct ttm_bo_device *bdev,unsigned mem_type) {struct ttm_mem_type_manager *man = &bdev->man[mem_type];
@@ -1585,21 +1548,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) {struct ttm_bo_global *glob = &ttm_bo_glob;int ret =0 ; -unsigned i =TTM_NUM_MEM_TYPES ; +unsigned i;struct ttm_mem_type_manager *man; -while (i--) { - man = &bdev->man[i]; -if (man->has_type) { - man->use_type = false; -if ((i !=TTM_PL_SYSTEM ) &&ttm_bo_clean_mm (bdev, i)) { - ret = -EBUSY ; -pr_err ("DRM memory manager type %d is not clean\n" , - i); - } - man->has_type = false; - } - } + man = &bdev->man[TTM_PL_SYSTEM ]; +ttm_bo_disable_mm (man);mutex_lock (&ttm_global_mutex);list_del (&bdev->device_list);
@@ -1612,7 +1565,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)spin_lock (&glob->lru_lock);for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i) -if (list_empty (&bdev->man[0 ].lru[0 ])) +if (list_empty (&man->lru[0 ]))pr_debug ("Swap list %d was clean\n" , i);spin_unlock (&glob->lru_lock);
include/drm/ttm/ttm_bo_api.h +0 -28
@@ -551,34 +551,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man, unsigned long p_size); -/** -* ttm_bo_clean_mm -* -* @bdev: Pointer to a ttm_bo_device struct. -* @mem_type: The memory type. -* -* Take down a manager for a given memory type after first walking -* the LRU list to evict any buffers left alive. -* -* Normally, this function is part of lastclose() or unload(), and at that -* point there shouldn't be any buffers left created by user-space, since -* there should've been removed by the file descriptor release() method. -* However, before this function is run, make sure to signal all sync objects, -* and verify that the delayed delete queue is empty. The driver must also -* make sure that there are no NO_EVICT buffers present in this memory type -* when the call is made. -* -* If this function is part of a VT switch, the caller must make sure that -* there are no appications currently validating buffers before this -* function is called. The caller can do that by first taking the -* struct ttm_bo_device::ttm_lock in write mode. -* -* Returns: -* -EINVAL: invalid or uninitialized memory type. -* -EBUSY: There are still buffers left in this memory type. -*/ -int ttm_bo_clean_mm (struct ttm_bo_device *bdev,unsigned mem_type); -/** * ttm_bo_evict_mm *
include/drm/ttm/ttm_bo_driver.h +0 -10
@@ -48,16 +48,6 @@struct ttm_mem_type_manager ;struct ttm_mem_type_manager_func { -/** -* struct ttm_mem_type_manager member takedown -* -* @man: Pointer to a memory type manager. -* -* Called to undo the setup done in init. All allocated resources -* should be freed. -*/ -int (*takedown)(struct ttm_mem_type_manager *man); -/** * struct ttm_mem_type_manager member get_node *
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 28/49 drm/vram-helper: use wrapper to access memory managers
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/drm_gem_vram_helper.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/drm_gem_vram_helper.c +3 -3
@@ -1075,7 +1075,7 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data) {struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_vram_mm *vmm = node->minor->dev->vram_mm; -struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&vmm->bdev,TTM_PL_VRAM );struct drm_printer p =drm_seq_file_printer (m); man->func->debug (man, &p);
@@ -1103,7 +1103,7 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);static int drm_vram_mm_init (struct drm_vram_mm *vmm,struct drm_device *dev,uint64_t vram_base,size_t vram_size) { -struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&vmm->bdev,TTM_PL_VRAM );int ret; vmm->vram_base = vram_base;
@@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,static void drm_vram_mm_cleanup (struct drm_vram_mm *vmm) { -ttm_bo_man_takedown (&vmm->bdev, &vmm->bdev.man[TTM_PL_VRAM ]); +ttm_bo_man_takedown (&vmm->bdev,ttm_manager_type (&vmm->bdev,TTM_PL_VRAM ));ttm_bo_device_release (&vmm->bdev); }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 34/49 drm/ttm: make manager debug function optional
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
@@ -88,7 +88,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching); -if (mem_type !=TTM_PL_SYSTEM ) +if (mem_type !=TTM_PL_SYSTEM && man->func->debug) (*man->func->debug)(man, p); }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 33/49 drm/ttm: rename manager variable to make sure wrapper is used.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Other users of this should notice this change and switch to wrapper.
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- include/drm/ttm/ttm_bo_driver.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -1
@@ -1610,7 +1610,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->driver = driver; -memset (bdev->man,0 ,sizeof (bdev->man)); +memset (bdev->man_priv,0 ,sizeof (bdev->man_priv));ttm_bo_init_sysman (bdev);
include/drm/ttm/ttm_bo_driver.h +5 -2
@@ -415,7 +415,10 @@ struct ttm_bo_device {*/ struct list_head device_list;struct ttm_bo_driver *driver; -struct ttm_mem_type_manager man[TTM_NUM_MEM_TYPES ]; +/* +* access via ttm_manager_type. +*/ +struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES ];/* * Protected by internal locks.
@@ -447,7 +450,7 @@ struct ttm_bo_device {static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev,int mem_type) { -return &bdev->man[mem_type]; +return &bdev->man_priv[mem_type]; }/**
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 29/49 drm/nouveau/ttm: use wrapper to access memory managers
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_ttm.c +4 -4
@@ -165,7 +165,7 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)static int nouveau_ttm_init_vram (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );struct nvif_mmu *mmu = &drm->client.mmu; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ;
@@ -195,7 +195,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)static void nouveau_ttm_fini_vram (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) {ttm_bo_disable_mm (man);
@@ -208,7 +208,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)static int nouveau_ttm_init_gtt (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_TT );unsigned long size_pages = drm->gem.gart_available >>PAGE_SHIFT ; man->use_tt = true;if (drm->agp.bridge) {
@@ -237,7 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)static void nouveau_ttm_fini_gtt (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man = &drm->ttm.bdev.man[TTM_PL_TT ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_TT );if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA && drm->agp.bridge)
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 27/49 drm/amdgfx/ttm: use wrapper to get ttm memory managers
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 3 ++- drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++--- drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 5 ++--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 12 +++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 21 +++++++++++--------- drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 12 +++++------ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 12 +++++------ 8 files changed, 39 insertions(+), 36 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c +2 -1
@@ -517,8 +517,9 @@ int amdgpu_amdkfd_get_dmabuf_info(struct kgd_dev *kgd, int dma_buf_fd,uint64_t amdgpu_amdkfd_get_vram_usage (struct kgd_dev *kgd) {struct amdgpu_device *adev = (struct amdgpu_device *)kgd; +struct ttm_mem_type_manager *vram_man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ); -return amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); +return amdgpu_vram_mgr_usage (vram_man); }uint64_t amdgpu_amdkfd_get_hive_id (struct kgd_dev *kgd)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +3 -3
@@ -299,7 +299,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, {s64 time_us, increment_us;u64 free_vram, total_vram, used_vram; - +struct ttm_mem_type_manager *vram_man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );/* Allow a maximum of 200 accumulated ms. This is basically per-IB * throttling. *
@@ -316,7 +316,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev, } total_vram = adev->gmc.real_vram_size -atomic64_read (&adev->vram_pin_size); - used_vram =amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); + used_vram =amdgpu_vram_mgr_usage (vram_man); free_vram = used_vram >= total_vram ?0 : total_vram - used_vram;spin_lock (&adev->mm_stats.lock);
@@ -363,7 +363,7 @@ static void amdgpu_cs_get_threshold_for_moves(struct amdgpu_device *adev,if (!amdgpu_gmc_vram_full_visible (&adev->gmc)) {u64 total_vis_vram = adev->gmc.visible_vram_size;u64 used_vis_vram = -amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); +amdgpu_vram_mgr_vis_usage (vram_man);if (used_vis_vram < total_vis_vram) {u64 free_vis_vram = total_vis_vram - used_vis_vram;
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +2 -3
@@ -3880,7 +3880,7 @@ static int amdgpu_device_reset_sriov(struct amdgpu_device *adev,amdgpu_virt_init_data_exchange (adev);/* we need recover gart prior to run SMC/CP/SDMA resume */ -amdgpu_gtt_mgr_recover (&adev->mman.bdev.man[TTM_PL_TT ]); +amdgpu_gtt_mgr_recover (ttm_manager_type (&adev->mman.bdev,TTM_PL_TT )); r =amdgpu_device_fw_loading (adev);if (r)
@@ -4079,8 +4079,7 @@ static int amdgpu_do_asic_reset(struct amdgpu_hive_info *hive,amdgpu_inc_vram_lost (tmp_adev); } - r =amdgpu_gtt_mgr_recover ( - &tmp_adev->mman.bdev.man[TTM_PL_TT ]); + r =amdgpu_gtt_mgr_recover (ttm_manager_type (&tmp_adev->mman.bdev,TTM_PL_TT ));if (r) goto out;
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +6 -6
@@ -48,9 +48,9 @@ static ssize_t amdgpu_mem_info_gtt_total_show(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; - +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT );return snprintf (buf,PAGE_SIZE ,"%llu\n" , - (adev->mman.bdev.man[TTM_PL_TT ].size) *PAGE_SIZE ); + man->size *PAGE_SIZE ); }/**
@@ -66,9 +66,9 @@ static ssize_t amdgpu_mem_info_gtt_used_show(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; - +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT );return snprintf (buf,PAGE_SIZE ,"%llu\n" , -amdgpu_gtt_mgr_usage (&adev->mman.bdev.man[TTM_PL_TT ])); +amdgpu_gtt_mgr_usage (man)); } static DEVICE_ATTR(mem_info_gtt_total, S_IRUGO,
@@ -87,7 +87,7 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;*/ int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size) { -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT );struct amdgpu_gtt_mgr *mgr;uint64_t start, size;int ret;
@@ -135,7 +135,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)*/ void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev) { -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT );struct amdgpu_gtt_mgr *mgr = man->priv;int ret;
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c +12 -9
@@ -594,13 +594,13 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file ui64 =atomic64_read (&adev->num_vram_cpu_page_faults);return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_VRAM_USAGE : - ui64 =amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); + ui64 =amdgpu_vram_mgr_usage (ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ));return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_VIS_VRAM_USAGE : - ui64 =amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); + ui64 =amdgpu_vram_mgr_vis_usage (ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ));return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_GTT_USAGE : - ui64 =amdgpu_gtt_mgr_usage (&adev->mman.bdev.man[TTM_PL_TT ]); + ui64 =amdgpu_gtt_mgr_usage (ttm_manager_type (&adev->mman.bdev,TTM_PL_TT ));return copy_to_user (out, &ui64,min (size,8u )) ? -EFAULT :0 ;case AMDGPU_INFO_GDS_CONFIG : {struct drm_amdgpu_info_gds gds_info;
@@ -623,7 +623,7 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_filemin (adev->gmc.visible_vram_size -atomic64_read (&adev->visible_pin_size), vram_gtt.vram_size); - vram_gtt.gtt_size = adev->mman.bdev.man[TTM_PL_TT ].size; + vram_gtt.gtt_size =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT )->size; vram_gtt.gtt_size *=PAGE_SIZE ; vram_gtt.gtt_size -=atomic64_read (&adev->gart_pin_size); return copy_to_user(out, &vram_gtt,
@@ -631,14 +631,17 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file }case AMDGPU_INFO_MEMORY : {struct drm_amdgpu_memory_info mem; - +struct ttm_mem_type_manager *vram_man = +ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ); +struct ttm_mem_type_manager *gtt_man = +ttm_manager_type (&adev->mman.bdev,TTM_PL_TT );memset (&mem,0 ,sizeof (mem)); mem.vram.total_heap_size = adev->gmc.real_vram_size; mem.vram.usable_heap_size = adev->gmc.real_vram_size -atomic64_read (&adev->vram_pin_size) -AMDGPU_VM_RESERVED_VRAM ; mem.vram.heap_usage = -amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); +amdgpu_vram_mgr_usage (vram_man); mem.vram.max_allocation = mem.vram.usable_heap_size *3 /4 ; mem.cpu_accessible_vram.total_heap_size =
@@ -648,16 +651,16 @@ static int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_fileatomic64_read (&adev->visible_pin_size), mem.vram.usable_heap_size); mem.cpu_accessible_vram.heap_usage = -amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ]); +amdgpu_vram_mgr_vis_usage (vram_man); mem.cpu_accessible_vram.max_allocation = mem.cpu_accessible_vram.usable_heap_size *3 /4 ; - mem.gtt.total_heap_size = adev->mman.bdev.man[TTM_PL_TT ].size; + mem.gtt.total_heap_size = gtt_man->size; mem.gtt.total_heap_size *=PAGE_SIZE ; mem.gtt.usable_heap_size = mem.gtt.total_heap_size -atomic64_read (&adev->gart_pin_size); mem.gtt.heap_usage = -amdgpu_gtt_mgr_usage (&adev->mman.bdev.man[TTM_PL_TT ]); +amdgpu_gtt_mgr_usage (gtt_man); mem.gtt.max_allocation = mem.gtt.usable_heap_size *3 /4 ; return copy_to_user(out, &mem,
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c +2 -2
@@ -449,7 +449,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev,* allow fall back to GTT */ if (domain &AMDGPU_GEM_DOMAIN_GTT ) { - man = &adev->mman.bdev.man[TTM_PL_TT ]; + man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT );if (size < (man->size <<PAGE_SHIFT ))return true;
@@ -458,7 +458,7 @@ static bool amdgpu_bo_validate_size(struct amdgpu_device *adev, }if (domain &AMDGPU_GEM_DOMAIN_VRAM ) { - man = &adev->mman.bdev.man[TTM_PL_VRAM ]; + man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );if (size < (man->size <<PAGE_SHIFT ))return true;
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -6
@@ -67,7 +67,7 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev, unsigned int type, uint64_t size) { -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[type]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev, type); man->available_caching =TTM_PL_FLAG_UNCACHED ; man->default_caching =TTM_PL_FLAG_UNCACHED ;
@@ -2014,9 +2014,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)amdgpu_vram_mgr_fini (adev);amdgpu_gtt_mgr_fini (adev); -ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS ]); -ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS ]); -ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA ]); +ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_GDS )); +ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_GWS )); +ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_OA ));ttm_bo_device_release (&adev->mman.bdev); adev->mman.initialized = false;DRM_INFO ("amdgpu: ttm finalized\n" );
@@ -2033,7 +2033,7 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)*/ void amdgpu_ttm_set_buffer_funcs_status (struct amdgpu_device *adev,bool enable) { -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );uint64_t size;int r;
@@ -2255,7 +2255,7 @@ static int amdgpu_mm_dump_table(struct seq_file *m, void *data)unsigned ttm_pl = (uintptr_t )node->info_ent->data;struct drm_device *dev = node->minor->dev;struct amdgpu_device *adev = dev->dev_private; -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[ttm_pl]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev, ttm_pl);struct drm_printer p =drm_seq_file_printer (m); man->func->debug (man, &p);
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +6 -6
@@ -82,9 +82,9 @@ static ssize_t amdgpu_mem_info_vram_used_show(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; - +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );return snprintf (buf,PAGE_SIZE ,"%llu\n" , -amdgpu_vram_mgr_usage (&adev->mman.bdev.man[TTM_PL_VRAM ])); +amdgpu_vram_mgr_usage (man)); }/**
@@ -100,9 +100,9 @@ static ssize_t amdgpu_mem_info_vis_vram_used_show(struct device *dev, {struct drm_device *ddev =dev_get_drvdata (dev);struct amdgpu_device *adev = ddev->dev_private; - +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );return snprintf (buf,PAGE_SIZE ,"%llu\n" , -amdgpu_vram_mgr_vis_usage (&adev->mman.bdev.man[TTM_PL_VRAM ])); +amdgpu_vram_mgr_vis_usage (man)); } static ssize_t amdgpu_mem_info_vram_vendor(struct device *dev,
@@ -170,7 +170,7 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;*/ int amdgpu_vram_mgr_init (struct amdgpu_device *adev) { -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );struct amdgpu_vram_mgr *mgr;int ret;
@@ -207,7 +207,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)*/ void amdgpu_vram_mgr_fini (struct amdgpu_device *adev) { -struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM );struct amdgpu_vram_mgr *mgr = man->priv;int ret;
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 32/49 drm/vmwgfx/ttm: use wrapper to access memory manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 21 ++++++++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 4 ++-- 3 files changed, 17 insertions(+), 12 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +13 -8
@@ -634,7 +634,7 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv) ret =ttm_bo_man_init (&dev_priv->bdev, man, dev_priv->vram_size >>PAGE_SHIFT );#endif - dev_priv->bdev.man[TTM_PL_VRAM ].use_type = false; +ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )->use_type = false;return ret; }
@@ -644,7 +644,7 @@ static void vmw_takedown_vram_manager(struct vmw_private *dev_priv)vmw_thp_takedown (dev_priv);#else ttm_bo_man_takedown (&dev_priv->bdev, - &dev_priv->bdev.man[TTM_PL_VRAM ]); +ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ));#endif }
@@ -1192,10 +1192,12 @@ static void vmw_master_drop(struct drm_device *dev,*/ static void __vmw_svga_enable (struct vmw_private *dev_priv) { +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ); +spin_lock (&dev_priv->svga_lock); -if (!dev_priv->bdev.man[TTM_PL_VRAM ].use_type) { +if (!man->use_type) {vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE ); - dev_priv->bdev.man[TTM_PL_VRAM ].use_type = true; + man->use_type = true; }spin_unlock (&dev_priv->svga_lock); }
@@ -1221,9 +1223,11 @@ void vmw_svga_enable(struct vmw_private *dev_priv)*/ static void __vmw_svga_disable (struct vmw_private *dev_priv) { +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ); +spin_lock (&dev_priv->svga_lock); -if (dev_priv->bdev.man[TTM_PL_VRAM ].use_type) { - dev_priv->bdev.man[TTM_PL_VRAM ].use_type = false; +if (man->use_type) { + man->use_type = false;vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE_HIDE |SVGA_REG_ENABLE_ENABLE );
@@ -1240,6 +1244,7 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)*/ void vmw_svga_disable (struct vmw_private *dev_priv) { +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );/* * Disabling SVGA will turn off device modesetting capabilities, so * notify KMS about that so that it doesn't cache atomic state that
@@ -1255,8 +1260,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)vmw_kms_lost_device (dev_priv->dev);ttm_write_lock (&dev_priv->reservation_sem, false);spin_lock (&dev_priv->svga_lock); -if (dev_priv->bdev.man[TTM_PL_VRAM ].use_type) { - dev_priv->bdev.man[TTM_PL_VRAM ].use_type = false; +if (man->use_type) { + man->use_type = false;spin_unlock (&dev_priv->svga_lock);if (ttm_bo_evict_mm (&dev_priv->bdev,TTM_PL_VRAM ))DRM_ERROR ("Failed evicting VRAM buffers.\n" );
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2 -2
@@ -98,7 +98,7 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;int vmw_gmrid_man_init (struct vmw_private *dev_priv,int type) { -struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type]; +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type);struct vmwgfx_gmrid_man *gman =kzalloc (sizeof (*gman),GFP_KERNEL );
@@ -133,7 +133,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)void vmw_gmrid_man_takedown (struct vmw_private *dev_priv,int type) { -struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type]; +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type);struct vmwgfx_gmrid_man *gman = (struct vmwgfx_gmrid_man *)man->priv;
drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +2 -2
@@ -117,7 +117,7 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,int vmw_thp_init (struct vmw_private *dev_priv) { -struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );struct vmw_thp_manager *rman; man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ;
@@ -137,7 +137,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)void vmw_thp_takedown (struct vmw_private *dev_priv) { -struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv;struct drm_mm *mm = &rman->mm;int ret;
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 31/49 drm/radeon/ttm: use wrapper to access memory manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/radeon/radeon_gem.c | 2 +- drivers/gpu/drm/radeon/radeon_ttm.c | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/radeon/radeon_gem.c +1 -1
@@ -226,7 +226,7 @@ int radeon_gem_info_ioctl(struct drm_device *dev, void *data,struct drm_radeon_gem_info *args = data;struct ttm_mem_type_manager *man; - man = &rdev->mman.bdev.man[TTM_PL_VRAM ]; + man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM ); args->vram_size = (u64 )man->size <<PAGE_SHIFT ; args->vram_visible = rdev->mc.visible_vram_size;
drivers/gpu/drm/radeon/radeon_ttm.c +6 -7
@@ -68,7 +68,7 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)static int radeon_ttm_init_vram (struct radeon_device *rdev) { -struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_VRAM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM ); man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ;
@@ -79,7 +79,7 @@ static int radeon_ttm_init_vram(struct radeon_device *rdev)static int radeon_ttm_init_gtt (struct radeon_device *rdev) { -struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[TTM_PL_TT ]; +struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_TT ); man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ;
@@ -379,7 +379,6 @@ static int radeon_bo_move(struct ttm_buffer_object *bo, bool evict,static int radeon_ttm_io_mem_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type];struct radeon_device *rdev =radeon_get_rdev (bdev); mem->bus.addr =NULL ;
@@ -826,8 +825,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) }radeon_bo_unref (&rdev->stolen_vga_memory); } -ttm_bo_man_takedown (&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM ]); -ttm_bo_man_takedown (&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT ]); +ttm_bo_man_takedown (&rdev->mman.bdev,ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM )); +ttm_bo_man_takedown (&rdev->mman.bdev,ttm_manager_type (&rdev->mman.bdev,TTM_PL_TT ));ttm_bo_device_release (&rdev->mman.bdev);radeon_gart_fini (rdev); rdev->mman.initialized = false;
@@ -843,7 +842,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)if (!rdev->mman.initialized)return ; - man = &rdev->mman.bdev.man[TTM_PL_VRAM ]; + man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM );/* this just adjusts TTM size idea, which sets lpfn to the correct value */ man->size = size >>PAGE_SHIFT ; }
@@ -897,7 +896,7 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)unsigned ttm_pl = *(int *)node->info_ent->data;struct drm_device *dev = node->minor->dev;struct radeon_device *rdev = dev->dev_private; -struct ttm_mem_type_manager *man = &rdev->mman.bdev.man[ttm_pl]; +struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev, ttm_pl);struct drm_printer p =drm_seq_file_printer (m); man->func->debug (man, &p);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 35/49 drm/nouveau/ttm: don't fill in blank ttm debug callback
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/gpu/drm/nouveau/nouveau_ttm.c +0 -9
@@ -37,12 +37,6 @@ nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)nouveau_mem_del (reg); } -static void -nouveau_manager_debug (struct ttm_mem_type_manager *man, -struct drm_printer *printer) -{ -} - static int nouveau_vram_manager_new(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo,
@@ -72,7 +66,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,const struct ttm_mem_type_manager_func nouveau_vram_manager = { .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug, }; static int
@@ -96,7 +89,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,const struct ttm_mem_type_manager_func nouveau_gart_manager = { .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug }; static int
@@ -129,7 +121,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,const struct ttm_mem_type_manager_func nv04_gart_manager = { .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug };int
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 40/49 drm/ttm: move range manager to subclassed driver allocation
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-)
drivers/gpu/drm/ttm/ttm_bo_manager.c +20 -12
@@ -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_bo_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_bo_init_mm_base (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_bo_use_mm (man);return 0 ; }
@@ -141,7 +148,7 @@ int ttm_bo_man_takedown(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,11 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,drm_mm_clean (mm);drm_mm_takedown (mm);spin_unlock (&rman->lock); -kfree (rman); - man->priv =NULL ;ttm_bo_man_cleanup (man); +ttm_set_driver_manager (bdev, type,NULL ); +kfree (rman); +return 0 ; }EXPORT_SYMBOL (ttm_bo_man_takedown);
@@ -166,7 +174,7 @@ EXPORT_SYMBOL(ttm_bo_man_takedown);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);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 26/49 drm/ttm: add wrapper to get manager from bdev.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This will allow different abstractions later.
--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++---------------- drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++--------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 4 files changed, 34 insertions(+), 28 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +17 -17
@@ -80,7 +80,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,static void ttm_mem_type_debug (struct ttm_bo_device *bdev,struct drm_printer *p,int mem_type) { -struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type);drm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);
@@ -156,7 +156,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,if (mem->placement &TTM_PL_FLAG_NO_EVICT )return ; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type);list_add_tail (&bo->lru, &man->lru[bo->priority]); if (man->use_tt && bo->ttm &&
@@ -231,7 +231,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)dma_resv_assert_held (pos->first->base.resv);dma_resv_assert_held (pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_TT ]; + man =ttm_manager_type (pos->first->bdev,TTM_PL_TT );list_bulk_move_tail (&man->lru[i], &pos->first->lru, &pos->last->lru); }
@@ -246,7 +246,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)dma_resv_assert_held (pos->first->base.resv);dma_resv_assert_held (pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_VRAM ]; + man =ttm_manager_type (pos->first->bdev,TTM_PL_VRAM );list_bulk_move_tail (&man->lru[i], &pos->first->lru, &pos->last->lru); }
@@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type]; -struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *old_man =ttm_manager_type (bdev, bo->mem.mem_type); +struct ttm_mem_type_manager *new_man =ttm_manager_type (bdev, mem->mem_type);int ret; ret =ttm_mem_io_lock (old_man, true);
@@ -338,7 +338,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,return 0 ; out_err: - new_man = &bdev->man[bo->mem.mem_type]; + new_man =ttm_manager_type (bdev, bo->mem.mem_type);if (!new_man->use_tt) {ttm_tt_destroy (bo->ttm); bo->ttm =NULL ;
@@ -550,7 +550,7 @@ static void ttm_bo_release(struct kref *kref)struct ttm_buffer_object *bo = container_of(kref, struct ttm_buffer_object, kref);struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, bo->mem.mem_type);size_t acc_size = bo->acc_size;int ret;
@@ -838,7 +838,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type); mem->mm_node =NULL ;if (!man->func || !man->func->get_node)
@@ -849,7 +849,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,void ttm_bo_mem_put (struct ttm_buffer_object *bo,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bo->bdev, mem->mem_type);if (!man->func || !man->func->put_node)return ;
@@ -906,7 +906,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem->mem_type);struct ww_acquire_ctx *ticket;int ret;
@@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,if (ret)return ret; - man = &bdev->man[mem_type]; + man =ttm_manager_type (bdev, mem_type);if (!man->has_type || !man->use_type)return -EBUSY ;
@@ -1059,7 +1059,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (unlikely (ret)) goto error; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type); ret =ttm_bo_add_move_fence (bo, man, mem, ctx->no_wait_gpu);if (unlikely (ret)) {ttm_bo_mem_put (bo, mem);
@@ -1448,7 +1448,7 @@ EXPORT_SYMBOL(ttm_bo_force_list_clean);int ttm_bo_evict_mm (struct ttm_bo_device *bdev,unsigned mem_type) { -struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type);if (mem_type ==0 || mem_type >=TTM_NUM_MEM_TYPES ) {pr_err ("Illegal memory manager memory type %u\n" , mem_type);
@@ -1551,7 +1551,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)unsigned i;struct ttm_mem_type_manager *man; - man = &bdev->man[TTM_PL_SYSTEM ]; + man =ttm_manager_type (bdev,TTM_PL_SYSTEM );ttm_bo_disable_mm (man);mutex_lock (&ttm_global_mutex);
@@ -1578,7 +1578,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);static void ttm_bo_init_sysman (struct ttm_bo_device *bdev) { -struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev,TTM_PL_SYSTEM );/* * Initialize the system memory buffer type.
@@ -1642,7 +1642,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)void ttm_bo_unmap_virtual (struct ttm_buffer_object *bo) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, bo->mem.mem_type);ttm_mem_io_lock (man, false);ttm_bo_unmap_virtual_locked (bo);
drivers/gpu/drm/ttm/ttm_bo_util.c +10 -10
@@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)int ttm_mem_io_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem->mem_type);int ret;if (mem->bus.io_reserved_count++)
@@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,int ttm_mem_io_reserve_vm (struct ttm_buffer_object *bo) { -struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bo->bdev, bo->mem.mem_type);struct ttm_mem_reg *mem = &bo->mem;int ret;
@@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,struct ttm_mem_reg *mem, void **virtual) { - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);int ret;void *addr;
@@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, {struct ttm_mem_type_manager *man; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type);if (virtual && mem->bus.addr ==NULL )iounmap (virtual);
@@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, new_mem->mem_type);struct ttm_tt *ttm = bo->ttm;struct ttm_mem_reg *old_mem = &bo->mem;struct ttm_mem_reg old_copy = *old_mem;
@@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *map) {struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; +ttm_manager_type (bo->bdev, bo->mem.mem_type);unsigned long offset, size;int ret;
@@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) {struct ttm_buffer_object *bo = map->bo;struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; +ttm_manager_type (bo->bdev, bo->mem.mem_type);if (!map->virtual)return ;
@@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, new_mem->mem_type);struct ttm_mem_reg *old_mem = &bo->mem;int ret;struct ttm_buffer_object *ghost_obj;
@@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,struct ttm_bo_device *bdev = bo->bdev;struct ttm_mem_reg *old_mem = &bo->mem; -struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type]; -struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *from =ttm_manager_type (bdev, old_mem->mem_type); +struct ttm_mem_type_manager *to =ttm_manager_type (bdev, new_mem->mem_type);int ret;
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
@@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,vm_fault_t ret =VM_FAULT_NOPAGE ;unsigned long address = vmf->address;struct ttm_mem_type_manager *man = - &bdev->man[bo->mem.mem_type]; +ttm_manager_type (bdev, bo->mem.mem_type);/* * Refuse to fault imported pages. This should be handled
include/drm/ttm/ttm_bo_driver.h +6 -0
@@ -444,6 +444,12 @@ struct ttm_bo_device {bool no_retry; }; +static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev, +int mem_type) +{ +return &bdev->man[mem_type]; +} +/** * struct ttm_lru_bulk_move_pos *
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 38/49 drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 35 +++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 36 +++++++++++++------- 2 files changed, 44 insertions(+), 27 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +21 -14
@@ -25,11 +25,17 @@#include "amdgpu.h" struct amdgpu_gtt_mgr { +struct ttm_mem_type_manager manager;struct drm_mm mm;spinlock_t lock;atomic64_t available; }; +static inline struct amdgpu_gtt_mgr *to_gtt_mgr (struct ttm_mem_type_manager *man) +{ + return container_of(man, struct amdgpu_gtt_mgr, manager); +} +struct amdgpu_gtt_node {struct drm_mm_node node;struct ttm_buffer_object *tbo;
@@ -87,11 +93,16 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;*/ int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT ); +struct ttm_mem_type_manager *man;struct amdgpu_gtt_mgr *mgr;uint64_t start, size;int ret; + mgr =kzalloc (sizeof (*mgr),GFP_KERNEL ); +if (!mgr) +return -ENOMEM ; + + man = &mgr->manager; man->use_tt = true; man->func = &amdgpu_gtt_mgr_func; man->available_caching =TTM_PL_MASK_CACHING ;
@@ -99,16 +110,11 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)ttm_bo_init_mm_base (&adev->mman.bdev, man, gtt_size >>PAGE_SHIFT ); - mgr =kzalloc (sizeof (*mgr),GFP_KERNEL ); -if (!mgr) -return -ENOMEM ; - start =AMDGPU_GTT_MAX_TRANSFER_SIZE *AMDGPU_GTT_NUM_TRANSFER_WINDOWS ; size = (adev->gmc.gart_size >>PAGE_SHIFT ) - start;drm_mm_init (&mgr->mm, start, size);spin_lock_init (&mgr->lock);atomic64_set (&mgr->available, gtt_size >>PAGE_SHIFT ); - man->priv = mgr; ret =device_create_file (adev->dev, &dev_attr_mem_info_gtt_total);if (ret) {
@@ -121,6 +127,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)return ret; } +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT , &mgr->manager);ttm_bo_use_mm (man);return 0 ; }
@@ -136,7 +143,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev) {struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT ); -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);int ret;ttm_bo_disable_mm (man);
@@ -148,13 +155,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);spin_unlock (&mgr->lock); -kfree (mgr); - man->priv =NULL ;device_remove_file (adev->dev, &dev_attr_mem_info_gtt_total);device_remove_file (adev->dev, &dev_attr_mem_info_gtt_used);ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT ,NULL ); +kfree (mgr); }/**
@@ -184,7 +191,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);struct amdgpu_gtt_node *node;int r;
@@ -245,7 +252,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,static void amdgpu_gtt_mgr_del (struct ttm_mem_type_manager *man,struct ttm_mem_reg *mem) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);struct amdgpu_gtt_node *node = mem->mm_node;if (node) {
@@ -267,7 +274,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,*/ uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);s64 result = man->size -atomic64_read (&mgr->available);return (result >0 ? result :0 ) *PAGE_SIZE ;
@@ -275,7 +282,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)int amdgpu_gtt_mgr_recover (struct ttm_mem_type_manager *man) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);struct amdgpu_gtt_node *node;struct drm_mm_node *mm_node;int r =0 ;
@@ -303,7 +310,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);spin_lock (&mgr->lock);drm_mm_print (&mgr->mm, printer);
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +23 -13
@@ -29,12 +29,18 @@#include "atom.h" struct amdgpu_vram_mgr { +struct ttm_mem_type_manager manager;struct drm_mm mm;spinlock_t lock;atomic64_t usage;atomic64_t vis_usage; }; +static inline struct amdgpu_vram_mgr *to_vram_mgr (struct ttm_mem_type_manager *man) +{ + return container_of(man, struct amdgpu_vram_mgr, manager); +} +/** * DOC: mem_info_vram_total *
@@ -170,29 +176,32 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;*/ int amdgpu_vram_mgr_init (struct amdgpu_device *adev) { -struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ); +struct ttm_mem_type_manager *man;struct amdgpu_vram_mgr *mgr;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->default_caching =TTM_PL_FLAG_WC ;ttm_bo_init_mm_base (&adev->mman.bdev, man, adev->gmc.real_vram_size >>PAGE_SHIFT ); man->func = &amdgpu_vram_mgr_func; - mgr =kzalloc (sizeof (*mgr),GFP_KERNEL ); -if (!mgr) -return -ENOMEM ;drm_mm_init (&mgr->mm,0 , man->size);spin_lock_init (&mgr->lock); - man->priv = mgr;/* Add the two VRAM-related sysfs files */ ret =sysfs_create_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes);if (ret)DRM_ERROR ("Failed to register sysfs\n" ); +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM , &mgr->manager);ttm_bo_use_mm (man);return 0 ; }
@@ -208,7 +217,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)void amdgpu_vram_mgr_fini (struct amdgpu_device *adev) {struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ); -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);int ret;ttm_bo_disable_mm (man);
@@ -220,11 +229,12 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);spin_unlock (&mgr->lock); -kfree (mgr); - man->priv =NULL ; +sysfs_remove_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes);ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM ,NULL ); +kfree (mgr); }/**
@@ -314,7 +324,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) {struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);struct drm_mm *mm = &mgr->mm;struct drm_mm_node *nodes;enum drm_mm_insert_mode mode;
@@ -430,7 +440,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) {struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);struct drm_mm_node *nodes = mem->mm_node;uint64_t usage =0 , vis_usage =0 ;unsigned pages = mem->num_pages;
@@ -562,7 +572,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,*/ uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man) { -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);return atomic64_read (&mgr->usage); }
@@ -576,7 +586,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)*/ uint64_t amdgpu_vram_mgr_vis_usage (struct ttm_mem_type_manager *man) { -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);return atomic64_read (&mgr->vis_usage); }
@@ -592,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)static void amdgpu_vram_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);spin_lock (&mgr->lock);drm_mm_print (&mgr->mm, printer);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 39/49 drm/ttm: make ttm_bo_man_init/takedown take type + args
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This makes it easier to move these to a driver allocated system
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++------ drivers/gpu/drm/drm_gem_vram_helper.c | 10 ++++---- drivers/gpu/drm/nouveau/nouveau_ttm.c | 21 ++++++++++------ drivers/gpu/drm/qxl/qxl_ttm.c | 12 +++------ drivers/gpu/drm/radeon/radeon_ttm.c | 33 ++++++++++++------------- drivers/gpu/drm/ttm/ttm_bo_manager.c | 19 ++++++++++---- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 +++------- include/drm/ttm/ttm_bo_driver.h | 7 ++++-- 8 files changed, 67 insertions(+), 63 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6 -9
@@ -67,12 +67,9 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev, unsigned int type, uint64_t size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev, type); - - man->available_caching =TTM_PL_FLAG_UNCACHED ; - man->default_caching =TTM_PL_FLAG_UNCACHED ; - -return ttm_bo_man_init (&adev->mman.bdev, man, size >>PAGE_SHIFT ); +return ttm_bo_man_init (&adev->mman.bdev, type, +TTM_PL_FLAG_UNCACHED ,TTM_PL_FLAG_UNCACHED , + false, size >>PAGE_SHIFT ); }/**
@@ -2014,9 +2011,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)amdgpu_vram_mgr_fini (adev);amdgpu_gtt_mgr_fini (adev); -ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_GDS )); -ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_GWS )); -ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_OA )); +ttm_bo_man_takedown (&adev->mman.bdev,AMDGPU_PL_GDS ); +ttm_bo_man_takedown (&adev->mman.bdev,AMDGPU_PL_GWS ); +ttm_bo_man_takedown (&adev->mman.bdev,AMDGPU_PL_OA );ttm_bo_device_release (&adev->mman.bdev); adev->mman.initialized = false;DRM_INFO ("amdgpu: ttm finalized\n" );
drivers/gpu/drm/drm_gem_vram_helper.c +5 -5
@@ -1103,7 +1103,6 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);static int drm_vram_mm_init (struct drm_vram_mm *vmm,struct drm_device *dev,uint64_t vram_base,size_t vram_size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&vmm->bdev,TTM_PL_VRAM );int ret; vmm->vram_base = vram_base;
@@ -1116,9 +1115,10 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,if (ret)return ret; - man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; - ret =ttm_bo_man_init (&vmm->bdev, man, vram_size >>PAGE_SHIFT ); + ret =ttm_bo_man_init (&vmm->bdev,TTM_PL_VRAM , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , false, + vram_size >>PAGE_SHIFT );if (ret)return ret;
@@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,static void drm_vram_mm_cleanup (struct drm_vram_mm *vmm) { -ttm_bo_man_takedown (&vmm->bdev,ttm_manager_type (&vmm->bdev,TTM_PL_VRAM )); +ttm_bo_man_takedown (&vmm->bdev,TTM_PL_VRAM );ttm_bo_device_release (&vmm->bdev); }
drivers/gpu/drm/nouveau/nouveau_ttm.c +13 -8
@@ -156,16 +156,17 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)static int nouveau_ttm_init_vram (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );struct nvif_mmu *mmu = &drm->client.mmu; - man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; -if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { +struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM ); +/* Some BARs do not support being ioremapped WC */ const u8 type = mmu->type[drm->ttm.type_vram].type; + man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; + man->default_caching =TTM_PL_FLAG_WC ; +if (type &NVIF_MEM_UNCACHED ) { man->available_caching =TTM_PL_FLAG_UNCACHED ; man->default_caching =TTM_PL_FLAG_UNCACHED ;
@@ -178,7 +179,9 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)ttm_bo_use_mm (man);return 0 ; }else { -return ttm_bo_man_init (&drm->ttm.bdev, man, +return ttm_bo_man_init (&drm->ttm.bdev,TTM_PL_VRAM , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , false, drm->gem.vram_available >>PAGE_SHIFT ); } }
@@ -193,7 +196,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man); }else -ttm_bo_man_takedown (&drm->ttm.bdev, man); +ttm_bo_man_takedown (&drm->ttm.bdev,TTM_PL_VRAM ); } static int
@@ -216,7 +219,9 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)else if (!drm->agp.bridge) man->func = &nv04_gart_manager;else -return ttm_bo_man_init (&drm->ttm.bdev, man, +return ttm_bo_man_init (&drm->ttm.bdev,TTM_PL_TT , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , true, size_pages); ttm_bo_init_mm_base(&drm->ttm.bdev, man,
@@ -232,7 +237,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA && drm->agp.bridge) -ttm_bo_man_takedown (&drm->ttm.bdev, man); +ttm_bo_man_takedown (&drm->ttm.bdev,TTM_PL_TT );else {ttm_bo_disable_mm (man);ttm_bo_force_list_clean (&drm->ttm.bdev, man);
drivers/gpu/drm/qxl/qxl_ttm.c +4 -8
@@ -219,12 +219,8 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, unsigned int type, uint64_t size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&qdev->mman.bdev, type); - - man->available_caching =TTM_PL_MASK_CACHING ; - man->default_caching =TTM_PL_FLAG_CACHED ; - -return ttm_bo_man_init (&qdev->mman.bdev, man, size); +return ttm_bo_man_init (&qdev->mman.bdev, type,TTM_PL_MASK_CACHING , +TTM_PL_FLAG_CACHED , false, size); }int qxl_ttm_init (struct qxl_device *qdev)
@@ -266,8 +262,8 @@ int qxl_ttm_init(struct qxl_device *qdev)void qxl_ttm_fini (struct qxl_device *qdev) { -ttm_bo_man_takedown (&qdev->mman.bdev,ttm_manager_type (&qdev->mman.bdev,TTM_PL_VRAM )); -ttm_bo_man_takedown (&qdev->mman.bdev,ttm_manager_type (&qdev->mman.bdev,TTM_PL_PRIV )); +ttm_bo_man_takedown (&qdev->mman.bdev,TTM_PL_VRAM ); +ttm_bo_man_takedown (&qdev->mman.bdev,TTM_PL_PRIV );ttm_bo_device_release (&qdev->mman.bdev);DRM_INFO ("qxl: ttm finalized\n" ); }
drivers/gpu/drm/radeon/radeon_ttm.c +16 -17
@@ -68,36 +68,35 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)static int radeon_ttm_init_vram (struct radeon_device *rdev) { -struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM ); - - man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; - -return ttm_bo_man_init (&rdev->mman.bdev, man, +return ttm_bo_man_init (&rdev->mman.bdev,TTM_PL_VRAM , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , false, rdev->mc.real_vram_size >>PAGE_SHIFT ); }static int radeon_ttm_init_gtt (struct radeon_device *rdev) { -struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_TT ); +uint32_t available_caching, default_caching; + + available_caching =TTM_PL_MASK_CACHING ; + default_caching =TTM_PL_FLAG_CACHED ; - man->available_caching =TTM_PL_MASK_CACHING ; - man->default_caching =TTM_PL_FLAG_CACHED ; - man->use_tt = true;#if IS_ENABLED (CONFIG_AGP )if (rdev->flags &RADEON_IS_AGP ) {if (!rdev->ddev->agp) {DRM_ERROR ("AGP is not enabled\n" );return -EINVAL ; } - man->available_caching =TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; + available_caching =TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_WC ; + default_caching =TTM_PL_FLAG_WC ; }#endif -return ttm_bo_man_init (&rdev->mman.bdev, man, - rdev->mc.gtt_size >>PAGE_SHIFT ); +return ttm_bo_man_init (&rdev->mman.bdev,TTM_PL_TT , + available_caching, + default_caching, true, + rdev->mc.gtt_size >>PAGE_SHIFT ); } static void radeon_evict_flags(struct ttm_buffer_object *bo,
@@ -825,8 +824,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) }radeon_bo_unref (&rdev->stolen_vga_memory); } -ttm_bo_man_takedown (&rdev->mman.bdev,ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM )); -ttm_bo_man_takedown (&rdev->mman.bdev,ttm_manager_type (&rdev->mman.bdev,TTM_PL_TT )); +ttm_bo_man_takedown (&rdev->mman.bdev,TTM_PL_VRAM ); +ttm_bo_man_takedown (&rdev->mman.bdev,TTM_PL_TT );ttm_bo_device_release (&rdev->mman.bdev);radeon_gart_fini (rdev); rdev->mman.initialized = false;
drivers/gpu/drm/ttm/ttm_bo_manager.c +14 -5
@@ -107,19 +107,27 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,static const struct ttm_mem_type_manager_func ttm_bo_manager_func;int ttm_bo_man_init (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +unsigned type, +uint32_t available_caching, +uint32_t default_caching, +bool use_tt,unsigned long p_size) { +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, type);struct ttm_range_manager *rman; - man->func = &ttm_bo_manager_func; - -ttm_bo_init_mm_base (bdev, man, p_size); + 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->func = &ttm_bo_manager_func; + +ttm_bo_init_mm_base (bdev, man, p_size); +drm_mm_init (&rman->mm,0 , p_size);spin_lock_init (&rman->lock); man->priv = rman;
@@ -130,8 +138,9 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev,EXPORT_SYMBOL (ttm_bo_man_init);int ttm_bo_man_takedown (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man) +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 drm_mm *mm = &rman->mm;int ret;
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4 -9
@@ -626,13 +626,9 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv)#ifdef CONFIG_TRANSPARENT_HUGEPAGE ret =vmw_thp_init (dev_priv);#else -struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ]; - - man->available_caching =TTM_PL_FLAG_CACHED ; - man->default_caching =TTM_PL_FLAG_CACHED ; - - ret =ttm_bo_man_init (&dev_priv->bdev, man, - dev_priv->vram_size >>PAGE_SHIFT ); + ret =ttm_bo_man_init (&dev_priv->bdev,TTM_PL_VRAM , +TTM_PL_FLAG_CACHED ,TTM_PL_FLAG_CACHED , + false, dev_priv->vram_size >>PAGE_SHIFT );#endif ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )->use_type = false;return ret;
@@ -643,8 +639,7 @@ static void vmw_takedown_vram_manager(struct vmw_private *dev_priv)#ifdef CONFIG_TRANSPARENT_HUGEPAGE vmw_thp_takedown (dev_priv);#else -ttm_bo_man_takedown (&dev_priv->bdev, -ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )); +ttm_bo_man_takedown (&dev_priv->bdev,TTM_PL_VRAM );#endif }
include/drm/ttm/ttm_bo_driver.h +5 -2
@@ -809,8 +809,11 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);pgprot_t ttm_io_prot (uint32_t caching_flags,pgprot_t tmp);int ttm_bo_man_init (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +unsigned type, +uint32_t available_caching, +uint32_t default_caching, +bool use_tt,unsigned long p_size);int ttm_bo_man_takedown (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man); +unsigned type);#endif
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 37/49 drm/ttm: allow drivers to provide their own manager subclasses
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This will get removed eventually and all drivers will use this.
--- include/drm/ttm/ttm_bo_driver.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
include/drm/ttm/ttm_bo_driver.h +10 -1
@@ -419,7 +419,7 @@ struct ttm_bo_device {* access via ttm_manager_type. */ struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES ]; - +struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES ];/* * Protected by internal locks. */
@@ -450,9 +450,18 @@ struct ttm_bo_device {static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev,int mem_type) { +if (bdev->man_drv[mem_type]) +return bdev->man_drv[mem_type];return &bdev->man_priv[mem_type]; } +static inline void ttm_set_driver_manager (struct ttm_bo_device *bdev, +int type, +struct ttm_mem_type_manager *manager) +{ + bdev->man_drv[type] = manager; +} +/** * struct ttm_lru_bulk_move_pos *
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 30/49 drm/qxl/ttm: use wrapper to access memory manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/qxl/qxl_ttm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/qxl/qxl_ttm.c +5 -5
@@ -219,7 +219,7 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, unsigned int type, uint64_t size) { -struct ttm_mem_type_manager *man = &qdev->mman.bdev.man[type]; +struct ttm_mem_type_manager *man =ttm_manager_type (&qdev->mman.bdev, type); man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ;
@@ -266,8 +266,8 @@ int qxl_ttm_init(struct qxl_device *qdev)void qxl_ttm_fini (struct qxl_device *qdev) { -ttm_bo_man_takedown (&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_VRAM ]); -ttm_bo_man_takedown (&qdev->mman.bdev, &qdev->mman.bdev.man[TTM_PL_PRIV ]); +ttm_bo_man_takedown (&qdev->mman.bdev,ttm_manager_type (&qdev->mman.bdev,TTM_PL_VRAM )); +ttm_bo_man_takedown (&qdev->mman.bdev,ttm_manager_type (&qdev->mman.bdev,TTM_PL_PRIV ));ttm_bo_device_release (&qdev->mman.bdev);DRM_INFO ("qxl: ttm finalized\n" ); }
@@ -302,9 +302,9 @@ void qxl_ttm_debugfs_init(struct qxl_device *qdev) qxl_mem_types_list[i].show = &qxl_mm_dump_table; qxl_mem_types_list[i].driver_features =0 ;if (i ==0 ) - qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_VRAM ]; + qxl_mem_types_list[i].data =ttm_manager_type (&qdev->mman.bdev,TTM_PL_VRAM );else - qxl_mem_types_list[i].data = &qdev->mman.bdev.man[TTM_PL_PRIV ]; + qxl_mem_types_list[i].data =ttm_manager_type (&qdev->mman.bdev,TTM_PL_PRIV ); }qxl_debugfs_add_files (qdev, qxl_mem_types_list, i);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 36/49 drm/vmwgfx/gmrid: don't provide pointless ttm debug callback
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +0 -7
@@ -149,14 +149,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type)ttm_bo_man_cleanup (man); } -static void vmw_gmrid_man_debug (struct ttm_mem_type_manager *man, -struct drm_printer *printer) -{ -drm_printf (printer,"No debug info available for the GMR id manager\n" ); -} -static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node, - .debug = vmw_gmrid_man_debug };
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 23/49 drm/vmwgfx: fix gmrid takedown paths to new interface
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 10 +++++----- drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 1 + drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 11 ++++++++--- 3 files changed, 14 insertions(+), 8 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +5 -5
@@ -994,9 +994,9 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)vmw_kms_close (dev_priv); out_no_kms:if (dev_priv->has_mob) - (void )ttm_bo_clean_mm (&dev_priv->bdev,VMW_PL_MOB ); +vmw_gmrid_man_takedown (dev_priv,VMW_PL_MOB );if (dev_priv->has_gmr) - (void )ttm_bo_clean_mm (&dev_priv->bdev,VMW_PL_GMR ); +vmw_gmrid_man_takedown (dev_priv,VMW_PL_GMR );vmw_takedown_vram_manager (dev_priv); out_no_vram: (void )ttm_bo_device_release (&dev_priv->bdev);
@@ -1045,12 +1045,12 @@ static void vmw_driver_unload(struct drm_device *dev)vmw_overlay_close (dev_priv);if (dev_priv->has_gmr) - (void )ttm_bo_clean_mm (&dev_priv->bdev,VMW_PL_GMR ); - (void )ttm_bo_clean_mm (&dev_priv->bdev,TTM_PL_VRAM ); +vmw_gmrid_man_takedown (dev_priv,VMW_PL_GMR ); +vmw_takedown_vram_manager (dev_priv);vmw_release_device_early (dev_priv);if (dev_priv->has_mob) - (void )ttm_bo_clean_mm (&dev_priv->bdev,VMW_PL_MOB ); +vmw_gmrid_man_takedown (dev_priv,VMW_PL_MOB ); (void )ttm_bo_device_release (&dev_priv->bdev);drm_vma_offset_manager_destroy (&dev_priv->vma_manager);vmw_release_device_late (dev_priv);
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +1 -0
@@ -1222,6 +1222,7 @@ int vmw_overlay_num_free_overlays(struct vmw_private *dev_priv);*/ int vmw_gmrid_man_init (struct vmw_private *dev_priv,int type); +void vmw_gmrid_man_takedown (struct vmw_private *dev_priv,int type);/** * Prime - vmwgfx_prime.c
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +8 -3
@@ -131,16 +131,22 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)return 0 ; } -static int vmw_gmrid_man_takedown (struct ttm_mem_type_manager *man) +void vmw_gmrid_man_takedown (struct vmw_private *dev_priv,int type) { +struct ttm_mem_type_manager *man = &dev_priv->bdev.man[type];struct vmwgfx_gmrid_man *gman = (struct vmwgfx_gmrid_man *)man->priv; +ttm_bo_disable_mm (man); + +ttm_bo_force_list_clean (&dev_priv->bdev, man); +if (gman) {ida_destroy (&gman->gmr_ida);kfree (gman); } -return 0 ; + +ttm_bo_man_cleanup (man); } static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
@@ -150,7 +156,6 @@ static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { - .takedown = vmw_gmrid_man_takedown, .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node, .debug = vmw_gmrid_man_debug
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 16/49 drm/ttm: start allowing drivers to use new takedown path
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Allow the takedown path callback to be optional as well.
--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++-- include/drm/ttm/ttm_bo_driver.h | 5 ++++- 3 files changed, 28 insertions(+), 6 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +5 -3
@@ -1401,8 +1401,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_create); -static int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man) +int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man) {struct ttm_operation_ctx ctx = { .interruptible = false,
@@ -1444,6 +1444,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,return 0 ; } +EXPORT_SYMBOL (ttm_bo_force_list_clean);int ttm_bo_clean_mm (struct ttm_bo_device *bdev,unsigned mem_type) {
@@ -1472,7 +1473,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)return ret; } - ret = (*man->func->takedown)(man); +if (man->func->takedown) + ret = (*man->func->takedown)(man); }ttm_bo_man_cleanup (man);
drivers/gpu/drm/ttm/ttm_bo_manager.c +19 -2
@@ -129,7 +129,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_man_init); -static int ttm_bo_man_takedown (struct ttm_mem_type_manager *man) +static int ttm_bo_man_takedown_private (struct ttm_mem_type_manager *man) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;struct drm_mm *mm = &rman->mm;
@@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)return -EBUSY ; } +int ttm_bo_man_takedown (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man) +{ +int ret; + +ttm_bo_disable_mm (man); + + ret =ttm_bo_force_list_clean (bdev, man); +if (ret) +return ret; + +ttm_bo_man_takedown_private (man); +ttm_bo_man_cleanup (man); +return 0 ; +} +EXPORT_SYMBOL (ttm_bo_man_takedown); +static void ttm_bo_man_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) {
@@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .takedown = ttm_bo_man_takedown, + .takedown = ttm_bo_man_takedown_private, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug
include/drm/ttm/ttm_bo_driver.h +4 -1
@@ -683,6 +683,8 @@ static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man) man->move =NULL ; } +int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man);/* * ttm_bo_util.c */
@@ -801,5 +803,6 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);int ttm_bo_man_init (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man,unsigned long p_size); - +int ttm_bo_man_takedown (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man);#endif
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 49/49 drm/ttm: consolidate manager used apis into a set and get.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This is probably something we could consider removing, vmwgfx is the only user, and we might be able to faciliate it another way
but for now just consolidate it all into accessors.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 +++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 8 ++++---- 9 files changed, 28 insertions(+), 28 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2 -2
@@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) }ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT , &mgr->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }
@@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&adev->mman.bdev, man);if (ret)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +2 -2
@@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)DRM_ERROR ("Failed to register sysfs\n" );ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM , &mgr->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }
@@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&adev->mman.bdev, man);if (ret)
drivers/gpu/drm/nouveau/nouveau_ttm.c +4 -4
@@ -176,7 +176,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->use_io_reserve_lru = true;ttm_bo_init_mm_base (man, drm->gem.vram_available >>PAGE_SHIFT );ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM , man); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }else { return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_VRAM,
@@ -192,7 +192,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM ,NULL );
@@ -237,7 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->use_tt = true;ttm_bo_init_mm_base (man, size_pages);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT , man); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }
@@ -250,7 +250,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm) drm->agp.bridge) ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_TT); else { -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT ,NULL );
drivers/gpu/drm/ttm/ttm_bo.c +3 -3
@@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,return ret; man =ttm_manager_type (bdev, mem_type); -if (!man || !man->use_type) +if (!man || !ttm_mm_used (man))return -EBUSY ;if (!ttm_bo_mt_compatible (man, mem_type, place, &cur_flags))
@@ -1548,7 +1548,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)struct ttm_mem_type_manager *man; man =ttm_manager_type (bdev,TTM_PL_SYSTEM ); -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);mutex_lock (&ttm_global_mutex);list_del (&bdev->device_list);
@@ -1585,7 +1585,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->default_caching =TTM_PL_FLAG_CACHED ;ttm_bo_init_mm_base (man,0 ); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true); } int ttm_bo_device_init(struct ttm_bo_device *bdev,
drivers/gpu/drm/ttm/ttm_bo_manager.c +2 -2
@@ -139,7 +139,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev,spin_lock_init (&rman->lock);ttm_set_driver_manager (bdev, type, &rman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }EXPORT_SYMBOL (ttm_bo_man_init);
@@ -152,7 +152,7 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,struct drm_mm *mm = &rman->mm;int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (bdev, man);if (ret)
drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7 -7
@@ -630,7 +630,7 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv)TTM_PL_FLAG_CACHED ,TTM_PL_FLAG_CACHED , false, dev_priv->vram_size >> PAGE_SHIFT);#endif -ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )->use_type = false; +ttm_mm_set_use (ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ), false);return ret; }
@@ -1190,9 +1190,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );spin_lock (&dev_priv->svga_lock); -if (!man->use_type) { +if (!ttm_mm_used (man)) {vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE ); - man->use_type = true; +ttm_mm_set_use (man, true); }spin_unlock (&dev_priv->svga_lock); }
@@ -1221,8 +1221,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );spin_lock (&dev_priv->svga_lock); -if (man->use_type) { - man->use_type = false; +if (ttm_mm_used (man)) { +ttm_mm_set_use (man, false);vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE_HIDE |SVGA_REG_ENABLE_ENABLE );
@@ -1255,8 +1255,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)vmw_kms_lost_device (dev_priv->dev);ttm_write_lock (&dev_priv->reservation_sem, false);spin_lock (&dev_priv->svga_lock); -if (man->use_type) { - man->use_type = false; +if (ttm_mm_used (man)) { +ttm_mm_set_use (man, false);spin_unlock (&dev_priv->svga_lock);if (ttm_bo_evict_mm (&dev_priv->bdev,TTM_PL_VRAM ))DRM_ERROR ("Failed evicting VRAM buffers.\n" );
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2 -2
@@ -135,7 +135,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) }ttm_set_driver_manager (&dev_priv->bdev, type, &gman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }
@@ -144,7 +144,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type);struct vmwgfx_gmrid_man *gman =to_gmrid_manager (man); -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&dev_priv->bdev, man);
drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +2 -2
@@ -142,7 +142,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)spin_lock_init (&rman->lock);ttm_set_driver_manager (&dev_priv->bdev,TTM_PL_VRAM , &rman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }
@@ -153,7 +153,7 @@ void vmw_thp_takedown(struct vmw_private *dev_priv)struct drm_mm *mm = &rman->mm;int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&dev_priv->bdev, man);if (ret)
include/drm/ttm/ttm_bo_driver.h +4 -4
@@ -668,14 +668,14 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)dma_resv_unlock (bo->base.resv); } -static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) +static inline void ttm_mm_set_use (struct ttm_mem_type_manager *man,bool use) { - man->use_type = true; + man->use_type = use; } -static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) +static inline bool ttm_mm_used (struct ttm_mem_type_manager *man) { - man->use_type = false; +return man->use_type; }static inline void ttm_bo_man_cleanup (struct ttm_mem_type_manager *man)
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 44/49 drm/ttm: drop priv pointer in memory manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This isn't needed anymore by any drivers.
--- include/drm/ttm/ttm_bo_driver.h | 2 -- 1 file changed, 2 deletions(-)
include/drm/ttm/ttm_bo_driver.h +0 -2
@@ -123,7 +123,6 @@ struct ttm_mem_type_manager_func {* @default_caching: The default caching policy used for a buffer object * placed in this memory type if the user doesn't provide one. * @func: structure pointer implementing the range manager. See above -* @priv: Driver private closure for @func. * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions * reserved by the TTM vm system.
@@ -152,7 +151,6 @@ struct ttm_mem_type_manager {uint32_t available_caching;uint32_t default_caching;const struct ttm_mem_type_manager_func *func; -void *priv;struct mutex io_reserve_mutex;bool use_io_reserve_lru;spinlock_t move_lock;
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 42/49 drm/vmwgfx/gmrid: convert to driver controlled allocation.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +20 -13
@@ -37,6 +37,7 @@#include <linux/kernel.h> struct vmwgfx_gmrid_man { +struct ttm_mem_type_manager manager;spinlock_t lock;struct ida gmr_ida;uint32_t max_gmr_ids;
@@ -44,13 +45,17 @@ struct vmwgfx_gmrid_man {uint32_t used_gmr_pages; }; +static struct vmwgfx_gmrid_man *to_gmrid_manager (struct ttm_mem_type_manager *man) +{ + return container_of(man, struct vmwgfx_gmrid_man, manager); +} +static int vmw_gmrid_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 vmwgfx_gmrid_man *gman = - (struct vmwgfx_gmrid_man *)man->priv; +struct vmwgfx_gmrid_man *gman =to_gmrid_manager (man);int id; id =ida_alloc_max (&gman->gmr_ida, gman->max_gmr_ids -1 ,GFP_KERNEL );
@@ -82,8 +87,7 @@ static int vmw_gmrid_man_get_node(struct ttm_mem_type_manager *man,static void vmw_gmrid_man_put_node (struct ttm_mem_type_manager *man,struct ttm_mem_reg *mem) { -struct vmwgfx_gmrid_man *gman = - (struct vmwgfx_gmrid_man *)man->priv; +struct vmwgfx_gmrid_man *gman =to_gmrid_manager (man);if (mem->mm_node) {ida_free (&gman->gmr_ida, mem->start);
@@ -98,13 +102,15 @@ static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func;int vmw_gmrid_man_init (struct vmw_private *dev_priv,int type) { -struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type); +struct ttm_mem_type_manager *man;struct vmwgfx_gmrid_man *gman =kzalloc (sizeof (*gman),GFP_KERNEL );if (unlikely (!gman))return -ENOMEM ; + man = &gman->manager; + man->func = &vmw_gmrid_manager_func; man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ;
@@ -127,26 +133,27 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type)default :BUG (); } - man->priv = (void *) gman; + +ttm_set_driver_manager (&dev_priv->bdev, type, &gman->manager); +ttm_bo_use_mm (man);return 0 ; }void vmw_gmrid_man_takedown (struct vmw_private *dev_priv,int type) {struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type); -struct vmwgfx_gmrid_man *gman = - (struct vmwgfx_gmrid_man *)man->priv; +struct vmwgfx_gmrid_man *gman =to_gmrid_manager (man);ttm_bo_disable_mm (man);ttm_bo_force_list_clean (&dev_priv->bdev, man); -if (gman) { -ida_destroy (&gman->gmr_ida); -kfree (gman); - } -ttm_bo_man_cleanup (man); + +ttm_set_driver_manager (&dev_priv->bdev, type,NULL ); +ida_destroy (&gman->gmr_ida); +kfree (gman); + }static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = {
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 47/49 drm/ttm: drop list of memory managers from device.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
The driver now controls these, the core just controls the system memory one.
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 -- include/drm/ttm/ttm_bo_driver.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +0 -2
@@ -1608,8 +1608,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->driver = driver; -memset (bdev->man_priv,0 ,sizeof (bdev->man_priv)); -ttm_bo_init_sysman (bdev); bdev->vma_manager = vma_manager;
include/drm/ttm/ttm_bo_driver.h +4 -2
@@ -414,7 +414,7 @@ struct ttm_bo_device {/* * access via ttm_manager_type. */ -struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES ]; +struct ttm_mem_type_manager sysman;/* move to global */ struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES ];/* * Protected by internal locks.
@@ -446,9 +446,11 @@ struct ttm_bo_device {static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev,int mem_type) { +if (mem_type ==TTM_PL_SYSTEM ) +return &bdev->sysman;if (bdev->man_drv[mem_type])return bdev->man_drv[mem_type]; -return &bdev->man_priv[mem_type]; +return NULL ; } static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 46/49 drm/ttm: drop man->bdev link.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
This link isn't needed anymore, drop it from the init interface.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ttm.c | 6 ++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- drivers/gpu/drm/ttm/ttm_bo_manager.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 2 +- include/drm/ttm/ttm_bo_api.h | 3 +-- include/drm/ttm/ttm_bo_driver.h | 2 -- 9 files changed, 10 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1 -1
@@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; -ttm_bo_init_mm_base (&adev->mman.bdev, man, gtt_size >>PAGE_SHIFT ); +ttm_bo_init_mm_base (man, gtt_size >>PAGE_SHIFT ); start =AMDGPU_GTT_MAX_TRANSFER_SIZE *AMDGPU_GTT_NUM_TRANSFER_WINDOWS ; size = (adev->gmc.gart_size >>PAGE_SHIFT ) - start;
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1 -1
@@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; -ttm_bo_init_mm_base (&adev->mman.bdev, man, adev->gmc.real_vram_size >>PAGE_SHIFT ); +ttm_bo_init_mm_base (man, adev->gmc.real_vram_size >>PAGE_SHIFT ); man->func = &amdgpu_vram_mgr_func;
drivers/gpu/drm/nouveau/nouveau_ttm.c +2 -4
@@ -174,8 +174,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->func = &nouveau_vram_manager; man->use_io_reserve_lru = true; -ttm_bo_init_mm_base (&drm->ttm.bdev, man, - drm->gem.vram_available >>PAGE_SHIFT ); +ttm_bo_init_mm_base (man, drm->gem.vram_available >>PAGE_SHIFT );ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM , man);ttm_bo_use_mm (man);return 0 ;
@@ -236,8 +235,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->available_caching = available_caching; man->default_caching = default_caching; man->use_tt = true; -ttm_bo_init_mm_base (&drm->ttm.bdev, man, - size_pages); +ttm_bo_init_mm_base (man, size_pages);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT , man);ttm_bo_use_mm (man);return 0 ;
drivers/gpu/drm/ttm/ttm_bo.c +2 -4
@@ -1464,8 +1464,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm); -void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +void ttm_bo_init_mm_base (struct ttm_mem_type_manager *man,unsigned long p_size) {unsigned i;
@@ -1475,7 +1474,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev,mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);INIT_LIST_HEAD (&man->io_reserve_lru); - man->bdev = bdev; man->size = p_size;for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i)
@@ -1588,7 +1586,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; -ttm_bo_init_mm_base (bdev, man,0 ); +ttm_bo_init_mm_base (man,0 );ttm_bo_use_mm (man); }
drivers/gpu/drm/ttm/ttm_bo_manager.c +1 -1
@@ -133,7 +133,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, man->func = &ttm_bo_manager_func; -ttm_bo_init_mm_base (bdev, man, p_size); +ttm_bo_init_mm_base (man, p_size);drm_mm_init (&rman->mm,0 , p_size);spin_lock_init (&rman->lock);
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +1 -1
@@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) man->default_caching =TTM_PL_FLAG_CACHED ;/* TODO: This is most likely not correct */ man->use_tt = true; -ttm_bo_init_mm_base (&dev_priv->bdev, man,0 ); +ttm_bo_init_mm_base (man,0 );spin_lock_init (&gman->lock); gman->used_gmr_pages =0 ;ida_init (&gman->gmr_ida);
drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +1 -1
@@ -134,7 +134,7 @@ int vmw_thp_init(struct vmw_private *dev_priv) man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ; -ttm_bo_init_mm_base (&dev_priv->bdev, man, +ttm_bo_init_mm_base (man, dev_priv->vram_size >>PAGE_SHIFT );
include/drm/ttm/ttm_bo_api.h +1 -2
@@ -547,8 +547,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,* May also return driver-specified errors. */ struct ttm_mem_type_manager ; -void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +void ttm_bo_init_mm_base (struct ttm_mem_type_manager *man,unsigned long p_size);/**
include/drm/ttm/ttm_bo_driver.h +0 -2
@@ -138,8 +138,6 @@ struct ttm_mem_type_manager_func {struct ttm_mem_type_manager { -struct ttm_bo_device *bdev; -/* * No protection. Constant from start. */
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 41/49 drm/vmwgfx/ttm: move thp to driver managed
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 33 +++++++++++++++++++---------- 1 file changed, 22 insertions(+), 11 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +22 -11
@@ -16,10 +16,16 @@* @lock: Manager lock. */ struct vmw_thp_manager { +struct ttm_mem_type_manager manager;struct drm_mm mm;spinlock_t lock; }; +static struct vmw_thp_manager *to_thp_manager (struct ttm_mem_type_manager *man) +{ + return container_of(man, struct vmw_thp_manager, manager); +} + static int vmw_thp_insert_aligned(struct drm_mm *mm, struct drm_mm_node *node, unsigned long align_pages, const struct ttm_place *place,
@@ -43,7 +49,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; + struct vmw_thp_manager *rman = to_thp_manager(man);struct drm_mm *mm = &rman->mm;struct drm_mm_node *node;unsigned long align_pages;
@@ -103,7 +109,7 @@ static int vmw_thp_get_node(struct ttm_mem_type_manager *man,static void vmw_thp_put_node (struct ttm_mem_type_manager *man,struct ttm_mem_reg *mem) { -struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; +struct vmw_thp_manager *rman =to_thp_manager (man);if (mem->mm_node) {spin_lock (&rman->lock);
@@ -117,20 +123,25 @@ static void vmw_thp_put_node(struct ttm_mem_type_manager *man,int vmw_thp_init (struct vmw_private *dev_priv) { -struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ); +struct ttm_mem_type_manager *man;struct vmw_thp_manager *rman; + + rman =kzalloc (sizeof (*rman),GFP_KERNEL ); +if (!rman) +return -ENOMEM ; + + man = &rman->manager; man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ;ttm_bo_init_mm_base (&dev_priv->bdev, man, dev_priv->vram_size >>PAGE_SHIFT ); - rman =kzalloc (sizeof (*rman),GFP_KERNEL ); -if (!rman) -return -ENOMEM ; +drm_mm_init (&rman->mm,0 , man->size);spin_lock_init (&rman->lock); - man->priv = rman; + +ttm_set_driver_manager (&dev_priv->bdev,TTM_PL_VRAM , &rman->manager);ttm_bo_use_mm (man);return 0 ; }
@@ -138,7 +149,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)void vmw_thp_takedown (struct vmw_private *dev_priv) {struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ); -struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; +struct vmw_thp_manager *rman =to_thp_manager (man);struct drm_mm *mm = &rman->mm;int ret;
@@ -151,15 +162,15 @@ void vmw_thp_takedown(struct vmw_private *dev_priv)drm_mm_clean (mm);drm_mm_takedown (mm);spin_unlock (&rman->lock); -kfree (rman); - man->priv =NULL ;ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&dev_priv->bdev,TTM_PL_VRAM ,NULL ); +kfree (rman); }static void vmw_thp_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { -struct vmw_thp_manager *rman = (struct vmw_thp_manager *) man->priv; +struct vmw_thp_manager *rman =to_thp_manager (man);spin_lock (&rman->lock);drm_mm_print (&rman->mm, printer);
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 45/49 drm/amdgpu/ttm: remove man->bdev references.
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
Just store the device in the private so the link
can be removed from the manager
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +5 -2
@@ -34,6 +34,7 @@ struct amdgpu_vram_mgr {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_mem_type_manager *man)
@@ -196,6 +197,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)drm_mm_init (&mgr->mm,0 , man->size);spin_lock_init (&mgr->lock); + mgr->adev = adev; +/* Add the two VRAM-related sysfs files */ ret =sysfs_create_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes);if (ret)
@@ -323,8 +326,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); +struct amdgpu_device *adev = mgr->adev;struct drm_mm *mm = &mgr->mm;struct drm_mm_node *nodes;enum drm_mm_insert_mode mode;
@@ -439,8 +442,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,static void amdgpu_vram_mgr_del (struct ttm_mem_type_manager *man,struct ttm_mem_reg *mem) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev);struct amdgpu_vram_mgr *mgr =to_vram_mgr (man); +struct amdgpu_device *adev = mgr->adev;struct drm_mm_node *nodes = mem->mm_node;uint64_t usage =0 , vis_usage =0 ;unsigned pages = mem->num_pages;
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 48/49 drm/ttm: drop type manager has_type
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
under driver control, this flag isn't needed anymore
--- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- include/drm/ttm/ttm_bo_driver.h | 5 ----- 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +2 -4
@@ -82,7 +82,6 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p {struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type); -drm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);drm_printf (p," use_tt: %d\n" , man->use_tt);drm_printf (p," size: %llu\n" , man->size);
@@ -997,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,return ret; man =ttm_manager_type (bdev, mem_type); -if (!man->has_type || !man->use_type) +if (!man || !man->use_type)return -EBUSY ;if (!ttm_bo_mt_compatible (man, mem_type, place, &cur_flags))
@@ -1455,7 +1454,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)return -EINVAL ; } -if (!man->has_type) { +if (!man) {pr_err ("Memory type %u has not been initialized\n" , mem_type);return 0 ; }
@@ -1469,7 +1468,6 @@ void ttm_bo_init_mm_base(struct ttm_mem_type_manager *man, {unsigned i; -BUG_ON (man->has_type); man->use_io_reserve_lru = false;mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);
include/drm/ttm/ttm_bo_driver.h +0 -5
@@ -111,7 +111,6 @@ struct ttm_mem_type_manager_func {/** * struct ttm_mem_type_manager * -* @has_type: The memory type has been initialized. * @use_type: The memory type is enabled. * @flags: TTM_MEMTYPE_XX flags identifying the traits of the memory * managed by this memory type.
@@ -141,8 +140,6 @@ struct ttm_mem_type_manager {/* * No protection. Constant from start. */ - -bool has_type;bool use_type;bool use_tt;uint64_t size;
@@ -673,13 +670,11 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) { - man->has_type = true; man->use_type = true; }static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) { - man->has_type = false; man->use_type = false; }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerPATCH 43/49 drm/nouveau/ttm: move to driver allocated manager
In reply to Dave AirlieFrom: Dave Airlie <[email protected]>
--- drivers/gpu/drm/nouveau/nouveau_ttm.c | 41 ++++++++++++++++++--------- 1 file changed, 28 insertions(+), 13 deletions(-)
drivers/gpu/drm/nouveau/nouveau_ttm.c +28 -13
@@ -157,12 +157,12 @@ static int nouveau_ttm_init_vram(struct nouveau_drm *drm) {struct nvif_mmu *mmu = &drm->client.mmu; -if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { -struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM ); -/* Some BARs do not support being ioremapped WC */ const u8 type = mmu->type[drm->ttm.type_vram].type; +struct ttm_mem_type_manager *man =kzalloc (sizeof (struct ttm_mem_type_manager ),GFP_KERNEL ); +if (!man) +return -ENOMEM ; man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ;
@@ -176,6 +176,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->use_io_reserve_lru = true;ttm_bo_init_mm_base (&drm->ttm.bdev, man, drm->gem.vram_available >>PAGE_SHIFT ); +ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM , man);ttm_bo_use_mm (man);return 0 ; }else {
@@ -195,6 +196,8 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)ttm_bo_disable_mm (man);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM ,NULL ); +kfree (man); }else ttm_bo_man_takedown (&drm->ttm.bdev,TTM_PL_VRAM ); }
@@ -202,30 +205,40 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)static int nouveau_ttm_init_gtt (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_TT ); +struct ttm_mem_type_manager *man;unsigned long size_pages = drm->gem.gart_available >>PAGE_SHIFT ; - man->use_tt = true; +unsigned available_caching, default_caching; +const struct ttm_mem_type_manager_func *func =NULL ;if (drm->agp.bridge) { - man->available_caching =TTM_PL_FLAG_UNCACHED | + available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; + default_caching =TTM_PL_FLAG_WC ; }else { - man->available_caching =TTM_PL_MASK_CACHING ; - man->default_caching =TTM_PL_FLAG_CACHED ; + available_caching =TTM_PL_MASK_CACHING ; + default_caching =TTM_PL_FLAG_CACHED ; }if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) - man->func = &nouveau_gart_manager; + func = &nouveau_gart_manager;else if (!drm->agp.bridge) - man->func = &nv04_gart_manager; + func = &nv04_gart_manager;else return ttm_bo_man_init (&drm->ttm.bdev,TTM_PL_TT , -TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , -TTM_PL_FLAG_WC , true, + available_caching, default_caching, + true, size_pages); + man =kzalloc (sizeof (struct ttm_mem_type_manager ),GFP_KERNEL ); +if (!man) +return -ENOMEM ; + + man->func = func; + man->available_caching = available_caching; + man->default_caching = default_caching; + man->use_tt = true;ttm_bo_init_mm_base (&drm->ttm.bdev, man, size_pages); +ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT , man);ttm_bo_use_mm (man);return 0 ; }
@@ -242,6 +255,8 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)ttm_bo_disable_mm (man);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT ,NULL ); +kfree (man); } }
Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/49] drm/ttm: split the mm manager init code
In reply to Dave AirlieHi Dave.
Quoted 18 lines · Dave Airlie
From: Dave Airlie <[email protected]>
This will allow the driver to control the ordering here better.
Eventually the old path will be removed.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) · line 1509
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-2@@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) {
General comment for all the ttm/* changes.
It would be very nice with some nice explanations for the exported functions, preferably in kernel-doc style.
In case someone that are more or less clueless (like me) would like to understand how a function is to be used or maybe reviewing some random code.
Sam
Quoted 85 lines
drivers/gpu/drm/ttm/ttm_bo.c +17
-12-int ret; -struct ttm_mem_type_manager *man;unsigned i; -BUG_ON (type >=TTM_NUM_MEM_TYPES ); - man = &bdev->man[type];BUG_ON (man->has_type); man->use_io_reserve_lru = false;mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);INIT_LIST_HEAD (&man->io_reserve_lru); man->bdev = bdev; - -if (type !=TTM_PL_SYSTEM ) { - ret = (*man->func->init)(man, p_size); -if (ret) -return ret; - } - man->has_type = true; - man->use_type = true; man->size = p_size;for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i)INIT_LIST_HEAD (&man->lru[i]); man->move =NULL ; +} +EXPORT_SYMBOL (ttm_bo_init_mm_base); +int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, +unsigned long p_size) +{ +int ret; +struct ttm_mem_type_manager *man; + +BUG_ON (type >=TTM_NUM_MEM_TYPES ); +ttm_bo_init_mm_base (bdev, &bdev->man[type], p_size); + +if (type !=TTM_PL_SYSTEM ) { + ret = (*man->func->init)(man, p_size); +if (ret) +return ret; + } +ttm_bo_use_mm (man);return 0 ; }EXPORT_SYMBOL (ttm_bo_init_mm);include/drm/ttm/ttm_bo_api.h +4
-0@@ -546,6 +546,10 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,* -ENOMEM: Not enough memory. * May also return driver-specified errors. */ +struct ttm_mem_type_manager ; +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type,unsigned long p_size);include/drm/ttm/ttm_bo_driver.h +6
-0@@ -678,6 +678,12 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)dma_resv_unlock (bo->base.resv); } +static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) +{ + man->has_type = true; + man->use_type = true; +} +/* * ttm_bo_util.c */ Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 03/49] drm/ttm: split the mm manager init code
Quoted 25 lines · Sam Ravnborg
Hi Dave.
Quoted 21 lines · Dave Airlie
From: Dave Airlie <[email protected]>
This will allow the driver to control the ordering here better.
Eventually the old path will be removed.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm);
Quoted 13 lines
drivers/gpu/drm/ttm/ttm_bo.c int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) · line 1509
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-2-int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) {General comment for all the ttm/* changes.
It would be very nice with some nice explanations for the exported functions, preferably in kernel-doc style.
In case someone that are more or less clueless (like me) would like to understand how a function is to be used or maybe reviewing some random code.
Good point, I just need to make sure I don't add anything for something I remove later, but I should definitely add some for the new interfaces.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 03/49] drm/ttm: split the mm manager init code
Quoted 41 lines · Dave Airlie
Quoted 25 lines · Sam Ravnborg
Hi Dave.
Quoted 21 lines · Dave Airlie
From: Dave Airlie <[email protected]>
This will allow the driver to control the ordering here better.
Eventually the old path will be removed.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0@@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm);Quoted 13 lines
drivers/gpu/drm/ttm/ttm_bo.c int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) · line 1509
Quoted 6 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-2-int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) {General comment for all the ttm/* changes.
It would be very nice with some nice explanations for the exported functions, preferably in kernel-doc style.
In case someone that are more or less clueless (like me) would like to understand how a function is to be used or maybe reviewing some random code.
Quoted 3 lines
Good point, I just need to make sure I don't add anything for something I remove later, but I should definitely add some for the new interfaces.
The version in my git branch has docs for all the new apis now.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 03/49] drm/ttm: split the mm manager init code
Quoted 42 lines · Dave Airlie
Quoted 41 lines · Dave Airlie
Quoted 38 lines · Sam Ravnborg
Hi Dave.
Quoted 18 lines · Dave Airlie
From: Dave Airlie <[email protected]>
This will allow the driver to control the ordering here better.
Eventually the old path will be removed.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0drivers/gpu/drm/ttm/ttm_bo.c int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) · line 1509
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +3
-2@@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) {General comment for all the ttm/* changes.
It would be very nice with some nice explanations for the exported functions, preferably in kernel-doc style.
In case someone that are more or less clueless (like me) would like to understand how a function is to be used or maybe reviewing some random code.
Quoted 5 lines
Quoted 3 lines
Good point, I just need to make sure I don't add anything for something I remove later, but I should definitely add some for the new interfaces.
The version in my git branch has docs for all the new apis now.
Thanks!
And now I am more or less oblieged to read/review the docs when you submit v2 - yeah, more reviews.
Sam
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 02/49] drm/vram-helper: call the ttm manager debug function
In reply to Dave AirlieHi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 4 lines
From: Dave Airlie <[email protected]>
This code was assuming there was a
drm_mmhere, don't do that call the correct API.
Maybe put a semicolon after 'that' for readability.
Quoted 2 lines
Signed-off-by Dave Airlie <[email protected]>
Quoted 24 lines
--- drivers/gpu/drm/drm_gem_vram_helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)drivers/gpu/drm/drm_gem_vram_helper.c +2
-4@@ -1075,12 +1075,10 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void *data) {struct drm_info_node *node = (struct drm_info_node *) m->private;struct drm_vram_mm *vmm = node->minor->dev->vram_mm; -struct drm_mm *mm = vmm->bdev.man[TTM_PL_VRAM ].priv; +struct ttm_mem_type_manager *man = &vmm->bdev.man[TTM_PL_VRAM ];struct drm_printer p =drm_seq_file_printer (m); -spin_lock (&ttm_bo_glob.lru_lock); -drm_mm_print (mm, &p); -spin_unlock (&ttm_bo_glob.lru_lock); + man->func->debug (man, &p);return 0 ; }
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerRe: [PATCH 04/49] drm/ttm: provide a driver-led init path for generic mm manager.
In reply to Dave AirlieHi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 26 lines
From: Dave Airlie <[email protected]>
This lets the generic mm manager be initialised by the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++--- include/drm/ttm/ttm_bo_driver.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-2@@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +unsigned long p_size) {struct ttm_range_manager *rman;
drivers/gpu/drm/ttm/ttm_bo_manager.c static int ttm_bo_man_init(struct ttm_mem_type_manager *man, · line 128
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +7
-0@@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,return 0 ; } +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) +{ +int ret; + + man->func = &ttm_bo_manager_func;
Overriding man->func is the only reason for drivers to call ttm_bo_man_init_mm_base and ttm_bo_use_mm directly (e.g., as in nouveau)?
If so, Wouldn't it be better to do
if (!man->func)
man->func = &ttm_bo_manager_func;in ttm_bo_man_init and forget about the other fucntions?
Best regards
Thomas
Quoted 37 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +11
-1+ +ttm_bo_init_mm_base (bdev, man, p_size); + ret =ttm_bo_man_init_private (man, p_size); +if (ret) +return ret; +ttm_bo_use_mm (man); +return 0 ; +} +EXPORT_SYMBOL (ttm_bo_man_init); +static int ttm_bo_man_takedown (struct ttm_mem_type_manager *man) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;@@ -147,7 +164,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init, + .init = ttm_bo_man_init_private, .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node,include/drm/ttm/ttm_bo_driver.h +3
-0@@ -799,6 +799,9 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);*/ pgprot_t ttm_io_prot (uint32_t caching_flags,pgprot_t tmp); +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;#endif
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerRe: [PATCH 04/49] drm/ttm: provide a driver-led init path for generic mm manager.
Am 31.07.20 um 08:57 schrieb Thomas Zimmermann:
Quoted 48 lines
Hi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 26 lines
From: Dave Airlie <[email protected]>
This lets the generic mm manager be initialised by the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++--- include/drm/ttm/ttm_bo_driver.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-2@@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +unsigned long p_size) {struct ttm_range_manager *rman;drivers/gpu/drm/ttm/ttm_bo_manager.c static int ttm_bo_man_init(struct ttm_mem_type_manager *man, · line 128
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +7
-0@@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,return 0 ; } +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) +{ +int ret; + + man->func = &ttm_bo_manager_func;Overriding
man->funcis the only reason for drivers to callttm_bo_man_init_mm_baseandttm_bo_use_mmdirectly (e.g., as in nouveau)?If so, Wouldn't it be better to do
if (!man->func) man->func = &ttm_bo_manager_func;
Quoted 8 lines
in
ttm_bo_man_initand forget about the other fucntions?Best regards
Thomasdrivers/gpu/drm/ttm/ttm_bo_manager.c static int ttm_bo_man_init(struct ttm_mem_type_manager *man, · line 131
Quoted 3 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +3
-0+ +ttm_bo_init_mm_base (bdev, man, p_size); + ret =ttm_bo_man_init_private (man, p_size);
Oh, I just realized that this line's also missing in nouveau.
Quoted 35 lines
Quoted 34 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +8
-1+if (ret) +return ret; +ttm_bo_use_mm (man); +return 0 ; +} +EXPORT_SYMBOL (ttm_bo_man_init); +static int ttm_bo_man_takedown (struct ttm_mem_type_manager *man) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;@@ -147,7 +164,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init, + .init = ttm_bo_man_init_private, .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node,include/drm/ttm/ttm_bo_driver.h +3
-0@@ -799,6 +799,9 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);*/ pgprot_t ttm_io_prot (uint32_t caching_flags,pgprot_t tmp); +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;#endif
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thomas Zimmermann
maintainerRe: [PATCH 26/49] drm/ttm: add wrapper to get manager from bdev.
In reply to Dave AirlieHi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This will allow different abstractions later.
You should consider moving this patch to the beginning of the series, so that patches 1 to 25 can benefit from it.
Best regards
Thomas
Quoted 277 lines
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++---------------- drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++--------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 4 files changed, 34 insertions(+), 28 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +17
-17@@ -80,7 +80,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,static void ttm_mem_type_debug (struct ttm_bo_device *bdev,struct drm_printer *p,int mem_type) { -struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type);drm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);@@ -156,7 +156,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,if (mem->placement &TTM_PL_FLAG_NO_EVICT )return ; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type);list_add_tail (&bo->lru, &man->lru[bo->priority]); if (man->use_tt && bo->ttm &&@@ -231,7 +231,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)dma_resv_assert_held (pos->first->base.resv);dma_resv_assert_held (pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_TT ]; + man =ttm_manager_type (pos->first->bdev,TTM_PL_TT );list_bulk_move_tail (&man->lru[i], &pos->first->lru, &pos->last->lru); }@@ -246,7 +246,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)dma_resv_assert_held (pos->first->base.resv);dma_resv_assert_held (pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_VRAM ]; + man =ttm_manager_type (pos->first->bdev,TTM_PL_VRAM );list_bulk_move_tail (&man->lru[i], &pos->first->lru, &pos->last->lru); }@@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type]; -struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *old_man =ttm_manager_type (bdev, bo->mem.mem_type); +struct ttm_mem_type_manager *new_man =ttm_manager_type (bdev, mem->mem_type);int ret; ret =ttm_mem_io_lock (old_man, true);@@ -338,7 +338,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,return 0 ; out_err: - new_man = &bdev->man[bo->mem.mem_type]; + new_man =ttm_manager_type (bdev, bo->mem.mem_type);if (!new_man->use_tt) {ttm_tt_destroy (bo->ttm); bo->ttm =NULL ;@@ -550,7 +550,7 @@ static void ttm_bo_release(struct kref *kref)struct ttm_buffer_object *bo = container_of(kref, struct ttm_buffer_object, kref);struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, bo->mem.mem_type);size_t acc_size = bo->acc_size;int ret;@@ -838,7 +838,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type); mem->mm_node =NULL ;if (!man->func || !man->func->get_node)@@ -849,7 +849,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,void ttm_bo_mem_put (struct ttm_buffer_object *bo,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bo->bdev, mem->mem_type);if (!man->func || !man->func->put_node)return ;@@ -906,7 +906,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem->mem_type);struct ww_acquire_ctx *ticket;int ret;@@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,if (ret)return ret; - man = &bdev->man[mem_type]; + man =ttm_manager_type (bdev, mem_type);if (!man->has_type || !man->use_type)return -EBUSY ;@@ -1059,7 +1059,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (unlikely (ret)) goto error; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type); ret =ttm_bo_add_move_fence (bo, man, mem, ctx->no_wait_gpu);if (unlikely (ret)) {ttm_bo_mem_put (bo, mem);@@ -1448,7 +1448,7 @@ EXPORT_SYMBOL(ttm_bo_force_list_clean);int ttm_bo_evict_mm (struct ttm_bo_device *bdev,unsigned mem_type) { -struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type);if (mem_type ==0 || mem_type >=TTM_NUM_MEM_TYPES ) {pr_err ("Illegal memory manager memory type %u\n" , mem_type);@@ -1551,7 +1551,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)unsigned i;struct ttm_mem_type_manager *man; - man = &bdev->man[TTM_PL_SYSTEM ]; + man =ttm_manager_type (bdev,TTM_PL_SYSTEM );ttm_bo_disable_mm (man);mutex_lock (&ttm_global_mutex);@@ -1578,7 +1578,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);static void ttm_bo_init_sysman (struct ttm_bo_device *bdev) { -struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev,TTM_PL_SYSTEM );/* * Initialize the system memory buffer type. @@ -1642,7 +1642,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)void ttm_bo_unmap_virtual (struct ttm_buffer_object *bo) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, bo->mem.mem_type);ttm_mem_io_lock (man, false);ttm_bo_unmap_virtual_locked (bo);drivers/gpu/drm/ttm/ttm_bo_util.c +10
-10@@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)int ttm_mem_io_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem->mem_type);int ret;if (mem->bus.io_reserved_count++)@@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,int ttm_mem_io_reserve_vm (struct ttm_buffer_object *bo) { -struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bo->bdev, bo->mem.mem_type);struct ttm_mem_reg *mem = &bo->mem;int ret;@@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,struct ttm_mem_reg *mem, void **virtual) { - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);int ret;void *addr;@@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, {struct ttm_mem_type_manager *man; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type);if (virtual && mem->bus.addr ==NULL )iounmap (virtual);@@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, new_mem->mem_type);struct ttm_tt *ttm = bo->ttm;struct ttm_mem_reg *old_mem = &bo->mem;struct ttm_mem_reg old_copy = *old_mem;@@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *map) {struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; +ttm_manager_type (bo->bdev, bo->mem.mem_type);unsigned long offset, size;int ret;@@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) {struct ttm_buffer_object *bo = map->bo;struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; +ttm_manager_type (bo->bdev, bo->mem.mem_type);if (!map->virtual)return ;@@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, new_mem->mem_type);struct ttm_mem_reg *old_mem = &bo->mem;int ret;struct ttm_buffer_object *ghost_obj;@@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,struct ttm_bo_device *bdev = bo->bdev;struct ttm_mem_reg *old_mem = &bo->mem; -struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type]; -struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *from =ttm_manager_type (bdev, old_mem->mem_type); +struct ttm_mem_type_manager *to =ttm_manager_type (bdev, new_mem->mem_type);int ret;drivers/gpu/drm/ttm/ttm_bo_vm.c +1
-1@@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,vm_fault_t ret =VM_FAULT_NOPAGE ;unsigned long address = vmf->address;struct ttm_mem_type_manager *man = - &bdev->man[bo->mem.mem_type]; +ttm_manager_type (bdev, bo->mem.mem_type);/* * Refuse to fault imported pages. This should be handled include/drm/ttm/ttm_bo_driver.h +6
-0@@ -444,6 +444,12 @@ struct ttm_bo_device {bool no_retry; }; +static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev, +int mem_type) +{ +return &bdev->man[mem_type]; +} +/** * struct ttm_lru_bulk_move_pos *
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 04/49] drm/ttm: provide a driver-led init path for generic mm manager.
In reply to Thomas ZimmermannQuoted 44 lines · Thomas Zimmermann
Hi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 26 lines
From: Dave Airlie <[email protected]>
This lets the generic mm manager be initialised by the driver.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++--- include/drm/ttm/ttm_bo_driver.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-2@@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +unsigned long p_size) {struct ttm_range_manager *rman;drivers/gpu/drm/ttm/ttm_bo_manager.c static int ttm_bo_man_init(struct ttm_mem_type_manager *man, · line 128
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +7
-0@@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,return 0 ; } +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) +{ +int ret; + + man->func = &ttm_bo_manager_func;Overriding
man->funcis the only reason for drivers to callttm_bo_man_init_mm_baseandttm_bo_use_mmdirectly (e.g., as in nouveau)?
Quoted 6 lines
If so, Wouldn't it be better to do
if (!man->func) man->func = &ttm_bo_manager_func;in
ttm_bo_man_initand forget about the other fucntions?
No ttm_bo_man_init, is just for the range manager, if you want to use it, it's not generic code for driver manager that want to use a different manager class (like nouveau).
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 26/49] drm/ttm: add wrapper to get manager from bdev.
In reply to Thomas ZimmermannQuoted 10 lines · Thomas Zimmermann
Hi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This will allow different abstractions later.
You should consider moving this patch to the beginning of the series, so that patches 1 to 25 can benefit from it.
I did consider it, but I'd have to move all the follow on patches as well, and it got messy in rebase land, and I started introducing errors, so I left it alone, and it's not necessary until the patch that changes it's definition anyways.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 03/49] drm/ttm: split the mm manager init code
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 78 lines
From: Dave Airlie <[email protected]>
This will allow the driver to control the ordering here better.
Eventually the old path will be removed.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++++++-------------- include/drm/ttm/ttm_bo_api.h | 4 ++++ include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 3 files changed, 30 insertions(+), 14 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +20
-14@@ -1503,35 +1503,41 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) { -int ret; -struct ttm_mem_type_manager *man;unsigned i; -BUG_ON (type >=TTM_NUM_MEM_TYPES ); - man = &bdev->man[type];BUG_ON (man->has_type); man->use_io_reserve_lru = false;mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);INIT_LIST_HEAD (&man->io_reserve_lru); man->bdev = bdev; - -if (type !=TTM_PL_SYSTEM ) { - ret = (*man->func->init)(man, p_size); -if (ret) -return ret; - } - man->has_type = true; - man->use_type = true; man->size = p_size;for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i)INIT_LIST_HEAD (&man->lru[i]); man->move =NULL ; +} +EXPORT_SYMBOL (ttm_bo_init_mm_base); +int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, +unsigned long p_size) +{ +int ret; +struct ttm_mem_type_manager *man; + +BUG_ON (type >=TTM_NUM_MEM_TYPES ); +ttm_bo_init_mm_base (bdev, &bdev->man[type], p_size); + +if (type !=TTM_PL_SYSTEM ) { + ret = (*man->func->init)(man, p_size); +if (ret) +return ret; + } +ttm_bo_use_mm (man);return 0 ; }EXPORT_SYMBOL (ttm_bo_init_mm);include/drm/ttm/ttm_bo_api.h +0
-0
include/drm/ttm/ttm_bo_api.h int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size, · line 552
Quoted 7 lines
include/drm/ttm/ttm_bo_api.h +4
-0@@ -546,6 +546,10 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,* -ENOMEM: Not enough memory. * May also return driver-specified errors. */ +struct ttm_mem_type_manager ; +void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);
As I wrote before I would completely rename the backend functions to ttm_resource_* since this is not related to the buffer objects in any way.
Moving a good bunch of the handling into a separate file might be a good idea as well. But that can obviously come later as well.
Christian.
Quoted 10 lines
include/drm/ttm/ttm_bo_api.h +0
-0int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type,unsigned long p_size);include/drm/ttm/ttm_bo_driver.h +0
-0@@ -678,6 +678,12 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)dma_resv_unlock (bo->base.resv); }
include/drm/ttm/ttm_bo_driver.h static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) · line 689
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +6
-0+static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) +{ + man->has_type = true; + man->use_type = true; +} +/* * ttm_bo_util.c */
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 1 line
I started pulling on a thread, and it led me down a hole.
We might want to make that hole even bigger :)
How about we rename the ttm_mem_reg into ttm_resource and ttm_mem_type_manager into ttm_resource_manager.
Neither amdgpu's OA/GWS resources nor the IDs in VMGFX are really memory.
In the long term I also want to move the whole address handling into each backend.
Going to send comments on the individual patches as well.
Quoted 18 lines
This series refactors the ttm
ttm_mem_type_managerobject into a driver owned, allocated, subclassaed object.It starts with two minor fixes for some bad assumptions in two drivers.
Enables a new init path, ports all the drivers to the new init path, and cleans up the old init path.
Enables a new takedown path, ports all the drivers to the new takedown path, and cleans up the old takedown path
Wraps all access to the memory managers in thebo_devicein a wrapper across all drivers.
Make debug callback optional
Enables driver to provide their own mem manager objects Subclasses the objects in all drivers and makes them into driver owned object Drops thebo_devicearrays of pointers, and some unneeded links and struct members
Cleans up one api.
Quoted 5 lines
I think I'd probably want to merge all this via drm-misc, so if I can collect acks/r-b from driver maintainers that would be good.
This is also based on Chrisitan's work to remove
init_mem_type, so it won't apply until he's finished getting all of that into drm-misc.
Preparing to push that to drm-misc-next just now.
Regards,
Christian.
Quoted 11 lines
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~airlied%2Flinux%2Flog%2F%3Fh%3Dttm-refactor-mem-manager&data=02%7C01%7Cchristian.koenig%40amd.com%7Caa32512acf9f4bf455ef08d83506f9d2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317651361302583&sdata=2sQt4A48ODl0Nq4P21YG3vRNdhkDZcZp0XHkQ930SAI%3D&reserved=0
is the tree I've built this on top off, so it's probably going to get rebased but the code should stay mostly the same.I've done some boot testing on nouveau, and I hope to test it on vmwgfx and amdgpu soon.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · Christian König
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 1 line
I started pulling on a thread, and it led me down a hole.
We might want to make that hole even bigger :)
How about we rename the
ttm_mem_regintottm_resourceandttm_mem_type_managerintottm_resource_manager.
+1 on names I can understand, I alwas get confused about what exactly ttm means with mem_reg and mem_type_manager.
-Daniel
Quoted 53 lines
Neither amdgpu's OA/GWS resources nor the IDs in VMGFX are really memory.
In the long term I also want to move the whole address handling into each backend.
Going to send comments on the individual patches as well.
Quoted 18 lines
This series refactors the ttm
ttm_mem_type_managerobject into a driver owned, allocated, subclassaed object.It starts with two minor fixes for some bad assumptions in two drivers.
Enables a new init path, ports all the drivers to the new init path, and cleans up the old init path.
Enables a new takedown path, ports all the drivers to the new takedown path, and cleans up the old takedown path
Wraps all access to the memory managers in thebo_devicein a wrapper across all drivers.
Make debug callback optional
Enables driver to provide their own mem manager objects Subclasses the objects in all drivers and makes them into driver owned object Drops thebo_devicearrays of pointers, and some unneeded links and struct members
Cleans up one api.Quoted 5 lines
I think I'd probably want to merge all this via drm-misc, so if I can collect acks/r-b from driver maintainers that would be good.
This is also based on Chrisitan's work to remove
init_mem_type, so it won't apply until he's finished getting all of that into drm-misc.Preparing to push that to drm-misc-next just now.
Regards,
Christian.Quoted 11 lines
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~airlied%2Flinux%2Flog%2F%3Fh%3Dttm-refactor-mem-manager&data=02%7C01%7Cchristian.koenig%40amd.com%7Caa32512acf9f4bf455ef08d83506f9d2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317651361302583&sdata=2sQt4A48ODl0Nq4P21YG3vRNdhkDZcZp0XHkQ930SAI%3D&reserved=0
is the tree I've built this on top off, so it's probably going to get rebased but the code should stay mostly the same.I've done some boot testing on nouveau, and I hope to test it on vmwgfx and amdgpu soon.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 34/49] drm/ttm: make manager debug function optional
In reply to Dave AirlieQuoted 12 lines · Dave Airlie
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p · line 93
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -88,7 +88,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching); -if (mem_type !=TTM_PL_SYSTEM ) +if (mem_type !=TTM_PL_SYSTEM && man->func->debug) (*man->func->debug)(man, p); }
Bit a bikeshed, but what about exporting this function (maybe with the man as argument, not the bdev, mem_type pair) and using it in the first 2 patches? Avoids surprises with optional func->debug.
-Daniel
Quoted 8 lines
Signature · 7 lines
-- 2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 49/49] drm/ttm: consolidate manager used apis into a set and get.
In reply to Dave AirlieQuoted 8 lines · Dave Airlie
From: Dave Airlie <[email protected]>
This is probably something we could consider removing, vmwgfx is the only user, and we might be able to faciliate it another way
but for now just consolidate it all into accessors.
Signed-off-by Dave Airlie <[email protected]>
Maybe I'm missing something, but doesn't this boild down to:
tmm_mm_used(type) = (bool) ttm_manager_type(type)
now that all resource managers are explicitly registered? I think there's nothing else left, your ttm_set_driver_manager essentially replaces ttm_mm_set_use.
-Daniel
Quoted 270 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 +++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 8 ++++---- 9 files changed, 28 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2
-2@@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) }ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT , &mgr->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&adev->mman.bdev, man);if (ret)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +2
-2@@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)DRM_ERROR ("Failed to register sysfs\n" );ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM , &mgr->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&adev->mman.bdev, man);if (ret)drivers/gpu/drm/nouveau/nouveau_ttm.c +4
-4@@ -176,7 +176,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->use_io_reserve_lru = true;ttm_bo_init_mm_base (man, drm->gem.vram_available >>PAGE_SHIFT );ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM , man); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }else { return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_VRAM,@@ -192,7 +192,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM ,NULL );@@ -237,7 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->use_tt = true;ttm_bo_init_mm_base (man, size_pages);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT , man); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -250,7 +250,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm) drm->agp.bridge) ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_TT); else { -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT ,NULL );drivers/gpu/drm/ttm/ttm_bo.c +3
-3@@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,return ret; man =ttm_manager_type (bdev, mem_type); -if (!man || !man->use_type) +if (!man || !ttm_mm_used (man))return -EBUSY ;if (!ttm_bo_mt_compatible (man, mem_type, place, &cur_flags))@@ -1548,7 +1548,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)struct ttm_mem_type_manager *man; man =ttm_manager_type (bdev,TTM_PL_SYSTEM ); -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);mutex_lock (&ttm_global_mutex);list_del (&bdev->device_list);@@ -1585,7 +1585,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->default_caching =TTM_PL_FLAG_CACHED ;ttm_bo_init_mm_base (man,0 ); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true); } int ttm_bo_device_init(struct ttm_bo_device *bdev,drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-2@@ -139,7 +139,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev,spin_lock_init (&rman->lock);ttm_set_driver_manager (bdev, type, &rman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }EXPORT_SYMBOL (ttm_bo_man_init);@@ -152,7 +152,7 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,struct drm_mm *mm = &rman->mm;int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (bdev, man);if (ret)drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7
-7@@ -630,7 +630,7 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv)TTM_PL_FLAG_CACHED ,TTM_PL_FLAG_CACHED , false, dev_priv->vram_size >> PAGE_SHIFT);#endif -ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )->use_type = false; +ttm_mm_set_use (ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ), false);return ret; }@@ -1190,9 +1190,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );spin_lock (&dev_priv->svga_lock); -if (!man->use_type) { +if (!ttm_mm_used (man)) {vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE ); - man->use_type = true; +ttm_mm_set_use (man, true); }spin_unlock (&dev_priv->svga_lock); }@@ -1221,8 +1221,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );spin_lock (&dev_priv->svga_lock); -if (man->use_type) { - man->use_type = false; +if (ttm_mm_used (man)) { +ttm_mm_set_use (man, false);vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE_HIDE |SVGA_REG_ENABLE_ENABLE );@@ -1255,8 +1255,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)vmw_kms_lost_device (dev_priv->dev);ttm_write_lock (&dev_priv->reservation_sem, false);spin_lock (&dev_priv->svga_lock); -if (man->use_type) { - man->use_type = false; +if (ttm_mm_used (man)) { +ttm_mm_set_use (man, false);spin_unlock (&dev_priv->svga_lock);if (ttm_bo_evict_mm (&dev_priv->bdev,TTM_PL_VRAM ))DRM_ERROR ("Failed evicting VRAM buffers.\n" );drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2
-2@@ -135,7 +135,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) }ttm_set_driver_manager (&dev_priv->bdev, type, &gman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -144,7 +144,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type);struct vmwgfx_gmrid_man *gman =to_gmrid_manager (man); -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&dev_priv->bdev, man);drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +2
-2@@ -142,7 +142,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)spin_lock_init (&rman->lock);ttm_set_driver_manager (&dev_priv->bdev,TTM_PL_VRAM , &rman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -153,7 +153,7 @@ void vmw_thp_takedown(struct vmw_private *dev_priv)struct drm_mm *mm = &rman->mm;int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&dev_priv->bdev, man);if (ret)include/drm/ttm/ttm_bo_driver.h +4
-4@@ -668,14 +668,14 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)dma_resv_unlock (bo->base.resv); } -static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) +static inline void ttm_mm_set_use (struct ttm_mem_type_manager *man,bool use) { - man->use_type = true; + man->use_type = use; } -static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) +static inline bool ttm_mm_used (struct ttm_mem_type_manager *man) { - man->use_type = false; +return man->use_type; }static inline void ttm_bo_man_cleanup (struct ttm_mem_type_manager *man)Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 47/49] drm/ttm: drop list of memory managers from device.
In reply to Dave AirlieQuoted 29 lines · Dave Airlie
From: Dave Airlie <[email protected]>
The driver now controls these, the core just controls the system memory one.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 2 -- include/drm/ttm/ttm_bo_driver.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-2@@ -1608,8 +1608,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->driver = driver; -memset (bdev->man_priv,0 ,sizeof (bdev->man_priv)); -ttm_bo_init_sysman (bdev); bdev->vma_manager = vma_manager;include/drm/ttm/ttm_bo_driver.h +0
-0
include/drm/ttm/ttm_bo_driver.h struct ttm_bo_device { · line 417
Quoted 5 lines
include/drm/ttm/ttm_bo_driver.h +1
-1@@ -414,7 +414,7 @@ struct ttm_bo_device {/* * access via ttm_manager_type. */ -struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES ]; +struct ttm_mem_type_manager sysman;/* move to global */
Not sure we want to move this to global. With the shrinker rework ideas I discussed with Christian somewhere (I think) we could easily do a per-device shrinker. And then global kinda completely disappears (minus maybe a drm-global limit on how much crap you can permanently pin in system memory for scanout, but that's a different thing I think). -Daniel
Quoted 23 lines
include/drm/ttm/ttm_bo_driver.h +3
-1struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES ];/* * Protected by internal locks. @@ -446,9 +446,11 @@ struct ttm_bo_device {static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev,int mem_type) { +if (mem_type ==TTM_PL_SYSTEM ) +return &bdev->sysman;if (bdev->man_drv[mem_type])return bdev->man_drv[mem_type]; -return &bdev->man_priv[mem_type]; +return NULL ; } static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,Signature · 6 lines
2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 12/49] drm/ttm: convert system manager init to new code.
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
Remove the exit path, since this can't fail now.
Signed-off-by Dave Airlie <[email protected]>
Quoted 50 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +17
-10@@ -1644,6 +1644,22 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) }EXPORT_SYMBOL (ttm_bo_device_release); +static void ttm_bo_init_sysman (struct ttm_bo_device *bdev) +{ +struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM ]; + +/* +* Initialize the system memory buffer type. +* Other types need to be driver / IOCTL initialized. +*/ + man->use_tt = true; + man->available_caching =TTM_PL_MASK_CACHING ; + man->default_caching =TTM_PL_FLAG_CACHED ; + +ttm_bo_init_mm_base (bdev, man,0 ); +ttm_bo_use_mm (man); +} + int ttm_bo_device_init(struct ttm_bo_device *bdev, struct ttm_bo_driver *driver, struct address_space *mapping,@@ -1664,16 +1680,7 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,memset (bdev->man,0 ,sizeof (bdev->man)); -/* -* Initialize the system memory buffer type. -* Other types need to be driver / IOCTL initialized. -*/ - bdev->man[TTM_PL_SYSTEM ].use_tt = true; - bdev->man[TTM_PL_SYSTEM ].available_caching =TTM_PL_MASK_CACHING ; - bdev->man[TTM_PL_SYSTEM ].default_caching =TTM_PL_FLAG_CACHED ; - ret =ttm_bo_init_mm (bdev,TTM_PL_SYSTEM ,0 ); -if (unlikely (ret !=0 )) - goto out_no_sys; +ttm_bo_init_sysman (bdev); bdev->vma_manager = vma_manager;INIT_DELAYED_WORK (&bdev->wq, ttm_bo_delayed_workqueue);
drivers/gpu/drm/ttm/ttm_bo.c int ttm_bo_device_init(struct ttm_bo_device *bdev, · line 1697
Quoted 9 lines
drivers/gpu/drm/ttm/ttm_bo.c +0
-3@@ -1685,9 +1692,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev,mutex_unlock (&ttm_global_mutex);return 0 ; -out_no_sys: -ttm_bo_global_release (); -return ret; }EXPORT_SYMBOL (ttm_bo_device_init);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 13/49] drm/ttm: purge old manager init path.
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 134 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 19 ------------------- drivers/gpu/drm/ttm/ttm_bo_manager.c | 27 +++++++++------------------ include/drm/ttm/ttm_bo_api.h | 2 -- include/drm/ttm/ttm_bo_driver.h | 14 -------------- 4 files changed, 9 insertions(+), 53 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-19@@ -1523,25 +1523,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_init_mm_base); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size) -{ -int ret; -struct ttm_mem_type_manager *man; - -BUG_ON (type >=TTM_NUM_MEM_TYPES ); -ttm_bo_init_mm_base (bdev, &bdev->man[type], p_size); - -if (type !=TTM_PL_SYSTEM ) { - ret = (*man->func->init)(man, p_size); -if (ret) -return ret; - } -ttm_bo_use_mm (man); -return 0 ; -} -EXPORT_SYMBOL (ttm_bo_init_mm); -static void ttm_bo_global_kobj_release (struct kobject *kobj) { struct ttm_bo_global *glob =drivers/gpu/drm/ttm/ttm_bo_manager.c +9
-18@@ -104,11 +104,18 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +static const struct ttm_mem_type_manager_func ttm_bo_manager_func; + +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man,unsigned long p_size) {struct ttm_range_manager *rman; + man->func = &ttm_bo_manager_func; + +ttm_bo_init_mm_base (bdev, man, p_size); + rman =kzalloc (sizeof (*rman),GFP_KERNEL );if (!rman)return -ENOMEM ;@@ -116,21 +123,7 @@ static int ttm_bo_man_init_private(struct ttm_mem_type_manager *man,drm_mm_init (&rman->mm,0 , p_size);spin_lock_init (&rman->lock); man->priv = rman; -return 0 ; -} -int ttm_bo_man_init (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, -unsigned long p_size) -{ -int ret; - - man->func = &ttm_bo_manager_func; - -ttm_bo_init_mm_base (bdev, man, p_size); - ret =ttm_bo_man_init_private (man, p_size); -if (ret) -return ret;ttm_bo_use_mm (man);return 0 ; }@@ -163,11 +156,9 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man,spin_unlock (&rman->lock); } -const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init_private, +static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug }; -EXPORT_SYMBOL (ttm_bo_manager_func);include/drm/ttm/ttm_bo_api.h +0
-2@@ -550,8 +550,6 @@ struct ttm_mem_type_manager;void ttm_bo_init_mm_base (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man,unsigned long p_size); -int ttm_bo_init_mm (struct ttm_bo_device *bdev,unsigned type, -unsigned long p_size);/** * ttm_bo_clean_mm include/drm/ttm/ttm_bo_driver.h +0
-13@@ -48,19 +48,6 @@struct ttm_mem_type_manager ;struct ttm_mem_type_manager_func { -/** -* struct ttm_mem_type_manager member init -* -* @man: Pointer to a memory type manager. -* @p_size: Implementation dependent, but typically the size of the -* range to be managed in pages. -* -* Called to initialize a private range manager. The function is -* expected to initialize the man::priv member. -* Returns 0 on success, negative error code on failure. -*/ -int (*init)(struct ttm_mem_type_manager *man,unsigned long p_size); -/** * struct ttm_mem_type_manager member takedown *
include/drm/ttm/ttm_bo_driver.h pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); · line 793
Quoted 6 lines
include/drm/ttm/ttm_bo_driver.h +0
-1@@ -802,6 +789,5 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);int ttm_bo_man_init (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man,unsigned long p_size); -extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 04/49] drm/ttm: provide a driver-led init path for generic mm manager.
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
This lets the generic mm manager be initialised by the driver.
Signed-off-by Dave Airlie <[email protected]>
Quoted 58 lines
--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 23 ++++++++++++++++++++--- include/drm/ttm/ttm_bo_driver.h | 3 +++ 2 files changed, 23 insertions(+), 3 deletions(-)drivers/gpu/drm/ttm/ttm_bo_manager.c +20
-3@@ -104,8 +104,8 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man, } } -static int ttm_bo_man_init (struct ttm_mem_type_manager *man, -unsigned long p_size) +static int ttm_bo_man_init_private (struct ttm_mem_type_manager *man, +unsigned long p_size) {struct ttm_range_manager *rman;@@ -119,6 +119,23 @@ static int ttm_bo_man_init(struct ttm_mem_type_manager *man,return 0 ; } +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size) +{ +int ret; + + man->func = &ttm_bo_manager_func; + +ttm_bo_init_mm_base (bdev, man, p_size); + ret =ttm_bo_man_init_private (man, p_size); +if (ret) +return ret; +ttm_bo_use_mm (man); +return 0 ; +} +EXPORT_SYMBOL (ttm_bo_man_init); +static int ttm_bo_man_takedown (struct ttm_mem_type_manager *man) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;@@ -147,7 +164,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .init = ttm_bo_man_init, + .init = ttm_bo_man_init_private, .takedown = ttm_bo_man_takedown, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node,include/drm/ttm/ttm_bo_driver.h +0
-0
include/drm/ttm/ttm_bo_driver.h int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo); · line 807
Quoted 9 lines
include/drm/ttm/ttm_bo_driver.h +3
-0@@ -799,6 +799,9 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);*/ pgprot_t ttm_io_prot (uint32_t caching_flags,pgprot_t tmp); +int ttm_bo_man_init (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man, +unsigned long p_size);extern const struct ttm_mem_type_manager_func ttm_bo_manager_func;#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerAm 31.07.20 um 11:29 schrieb [email protected]:
Quoted 9 lines · Christian König
Quoted 6 lines
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 1 line
I started pulling on a thread, and it led me down a hole.
We might want to make that hole even bigger :)
How about we rename the
ttm_mem_regintottm_resourceandttm_mem_type_managerintottm_resource_manager.+1 on names I can understand, I alwas get confused about what exactly ttm means with
mem_regandmem_type_manager.
Well mem_type_manager was obvious, but to be honest I never figured out what _reg meant either :)
Christian.
Quoted 51 lines
-Daniel
Quoted 49 lines
Neither amdgpu's OA/GWS resources nor the IDs in VMGFX are really memory.
In the long term I also want to move the whole address handling into each backend.
Going to send comments on the individual patches as well.
Quoted 18 lines
This series refactors the ttm
ttm_mem_type_managerobject into a driver owned, allocated, subclassaed object.It starts with two minor fixes for some bad assumptions in two drivers.
Enables a new init path, ports all the drivers to the new init path, and cleans up the old init path.
Enables a new takedown path, ports all the drivers to the new takedown path, and cleans up the old takedown path
Wraps all access to the memory managers in thebo_devicein a wrapper across all drivers.
Make debug callback optional
Enables driver to provide their own mem manager objects Subclasses the objects in all drivers and makes them into driver owned object Drops thebo_devicearrays of pointers, and some unneeded links and struct members
Cleans up one api.Quoted 5 lines
I think I'd probably want to merge all this via drm-misc, so if I can collect acks/r-b from driver maintainers that would be good.
This is also based on Chrisitan's work to remove
init_mem_type, so it won't apply until he's finished getting all of that into drm-misc.Preparing to push that to drm-misc-next just now.
Regards,
Christian.Quoted 10 lines
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~airlied%2Flinux%2Flog%2F%3Fh%3Dttm-refactor-mem-manager&data=02%7C01%7Cchristian.koenig%40amd.com%7C7966b55d1dfd4ffd393908d835343faf%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317846121673630&sdata=mqjdwhu9o3LfYSa%2FgW3GDDv2AABddmIPMZiAXoaNv6M%3D&reserved=0
is the tree I've built this on top off, so it's probably going to get rebased but the code should stay mostly the same.I've done some boot testing on nouveau, and I hope to test it on vmwgfx and amdgpu soon.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7Cchristian.koenig%40amd.com%7C7966b55d1dfd4ffd393908d835343faf%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317846121673630&sdata=%2BiZVquH6tc7FwEubwDmqkU6PcwdsdCCzDm1leuwOIa4%3D&reserved=0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 34/49] drm/ttm: make manager debug function optional
In reply to [email protected]Am 31.07.20 um 11:46 schrieb [email protected]:
Quoted 8 lines · Dave Airlie
Quoted 7 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
drivers/gpu/drm/ttm/ttm_bo.c static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p · line 93
Quoted 12 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -88,7 +88,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching); -if (mem_type !=TTM_PL_SYSTEM ) +if (mem_type !=TTM_PL_SYSTEM && man->func->debug) (*man->func->debug)(man, p); }Bit a bikeshed, but what about exporting this function (maybe with the man as argument, not the bdev,
mem_typepair) and using it in the first 2 patches? Avoids surprises with optionalfunc->debug.
+1 for that. That's no bikeshed at all but just clean design.
And we should rename all those backend related functions and move them into a separate [ch] file.
E.g. let's just have a backend resource object TTM works with.
Christian.
Quoted 10 lines
-Daniel
Quoted 8 lines
Signature · 7 lines
-- 2.26.2 _______________________________________________ dri-devel mailing list [email protected] https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Fdri-devel&data=02%7C01%7Cchristian.koenig%40amd.com%7C8540e6d1e99547722b2c08d83536929d%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317855794189396&sdata=GpkfEetygk53dJ1qWiF%2FucNVRc9%2FxWLzKc2BGuG9bLg%3D&reserved=0
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 14/49] drm/ttm: pass man around instead of mem_type in some places
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
This makes it easier to cleanup things
Signed-off-by Dave Airlie <[email protected]>
Quoted 67 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +5
-7@@ -763,13 +763,12 @@ static int ttm_mem_evict_wait_busy(struct ttm_buffer_object *busy_bo, }static int ttm_mem_evict_first (struct ttm_bo_device *bdev, -uint32_t mem_type, +struct ttm_mem_type_manager *man,const struct ttm_place *place,struct ttm_operation_ctx *ctx,struct ww_acquire_ctx *ticket) {struct ttm_buffer_object *bo =NULL , *busy_bo =NULL ; -struct ttm_mem_type_manager *man = &bdev->man[mem_type];bool locked = false;unsigned i;int ret;@@ -918,7 +917,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo,break ;if (unlikely (ret != -ENOSPC ))return ret; - ret =ttm_mem_evict_first (bdev, mem->mem_type, place, ctx, + ret =ttm_mem_evict_first (bdev, man, place, ctx, ticket);if (unlikely (ret !=0 ))return ret;@@ -1403,14 +1402,13 @@ int ttm_bo_create(struct ttm_bo_device *bdev,EXPORT_SYMBOL (ttm_bo_create);static int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, -unsigned mem_type) +struct ttm_mem_type_manager *man) {struct ttm_operation_ctx ctx = { .interruptible = false, .no_wait_gpu = false, .flags =TTM_OPT_FLAG_FORCE_ALLOC }; -struct ttm_mem_type_manager *man = &bdev->man[mem_type];struct ttm_bo_global *glob = &ttm_bo_glob;struct dma_fence *fence;int ret;@@ -1424,7 +1422,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i) {while (!list_empty (&man->lru[i])) {spin_unlock (&glob->lru_lock); - ret =ttm_mem_evict_first (bdev, mem_type,NULL , &ctx, + ret =ttm_mem_evict_first (bdev, man,NULL , &ctx,NULL );if (ret)return ret;@@ -1469,7 +1467,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret =0 ;if (mem_type >0 ) { - ret =ttm_bo_force_list_clean (bdev, mem_type); + ret =ttm_bo_force_list_clean (bdev, man);if (ret) {pr_err ("Cleanup eviction failed\n" );return ret;
drivers/gpu/drm/ttm/ttm_bo.c int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) · line 1503
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -1499,7 +1497,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type)return 0 ; } -return ttm_bo_force_list_clean (bdev, mem_type); +return ttm_bo_force_list_clean (bdev, man); }EXPORT_SYMBOL (ttm_bo_evict_mm);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 15/49] drm/ttm: make some inline helper functions for cleanup paths.
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 42 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- include/drm/ttm/ttm_bo_driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +2
-4@@ -1462,8 +1462,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)return ret; } - man->use_type = false; - man->has_type = false; +ttm_bo_disable_mm (man); ret =0 ;if (mem_type >0 ) {@@ -1476,8 +1475,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = (*man->func->takedown)(man); } -dma_fence_put (man->move); - man->move =NULL ; +ttm_bo_man_cleanup (man);return ret; }include/drm/ttm/ttm_bo_driver.h +2
-0@@ -671,6 +671,18 @@ static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) man->use_type = true; } +static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) +{
include/drm/ttm/ttm_bo_driver.h static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) · line 685
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +10
-0+ man->has_type = false; + man->use_type = false; +} + +static inline void ttm_bo_man_cleanup (struct ttm_mem_type_manager *man) +{ +dma_fence_put (man->move); + man->move =NULL ; +} +
What's the value in making those inline? This is not performance critical at all.
Christian.
include/drm/ttm/ttm_bo_driver.h static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) · line 688
Quoted 3 lines
include/drm/ttm/ttm_bo_driver.h +0
-0/* * ttm_bo_util.c */
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 17/49] drm/amdgpu/ttm: use new takedown path
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 119 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 15 +++++++++++---- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++----- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h | 2 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 15 +++++++++++---- 4 files changed, 29 insertions(+), 13 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +11
-4@@ -133,10 +133,18 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)* Destroy and free the GTT manager, returns -EBUSY if ranges are still * allocated inside it. */ -static int amdgpu_gtt_mgr_fini (struct ttm_mem_type_manager *man) +void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_TT ];struct amdgpu_gtt_mgr *mgr = man->priv; +int ret; + +ttm_bo_disable_mm (man); + + ret =ttm_bo_force_list_clean (&adev->mman.bdev, man); +if (ret) +return ; +spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);spin_unlock (&mgr->lock);@@ -146,7 +154,7 @@ static int amdgpu_gtt_mgr_fini(struct ttm_mem_type_manager *man)device_remove_file (adev->dev, &dev_attr_mem_info_gtt_total);device_remove_file (adev->dev, &dev_attr_mem_info_gtt_used); -return 0 ; +ttm_bo_man_cleanup (man); }/** @@ -307,7 +315,6 @@ static void amdgpu_gtt_mgr_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func = { - .takedown = amdgpu_gtt_mgr_fini, .get_node = amdgpu_gtt_mgr_new, .put_node = amdgpu_gtt_mgr_del, .debug = amdgpu_gtt_mgr_debugdrivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +5
-5@@ -2012,11 +2012,11 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)iounmap (adev->mman.aper_base_kaddr); adev->mman.aper_base_kaddr =NULL ; -ttm_bo_clean_mm (&adev->mman.bdev,TTM_PL_VRAM ); -ttm_bo_clean_mm (&adev->mman.bdev,TTM_PL_TT ); -ttm_bo_clean_mm (&adev->mman.bdev,AMDGPU_PL_GDS ); -ttm_bo_clean_mm (&adev->mman.bdev,AMDGPU_PL_GWS ); -ttm_bo_clean_mm (&adev->mman.bdev,AMDGPU_PL_OA ); +amdgpu_vram_mgr_fini (adev); +amdgpu_gtt_mgr_fini (adev); +ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GDS ]); +ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_GWS ]); +ttm_bo_man_takedown (&adev->mman.bdev, &adev->mman.bdev.man[AMDGPU_PL_OA ]);ttm_bo_device_release (&adev->mman.bdev); adev->mman.initialized = false;DRM_INFO ("amdgpu: ttm finalized\n" );drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.h +2
-0@@ -68,7 +68,9 @@ struct amdgpu_copy_mem { };int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size); +void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev);int amdgpu_vram_mgr_init (struct amdgpu_device *adev); +void amdgpu_vram_mgr_fini (struct amdgpu_device *adev);bool amdgpu_gtt_mgr_has_gart_addr (struct ttm_mem_reg *mem);uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man);drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +11
-3@@ -205,10 +205,17 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)* Destroy and free the VRAM manager, returns -EBUSY if ranges are still * allocated inside it. */ -static int amdgpu_vram_mgr_fini (struct ttm_mem_type_manager *man) +void amdgpu_vram_mgr_fini (struct amdgpu_device *adev) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); +struct ttm_mem_type_manager *man = &adev->mman.bdev.man[TTM_PL_VRAM ];struct amdgpu_vram_mgr *mgr = man->priv; +int ret; + +ttm_bo_disable_mm (man); + + ret =ttm_bo_force_list_clean (&adev->mman.bdev, man); +if (ret) +return ;spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);@@ -216,7 +223,8 @@ static int amdgpu_vram_mgr_fini(struct ttm_mem_type_manager *man)kfree (mgr); man->priv =NULL ;sysfs_remove_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes); -return 0 ; + +ttm_bo_man_cleanup (man); }/**
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, · line 609
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +0
-1@@ -596,7 +604,6 @@ static void amdgpu_vram_mgr_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func = { - .takedown = amdgpu_vram_mgr_fini, .get_node = amdgpu_vram_mgr_new, .put_node = amdgpu_vram_mgr_del, .debug = amdgpu_vram_mgr_debug
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 16/49] drm/ttm: start allowing drivers to use new takedown path
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 58 lines
From: Dave Airlie <[email protected]>
Allow the takedown path callback to be optional as well.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 21 +++++++++++++++++++-- include/drm/ttm/ttm_bo_driver.h | 5 ++++- 3 files changed, 28 insertions(+), 6 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +5
-3@@ -1401,8 +1401,8 @@ int ttm_bo_create(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_create); -static int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man) +int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man) {struct ttm_operation_ctx ctx = { .interruptible = false,@@ -1444,6 +1444,7 @@ static int ttm_bo_force_list_clean(struct ttm_bo_device *bdev,return 0 ; } +EXPORT_SYMBOL (ttm_bo_force_list_clean);int ttm_bo_clean_mm (struct ttm_bo_device *bdev,unsigned mem_type) {@@ -1472,7 +1473,8 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)return ret; } - ret = (*man->func->takedown)(man); +if (man->func->takedown) + ret = (*man->func->takedown)(man); }ttm_bo_man_cleanup (man);drivers/gpu/drm/ttm/ttm_bo_manager.c +1
-1@@ -129,7 +129,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_man_init); -static int ttm_bo_man_takedown (struct ttm_mem_type_manager *man) +static int ttm_bo_man_takedown_private (struct ttm_mem_type_manager *man) {struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;struct drm_mm *mm = &rman->mm;
drivers/gpu/drm/ttm/ttm_bo_manager.c static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man) · line 150
Quoted 5 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-0@@ -146,6 +146,23 @@ static int ttm_bo_man_takedown(struct ttm_mem_type_manager *man)return -EBUSY ; } +int ttm_bo_man_takedown (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man)
Regarding naming I prefer init() and fini() as functions for object initialization and destruction in C.
Christian.
Quoted 41 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +16
-1+{ +int ret; + +ttm_bo_disable_mm (man); + + ret =ttm_bo_force_list_clean (bdev, man); +if (ret) +return ret; + +ttm_bo_man_takedown_private (man); +ttm_bo_man_cleanup (man); +return 0 ; +} +EXPORT_SYMBOL (ttm_bo_man_takedown); +static void ttm_bo_man_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) {@@ -157,7 +174,7 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .takedown = ttm_bo_man_takedown, + .takedown = ttm_bo_man_takedown_private, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debuginclude/drm/ttm/ttm_bo_driver.h +2
-0@@ -683,6 +683,8 @@ static inline void ttm_bo_man_cleanup(struct ttm_mem_type_manager *man) man->move =NULL ; } +int ttm_bo_force_list_clean (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man);/* * ttm_bo_util.c */
include/drm/ttm/ttm_bo_driver.h pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp); · line 808
Quoted 7 lines
include/drm/ttm/ttm_bo_driver.h +2
-1@@ -801,5 +803,6 @@ pgprot_t ttm_io_prot(uint32_t caching_flags, pgprot_t tmp);int ttm_bo_man_init (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man,unsigned long p_size); - +int ttm_bo_man_takedown (struct ttm_bo_device *bdev, +struct ttm_mem_type_manager *man);#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 21/49] drm/radeon/ttm: use new takedown paths
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/radeon/radeon_ttm.c +0
-0
drivers/gpu/drm/radeon/radeon_ttm.c void radeon_ttm_fini(struct radeon_device *rdev) · line 833
Quoted 10 lines
drivers/gpu/drm/radeon/radeon_ttm.c +2
-2@@ -826,8 +826,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) }radeon_bo_unref (&rdev->stolen_vga_memory); } -ttm_bo_clean_mm (&rdev->mman.bdev,TTM_PL_VRAM ); -ttm_bo_clean_mm (&rdev->mman.bdev,TTM_PL_TT ); +ttm_bo_man_takedown (&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_VRAM ]); +ttm_bo_man_takedown (&rdev->mman.bdev, &rdev->mman.bdev.man[TTM_PL_TT ]);ttm_bo_device_release (&rdev->mman.bdev);radeon_gart_fini (rdev); rdev->mman.initialized = false;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 24/49] drm/ttm: remove range manager legacy takedown path
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Now no drivers have been converted, drop the non-driver path.
I'm not a native speak, but that sounds odd.
Apart from that patch is Reviewed-by: Christian König <[email protected]>
Quoted 55 lines
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-)drivers/gpu/drm/ttm/ttm_bo_manager.c +9
-18@@ -129,26 +129,11 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_man_init); -static int ttm_bo_man_takedown_private (struct ttm_mem_type_manager *man) -{ -struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; -struct drm_mm *mm = &rman->mm; - -spin_lock (&rman->lock); -if (drm_mm_clean (mm)) { -drm_mm_takedown (mm); -spin_unlock (&rman->lock); -kfree (rman); - man->priv =NULL ; -return 0 ; - } -spin_unlock (&rman->lock); -return -EBUSY ; -} -int ttm_bo_man_takedown (struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man) { +struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv; +struct drm_mm *mm = &rman->mm;int ret;ttm_bo_disable_mm (man);@@ -157,7 +142,13 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,if (ret)return ret; -ttm_bo_man_takedown_private (man); +spin_lock (&rman->lock); +drm_mm_clean (mm); +drm_mm_takedown (mm); +spin_unlock (&rman->lock); +kfree (rman); + man->priv =NULL ; +ttm_bo_man_cleanup (man);return 0 ; }
drivers/gpu/drm/ttm/ttm_bo_manager.c static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, · line 170
Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +0
-1@@ -174,7 +165,6 @@ static void ttm_bo_man_debug(struct ttm_mem_type_manager *man, }static const struct ttm_mem_type_manager_func ttm_bo_manager_func = { - .takedown = ttm_bo_man_takedown_private, .get_node = ttm_bo_man_get_node, .put_node = ttm_bo_man_put_node, .debug = ttm_bo_man_debug
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 26/49] drm/ttm: add wrapper to get manager from bdev.
In reply to Dave AirlieQuoted 9 lines · Dave Airlie
Quoted 8 lines · Thomas Zimmermann
Hi
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This will allow different abstractions later.
Quoted 7 lines
Quoted 2 lines
You should consider moving this patch to the beginning of the series, so that patches 1 to 25 can benefit from it.
I did consider it, but I'd have to move all the follow on patches as well, and it got messy in rebase land, and I started introducing errors, so I left it alone, and it's not necessary until the patch that changes it's definition anyways.
I like this ordering a lot better, it gives a clear separation between the different steps. Some code gets touched multiple times, but interleaving the demidlayering would only make this worse I think.
-Daniel
Quoted 6 lines
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 25/49] drm/ttm: make TTM responsible for cleaning system only.
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 8 lines
From: Dave Airlie <[email protected]>
drivers should all be cleaning up their memory managers themselves now, so let the core just clean the system one up.
Remove the legacy cleaning interface.
Signed-off-by Dave Airlie <[email protected]>
Quoted 138 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 55 +++------------------------------ include/drm/ttm/ttm_bo_api.h | 28 ----------------- include/drm/ttm/ttm_bo_driver.h | 10 ------ 3 files changed, 4 insertions(+), 89 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +4
-51@@ -1446,43 +1446,6 @@ int ttm_bo_force_list_clean(struct ttm_bo_device *bdev, }EXPORT_SYMBOL (ttm_bo_force_list_clean); -int ttm_bo_clean_mm (struct ttm_bo_device *bdev,unsigned mem_type) -{ -struct ttm_mem_type_manager *man; -int ret = -EINVAL ; - -if (mem_type >=TTM_NUM_MEM_TYPES ) { -pr_err ("Illegal memory type %d\n" , mem_type); -return ret; - } - man = &bdev->man[mem_type]; - -if (!man->has_type) { -pr_err ("Trying to take down uninitialized memory manager type %u\n" , - mem_type); -return ret; - } - -ttm_bo_disable_mm (man); - - ret =0 ; -if (mem_type >0 ) { - ret =ttm_bo_force_list_clean (bdev, man); -if (ret) { -pr_err ("Cleanup eviction failed\n" ); -return ret; - } - -if (man->func->takedown) - ret = (*man->func->takedown)(man); - } - -ttm_bo_man_cleanup (man); - -return ret; -} -EXPORT_SYMBOL (ttm_bo_clean_mm); -int ttm_bo_evict_mm (struct ttm_bo_device *bdev,unsigned mem_type) {struct ttm_mem_type_manager *man = &bdev->man[mem_type];@@ -1585,21 +1548,11 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev) {struct ttm_bo_global *glob = &ttm_bo_glob;int ret =0 ; -unsigned i =TTM_NUM_MEM_TYPES ; +unsigned i;struct ttm_mem_type_manager *man; -while (i--) { - man = &bdev->man[i]; -if (man->has_type) { - man->use_type = false; -if ((i !=TTM_PL_SYSTEM ) &&ttm_bo_clean_mm (bdev, i)) { - ret = -EBUSY ; -pr_err ("DRM memory manager type %d is not clean\n" , - i); - } - man->has_type = false; - } - } + man = &bdev->man[TTM_PL_SYSTEM ]; +ttm_bo_disable_mm (man);mutex_lock (&ttm_global_mutex);list_del (&bdev->device_list);@@ -1612,7 +1565,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)spin_lock (&glob->lru_lock);for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i) -if (list_empty (&bdev->man[0 ].lru[0 ])) +if (list_empty (&man->lru[0 ]))pr_debug ("Swap list %d was clean\n" , i);spin_unlock (&glob->lru_lock);include/drm/ttm/ttm_bo_api.h +0
-28@@ -551,34 +551,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev,struct ttm_mem_type_manager *man, unsigned long p_size); -/** -* ttm_bo_clean_mm -* -* @bdev: Pointer to a ttm_bo_device struct. -* @mem_type: The memory type. -* -* Take down a manager for a given memory type after first walking -* the LRU list to evict any buffers left alive. -* -* Normally, this function is part of lastclose() or unload(), and at that -* point there shouldn't be any buffers left created by user-space, since -* there should've been removed by the file descriptor release() method. -* However, before this function is run, make sure to signal all sync objects, -* and verify that the delayed delete queue is empty. The driver must also -* make sure that there are no NO_EVICT buffers present in this memory type -* when the call is made. -* -* If this function is part of a VT switch, the caller must make sure that -* there are no appications currently validating buffers before this -* function is called. The caller can do that by first taking the -* struct ttm_bo_device::ttm_lock in write mode. -* -* Returns: -* -EINVAL: invalid or uninitialized memory type. -* -EBUSY: There are still buffers left in this memory type. -*/ -int ttm_bo_clean_mm (struct ttm_bo_device *bdev,unsigned mem_type); -/** * ttm_bo_evict_mm * include/drm/ttm/ttm_bo_driver.h +0
-3@@ -48,16 +48,6 @@struct ttm_mem_type_manager ;struct ttm_mem_type_manager_func { -/** -* struct ttm_mem_type_manager member takedown -*
include/drm/ttm/ttm_bo_driver.h line 53
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +0
-7-* @man: Pointer to a memory type manager. -* -* Called to undo the setup done in init. All allocated resources -* should be freed. -*/ -int (*takedown)(struct ttm_mem_type_manager *man); -/** * struct ttm_mem_type_manager member get_node *
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 26/49] drm/ttm: add wrapper to get manager from bdev.
In reply to Dave AirlieAm 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This will allow different abstractions later.
Mhm, I'm questioning if this is really worth it and not just overkill.
Running "sed -i 's/&bdev->man/bdev->man/'" on all drivers when we make the switch to a pointer should do it as well.
Christian.
Quoted 266 lines
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 34 +++++++++++++++---------------- drivers/gpu/drm/ttm/ttm_bo_util.c | 20 +++++++++--------- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- include/drm/ttm/ttm_bo_driver.h | 6 ++++++ 4 files changed, 34 insertions(+), 28 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +17
-17@@ -80,7 +80,7 @@ static inline int ttm_mem_type_from_place(const struct ttm_place *place,static void ttm_mem_type_debug (struct ttm_bo_device *bdev,struct drm_printer *p,int mem_type) { -struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type);drm_printf (p," has_type: %d\n" , man->has_type);drm_printf (p," use_type: %d\n" , man->use_type);@@ -156,7 +156,7 @@ static void ttm_bo_add_mem_to_lru(struct ttm_buffer_object *bo,if (mem->placement &TTM_PL_FLAG_NO_EVICT )return ; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type);list_add_tail (&bo->lru, &man->lru[bo->priority]); if (man->use_tt && bo->ttm &&@@ -231,7 +231,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)dma_resv_assert_held (pos->first->base.resv);dma_resv_assert_held (pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_TT ]; + man =ttm_manager_type (pos->first->bdev,TTM_PL_TT );list_bulk_move_tail (&man->lru[i], &pos->first->lru, &pos->last->lru); }@@ -246,7 +246,7 @@ void ttm_bo_bulk_move_lru_tail(struct ttm_lru_bulk_move *bulk)dma_resv_assert_held (pos->first->base.resv);dma_resv_assert_held (pos->last->base.resv); - man = &pos->first->bdev->man[TTM_PL_VRAM ]; + man =ttm_manager_type (pos->first->bdev,TTM_PL_VRAM );list_bulk_move_tail (&man->lru[i], &pos->first->lru, &pos->last->lru); }@@ -272,8 +272,8 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *old_man = &bdev->man[bo->mem.mem_type]; -struct ttm_mem_type_manager *new_man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *old_man =ttm_manager_type (bdev, bo->mem.mem_type); +struct ttm_mem_type_manager *new_man =ttm_manager_type (bdev, mem->mem_type);int ret; ret =ttm_mem_io_lock (old_man, true);@@ -338,7 +338,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,return 0 ; out_err: - new_man = &bdev->man[bo->mem.mem_type]; + new_man =ttm_manager_type (bdev, bo->mem.mem_type);if (!new_man->use_tt) {ttm_tt_destroy (bo->ttm); bo->ttm =NULL ;@@ -550,7 +550,7 @@ static void ttm_bo_release(struct kref *kref)struct ttm_buffer_object *bo = container_of(kref, struct ttm_buffer_object, kref);struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, bo->mem.mem_type);size_t acc_size = bo->acc_size;int ret;@@ -838,7 +838,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bo->bdev, mem->mem_type); mem->mm_node =NULL ;if (!man->func || !man->func->get_node)@@ -849,7 +849,7 @@ static int ttm_bo_mem_get(struct ttm_buffer_object *bo,void ttm_bo_mem_put (struct ttm_buffer_object *bo,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bo->bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bo->bdev, mem->mem_type);if (!man->func || !man->func->put_node)return ;@@ -906,7 +906,7 @@ static int ttm_bo_mem_force_space(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem->mem_type);struct ww_acquire_ctx *ticket;int ret;@@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,if (ret)return ret; - man = &bdev->man[mem_type]; + man =ttm_manager_type (bdev, mem_type);if (!man->has_type || !man->use_type)return -EBUSY ;@@ -1059,7 +1059,7 @@ int ttm_bo_mem_space(struct ttm_buffer_object *bo,if (unlikely (ret)) goto error; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type); ret =ttm_bo_add_move_fence (bo, man, mem, ctx->no_wait_gpu);if (unlikely (ret)) {ttm_bo_mem_put (bo, mem);@@ -1448,7 +1448,7 @@ EXPORT_SYMBOL(ttm_bo_force_list_clean);int ttm_bo_evict_mm (struct ttm_bo_device *bdev,unsigned mem_type) { -struct ttm_mem_type_manager *man = &bdev->man[mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem_type);if (mem_type ==0 || mem_type >=TTM_NUM_MEM_TYPES ) {pr_err ("Illegal memory manager memory type %u\n" , mem_type);@@ -1551,7 +1551,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)unsigned i;struct ttm_mem_type_manager *man; - man = &bdev->man[TTM_PL_SYSTEM ]; + man =ttm_manager_type (bdev,TTM_PL_SYSTEM );ttm_bo_disable_mm (man);mutex_lock (&ttm_global_mutex);@@ -1578,7 +1578,7 @@ EXPORT_SYMBOL(ttm_bo_device_release);static void ttm_bo_init_sysman (struct ttm_bo_device *bdev) { -struct ttm_mem_type_manager *man = &bdev->man[TTM_PL_SYSTEM ]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev,TTM_PL_SYSTEM );/* * Initialize the system memory buffer type. @@ -1642,7 +1642,7 @@ void ttm_bo_unmap_virtual_locked(struct ttm_buffer_object *bo)void ttm_bo_unmap_virtual (struct ttm_buffer_object *bo) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, bo->mem.mem_type);ttm_mem_io_lock (man, false);ttm_bo_unmap_virtual_locked (bo);drivers/gpu/drm/ttm/ttm_bo_util.c +10
-10@@ -129,7 +129,7 @@ static int ttm_mem_io_evict(struct ttm_mem_type_manager *man)int ttm_mem_io_reserve (struct ttm_bo_device *bdev,struct ttm_mem_reg *mem) { -struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, mem->mem_type);int ret;if (mem->bus.io_reserved_count++)@@ -162,7 +162,7 @@ void ttm_mem_io_free(struct ttm_bo_device *bdev,int ttm_mem_io_reserve_vm (struct ttm_buffer_object *bo) { -struct ttm_mem_type_manager *man = &bo->bdev->man[bo->mem.mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bo->bdev, bo->mem.mem_type);struct ttm_mem_reg *mem = &bo->mem;int ret;@@ -195,7 +195,7 @@ static int ttm_mem_reg_ioremap(struct ttm_bo_device *bdev,struct ttm_mem_reg *mem, void **virtual) { - struct ttm_mem_type_manager *man = &bdev->man[mem->mem_type]; + struct ttm_mem_type_manager *man = ttm_manager_type(bdev, mem->mem_type);int ret;void *addr;@@ -232,7 +232,7 @@ static void ttm_mem_reg_iounmap(struct ttm_bo_device *bdev, {struct ttm_mem_type_manager *man; - man = &bdev->man[mem->mem_type]; + man =ttm_manager_type (bdev, mem->mem_type);if (virtual && mem->bus.addr ==NULL )iounmap (virtual);@@ -303,7 +303,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, new_mem->mem_type);struct ttm_tt *ttm = bo->ttm;struct ttm_mem_reg *old_mem = &bo->mem;struct ttm_mem_reg old_copy = *old_mem;@@ -571,7 +571,7 @@ int ttm_bo_kmap(struct ttm_buffer_object *bo, struct ttm_bo_kmap_obj *map) {struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; +ttm_manager_type (bo->bdev, bo->mem.mem_type);unsigned long offset, size;int ret;@@ -601,7 +601,7 @@ void ttm_bo_kunmap(struct ttm_bo_kmap_obj *map) {struct ttm_buffer_object *bo = map->bo;struct ttm_mem_type_manager *man = - &bo->bdev->man[bo->mem.mem_type]; +ttm_manager_type (bo->bdev, bo->mem.mem_type);if (!map->virtual)return ;@@ -634,7 +634,7 @@ int ttm_bo_move_accel_cleanup(struct ttm_buffer_object *bo, struct ttm_mem_reg *new_mem) {struct ttm_bo_device *bdev = bo->bdev; -struct ttm_mem_type_manager *man = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, new_mem->mem_type);struct ttm_mem_reg *old_mem = &bo->mem;int ret;struct ttm_buffer_object *ghost_obj;@@ -697,8 +697,8 @@ int ttm_bo_pipeline_move(struct ttm_buffer_object *bo,struct ttm_bo_device *bdev = bo->bdev;struct ttm_mem_reg *old_mem = &bo->mem; -struct ttm_mem_type_manager *from = &bdev->man[old_mem->mem_type]; -struct ttm_mem_type_manager *to = &bdev->man[new_mem->mem_type]; +struct ttm_mem_type_manager *from =ttm_manager_type (bdev, old_mem->mem_type); +struct ttm_mem_type_manager *to =ttm_manager_type (bdev, new_mem->mem_type);int ret;drivers/gpu/drm/ttm/ttm_bo_vm.c +1
-1@@ -282,7 +282,7 @@ vm_fault_t ttm_bo_vm_fault_reserved(struct vm_fault *vmf,vm_fault_t ret =VM_FAULT_NOPAGE ;unsigned long address = vmf->address;struct ttm_mem_type_manager *man = - &bdev->man[bo->mem.mem_type]; +ttm_manager_type (bdev, bo->mem.mem_type);/* * Refuse to fault imported pages. This should be handled include/drm/ttm/ttm_bo_driver.h +0
-0@@ -444,6 +444,12 @@ struct ttm_bo_device {bool no_retry; };
include/drm/ttm/ttm_bo_driver.h struct ttm_bo_device { · line 455
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +6
-0+static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev, +int mem_type) +{ +return &bdev->man[mem_type]; +} +/** * struct ttm_lru_bulk_move_pos *
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 34/49] drm/ttm: make manager debug function optional
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 9 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-0
drivers/gpu/drm/ttm/ttm_bo.c static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *p · line 94
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo.c +1
-1@@ -88,7 +88,7 @@ static void ttm_mem_type_debug(struct ttm_bo_device *bdev, struct drm_printer *pdrm_printf (p," size: %llu\n" , man->size);drm_printf (p," available_caching: 0x%08X\n" , man->available_caching);drm_printf (p," default_caching: 0x%08X\n" , man->default_caching); -if (mem_type !=TTM_PL_SYSTEM ) +if (mem_type !=TTM_PL_SYSTEM && man->func->debug) (*man->func->debug)(man, p); }
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 35/49] drm/nouveau/ttm: don't fill in blank ttm debug callback
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 38 lines
--- drivers/gpu/drm/nouveau/nouveau_ttm.c | 9 --------- 1 file changed, 9 deletions(-)drivers/gpu/drm/nouveau/nouveau_ttm.c +0
-8@@ -37,12 +37,6 @@ nouveau_manager_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *reg)nouveau_mem_del (reg); } -static void -nouveau_manager_debug (struct ttm_mem_type_manager *man, -struct drm_printer *printer) -{ -} - static int nouveau_vram_manager_new(struct ttm_mem_type_manager *man, struct ttm_buffer_object *bo,@@ -72,7 +66,6 @@ nouveau_vram_manager_new(struct ttm_mem_type_manager *man,const struct ttm_mem_type_manager_func nouveau_vram_manager = { .get_node = nouveau_vram_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug, }; static int@@ -96,7 +89,6 @@ nouveau_gart_manager_new(struct ttm_mem_type_manager *man,const struct ttm_mem_type_manager_func nouveau_gart_manager = { .get_node = nouveau_gart_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug }; static int
drivers/gpu/drm/nouveau/nouveau_ttm.c nv04_gart_manager_new(struct ttm_mem_type_manager *man, · line 126
Quoted 7 lines
drivers/gpu/drm/nouveau/nouveau_ttm.c +0
-1@@ -129,7 +121,6 @@ nv04_gart_manager_new(struct ttm_mem_type_manager *man,const struct ttm_mem_type_manager_func nv04_gart_manager = { .get_node = nv04_gart_manager_new, .put_node = nouveau_manager_del, - .debug = nouveau_manager_debug };int
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 36/49] drm/vmwgfx/gmrid: don't provide pointless ttm debug callback
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 13 lines
--- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 7 ------- 1 file changed, 7 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +0
-1@@ -149,14 +149,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type)ttm_bo_man_cleanup (man); } -static void vmw_gmrid_man_debug(struct ttm_mem_type_manager *man,
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type) · line 155
Quoted 10 lines
drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +0
-6- struct drm_printer *printer) -{ -drm_printf (printer,"No debug info available for the GMR id manager\n" ); -} -static const struct ttm_mem_type_manager_func vmw_gmrid_manager_func = { .get_node = vmw_gmrid_man_get_node, .put_node = vmw_gmrid_man_put_node, - .debug = vmw_gmrid_man_debug };
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 38/49] drm/amdgpu/ttm: use bo manager subclassing for vram/gtt mgrs
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 262 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 35 +++++++++++-------- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 36 +++++++++++++------- 2 files changed, 44 insertions(+), 27 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +21
-14@@ -25,11 +25,17 @@#include "amdgpu.h" struct amdgpu_gtt_mgr { +struct ttm_mem_type_manager manager;struct drm_mm mm;spinlock_t lock;atomic64_t available; }; +static inline struct amdgpu_gtt_mgr *to_gtt_mgr (struct ttm_mem_type_manager *man) +{ + return container_of(man, struct amdgpu_gtt_mgr, manager); +} +struct amdgpu_gtt_node {struct drm_mm_node node;struct ttm_buffer_object *tbo;@@ -87,11 +93,16 @@ static const struct ttm_mem_type_manager_func amdgpu_gtt_mgr_func;*/ int amdgpu_gtt_mgr_init (struct amdgpu_device *adev,uint64_t gtt_size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT ); +struct ttm_mem_type_manager *man;struct amdgpu_gtt_mgr *mgr;uint64_t start, size;int ret; + mgr =kzalloc (sizeof (*mgr),GFP_KERNEL ); +if (!mgr) +return -ENOMEM ; + + man = &mgr->manager; man->use_tt = true; man->func = &amdgpu_gtt_mgr_func; man->available_caching =TTM_PL_MASK_CACHING ;@@ -99,16 +110,11 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)ttm_bo_init_mm_base (&adev->mman.bdev, man, gtt_size >>PAGE_SHIFT ); - mgr =kzalloc (sizeof (*mgr),GFP_KERNEL ); -if (!mgr) -return -ENOMEM ; - start =AMDGPU_GTT_MAX_TRANSFER_SIZE *AMDGPU_GTT_NUM_TRANSFER_WINDOWS ; size = (adev->gmc.gart_size >>PAGE_SHIFT ) - start;drm_mm_init (&mgr->mm, start, size);spin_lock_init (&mgr->lock);atomic64_set (&mgr->available, gtt_size >>PAGE_SHIFT ); - man->priv = mgr; ret =device_create_file (adev->dev, &dev_attr_mem_info_gtt_total);if (ret) {@@ -121,6 +127,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)return ret; } +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT , &mgr->manager);ttm_bo_use_mm (man);return 0 ; }@@ -136,7 +143,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)void amdgpu_gtt_mgr_fini (struct amdgpu_device *adev) {struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_TT ); -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);int ret;ttm_bo_disable_mm (man);@@ -148,13 +155,13 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);spin_unlock (&mgr->lock); -kfree (mgr); - man->priv =NULL ;device_remove_file (adev->dev, &dev_attr_mem_info_gtt_total);device_remove_file (adev->dev, &dev_attr_mem_info_gtt_used);ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT ,NULL ); +kfree (mgr); }/** @@ -184,7 +191,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct amdgpu_gtt_mgr *mgr = man->priv; + struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);struct amdgpu_gtt_node *node;int r;@@ -245,7 +252,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_mem_type_manager *man,static void amdgpu_gtt_mgr_del (struct ttm_mem_type_manager *man,struct ttm_mem_reg *mem) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);struct amdgpu_gtt_node *node = mem->mm_node;if (node) {@@ -267,7 +274,7 @@ static void amdgpu_gtt_mgr_del(struct ttm_mem_type_manager *man,*/ uint64_t amdgpu_gtt_mgr_usage (struct ttm_mem_type_manager *man) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);s64 result = man->size -atomic64_read (&mgr->available);return (result >0 ? result :0 ) *PAGE_SIZE ;@@ -275,7 +282,7 @@ uint64_t amdgpu_gtt_mgr_usage(struct ttm_mem_type_manager *man)int amdgpu_gtt_mgr_recover (struct ttm_mem_type_manager *man) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);struct amdgpu_gtt_node *node;struct drm_mm_node *mm_node;int r =0 ;@@ -303,7 +310,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_mem_type_manager *man)static void amdgpu_gtt_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { -struct amdgpu_gtt_mgr *mgr = man->priv; +struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);spin_lock (&mgr->lock);drm_mm_print (&mgr->mm, printer);drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +22
-12@@ -29,12 +29,18 @@#include "atom.h" struct amdgpu_vram_mgr { +struct ttm_mem_type_manager manager;struct drm_mm mm;spinlock_t lock;atomic64_t usage;atomic64_t vis_usage; }; +static inline struct amdgpu_vram_mgr *to_vram_mgr (struct ttm_mem_type_manager *man) +{ + return container_of(man, struct amdgpu_vram_mgr, manager); +} +/** * DOC: mem_info_vram_total * @@ -170,29 +176,32 @@ static const struct ttm_mem_type_manager_func amdgpu_vram_mgr_func;*/ int amdgpu_vram_mgr_init (struct amdgpu_device *adev) { -struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ); +struct ttm_mem_type_manager *man;struct amdgpu_vram_mgr *mgr;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->default_caching =TTM_PL_FLAG_WC ;ttm_bo_init_mm_base (&adev->mman.bdev, man, adev->gmc.real_vram_size >>PAGE_SHIFT ); man->func = &amdgpu_vram_mgr_func; - mgr =kzalloc (sizeof (*mgr),GFP_KERNEL ); -if (!mgr) -return -ENOMEM ;drm_mm_init (&mgr->mm,0 , man->size);spin_lock_init (&mgr->lock); - man->priv = mgr;/* Add the two VRAM-related sysfs files */ ret =sysfs_create_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes);if (ret)DRM_ERROR ("Failed to register sysfs\n" ); +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM , &mgr->manager);ttm_bo_use_mm (man);return 0 ; }@@ -208,7 +217,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)void amdgpu_vram_mgr_fini (struct amdgpu_device *adev) {struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev,TTM_PL_VRAM ); -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);int ret;ttm_bo_disable_mm (man);@@ -220,11 +229,12 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)spin_lock (&mgr->lock);drm_mm_takedown (&mgr->mm);spin_unlock (&mgr->lock); -kfree (mgr); - man->priv =NULL ; +sysfs_remove_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes);ttm_bo_man_cleanup (man); +ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM ,NULL ); +kfree (mgr); }/** @@ -314,7 +324,7 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) {struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);struct drm_mm *mm = &mgr->mm;struct drm_mm_node *nodes;enum drm_mm_insert_mode mode;@@ -430,7 +440,7 @@ static void amdgpu_vram_mgr_del(struct ttm_mem_type_manager *man, struct ttm_mem_reg *mem) {struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev); -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);struct drm_mm_node *nodes = mem->mm_node;uint64_t usage =0 , vis_usage =0 ;unsigned pages = mem->num_pages;@@ -562,7 +572,7 @@ void amdgpu_vram_mgr_free_sgt(struct amdgpu_device *adev,*/ uint64_t amdgpu_vram_mgr_usage (struct ttm_mem_type_manager *man) { -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);return atomic64_read (&mgr->usage); }@@ -576,7 +586,7 @@ uint64_t amdgpu_vram_mgr_usage(struct ttm_mem_type_manager *man)*/ uint64_t amdgpu_vram_mgr_vis_usage (struct ttm_mem_type_manager *man) { -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);return atomic64_read (&mgr->vis_usage); }
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man) · line 608
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1
-1@@ -592,7 +602,7 @@ uint64_t amdgpu_vram_mgr_vis_usage(struct ttm_mem_type_manager *man)static void amdgpu_vram_mgr_debug (struct ttm_mem_type_manager *man,struct drm_printer *printer) { -struct amdgpu_vram_mgr *mgr = man->priv; +struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);spin_lock (&mgr->lock);drm_mm_print (&mgr->mm, printer);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 39/49] drm/ttm: make ttm_bo_man_init/takedown take type + args
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This makes it easier to move these to a driver allocated system
No, sorry that looks like going into the wrong direction to me.
I already wanted to suggest to get rid of the size argument instead.
Christian.
Quoted 329 lines
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 15 +++++------ drivers/gpu/drm/drm_gem_vram_helper.c | 10 ++++---- drivers/gpu/drm/nouveau/nouveau_ttm.c | 21 ++++++++++------ drivers/gpu/drm/qxl/qxl_ttm.c | 12 +++------ drivers/gpu/drm/radeon/radeon_ttm.c | 33 ++++++++++++------------- drivers/gpu/drm/ttm/ttm_bo_manager.c | 19 ++++++++++---- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 13 +++------- include/drm/ttm/ttm_bo_driver.h | 7 ++++-- 8 files changed, 67 insertions(+), 63 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +6
-9@@ -67,12 +67,9 @@ static int amdgpu_ttm_init_on_chip(struct amdgpu_device *adev, unsigned int type, uint64_t size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&adev->mman.bdev, type); - - man->available_caching =TTM_PL_FLAG_UNCACHED ; - man->default_caching =TTM_PL_FLAG_UNCACHED ; - -return ttm_bo_man_init (&adev->mman.bdev, man, size >>PAGE_SHIFT ); +return ttm_bo_man_init (&adev->mman.bdev, type, +TTM_PL_FLAG_UNCACHED ,TTM_PL_FLAG_UNCACHED , + false, size >>PAGE_SHIFT ); }/** @@ -2014,9 +2011,9 @@ void amdgpu_ttm_fini(struct amdgpu_device *adev)amdgpu_vram_mgr_fini (adev);amdgpu_gtt_mgr_fini (adev); -ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_GDS )); -ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_GWS )); -ttm_bo_man_takedown (&adev->mman.bdev,ttm_manager_type (&adev->mman.bdev,AMDGPU_PL_OA )); +ttm_bo_man_takedown (&adev->mman.bdev,AMDGPU_PL_GDS ); +ttm_bo_man_takedown (&adev->mman.bdev,AMDGPU_PL_GWS ); +ttm_bo_man_takedown (&adev->mman.bdev,AMDGPU_PL_OA );ttm_bo_device_release (&adev->mman.bdev); adev->mman.initialized = false;DRM_INFO ("amdgpu: ttm finalized\n" );drivers/gpu/drm/drm_gem_vram_helper.c +5
-5@@ -1103,7 +1103,6 @@ EXPORT_SYMBOL(drm_vram_mm_debugfs_init);static int drm_vram_mm_init (struct drm_vram_mm *vmm,struct drm_device *dev,uint64_t vram_base,size_t vram_size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&vmm->bdev,TTM_PL_VRAM );int ret; vmm->vram_base = vram_base;@@ -1116,9 +1115,10 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,if (ret)return ret; - man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; - ret =ttm_bo_man_init (&vmm->bdev, man, vram_size >>PAGE_SHIFT ); + ret =ttm_bo_man_init (&vmm->bdev,TTM_PL_VRAM , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , false, + vram_size >>PAGE_SHIFT );if (ret)return ret;@@ -1127,7 +1127,7 @@ static int drm_vram_mm_init(struct drm_vram_mm *vmm, struct drm_device *dev,static void drm_vram_mm_cleanup (struct drm_vram_mm *vmm) { -ttm_bo_man_takedown (&vmm->bdev,ttm_manager_type (&vmm->bdev,TTM_PL_VRAM )); +ttm_bo_man_takedown (&vmm->bdev,TTM_PL_VRAM );ttm_bo_device_release (&vmm->bdev); }drivers/gpu/drm/nouveau/nouveau_ttm.c +13
-8@@ -156,16 +156,17 @@ nouveau_ttm_init_host(struct nouveau_drm *drm, u8 kind)static int nouveau_ttm_init_vram (struct nouveau_drm *drm) { -struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );struct nvif_mmu *mmu = &drm->client.mmu; - man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; -if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { +struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM ); +/* Some BARs do not support being ioremapped WC */ const u8 type = mmu->type[drm->ttm.type_vram].type; + man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; + man->default_caching =TTM_PL_FLAG_WC ; +if (type &NVIF_MEM_UNCACHED ) { man->available_caching =TTM_PL_FLAG_UNCACHED ; man->default_caching =TTM_PL_FLAG_UNCACHED ;@@ -178,7 +179,9 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm)ttm_bo_use_mm (man);return 0 ; }else { -return ttm_bo_man_init (&drm->ttm.bdev, man, +return ttm_bo_man_init (&drm->ttm.bdev,TTM_PL_VRAM , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , false, drm->gem.vram_available >>PAGE_SHIFT ); } }@@ -193,7 +196,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man); }else -ttm_bo_man_takedown (&drm->ttm.bdev, man); +ttm_bo_man_takedown (&drm->ttm.bdev,TTM_PL_VRAM ); } static int@@ -216,7 +219,9 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm)else if (!drm->agp.bridge) man->func = &nv04_gart_manager;else -return ttm_bo_man_init (&drm->ttm.bdev, man, +return ttm_bo_man_init (&drm->ttm.bdev,TTM_PL_TT , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , true, size_pages); ttm_bo_init_mm_base(&drm->ttm.bdev, man,@@ -232,7 +237,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm)if (drm->client.device.info.family <NV_DEVICE_INFO_V0_TESLA && drm->agp.bridge) -ttm_bo_man_takedown (&drm->ttm.bdev, man); +ttm_bo_man_takedown (&drm->ttm.bdev,TTM_PL_TT );else {ttm_bo_disable_mm (man);ttm_bo_force_list_clean (&drm->ttm.bdev, man);drivers/gpu/drm/qxl/qxl_ttm.c +4
-8@@ -219,12 +219,8 @@ static int qxl_ttm_init_mem_type(struct qxl_device *qdev, unsigned int type, uint64_t size) { -struct ttm_mem_type_manager *man =ttm_manager_type (&qdev->mman.bdev, type); - - man->available_caching =TTM_PL_MASK_CACHING ; - man->default_caching =TTM_PL_FLAG_CACHED ; - -return ttm_bo_man_init (&qdev->mman.bdev, man, size); +return ttm_bo_man_init (&qdev->mman.bdev, type,TTM_PL_MASK_CACHING , +TTM_PL_FLAG_CACHED , false, size); }int qxl_ttm_init (struct qxl_device *qdev)@@ -266,8 +262,8 @@ int qxl_ttm_init(struct qxl_device *qdev)void qxl_ttm_fini (struct qxl_device *qdev) { -ttm_bo_man_takedown (&qdev->mman.bdev,ttm_manager_type (&qdev->mman.bdev,TTM_PL_VRAM )); -ttm_bo_man_takedown (&qdev->mman.bdev,ttm_manager_type (&qdev->mman.bdev,TTM_PL_PRIV )); +ttm_bo_man_takedown (&qdev->mman.bdev,TTM_PL_VRAM ); +ttm_bo_man_takedown (&qdev->mman.bdev,TTM_PL_PRIV );ttm_bo_device_release (&qdev->mman.bdev);DRM_INFO ("qxl: ttm finalized\n" ); }drivers/gpu/drm/radeon/radeon_ttm.c +16
-17@@ -68,36 +68,35 @@ struct radeon_device *radeon_get_rdev(struct ttm_bo_device *bdev)static int radeon_ttm_init_vram (struct radeon_device *rdev) { -struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM ); - - man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; - -return ttm_bo_man_init (&rdev->mman.bdev, man, +return ttm_bo_man_init (&rdev->mman.bdev,TTM_PL_VRAM , +TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC , +TTM_PL_FLAG_WC , false, rdev->mc.real_vram_size >>PAGE_SHIFT ); }static int radeon_ttm_init_gtt (struct radeon_device *rdev) { -struct ttm_mem_type_manager *man =ttm_manager_type (&rdev->mman.bdev,TTM_PL_TT ); +uint32_t available_caching, default_caching; + + available_caching =TTM_PL_MASK_CACHING ; + default_caching =TTM_PL_FLAG_CACHED ; - man->available_caching =TTM_PL_MASK_CACHING ; - man->default_caching =TTM_PL_FLAG_CACHED ; - man->use_tt = true;#if IS_ENABLED (CONFIG_AGP )if (rdev->flags &RADEON_IS_AGP ) {if (!rdev->ddev->agp) {DRM_ERROR ("AGP is not enabled\n" );return -EINVAL ; } - man->available_caching =TTM_PL_FLAG_UNCACHED | -TTM_PL_FLAG_WC ; - man->default_caching =TTM_PL_FLAG_WC ; + available_caching =TTM_PL_FLAG_UNCACHED | +TTM_PL_FLAG_WC ; + default_caching =TTM_PL_FLAG_WC ; }#endif -return ttm_bo_man_init (&rdev->mman.bdev, man, - rdev->mc.gtt_size >>PAGE_SHIFT ); +return ttm_bo_man_init (&rdev->mman.bdev,TTM_PL_TT , + available_caching, + default_caching, true, + rdev->mc.gtt_size >>PAGE_SHIFT ); } static void radeon_evict_flags(struct ttm_buffer_object *bo,@@ -825,8 +824,8 @@ void radeon_ttm_fini(struct radeon_device *rdev) }radeon_bo_unref (&rdev->stolen_vga_memory); } -ttm_bo_man_takedown (&rdev->mman.bdev,ttm_manager_type (&rdev->mman.bdev,TTM_PL_VRAM )); -ttm_bo_man_takedown (&rdev->mman.bdev,ttm_manager_type (&rdev->mman.bdev,TTM_PL_TT )); +ttm_bo_man_takedown (&rdev->mman.bdev,TTM_PL_VRAM ); +ttm_bo_man_takedown (&rdev->mman.bdev,TTM_PL_TT );ttm_bo_device_release (&rdev->mman.bdev);radeon_gart_fini (rdev); rdev->mman.initialized = false;drivers/gpu/drm/ttm/ttm_bo_manager.c +14
-5@@ -107,19 +107,27 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,static const struct ttm_mem_type_manager_func ttm_bo_manager_func;int ttm_bo_man_init (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +unsigned type, +uint32_t available_caching, +uint32_t default_caching, +bool use_tt,unsigned long p_size) { +struct ttm_mem_type_manager *man =ttm_manager_type (bdev, type);struct ttm_range_manager *rman; - man->func = &ttm_bo_manager_func; - -ttm_bo_init_mm_base (bdev, man, p_size); + 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->func = &ttm_bo_manager_func; + +ttm_bo_init_mm_base (bdev, man, p_size); +drm_mm_init (&rman->mm,0 , p_size);spin_lock_init (&rman->lock); man->priv = rman;@@ -130,8 +138,9 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev,EXPORT_SYMBOL (ttm_bo_man_init);int ttm_bo_man_takedown (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man) +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 drm_mm *mm = &rman->mm;int ret;drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +4
-9@@ -626,13 +626,9 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv)#ifdef CONFIG_TRANSPARENT_HUGEPAGE ret =vmw_thp_init (dev_priv);#else -struct ttm_mem_type_manager *man = &dev_priv->bdev.man[TTM_PL_VRAM ]; - - man->available_caching =TTM_PL_FLAG_CACHED ; - man->default_caching =TTM_PL_FLAG_CACHED ; - - ret =ttm_bo_man_init (&dev_priv->bdev, man, - dev_priv->vram_size >>PAGE_SHIFT ); + ret =ttm_bo_man_init (&dev_priv->bdev,TTM_PL_VRAM , +TTM_PL_FLAG_CACHED ,TTM_PL_FLAG_CACHED , + false, dev_priv->vram_size >>PAGE_SHIFT );#endif ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )->use_type = false;return ret;@@ -643,8 +639,7 @@ static void vmw_takedown_vram_manager(struct vmw_private *dev_priv)#ifdef CONFIG_TRANSPARENT_HUGEPAGE vmw_thp_takedown (dev_priv);#else -ttm_bo_man_takedown (&dev_priv->bdev, -ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )); +ttm_bo_man_takedown (&dev_priv->bdev,TTM_PL_VRAM );#endif }include/drm/ttm/ttm_bo_driver.h renamed from include/drm/ttm/ttm_bo_driver.hA r +0
-0@@ -809,8 +809,11 @@ int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo);pgprot_t ttm_io_prot (uint32_t caching_flags,pgprot_t tmp); int ttm_bo_man_init(struct ttm_bo_device *bdev,
include/drm/ttm/ttm_bo_driver.h int ttm_bo_pipeline_gutting(struct ttm_buffer_object *bo); · line 819
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h renamed from include/drm/ttm/ttm_bo_driver.hA r +5
-2-struct ttm_mem_type_manager *man, +unsigned type, + uint32_t available_caching, + uint32_t default_caching, + bool use_tt, unsigned long p_size);int ttm_bo_man_takedown (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man); +unsigned type);#endif
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 40/49] drm/ttm: move range manager to subclassed driver allocation
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>
Quoted 98 lines
--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 32 +++++++++++++++++----------- 1 file changed, 20 insertions(+), 12 deletions(-)drivers/gpu/drm/ttm/ttm_bo_manager.c +19
-11@@ -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_bo_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_bo_init_mm_base (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_bo_use_mm (man);return 0 ; }@@ -141,7 +148,7 @@ int ttm_bo_man_takedown(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,11 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,drm_mm_clean (mm);drm_mm_takedown (mm);spin_unlock (&rman->lock); -kfree (rman); - man->priv =NULL ;ttm_bo_man_cleanup (man); +ttm_set_driver_manager (bdev, type,NULL ); +kfree (rman); +return 0 ; }EXPORT_SYMBOL (ttm_bo_man_takedown);
drivers/gpu/drm/ttm/ttm_bo_manager.c EXPORT_SYMBOL(ttm_bo_man_takedown); · line 180
Quoted 8 lines
drivers/gpu/drm/ttm/ttm_bo_manager.c +1
-1@@ -166,7 +174,7 @@ EXPORT_SYMBOL(ttm_bo_man_takedown);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);
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 44/49] drm/ttm: drop priv pointer in memory manager
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
This isn't needed anymore by any drivers.
Signed-off-by Dave Airlie <[email protected]>
Quoted 17 lines
--- include/drm/ttm/ttm_bo_driver.h | 2 -- 1 file changed, 2 deletions(-)include/drm/ttm/ttm_bo_driver.h +0
-1@@ -123,7 +123,6 @@ struct ttm_mem_type_manager_func {* @default_caching: The default caching policy used for a buffer object * placed in this memory type if the user doesn't provide one. * @func: structure pointer implementing the range manager. See above -* @priv: Driver private closure for @func. * @io_reserve_mutex: Mutex optionally protecting shared io_reserve structures * @use_io_reserve_lru: Use an lru list to try to unreserve io_mem_regions * reserved by the TTM vm system.
include/drm/ttm/ttm_bo_driver.h struct ttm_mem_type_manager { · line 156
Quoted 7 lines
include/drm/ttm/ttm_bo_driver.h +0
-1@@ -152,7 +151,6 @@ struct ttm_mem_type_manager {uint32_t available_caching;uint32_t default_caching;const struct ttm_mem_type_manager_func *func; -void *priv;struct mutex io_reserve_mutex;bool use_io_reserve_lru;spinlock_t move_lock;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 46/49] drm/ttm: drop man->bdev link.
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 5 lines
From: Dave Airlie <[email protected]>
This link isn't needed anymore, drop it from the init interface.
Signed-off-by Dave Airlie <[email protected]>
Quoted 151 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ttm.c | 6 ++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- drivers/gpu/drm/ttm/ttm_bo_manager.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 2 +- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 2 +- include/drm/ttm/ttm_bo_api.h | 3 +-- include/drm/ttm/ttm_bo_driver.h | 2 -- 9 files changed, 10 insertions(+), 17 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +1
-1@@ -108,7 +108,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; -ttm_bo_init_mm_base (&adev->mman.bdev, man, gtt_size >>PAGE_SHIFT ); +ttm_bo_init_mm_base (man, gtt_size >>PAGE_SHIFT ); start =AMDGPU_GTT_MAX_TRANSFER_SIZE *AMDGPU_GTT_NUM_TRANSFER_WINDOWS ; size = (adev->gmc.gart_size >>PAGE_SHIFT ) - start;drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1
-1@@ -190,7 +190,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev) man->available_caching =TTM_PL_FLAG_UNCACHED |TTM_PL_FLAG_WC ; man->default_caching =TTM_PL_FLAG_WC ; -ttm_bo_init_mm_base (&adev->mman.bdev, man, adev->gmc.real_vram_size >>PAGE_SHIFT ); +ttm_bo_init_mm_base (man, adev->gmc.real_vram_size >>PAGE_SHIFT ); man->func = &amdgpu_vram_mgr_func;drivers/gpu/drm/nouveau/nouveau_ttm.c +2
-4@@ -174,8 +174,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->func = &nouveau_vram_manager; man->use_io_reserve_lru = true; -ttm_bo_init_mm_base (&drm->ttm.bdev, man, - drm->gem.vram_available >>PAGE_SHIFT ); +ttm_bo_init_mm_base (man, drm->gem.vram_available >>PAGE_SHIFT );ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM , man);ttm_bo_use_mm (man);return 0 ;@@ -236,8 +235,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->available_caching = available_caching; man->default_caching = default_caching; man->use_tt = true; -ttm_bo_init_mm_base (&drm->ttm.bdev, man, - size_pages); +ttm_bo_init_mm_base (man, size_pages);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT , man);ttm_bo_use_mm (man);return 0 ;drivers/gpu/drm/ttm/ttm_bo.c +2
-4@@ -1464,8 +1464,7 @@ int ttm_bo_evict_mm(struct ttm_bo_device *bdev, unsigned mem_type) }EXPORT_SYMBOL (ttm_bo_evict_mm); -void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +void ttm_bo_init_mm_base (struct ttm_mem_type_manager *man,unsigned long p_size) {unsigned i;@@ -1475,7 +1474,6 @@ void ttm_bo_init_mm_base(struct ttm_bo_device *bdev,mutex_init (&man->io_reserve_mutex);spin_lock_init (&man->move_lock);INIT_LIST_HEAD (&man->io_reserve_lru); - man->bdev = bdev; man->size = p_size;for (i =0 ; i <TTM_MAX_BO_PRIORITY ; ++i)@@ -1588,7 +1586,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->available_caching =TTM_PL_MASK_CACHING ; man->default_caching =TTM_PL_FLAG_CACHED ; -ttm_bo_init_mm_base (bdev, man,0 ); +ttm_bo_init_mm_base (man,0 );ttm_bo_use_mm (man); }drivers/gpu/drm/ttm/ttm_bo_manager.c +1
-1@@ -133,7 +133,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev, man->func = &ttm_bo_manager_func; -ttm_bo_init_mm_base (bdev, man, p_size); +ttm_bo_init_mm_base (man, p_size);drm_mm_init (&rman->mm,0 , p_size);spin_lock_init (&rman->lock);drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +1
-1@@ -116,7 +116,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) man->default_caching =TTM_PL_FLAG_CACHED ;/* TODO: This is most likely not correct */ man->use_tt = true; -ttm_bo_init_mm_base (&dev_priv->bdev, man,0 ); +ttm_bo_init_mm_base (man,0 );spin_lock_init (&gman->lock); gman->used_gmr_pages =0 ;ida_init (&gman->gmr_ida);drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +1
-1@@ -134,7 +134,7 @@ int vmw_thp_init(struct vmw_private *dev_priv) man->available_caching =TTM_PL_FLAG_CACHED ; man->default_caching =TTM_PL_FLAG_CACHED ; -ttm_bo_init_mm_base (&dev_priv->bdev, man, +ttm_bo_init_mm_base (man, dev_priv->vram_size >>PAGE_SHIFT );include/drm/ttm/ttm_bo_api.h +1
-2@@ -547,8 +547,7 @@ int ttm_bo_create(struct ttm_bo_device *bdev, unsigned long size,* May also return driver-specified errors. */ struct ttm_mem_type_manager ; -void ttm_bo_init_mm_base (struct ttm_bo_device *bdev, -struct ttm_mem_type_manager *man, +void ttm_bo_init_mm_base (struct ttm_mem_type_manager *man,unsigned long p_size);/** include/drm/ttm/ttm_bo_driver.h +0
-0
include/drm/ttm/ttm_bo_driver.h struct ttm_mem_type_manager_func { · line 143
Quoted 8 lines
include/drm/ttm/ttm_bo_driver.h +0
-2@@ -138,8 +138,6 @@ struct ttm_mem_type_manager_func {struct ttm_mem_type_manager { -struct ttm_bo_device *bdev; -/* * No protection. Constant from start. */
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 45/49] drm/amdgpu/ttm: remove man->bdev references.
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 6 lines
From: Dave Airlie <[email protected]>
Just store the device in the private so the link
can be removed from the managerSigned-off-by Dave Airlie <[email protected]>
Quoted 36 lines
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +4
-1@@ -34,6 +34,7 @@ struct amdgpu_vram_mgr {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_mem_type_manager *man)@@ -196,6 +197,8 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)drm_mm_init (&mgr->mm,0 , man->size);spin_lock_init (&mgr->lock); + mgr->adev = adev; +/* Add the two VRAM-related sysfs files */ ret =sysfs_create_files (&adev->dev->kobj, amdgpu_vram_mgr_attributes);if (ret)@@ -323,8 +326,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,const struct ttm_place *place, struct ttm_mem_reg *mem) { - struct amdgpu_device *adev = amdgpu_ttm_adev(man->bdev); struct amdgpu_vram_mgr *mgr = to_vram_mgr(man); +struct amdgpu_device *adev = mgr->adev;struct drm_mm *mm = &mgr->mm;struct drm_mm_node *nodes;enum drm_mm_insert_mode mode;
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man, · line 449
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +1
-1@@ -439,8 +442,8 @@ static int amdgpu_vram_mgr_new(struct ttm_mem_type_manager *man,static void amdgpu_vram_mgr_del (struct ttm_mem_type_manager *man,struct ttm_mem_reg *mem) { -struct amdgpu_device *adev =amdgpu_ttm_adev (man->bdev);struct amdgpu_vram_mgr *mgr =to_vram_mgr (man); +struct amdgpu_device *adev = mgr->adev;struct drm_mm_node *nodes = mem->mm_node;uint64_t usage =0 , vis_usage =0 ;unsigned pages = mem->num_pages;
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 47/49] drm/ttm: drop list of memory managers from device.
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 38 lines
From: Dave Airlie <[email protected]>
The driver now controls these, the core just controls the system memory one.
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 2 -- include/drm/ttm/ttm_bo_driver.h | 6 ++++-- 2 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +0
-2@@ -1608,8 +1608,6 @@ int ttm_bo_device_init(struct ttm_bo_device *bdev, bdev->driver = driver; -memset (bdev->man_priv,0 ,sizeof (bdev->man_priv)); -ttm_bo_init_sysman (bdev); bdev->vma_manager = vma_manager;include/drm/ttm/ttm_bo_driver.h +1
-1@@ -414,7 +414,7 @@ struct ttm_bo_device {/* * access via ttm_manager_type. */ -struct ttm_mem_type_manager man_priv[TTM_NUM_MEM_TYPES ]; +struct ttm_mem_type_manager sysman;/* move to global */ struct ttm_mem_type_manager *man_drv[TTM_NUM_MEM_TYPES ];/* * Protected by internal locks.
include/drm/ttm/ttm_bo_driver.h struct ttm_bo_device { · line 453
Quoted 9 lines
include/drm/ttm/ttm_bo_driver.h +3
-1@@ -446,9 +446,11 @@ struct ttm_bo_device {static inline struct ttm_mem_type_manager *ttm_manager_type (struct ttm_bo_device *bdev,int mem_type) { +if (mem_type ==TTM_PL_SYSTEM ) +return &bdev->sysman;if (bdev->man_drv[mem_type])return bdev->man_drv[mem_type]; -return &bdev->man_priv[mem_type]; +return NULL ;
Could be simplified to "return bdev->man_drv[mem_type];" if we just assign bdev->man_drv[TTM_PL_SYSTEM] during driver init.
Christian.
include/drm/ttm/ttm_bo_driver.h struct ttm_bo_device { · line 456
Quoted 3 lines
include/drm/ttm/ttm_bo_driver.h +0
-0} static inline void ttm_set_driver_manager(struct ttm_bo_device *bdev,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 49/49] drm/ttm: consolidate manager used apis into a set and get.
In reply to Dave AirlieAm 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 6 lines
From: Dave Airlie <[email protected]>
This is probably something we could consider removing, vmwgfx is the only user, and we might be able to faciliate it another way
but for now just consolidate it all into accessors.
I always found the "use_type" wording confusing and this set_use() name even more confusing.
Why not call it "enabled"?
Christian.
Quoted 255 lines
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 4 ++-- drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c | 4 ++-- drivers/gpu/drm/nouveau/nouveau_ttm.c | 8 ++++---- drivers/gpu/drm/ttm/ttm_bo.c | 6 +++--- drivers/gpu/drm/ttm/ttm_bo_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 14 +++++++------- drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c | 4 ++-- drivers/gpu/drm/vmwgfx/vmwgfx_thp.c | 4 ++-- include/drm/ttm/ttm_bo_driver.h | 8 ++++---- 9 files changed, 28 insertions(+), 28 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c +2
-2@@ -128,7 +128,7 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size) }ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_TT , &mgr->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -146,7 +146,7 @@ void amdgpu_gtt_mgr_fini(struct amdgpu_device *adev)struct amdgpu_gtt_mgr *mgr =to_gtt_mgr (man);int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&adev->mman.bdev, man);if (ret)drivers/gpu/drm/amd/amdgpu/amdgpu_vram_mgr.c +2
-2@@ -205,7 +205,7 @@ int amdgpu_vram_mgr_init(struct amdgpu_device *adev)DRM_ERROR ("Failed to register sysfs\n" );ttm_set_driver_manager (&adev->mman.bdev,TTM_PL_VRAM , &mgr->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -223,7 +223,7 @@ void amdgpu_vram_mgr_fini(struct amdgpu_device *adev)struct amdgpu_vram_mgr *mgr =to_vram_mgr (man);int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&adev->mman.bdev, man);if (ret)drivers/gpu/drm/nouveau/nouveau_ttm.c +4
-4@@ -176,7 +176,7 @@ nouveau_ttm_init_vram(struct nouveau_drm *drm) man->use_io_reserve_lru = true;ttm_bo_init_mm_base (man, drm->gem.vram_available >>PAGE_SHIFT );ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM , man); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }else { return ttm_bo_man_init(&drm->ttm.bdev, TTM_PL_VRAM,@@ -192,7 +192,7 @@ nouveau_ttm_fini_vram(struct nouveau_drm *drm)struct ttm_mem_type_manager *man =ttm_manager_type (&drm->ttm.bdev,TTM_PL_VRAM );if (drm->client.device.info.family >=NV_DEVICE_INFO_V0_TESLA ) { -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_VRAM ,NULL );@@ -237,7 +237,7 @@ nouveau_ttm_init_gtt(struct nouveau_drm *drm) man->use_tt = true;ttm_bo_init_mm_base (man, size_pages);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT , man); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -250,7 +250,7 @@ nouveau_ttm_fini_gtt(struct nouveau_drm *drm) drm->agp.bridge) ttm_bo_man_takedown(&drm->ttm.bdev, TTM_PL_TT); else { -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&drm->ttm.bdev, man);ttm_bo_man_cleanup (man);ttm_set_driver_manager (&drm->ttm.bdev,TTM_PL_TT ,NULL );drivers/gpu/drm/ttm/ttm_bo.c +3
-3@@ -996,7 +996,7 @@ static int ttm_bo_mem_placement(struct ttm_buffer_object *bo,return ret; man =ttm_manager_type (bdev, mem_type); -if (!man || !man->use_type) +if (!man || !ttm_mm_used (man))return -EBUSY ;if (!ttm_bo_mt_compatible (man, mem_type, place, &cur_flags))@@ -1548,7 +1548,7 @@ int ttm_bo_device_release(struct ttm_bo_device *bdev)struct ttm_mem_type_manager *man; man =ttm_manager_type (bdev,TTM_PL_SYSTEM ); -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);mutex_lock (&ttm_global_mutex);list_del (&bdev->device_list);@@ -1585,7 +1585,7 @@ static void ttm_bo_init_sysman(struct ttm_bo_device *bdev) man->default_caching =TTM_PL_FLAG_CACHED ;ttm_bo_init_mm_base (man,0 ); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true); } int ttm_bo_device_init(struct ttm_bo_device *bdev,drivers/gpu/drm/ttm/ttm_bo_manager.c +2
-2@@ -139,7 +139,7 @@ int ttm_bo_man_init(struct ttm_bo_device *bdev,spin_lock_init (&rman->lock);ttm_set_driver_manager (bdev, type, &rman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }EXPORT_SYMBOL (ttm_bo_man_init);@@ -152,7 +152,7 @@ int ttm_bo_man_takedown(struct ttm_bo_device *bdev,struct drm_mm *mm = &rman->mm;int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (bdev, man);if (ret)drivers/gpu/drm/vmwgfx/vmwgfx_drv.c +7
-7@@ -630,7 +630,7 @@ static int vmw_init_vram_manager(struct vmw_private *dev_priv)TTM_PL_FLAG_CACHED ,TTM_PL_FLAG_CACHED , false, dev_priv->vram_size >> PAGE_SHIFT);#endif -ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM )->use_type = false; +ttm_mm_set_use (ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM ), false);return ret; }@@ -1190,9 +1190,9 @@ static void __vmw_svga_enable(struct vmw_private *dev_priv)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );spin_lock (&dev_priv->svga_lock); -if (!man->use_type) { +if (!ttm_mm_used (man)) {vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE ); - man->use_type = true; +ttm_mm_set_use (man, true); }spin_unlock (&dev_priv->svga_lock); }@@ -1221,8 +1221,8 @@ static void __vmw_svga_disable(struct vmw_private *dev_priv)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev,TTM_PL_VRAM );spin_lock (&dev_priv->svga_lock); -if (man->use_type) { - man->use_type = false; +if (ttm_mm_used (man)) { +ttm_mm_set_use (man, false);vmw_write (dev_priv,SVGA_REG_ENABLE ,SVGA_REG_ENABLE_HIDE |SVGA_REG_ENABLE_ENABLE );@@ -1255,8 +1255,8 @@ void vmw_svga_disable(struct vmw_private *dev_priv)vmw_kms_lost_device (dev_priv->dev);ttm_write_lock (&dev_priv->reservation_sem, false);spin_lock (&dev_priv->svga_lock); -if (man->use_type) { - man->use_type = false; +if (ttm_mm_used (man)) { +ttm_mm_set_use (man, false);spin_unlock (&dev_priv->svga_lock);if (ttm_bo_evict_mm (&dev_priv->bdev,TTM_PL_VRAM ))DRM_ERROR ("Failed evicting VRAM buffers.\n" );drivers/gpu/drm/vmwgfx/vmwgfx_gmrid_manager.c +2
-2@@ -135,7 +135,7 @@ int vmw_gmrid_man_init(struct vmw_private *dev_priv, int type) }ttm_set_driver_manager (&dev_priv->bdev, type, &gman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -144,7 +144,7 @@ void vmw_gmrid_man_takedown(struct vmw_private *dev_priv, int type)struct ttm_mem_type_manager *man =ttm_manager_type (&dev_priv->bdev, type);struct vmwgfx_gmrid_man *gman =to_gmrid_manager (man); -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false);ttm_bo_force_list_clean (&dev_priv->bdev, man);drivers/gpu/drm/vmwgfx/vmwgfx_thp.c +2
-2@@ -142,7 +142,7 @@ int vmw_thp_init(struct vmw_private *dev_priv)spin_lock_init (&rman->lock);ttm_set_driver_manager (&dev_priv->bdev,TTM_PL_VRAM , &rman->manager); -ttm_bo_use_mm (man); +ttm_mm_set_use (man, true);return 0 ; }@@ -153,7 +153,7 @@ void vmw_thp_takedown(struct vmw_private *dev_priv)struct drm_mm *mm = &rman->mm;int ret; -ttm_bo_disable_mm (man); +ttm_mm_set_use (man, false); ret =ttm_bo_force_list_clean (&dev_priv->bdev, man);if (ret)include/drm/ttm/ttm_bo_driver.h +2
-2@@ -668,14 +668,14 @@ static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo)dma_resv_unlock (bo->base.resv); } -static inline void ttm_bo_use_mm (struct ttm_mem_type_manager *man) +static inline void ttm_mm_set_use (struct ttm_mem_type_manager *man,bool use) { - man->use_type = true; + man->use_type = use;
include/drm/ttm/ttm_bo_driver.h static inline void ttm_bo_unreserve(struct ttm_buffer_object *bo) · line 681
Quoted 10 lines
include/drm/ttm/ttm_bo_driver.h +2
-2} -static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) +static inline bool ttm_mm_used (struct ttm_mem_type_manager *man) { - man->use_type = false; +return man->use_type; }static inline void ttm_bo_man_cleanup (struct ttm_mem_type_manager *man)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 26/49] drm/ttm: add wrapper to get manager from bdev.
In reply to Christian KönigQuoted 11 lines · Christian König
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This will allow different abstractions later.
Mhm, I'm questioning if this is really worth it and not just overkill.
Running "sed -i 's/&bdev->man/bdev->man/'" on all drivers when we make the switch to a pointer should do it as well.
It's a good place to hook debugging in if you get something rogue accessing unregistered bdev->man ptrs as well.
I'd rather not sed the interface later, it's nice to transition things cleanly between states.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerQuoted 9 lines · Christian König
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 1 line
I started pulling on a thread, and it led me down a hole.
We might want to make that hole even bigger :)
How about we rename the
ttm_mem_regintottm_resourceandttm_mem_type_managerintottm_resource_manager.
https://cgit.freedesktop.org/~airlied/linux/log/?h=ttm-refactor-mem-manager-rename
has the series with some stuff moved around but 3 added rename patches at the end.
ttm_bo_manager -> ttm_range_managerttm_mem_type_manager -> ttm_resource_managerttm_mem_reg -> ttm_resource.
The one slightly messy one is we have a lot of ttm_mem_reg *mem (*old_mem or *new_mem).
I didn't try and rename those, but I could probably do it if we
decided it was really necessary.
I've got to go back and fold in some review comments from people yet and add r-bs I'll try and get to that tomorrow.
Dave.
Quoted 28 lines
Neither amdgpu's OA/GWS resources nor the IDs in VMGFX are really memory.
In the long term I also want to move the whole address handling into each backend.
Going to send comments on the individual patches as well.
Quoted 21 lines
This series refactors the ttm
ttm_mem_type_managerobject into a driver owned, allocated, subclassaed object.It starts with two minor fixes for some bad assumptions in two drivers.
Enables a new init path, ports all the drivers to the new init path, and cleans up the old init path.
Enables a new takedown path, ports all the drivers to the new takedown path, and cleans up the old takedown path
Wraps all access to the memory managers in thebo_devicein a wrapper across all drivers.
Make debug callback optional
Enables driver to provide their own mem manager objects Subclasses the objects in all drivers and makes them into driver owned object Drops thebo_devicearrays of pointers, and some unneeded links and struct members
Cleans up one api.I think I'd probably want to merge all this via drm-misc, so if I can collect acks/r-b from driver maintainers that would be good.
Quoted 20 lines
Quoted 2 lines
This is also based on Chrisitan's work to remove
init_mem_type, so it won't apply until he's finished getting all of that into drm-misc.Preparing to push that to drm-misc-next just now.
Regards,
Christian.Quoted 11 lines
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~airlied%2Flinux%2Flog%2F%3Fh%3Dttm-refactor-mem-manager&data=02%7C01%7Cchristian.koenig%40amd.com%7Caa32512acf9f4bf455ef08d83506f9d2%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637317651361302583&sdata=2sQt4A48ODl0Nq4P21YG3vRNdhkDZcZp0XHkQ930SAI%3D&reserved=0
is the tree I've built this on top off, so it's probably going to get rebased but the code should stay mostly the same.I've done some boot testing on nouveau, and I hope to test it on vmwgfx and amdgpu soon.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerAm 03.08.20 um 09:12 schrieb Dave Airlie:
Quoted 13 lines · Christian König
Quoted 7 lines
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 1 line
I started pulling on a thread, and it led me down a hole.
We might want to make that hole even bigger :)
How about we rename the
ttm_mem_regintottm_resourceandttm_mem_type_managerintottm_resource_manager.has the series with some stuff moved around but 3 added rename patches at the end.
Quoted 8 lines
ttm_bo_manager->ttm_range_managerttm_mem_type_manager->ttm_resource_managerttm_mem_reg->ttm_resource.The one slightly messy one is we have a lot of
ttm_mem_reg*mem (*old_memor*new_mem).
I didn't try and rename those, but I could probably do it if we
decided it was really necessary.
I really want to reduce the usage of those in the long term from the driver anyway.
Quoted 2 lines
I've got to go back and fold in some review comments from people yet and add r-bs I'll try and get to that tomorrow.
Feel free to add my Acked-by to the ones where I haven't given an explicit rb so for.
Going to prepare more cleanups on top of this series.
Christian.
Quoted 48 lines
Dave.
Quoted 45 lines
Neither amdgpu's OA/GWS resources nor the IDs in VMGFX are really memory.
In the long term I also want to move the whole address handling into each backend.
Going to send comments on the individual patches as well.
Quoted 18 lines
This series refactors the ttm
ttm_mem_type_managerobject into a driver owned, allocated, subclassaed object.It starts with two minor fixes for some bad assumptions in two drivers.
Enables a new init path, ports all the drivers to the new init path, and cleans up the old init path.
Enables a new takedown path, ports all the drivers to the new takedown path, and cleans up the old takedown path
Wraps all access to the memory managers in thebo_devicein a wrapper across all drivers.
Make debug callback optional
Enables driver to provide their own mem manager objects Subclasses the objects in all drivers and makes them into driver owned object Drops thebo_devicearrays of pointers, and some unneeded links and struct members
Cleans up one api.Quoted 5 lines
I think I'd probably want to merge all this via drm-misc, so if I can collect acks/r-b from driver maintainers that would be good.
This is also based on Chrisitan's work to remove
init_mem_type, so it won't apply until he's finished getting all of that into drm-misc.Preparing to push that to drm-misc-next just now.
Regards,
Christian.Quoted 10 lines
https://nam11.safelinks.protection.outlook.com/?url=https:%2F%2Fcgit.freedesktop.org%2F~airlied%2Flinux%2Flog%2F%3Fh%3Dttm-refactor-mem-manager&data=02%7C01%7Cchristian.koenig%40amd.com%7Cc1498ce352be4c56b30908d8377cae61%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637320355926010223&sdata=zrVYgyObEI8auSZ4AS7dDO%2BJ6WHYMITmuDQ%2F0lCxt1I%3D&reserved=0
is the tree I've built this on top off, so it's probably going to get rebased but the code should stay mostly the same.I've done some boot testing on nouveau, and I hope to test it on vmwgfx and amdgpu soon.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 39/49] drm/ttm: make ttm_bo_man_init/takedown take type + args
In reply to Christian KönigQuoted 9 lines · Christian König
Am 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This makes it easier to move these to a driver allocated system
No, sorry that looks like going into the wrong direction to me.
I already wanted to suggest to get rid of the size argument instead.
I'm not sure how it should look then, I don't want the driver poking around inside the range manager code, the range manager should be a generic object that driver inits and leaves alone,
I definitely don't want the driver to be poking caching and size values into the man objects for it, since it isn't a driver object.
Do you have some other view on how the generic range manager should work?
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 15/49] drm/ttm: make some inline helper functions for cleanup paths.
In reply to Christian KönigQuoted 42 lines · Christian König
Am 31.07.20 um 06:04 schrieb Dave Airlie:
Quoted 40 lines
From: Dave Airlie <[email protected]>
Signed-off-by Dave Airlie <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 6 ++---- include/drm/ttm/ttm_bo_driver.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +2
-4@@ -1462,8 +1462,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type)return ret; } - man->use_type = false; - man->has_type = false; +ttm_bo_disable_mm (man); ret =0 ;if (mem_type >0 ) {@@ -1476,8 +1475,7 @@ int ttm_bo_clean_mm(struct ttm_bo_device *bdev, unsigned mem_type) ret = (*man->func->takedown)(man); } -dma_fence_put (man->move); - man->move =NULL ; +ttm_bo_man_cleanup (man);return ret; }include/drm/ttm/ttm_bo_driver.h +0
-0@@ -671,6 +671,18 @@ static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) man->use_type = true; }
Quoted 16 lines
include/drm/ttm/ttm_bo_driver.h static inline void ttm_bo_use_mm(struct ttm_mem_type_manager *man) · line 685
Quoted 12 lines
include/drm/ttm/ttm_bo_driver.h +12
-0+static inline void ttm_bo_disable_mm (struct ttm_mem_type_manager *man) +{ + man->has_type = false; + man->use_type = false; +} + +static inline void ttm_bo_man_cleanup (struct ttm_mem_type_manager *man) +{ +dma_fence_put (man->move); + man->move =NULL ; +} +What's the value in making those inline? This is not performance critical at all.
Not for performance, but they were too trivial to bother putting in real functions, if there was more going on I'd probably have put them into functions, but setting two bits, and putting a fence didn't seem worth adding function call overhead where there was none before.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 39/49] drm/ttm: make ttm_bo_man_init/takedown take type + args
In reply to Dave AirlieAm 04.08.20 um 03:42 schrieb Dave Airlie:
Quoted 8 lines · Christian König
Quoted 7 lines
Am 31.07.20 um 06:05 schrieb Dave Airlie:
Quoted 3 lines
From: Dave Airlie <[email protected]>
This makes it easier to move these to a driver allocated system
No, sorry that looks like going into the wrong direction to me.
I already wanted to suggest to get rid of the size argument instead.
Quoted 8 lines
I'm not sure how it should look then, I don't want the driver poking around inside the range manager code, the range manager should be a generic object that driver inits and leaves alone,
I definitely don't want the driver to be poking caching and size values into the man objects for it, since it isn't a driver object.
Do you have some other view on how the generic range manager should work?
That was not what I was talking about. Take a look at what those fields are used for :)
As far as I see the only usage of the size is in ttm_resource_manager_debug(). But this size is actually totally opaque to TTM, it could be pages, bytes, fried chicken wings or whatever. In other words it would be much better to print it in the debug callback of each resource manager.
The available_caching is completely superfluous as well. The original idea what that a driver could specify multiple placements as flags in one entry, but no driver ever used that as far as I know and it became completely deprecated in 2014 when I moved the lpfn and fpfn into each place.
The default_caching is used in ttm_bo_select_caching(), but this is complete utterly nonsense. It just results in multiple possible cache behaviors being selected, which are then fortunately ignored by ttm_tt_set_placement_caching :)
To be honest I think just removing those parameters and the associated caching flags all together is the next logical step.
Regards,
Christian.
Quoted 2 lines
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Dave Airlie
maintainerRe: [PATCH 39/49] drm/ttm: make ttm_bo_man_init/takedown take type + args
Quoted 9 lines
That was not what I was talking about. Take a look at what those fields are used for :)
As far as I see the only usage of the size is in
ttm_resource_manager_debug(). But this size is actually totally opaque to TTM, it could be pages, bytes, fried chicken wings or whatever. In other words it would be much better to print it in the debug callback of each resource manager.
Size is a bit trickier as the drivers use in a couple of funky places, radeon pokes inside the range manager and adjust its size post init, and amdgpu uses size to validate a bunch of bo sizing. These shouldn't be too messy to workaround.
Quoted 7 lines
The
available_cachingis completely superfluous as well. The original idea what that a driver could specify multiple placements as flags in one entry, but no driver ever used that as far as I know and it became completely deprecated in 2014 when I moved the lpfn and fpfn into each place.
Quoted 8 lines
The
default_cachingis used inttm_bo_select_caching(), but this is complete utterly nonsense. It just results in multiple possible cache behaviors being selected, which are then fortunately ignored byttm_tt_set_placement_caching:)To be honest I think just removing those parameters and the associated caching flags all together is the next logical step.
Definitely something to burn down alright.
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Christian König
maintainerRe: [PATCH 39/49] drm/ttm: make ttm_bo_man_init/takedown take type + args
Am 06.08.20 um 05:46 schrieb Dave Airlie:
Quoted 9 lines
Quoted 9 lines
That was not what I was talking about. Take a look at what those fields are used for :)
As far as I see the only usage of the size is in
ttm_resource_manager_debug(). But this size is actually totally opaque to TTM, it could be pages, bytes, fried chicken wings or whatever. In other words it would be much better to print it in the debug callback of each resource manager.
Quoted 4 lines
Size is a bit trickier as the drivers use in a couple of funky places, radeon pokes inside the range manager and adjust its size post init, and amdgpu uses size to validate a bunch of bo sizing. These shouldn't be too messy to workaround.
Yeah, I already wanted o clean that up in radeon for years now :)
Amdgpu should be easy to fix, most likely we just don't store the gtt size anywhere else.
But yes, those are TTM internals which drivers should not touch.
Quoted 13 lines
Quoted 13 lines
The
available_cachingis completely superfluous as well. The original idea what that a driver could specify multiple placements as flags in one entry, but no driver ever used that as far as I know and it became completely deprecated in 2014 when I moved the lpfn and fpfn into each place.The
default_cachingis used inttm_bo_select_caching(), but this is complete utterly nonsense. It just results in multiple possible cache behaviors being selected, which are then fortunately ignored byttm_tt_set_placement_caching:)
Quoted 3 lines
Quoted 2 lines
To be honest I think just removing those parameters and the associated caching flags all together is the next logical step.
Definitely something to burn down alright.
IIRC we have a bit of dead AGP code in radeon which still tries to use this.
Nouveau might have something as well, going to take a look now.
But in general I think that drivers should just say I want caching X for this BO instead of TTM making an educated guess based on some flags set in different places.
Christian.
Quoted 2 lines
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel