forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
....@@ -33,7 +33,6 @@
3333 * when freed).
3434 */
3535
36
-#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU)
3736 #define pr_fmt(fmt) "[TTM] " fmt
3837
3938 #include <linux/dma-mapping.h>
....@@ -285,9 +284,13 @@
285284
286285 static void __ttm_dma_free_page(struct dma_pool *pool, struct dma_page *d_page)
287286 {
287
+ unsigned long attrs = 0;
288288 dma_addr_t dma = d_page->dma;
289289 d_page->vaddr &= ~VADDR_FLAG_HUGE_POOL;
290
- dma_free_coherent(pool->dev, pool->size, (void *)d_page->vaddr, dma);
290
+ if (pool->type & IS_HUGE)
291
+ attrs = DMA_ATTR_NO_WARN;
292
+
293
+ dma_free_attrs(pool->dev, pool->size, (void *)d_page->vaddr, dma, attrs);
291294
292295 kfree(d_page);
293296 d_page = NULL;
....@@ -410,13 +413,7 @@
410413
411414 if (NUM_PAGES_TO_ALLOC < nr_free)
412415 npages_to_free = NUM_PAGES_TO_ALLOC;
413
-#if 0
414
- if (nr_free > 1) {
415
- pr_debug("%s: (%s:%d) Attempting to free %d (%d) pages\n",
416
- pool->dev_name, pool->name, current->pid,
417
- npages_to_free, nr_free);
418
- }
419
-#endif
416
+
420417 if (use_static)
421418 pages_to_free = static_buf;
422419 else
....@@ -607,7 +604,7 @@
607604 p = pool->name;
608605 for (i = 0; i < ARRAY_SIZE(t); i++) {
609606 if (type & t[i]) {
610
- p += snprintf(p, sizeof(pool->name) - (p - pool->name),
607
+ p += scnprintf(p, sizeof(pool->name) - (p - pool->name),
611608 "%s", n[i]);
612609 }
613610 }
....@@ -888,8 +885,8 @@
888885 int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev,
889886 struct ttm_operation_ctx *ctx)
890887 {
888
+ struct ttm_mem_global *mem_glob = &ttm_mem_glob;
891889 struct ttm_tt *ttm = &ttm_dma->ttm;
892
- struct ttm_mem_global *mem_glob = ttm->bdev->glob->mem_glob;
893890 unsigned long num_pages = ttm->num_pages;
894891 struct dma_pool *pool;
895892 struct dma_page *d_page;
....@@ -897,7 +894,7 @@
897894 unsigned i;
898895 int ret;
899896
900
- if (ttm->state != tt_unpopulated)
897
+ if (ttm_tt_is_populated(ttm))
901898 return 0;
902899
903900 if (ttm_check_under_lowerlimit(mem_glob, num_pages, ctx))
....@@ -985,7 +982,7 @@
985982 }
986983 }
987984
988
- ttm->state = tt_unbound;
985
+ ttm_tt_set_populated(ttm);
989986 return 0;
990987 }
991988 EXPORT_SYMBOL_GPL(ttm_dma_populate);
....@@ -993,8 +990,8 @@
993990 /* Put all pages in pages list to correct pool to wait for reuse */
994991 void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev)
995992 {
993
+ struct ttm_mem_global *mem_glob = &ttm_mem_glob;
996994 struct ttm_tt *ttm = &ttm_dma->ttm;
997
- struct ttm_mem_global *mem_glob = ttm->bdev->glob->mem_glob;
998995 struct dma_pool *pool;
999996 struct dma_page *d_page, *next;
1000997 enum pool_type type;
....@@ -1079,7 +1076,7 @@
10791076 /* shrink pool if necessary (only on !is_cached pools)*/
10801077 if (npages)
10811078 ttm_dma_page_pool_free(pool, npages, false);
1082
- ttm->state = tt_unpopulated;
1079
+ ttm_tt_set_unpopulated(ttm);
10831080 }
10841081 EXPORT_SYMBOL_GPL(ttm_dma_unpopulate);
10851082
....@@ -1240,5 +1237,3 @@
12401237 return 0;
12411238 }
12421239 EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs);
1243
-
1244
-#endif