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

drm/amdgpu: only enable swiotlb alloc when need v2

get the max io mapping address of system memory to see if it is over
our card accessing range.
v2: move checking 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-2-david1.zhou@amd.com

authored by

Chunming Zhou and committed by
Alex Deucher
fd5fd480 82626363

+13 -3
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1504 1504 const struct amdgpu_asic_funcs *asic_funcs; 1505 1505 bool shutdown; 1506 1506 bool need_dma32; 1507 + bool need_swiotlb; 1507 1508 bool accel_working; 1508 1509 struct work_struct reset_work; 1509 1510 struct notifier_block acpi_nb;
+3 -3
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
··· 1018 1018 } 1019 1019 1020 1020 #ifdef CONFIG_SWIOTLB 1021 - if (swiotlb_nr_tbl()) { 1021 + if (adev->need_swiotlb && swiotlb_nr_tbl()) { 1022 1022 return ttm_dma_populate(&gtt->ttm, adev->dev, ctx); 1023 1023 } 1024 1024 #endif ··· 1045 1045 adev = amdgpu_ttm_adev(ttm->bdev); 1046 1046 1047 1047 #ifdef CONFIG_SWIOTLB 1048 - if (swiotlb_nr_tbl()) { 1048 + if (adev->need_swiotlb && swiotlb_nr_tbl()) { 1049 1049 ttm_dma_unpopulate(&gtt->ttm, adev->dev); 1050 1050 return; 1051 1051 } ··· 2010 2010 count = ARRAY_SIZE(amdgpu_ttm_debugfs_list); 2011 2011 2012 2012 #ifdef CONFIG_SWIOTLB 2013 - if (!swiotlb_nr_tbl()) 2013 + if (!(adev->need_swiotlb && swiotlb_nr_tbl())) 2014 2014 --count; 2015 2015 #endif 2016 2016
+2
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c
··· 22 22 */ 23 23 #include <linux/firmware.h> 24 24 #include <drm/drmP.h> 25 + #include <drm/drm_cache.h> 25 26 #include "amdgpu.h" 26 27 #include "gmc_v6_0.h" 27 28 #include "amdgpu_ucode.h" ··· 852 851 pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(32)); 853 852 dev_warn(adev->dev, "amdgpu: No coherent DMA available.\n"); 854 853 } 854 + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 855 855 856 856 r = gmc_v6_0_init_microcode(adev); 857 857 if (r) {
+2
drivers/gpu/drm/amd/amdgpu/gmc_v7_0.c
··· 22 22 */ 23 23 #include <linux/firmware.h> 24 24 #include <drm/drmP.h> 25 + #include <drm/drm_cache.h> 25 26 #include "amdgpu.h" 26 27 #include "cikd.h" 27 28 #include "cik.h" ··· 1000 999 pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(32)); 1001 1000 pr_warn("amdgpu: No coherent DMA available\n"); 1002 1001 } 1002 + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 1003 1003 1004 1004 r = gmc_v7_0_init_microcode(adev); 1005 1005 if (r) {
+3
drivers/gpu/drm/amd/amdgpu/gmc_v8_0.c
··· 22 22 */ 23 23 #include <linux/firmware.h> 24 24 #include <drm/drmP.h> 25 + #include <drm/drm_cache.h> 25 26 #include "amdgpu.h" 26 27 #include "gmc_v8_0.h" 27 28 #include "amdgpu_ucode.h" ··· 1086 1085 */ 1087 1086 adev->need_dma32 = false; 1088 1087 dma_bits = adev->need_dma32 ? 32 : 40; 1088 + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 1089 1089 r = pci_set_dma_mask(adev->pdev, DMA_BIT_MASK(dma_bits)); 1090 1090 if (r) { 1091 1091 adev->need_dma32 = true; ··· 1098 1096 pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(32)); 1099 1097 pr_warn("amdgpu: No coherent DMA available\n"); 1100 1098 } 1099 + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 1101 1100 1102 1101 r = gmc_v8_0_init_microcode(adev); 1103 1102 if (r) {
+2
drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
··· 21 21 * 22 22 */ 23 23 #include <linux/firmware.h> 24 + #include <drm/drm_cache.h> 24 25 #include "amdgpu.h" 25 26 #include "gmc_v9_0.h" 26 27 #include "amdgpu_atomfirmware.h" ··· 851 850 pci_set_consistent_dma_mask(adev->pdev, DMA_BIT_MASK(32)); 852 851 printk(KERN_WARNING "amdgpu: No coherent DMA available.\n"); 853 852 } 853 + adev->need_swiotlb = drm_get_max_iomem() > ((u64)1 << dma_bits); 854 854 855 855 r = gmc_v9_0_mc_init(adev); 856 856 if (r)