summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ttm/ttm_device.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2020-11-17 15:52:28 +0300
committerChristian König <christian.koenig@amd.com>2021-02-09 19:27:33 +0300
commitf07069da6b4c5f937d6df2de6504394845513964 (patch)
tree306bc358491ab26c0fc9b53e70128828a053363b /drivers/gpu/drm/ttm/ttm_device.c
parentd4bd7776a7ac504510656c0053a55c0cfd1ebc96 (diff)
downloadlinux-f07069da6b4c5f937d6df2de6504394845513964.tar.xz
drm/ttm: move memory accounting into vmwgfx v4
This is just another feature which is only used by VMWGFX, so move it into the driver instead. I've tried to add the accounting sysfs file to the kobject of the drm minor, but I'm not 100% sure if this works as expected. v2: fix typo in KFD and avoid 64bit divide v3: fix init order in VMWGFX v4: use pdev sysfs reference instead of drm Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Zack Rusin <zackr@vmware.com> (v3) Tested-by: Nirmoy Das <nirmoy.das@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210208133226.36955-2-christian.koenig@amd.com
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_device.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_device.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
index 8bb61dd26437..95e1b7b1f2e6 100644
--- a/drivers/gpu/drm/ttm/ttm_device.c
+++ b/drivers/gpu/drm/ttm/ttm_device.c
@@ -27,9 +27,12 @@
#define pr_fmt(fmt) "[TTM DEVICE] " fmt
+#include <linux/mm.h>
+
#include <drm/ttm/ttm_device.h>
-#include <drm/ttm/ttm_memory.h>
+#include <drm/ttm/ttm_tt.h>
#include <drm/ttm/ttm_placement.h>
+#include <drm/ttm/ttm_bo_api.h>
#include "ttm_module.h"
@@ -49,7 +52,9 @@ static void ttm_global_release(void)
if (--ttm_glob_use_count > 0)
goto out;
- ttm_mem_global_release(&ttm_mem_glob);
+ ttm_pool_mgr_fini();
+ ttm_tt_mgr_fini();
+
__free_page(glob->dummy_read_page);
memset(glob, 0, sizeof(*glob));
out:
@@ -59,6 +64,8 @@ out:
static int ttm_global_init(void)
{
struct ttm_global *glob = &ttm_glob;
+ unsigned long num_pages;
+ struct sysinfo si;
int ret = 0;
unsigned i;
@@ -66,9 +73,14 @@ static int ttm_global_init(void)
if (++ttm_glob_use_count > 1)
goto out;
- ret = ttm_mem_global_init(&ttm_mem_glob);
- if (ret)
- goto out;
+ si_meminfo(&si);
+
+ /* Limit the number of pages in the pool to about 50% of the total
+ * system memory.
+ */
+ num_pages = ((u64)si.totalram * si.mem_unit) >> PAGE_SHIFT;
+ ttm_pool_mgr_init(num_pages * 50 / 100);
+ ttm_tt_mgr_init();
spin_lock_init(&glob->lru_lock);
glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32);