Skip to contentSkip to conversation

drm/ttm: switch back to static allocation limits for now

PATCH New Christian König 1 participant 1 message Mar 25, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: switch back to static allocation limits for now

The shrinker based approach still has some flaws. Especially that we need temporary pages to free up the pages allocated to the driver is problematic in a shrinker.

---
 drivers/gpu/drm/ttm/ttm_device.c |  14 ++--
 drivers/gpu/drm/ttm/ttm_tt.c     | 112 ++++++++++++-------------------
 include/drm/ttm/ttm_tt.h         |   3 +-
 3 files changed, 53 insertions(+), 76 deletions(-)
drivers/gpu/drm/ttm/ttm_device.c +10 -4
index 8e821cddf81c..9b787b3caeb5 100644
@@ -53,7 +53,6 @@ static void ttm_global_release(void)
 		goto out;
 
 	ttm_pool_mgr_fini();
-	ttm_tt_mgr_fini();
 
 	__free_page(glob->dummy_read_page);
 	memset(glob, 0, sizeof(*glob));
@@ -64,7 +63,7 @@ static void ttm_global_release(void)
 static int ttm_global_init(void)
 {
 	struct ttm_global *glob = &ttm_glob;
-	unsigned long num_pages;
+	unsigned long num_pages, num_dma32;
 	struct sysinfo si;
 	int ret = 0;
 
@@ -78,8 +77,15 @@ static int ttm_global_init(void)
 	 * system memory.
 	 */
 	num_pages = ((u64)si.totalram * si.mem_unit) >> PAGE_SHIFT;
-	ttm_pool_mgr_init(num_pages * 50 / 100);
-	ttm_tt_mgr_init();
+	num_pages /= 2;
+
+	/* But for DMA32 we limit ourself to only use 2GiB maximum. */
+	num_dma32 = (u64)(si.totalram - si.totalhigh) * si.mem_unit
+		>> PAGE_SHIFT;
+	num_dma32 = min(num_dma32, 2UL << (30 - PAGE_SHIFT));
+
+	ttm_pool_mgr_init(num_pages);
+	ttm_tt_mgr_init(num_pages, num_dma32);
 
 	glob->dummy_read_page = alloc_page(__GFP_ZERO | GFP_DMA32);
 
drivers/gpu/drm/ttm/ttm_tt.c +42 -70

164 lines not on this page · raw message

include/drm/ttm/ttm_tt.h +1 -2
index 069f8130241a..134d09ef7766 100644
@@ -157,8 +157,7 @@ int ttm_tt_populate(struct ttm_device *bdev, struct ttm_tt *ttm, struct ttm_oper
  */
 void ttm_tt_unpopulate(struct ttm_device *bdev, struct ttm_tt *ttm);
 
-int ttm_tt_mgr_init(void);
-void ttm_tt_mgr_fini(void);
+void ttm_tt_mgr_init(unsigned long num_pages, unsigned long num_dma32_pages);
 
 #if IS_ENABLED(CONFIG_AGP)
 #include <linux/agp_backend.h>
Signature · 6 lines
2.25.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel