Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/radeon: only enable swiotlb path when need v2

swiotlb expands our card accessing range, but its path always is slower
than ttm pool allocation.
So add condition to use it.
v2: move a bit later

Signed-off-by: Chunming Zhou <david1.zhou@amd.com>
Reviewed-by: Monk Liu <monk.liu@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180209024410.1469-3-david1.zhou@amd.com

authored by

Chunming Zhou and committed by
Alex Deucher
1bc3d3cc fd5fd480

+6 -3
+1
drivers/gpu/drm/radeon/radeon.h
··· 2387 2387 struct radeon_dummy_page dummy_page; 2388 2388 bool shutdown; 2389 2389 bool need_dma32; 2390 + bool need_swiotlb; 2390 2391 bool accel_working; 2391 2392 bool fastfb_working; /* IGP feature*/ 2392 2393 bool needs_reset, in_reset;
+2
drivers/gpu/drm/radeon/radeon_device.c
··· 29 29 #include <linux/slab.h> 30 30 #include <drm/drmP.h> 31 31 #include <drm/drm_crtc_helper.h> 32 + #include <drm/drm_cache.h> 32 33 #include <drm/radeon_drm.h> 33 34 #include <linux/pm_runtime.h> 34 35 #include <linux/vgaarb.h> ··· 1379 1378 pci_set_consistent_dma_mask(rdev->pdev, DMA_BIT_MASK(32)); 1380 1379 pr_warn("radeon: No coherent DMA available\n"); 1381 1380 } 1381 + rdev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 1382 1382 1383 1383 /* Registers mapping */ 1384 1384 /* TODO: block userspace mapping of io register */
+3 -3
drivers/gpu/drm/radeon/radeon_ttm.c
··· 756 756 #endif 757 757 758 758 #ifdef CONFIG_SWIOTLB 759 - if (swiotlb_nr_tbl()) { 759 + if (rdev->need_swiotlb && swiotlb_nr_tbl()) { 760 760 return ttm_dma_populate(&gtt->ttm, rdev->dev, ctx); 761 761 } 762 762 #endif ··· 788 788 #endif 789 789 790 790 #ifdef CONFIG_SWIOTLB 791 - if (swiotlb_nr_tbl()) { 791 + if (rdev->need_swiotlb && swiotlb_nr_tbl()) { 792 792 ttm_dma_unpopulate(&gtt->ttm, rdev->dev); 793 793 return; 794 794 } ··· 1155 1155 count = ARRAY_SIZE(radeon_ttm_debugfs_list); 1156 1156 1157 1157 #ifdef CONFIG_SWIOTLB 1158 - if (!swiotlb_nr_tbl()) 1158 + if (!(rdev->need_swiotlb && swiotlb_nr_tbl())) 1159 1159 --count; 1160 1160 #endif 1161 1161