.. | .. |
---|
33 | 33 | * when freed). |
---|
34 | 34 | */ |
---|
35 | 35 | |
---|
36 | | -#if defined(CONFIG_SWIOTLB) || defined(CONFIG_INTEL_IOMMU) |
---|
37 | 36 | #define pr_fmt(fmt) "[TTM] " fmt |
---|
38 | 37 | |
---|
39 | 38 | #include <linux/dma-mapping.h> |
---|
.. | .. |
---|
285 | 284 | |
---|
286 | 285 | static void __ttm_dma_free_page(struct dma_pool *pool, struct dma_page *d_page) |
---|
287 | 286 | { |
---|
| 287 | + unsigned long attrs = 0; |
---|
288 | 288 | dma_addr_t dma = d_page->dma; |
---|
289 | 289 | 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); |
---|
291 | 294 | |
---|
292 | 295 | kfree(d_page); |
---|
293 | 296 | d_page = NULL; |
---|
.. | .. |
---|
410 | 413 | |
---|
411 | 414 | if (NUM_PAGES_TO_ALLOC < nr_free) |
---|
412 | 415 | 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 | + |
---|
420 | 417 | if (use_static) |
---|
421 | 418 | pages_to_free = static_buf; |
---|
422 | 419 | else |
---|
.. | .. |
---|
607 | 604 | p = pool->name; |
---|
608 | 605 | for (i = 0; i < ARRAY_SIZE(t); i++) { |
---|
609 | 606 | if (type & t[i]) { |
---|
610 | | - p += snprintf(p, sizeof(pool->name) - (p - pool->name), |
---|
| 607 | + p += scnprintf(p, sizeof(pool->name) - (p - pool->name), |
---|
611 | 608 | "%s", n[i]); |
---|
612 | 609 | } |
---|
613 | 610 | } |
---|
.. | .. |
---|
888 | 885 | int ttm_dma_populate(struct ttm_dma_tt *ttm_dma, struct device *dev, |
---|
889 | 886 | struct ttm_operation_ctx *ctx) |
---|
890 | 887 | { |
---|
| 888 | + struct ttm_mem_global *mem_glob = &ttm_mem_glob; |
---|
891 | 889 | struct ttm_tt *ttm = &ttm_dma->ttm; |
---|
892 | | - struct ttm_mem_global *mem_glob = ttm->bdev->glob->mem_glob; |
---|
893 | 890 | unsigned long num_pages = ttm->num_pages; |
---|
894 | 891 | struct dma_pool *pool; |
---|
895 | 892 | struct dma_page *d_page; |
---|
.. | .. |
---|
897 | 894 | unsigned i; |
---|
898 | 895 | int ret; |
---|
899 | 896 | |
---|
900 | | - if (ttm->state != tt_unpopulated) |
---|
| 897 | + if (ttm_tt_is_populated(ttm)) |
---|
901 | 898 | return 0; |
---|
902 | 899 | |
---|
903 | 900 | if (ttm_check_under_lowerlimit(mem_glob, num_pages, ctx)) |
---|
.. | .. |
---|
985 | 982 | } |
---|
986 | 983 | } |
---|
987 | 984 | |
---|
988 | | - ttm->state = tt_unbound; |
---|
| 985 | + ttm_tt_set_populated(ttm); |
---|
989 | 986 | return 0; |
---|
990 | 987 | } |
---|
991 | 988 | EXPORT_SYMBOL_GPL(ttm_dma_populate); |
---|
.. | .. |
---|
993 | 990 | /* Put all pages in pages list to correct pool to wait for reuse */ |
---|
994 | 991 | void ttm_dma_unpopulate(struct ttm_dma_tt *ttm_dma, struct device *dev) |
---|
995 | 992 | { |
---|
| 993 | + struct ttm_mem_global *mem_glob = &ttm_mem_glob; |
---|
996 | 994 | struct ttm_tt *ttm = &ttm_dma->ttm; |
---|
997 | | - struct ttm_mem_global *mem_glob = ttm->bdev->glob->mem_glob; |
---|
998 | 995 | struct dma_pool *pool; |
---|
999 | 996 | struct dma_page *d_page, *next; |
---|
1000 | 997 | enum pool_type type; |
---|
.. | .. |
---|
1079 | 1076 | /* shrink pool if necessary (only on !is_cached pools)*/ |
---|
1080 | 1077 | if (npages) |
---|
1081 | 1078 | ttm_dma_page_pool_free(pool, npages, false); |
---|
1082 | | - ttm->state = tt_unpopulated; |
---|
| 1079 | + ttm_tt_set_unpopulated(ttm); |
---|
1083 | 1080 | } |
---|
1084 | 1081 | EXPORT_SYMBOL_GPL(ttm_dma_unpopulate); |
---|
1085 | 1082 | |
---|
.. | .. |
---|
1240 | 1237 | return 0; |
---|
1241 | 1238 | } |
---|
1242 | 1239 | EXPORT_SYMBOL_GPL(ttm_dma_page_alloc_debugfs); |
---|
1243 | | - |
---|
1244 | | -#endif |
---|