From 6aa339bd361e862edb7724a4c61969ed72f3035f Mon Sep 17 00:00:00 2001 From: Gabriel Craciunescu Date: Thu, 12 Apr 2018 03:20:06 +0200 Subject: [PATCH] Make it possible to disable SWIOTLB code on admgpu and radeon added admgpu.swiotlb and radeon.swiotlb option, defaults to disabled since new the code doesn't seems to work good or work at all on some HW. https://lkml.org/lkml/2018/4/5/737 https://bugzilla.kernel.org/show_bug.cgi?id=198511 https://bugs.freedesktop.org/show_bug.cgi?id=105038 --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 10 ++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 20 +++++++++++++------- drivers/gpu/drm/radeon/radeon.h | 1 + drivers/gpu/drm/radeon/radeon_drv.c | 9 +++++++++ drivers/gpu/drm/radeon/radeon_ttm.c | 20 +++++++++++++------- 6 files changed, 47 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 74edba18b159..8371b06e5ecf 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -127,6 +127,7 @@ extern int amdgpu_job_hang_limit; extern int amdgpu_lbpw; extern int amdgpu_compute_multipipe; extern int amdgpu_gpu_recovery; +extern int amdgpu_swiotlb; #ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 50afcf65181a..d67c411fbaad 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -129,6 +129,8 @@ int amdgpu_job_hang_limit = 0; int amdgpu_lbpw = -1; int amdgpu_compute_multipipe = -1; int amdgpu_gpu_recovery = -1; /* auto */ +int amdgpu_swiotlb = 0; + MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); @@ -284,6 +286,9 @@ module_param_named(compute_multipipe, amdgpu_compute_multipipe, int, 0444); MODULE_PARM_DESC(gpu_recovery, "Enable GPU recovery mechanism, (1 = enable, 0 = disable, -1 = auto"); module_param_named(gpu_recovery, amdgpu_gpu_recovery, int, 0444); +MODULE_PARM_DESC(swiotlb, "Enable new SWIOTLB code , (1 = enable , 0 = disable ( default )"); +module_param_named(swiotlb, amdgpu_swiotlb, int, 0444); + #ifdef CONFIG_DRM_AMDGPU_SI #if defined(CONFIG_DRM_RADEON) || defined(CONFIG_DRM_RADEON_MODULE) @@ -918,6 +923,11 @@ static int __init amdgpu_init(void) return -EINVAL; } DRM_INFO("amdgpu kernel modesetting enabled.\n"); + + if(amdgpu_swiotlb) { + DRM_INFO("amdgpu new SWIOTLB code enabled.\n"); + } + driver = &kms_driver; pdriver = &amdgpu_kms_pci_driver; driver->num_ioctls = amdgpu_max_kms_ioctl; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index e4bb435e614b..58cd95c35a54 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1018,8 +1018,10 @@ static int amdgpu_ttm_tt_populate(struct ttm_tt *ttm, } #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { - return ttm_dma_populate(>t->ttm, adev->dev, ctx); + if (amdgpu_swiotlb) { + if (swiotlb_nr_tbl()) { + return ttm_dma_populate(>t->ttm, adev->dev, ctx); + } } #endif @@ -1045,9 +1047,11 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_tt *ttm) adev = amdgpu_ttm_adev(ttm->bdev); #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { - ttm_dma_unpopulate(>t->ttm, adev->dev); - return; + if (amdgpu_swiotlb) { + if (swiotlb_nr_tbl()) { + ttm_dma_unpopulate(>t->ttm, adev->dev); + return; + } } #endif @@ -2010,8 +2014,10 @@ static int amdgpu_ttm_debugfs_init(struct amdgpu_device *adev) count = ARRAY_SIZE(amdgpu_ttm_debugfs_list); #ifdef CONFIG_SWIOTLB - if (!swiotlb_nr_tbl()) - --count; + if (amdgpu_swiotlb) { + if (!swiotlb_nr_tbl()) + --count; + } #endif return amdgpu_debugfs_add_files(adev, amdgpu_ttm_debugfs_list, count); diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index d34887873dea..d614de12e30c 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -117,6 +117,7 @@ extern int radeon_uvd; extern int radeon_vce; extern int radeon_si_support; extern int radeon_cik_support; +extern int radeon_swiotlb; /* * Copy from radeon_drv.h so we don't have to include both and have conflicting diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 31dd04f6baa1..20b1110e4698 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -196,6 +196,7 @@ int radeon_auxch = -1; int radeon_mst = 0; int radeon_uvd = 1; int radeon_vce = 1; +int radeon_swiotlb = 0; MODULE_PARM_DESC(no_wb, "Disable AGP writeback for scratch registers"); module_param_named(no_wb, radeon_no_wb, int, 0444); @@ -301,6 +302,9 @@ int radeon_cik_support = 1; MODULE_PARM_DESC(cik_support, "CIK support (1 = enabled (default), 0 = disabled)"); module_param_named(cik_support, radeon_cik_support, int, 0444); +MODULE_PARM_DESC(swiotlb, "Enable new SWIOTLB code , (1 = enable, 0 = disable ( default )"); +module_param_named(swiotlb, radeon_swiotlb, int, 0444); + static struct pci_device_id pciidlist[] = { radeon_PCI_IDS }; @@ -620,6 +624,11 @@ static int __init radeon_init(void) if (radeon_modeset == 1) { DRM_INFO("radeon kernel modesetting enabled.\n"); + + if(radeon_swiotlb) { + DRM_INFO("radeon new SWIOTLB code enabled.\n"); + } + driver = &kms_driver; pdriver = &radeon_kms_pci_driver; driver->driver_features |= DRIVER_MODESET; diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index a0a839bc39bf..952b1216c729 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -756,8 +756,10 @@ static int radeon_ttm_tt_populate(struct ttm_tt *ttm, #endif #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { - return ttm_dma_populate(>t->ttm, rdev->dev, ctx); + if (radeon_swiotlb) { + if (swiotlb_nr_tbl()) { + return ttm_dma_populate(>t->ttm, rdev->dev, ctx); + } } #endif @@ -788,9 +790,11 @@ static void radeon_ttm_tt_unpopulate(struct ttm_tt *ttm) #endif #ifdef CONFIG_SWIOTLB - if (swiotlb_nr_tbl()) { - ttm_dma_unpopulate(>t->ttm, rdev->dev); - return; + if (radeon_swiotlb) { + if (swiotlb_nr_tbl()) { + ttm_dma_unpopulate(>t->ttm, rdev->dev); + return; + } } #endif @@ -1155,8 +1159,10 @@ static int radeon_ttm_debugfs_init(struct radeon_device *rdev) count = ARRAY_SIZE(radeon_ttm_debugfs_list); #ifdef CONFIG_SWIOTLB - if (!swiotlb_nr_tbl()) - --count; + if (radeon_swiotlb) { + if (!swiotlb_nr_tbl()) + --count; + } #endif return radeon_debugfs_add_files(rdev, radeon_ttm_debugfs_list, count); -- 2.17.0