summaryrefslogtreecommitdiff
path: root/sys-kernel
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2018-04-12 03:15:50 +0100
committerV3n3RiX <venerix@redcorelinux.org>2018-04-12 03:15:50 +0100
commit05dd9a296958364794a0b4910bf9623f51b083f9 (patch)
tree448e3c1f8e93ed9301b99124da2636fca71a968b /sys-kernel
parent120066f9e16553b0569c6a94336b6b688e7a91c1 (diff)
- Workaround amdgpu and radeon issues by adding a new swiotlb option.
defaults to disabled ( old way ) while still possible to enable and test the new way / code. The newer code does not work good or does not work at all on some HW ( mine as example ) see: 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
Diffstat (limited to 'sys-kernel')
-rw-r--r--sys-kernel/linux-image-redcore/Manifest (renamed from sys-kernel/linux-headers/Manifest)0
-rw-r--r--sys-kernel/linux-image-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch206
-rw-r--r--sys-kernel/linux-image-redcore/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch (renamed from sys-kernel/linux-headers/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/0001-Revert-swiotlb-remove-various-exports.patch (renamed from sys-kernel/linux-headers/files/0001-Revert-swiotlb-remove-various-exports.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch (renamed from sys-kernel/linux-headers/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/drop_ancient-and-wrong-msg.patch (renamed from sys-kernel/linux-headers/files/drop_ancient-and-wrong-msg.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/enable_alx_wol.patch (renamed from sys-kernel/linux-headers/files/enable_alx_wol.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/linux-hardened.patch (renamed from sys-kernel/linux-headers/files/linux-hardened.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/mute-pps_state_mismatch.patch (renamed from sys-kernel/linux-headers/files/mute-pps_state_mismatch.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/nouveau-pascal-backlight.patch (renamed from sys-kernel/linux-headers/files/nouveau-pascal-backlight.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/files/redcore-amd64.config (renamed from sys-kernel/linux-headers/files/redcore-amd64.config)0
-rw-r--r--sys-kernel/linux-image-redcore/files/uksm-for-linux-hardened.patch (renamed from sys-kernel/linux-headers/files/uksm-for-linux-hardened.patch)0
-rw-r--r--sys-kernel/linux-image-redcore/linux-image-redcore-4.16.1.ebuild (renamed from sys-kernel/linux-image/linux-image-4.16.1.ebuild)3
-rw-r--r--sys-kernel/linux-sources-redcore/Manifest (renamed from sys-kernel/linux-image/Manifest)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch206
-rw-r--r--sys-kernel/linux-sources-redcore/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch (renamed from sys-kernel/linux-image/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/0001-Revert-swiotlb-remove-various-exports.patch (renamed from sys-kernel/linux-image/files/0001-Revert-swiotlb-remove-various-exports.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch (renamed from sys-kernel/linux-image/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/drop_ancient-and-wrong-msg.patch (renamed from sys-kernel/linux-image/files/drop_ancient-and-wrong-msg.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/enable_alx_wol.patch (renamed from sys-kernel/linux-image/files/enable_alx_wol.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/linux-hardened.patch (renamed from sys-kernel/linux-image/files/linux-hardened.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/mute-pps_state_mismatch.patch (renamed from sys-kernel/linux-image/files/mute-pps_state_mismatch.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/nouveau-pascal-backlight.patch (renamed from sys-kernel/linux-image/files/nouveau-pascal-backlight.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/redcore-amd64.config (renamed from sys-kernel/linux-image/files/redcore-amd64.config)0
-rw-r--r--sys-kernel/linux-sources-redcore/files/uksm-for-linux-hardened.patch (renamed from sys-kernel/linux-image/files/uksm-for-linux-hardened.patch)0
-rw-r--r--sys-kernel/linux-sources-redcore/linux-sources-redcore-4.16.1.ebuild (renamed from sys-kernel/linux-headers/linux-headers-4.16.1.ebuild)1
26 files changed, 415 insertions, 1 deletions
diff --git a/sys-kernel/linux-headers/Manifest b/sys-kernel/linux-image-redcore/Manifest
index bdc08839..bdc08839 100644
--- a/sys-kernel/linux-headers/Manifest
+++ b/sys-kernel/linux-image-redcore/Manifest
diff --git a/sys-kernel/linux-image-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch b/sys-kernel/linux-image-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch
new file mode 100644
index 00000000..1d988b37
--- /dev/null
+++ b/sys-kernel/linux-image-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch
@@ -0,0 +1,206 @@
+From 6aa339bd361e862edb7724a4c61969ed72f3035f Mon Sep 17 00:00:00 2001
+From: Gabriel Craciunescu <nix.or.die@gmail.com>
+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(&gtt->ttm, adev->dev, ctx);
++ if (amdgpu_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ return ttm_dma_populate(&gtt->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(&gtt->ttm, adev->dev);
+- return;
++ if (amdgpu_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ ttm_dma_unpopulate(&gtt->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(&gtt->ttm, rdev->dev, ctx);
++ if (radeon_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ return ttm_dma_populate(&gtt->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(&gtt->ttm, rdev->dev);
+- return;
++ if (radeon_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ ttm_dma_unpopulate(&gtt->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
+
diff --git a/sys-kernel/linux-headers/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch b/sys-kernel/linux-image-redcore/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
index 281ede4b..281ede4b 100644
--- a/sys-kernel/linux-headers/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
+++ b/sys-kernel/linux-image-redcore/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
diff --git a/sys-kernel/linux-headers/files/0001-Revert-swiotlb-remove-various-exports.patch b/sys-kernel/linux-image-redcore/files/0001-Revert-swiotlb-remove-various-exports.patch
index 71133922..71133922 100644
--- a/sys-kernel/linux-headers/files/0001-Revert-swiotlb-remove-various-exports.patch
+++ b/sys-kernel/linux-image-redcore/files/0001-Revert-swiotlb-remove-various-exports.patch
diff --git a/sys-kernel/linux-headers/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch b/sys-kernel/linux-image-redcore/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
index e8f3bfda..e8f3bfda 100644
--- a/sys-kernel/linux-headers/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
+++ b/sys-kernel/linux-image-redcore/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
diff --git a/sys-kernel/linux-headers/files/drop_ancient-and-wrong-msg.patch b/sys-kernel/linux-image-redcore/files/drop_ancient-and-wrong-msg.patch
index f184b08e..f184b08e 100644
--- a/sys-kernel/linux-headers/files/drop_ancient-and-wrong-msg.patch
+++ b/sys-kernel/linux-image-redcore/files/drop_ancient-and-wrong-msg.patch
diff --git a/sys-kernel/linux-headers/files/enable_alx_wol.patch b/sys-kernel/linux-image-redcore/files/enable_alx_wol.patch
index f9347bfa..f9347bfa 100644
--- a/sys-kernel/linux-headers/files/enable_alx_wol.patch
+++ b/sys-kernel/linux-image-redcore/files/enable_alx_wol.patch
diff --git a/sys-kernel/linux-headers/files/linux-hardened.patch b/sys-kernel/linux-image-redcore/files/linux-hardened.patch
index 94b56b85..94b56b85 100644
--- a/sys-kernel/linux-headers/files/linux-hardened.patch
+++ b/sys-kernel/linux-image-redcore/files/linux-hardened.patch
diff --git a/sys-kernel/linux-headers/files/mute-pps_state_mismatch.patch b/sys-kernel/linux-image-redcore/files/mute-pps_state_mismatch.patch
index 5bc1eff7..5bc1eff7 100644
--- a/sys-kernel/linux-headers/files/mute-pps_state_mismatch.patch
+++ b/sys-kernel/linux-image-redcore/files/mute-pps_state_mismatch.patch
diff --git a/sys-kernel/linux-headers/files/nouveau-pascal-backlight.patch b/sys-kernel/linux-image-redcore/files/nouveau-pascal-backlight.patch
index 754d982a..754d982a 100644
--- a/sys-kernel/linux-headers/files/nouveau-pascal-backlight.patch
+++ b/sys-kernel/linux-image-redcore/files/nouveau-pascal-backlight.patch
diff --git a/sys-kernel/linux-headers/files/redcore-amd64.config b/sys-kernel/linux-image-redcore/files/redcore-amd64.config
index 69121c88..69121c88 100644
--- a/sys-kernel/linux-headers/files/redcore-amd64.config
+++ b/sys-kernel/linux-image-redcore/files/redcore-amd64.config
diff --git a/sys-kernel/linux-headers/files/uksm-for-linux-hardened.patch b/sys-kernel/linux-image-redcore/files/uksm-for-linux-hardened.patch
index 733618de..733618de 100644
--- a/sys-kernel/linux-headers/files/uksm-for-linux-hardened.patch
+++ b/sys-kernel/linux-image-redcore/files/uksm-for-linux-hardened.patch
diff --git a/sys-kernel/linux-image/linux-image-4.16.1.ebuild b/sys-kernel/linux-image-redcore/linux-image-redcore-4.16.1.ebuild
index 3c2b1f3d..e2aef197 100644
--- a/sys-kernel/linux-image/linux-image-4.16.1.ebuild
+++ b/sys-kernel/linux-image-redcore/linux-image-redcore-4.16.1.ebuild
@@ -26,7 +26,7 @@ DEPEND="
cryptsetup? ( sys-fs/cryptsetup )
dmraid? ( sys-fs/dmraid )
dracut? ( sys-kernel/dracut )
- dkms? ( sys-kernel/dkms ~sys-kernel/linux-headers-${PV} )
+ dkms? ( sys-kernel/dkms ~sys-kernel/linux-sources-redcore-${PV} )
mdadm? ( sys-fs/mdadm )
>=sys-kernel/linux-firmware-20180314"
RDEPEND="${DEPEND}"
@@ -35,6 +35,7 @@ PATCHES=( "${FILESDIR}"/enable_alx_wol.patch
"${FILESDIR}"/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
"${FILESDIR}"/0001-Revert-swiotlb-remove-various-exports.patch
"${FILESDIR}"/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
+ "${FILESDIR}"/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch
"${FILESDIR}"/mute-pps_state_mismatch.patch
"${FILESDIR}"/drop_ancient-and-wrong-msg.patch
"${FILESDIR}"/nouveau-pascal-backlight.patch
diff --git a/sys-kernel/linux-image/Manifest b/sys-kernel/linux-sources-redcore/Manifest
index bdc08839..bdc08839 100644
--- a/sys-kernel/linux-image/Manifest
+++ b/sys-kernel/linux-sources-redcore/Manifest
diff --git a/sys-kernel/linux-sources-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch b/sys-kernel/linux-sources-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch
new file mode 100644
index 00000000..1d988b37
--- /dev/null
+++ b/sys-kernel/linux-sources-redcore/files/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch
@@ -0,0 +1,206 @@
+From 6aa339bd361e862edb7724a4c61969ed72f3035f Mon Sep 17 00:00:00 2001
+From: Gabriel Craciunescu <nix.or.die@gmail.com>
+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(&gtt->ttm, adev->dev, ctx);
++ if (amdgpu_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ return ttm_dma_populate(&gtt->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(&gtt->ttm, adev->dev);
+- return;
++ if (amdgpu_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ ttm_dma_unpopulate(&gtt->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(&gtt->ttm, rdev->dev, ctx);
++ if (radeon_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ return ttm_dma_populate(&gtt->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(&gtt->ttm, rdev->dev);
+- return;
++ if (radeon_swiotlb) {
++ if (swiotlb_nr_tbl()) {
++ ttm_dma_unpopulate(&gtt->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
+
diff --git a/sys-kernel/linux-image/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch b/sys-kernel/linux-sources-redcore/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
index 281ede4b..281ede4b 100644
--- a/sys-kernel/linux-image/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
+++ b/sys-kernel/linux-sources-redcore/files/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
diff --git a/sys-kernel/linux-image/files/0001-Revert-swiotlb-remove-various-exports.patch b/sys-kernel/linux-sources-redcore/files/0001-Revert-swiotlb-remove-various-exports.patch
index 71133922..71133922 100644
--- a/sys-kernel/linux-image/files/0001-Revert-swiotlb-remove-various-exports.patch
+++ b/sys-kernel/linux-sources-redcore/files/0001-Revert-swiotlb-remove-various-exports.patch
diff --git a/sys-kernel/linux-image/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch b/sys-kernel/linux-sources-redcore/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
index e8f3bfda..e8f3bfda 100644
--- a/sys-kernel/linux-image/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
+++ b/sys-kernel/linux-sources-redcore/files/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
diff --git a/sys-kernel/linux-image/files/drop_ancient-and-wrong-msg.patch b/sys-kernel/linux-sources-redcore/files/drop_ancient-and-wrong-msg.patch
index f184b08e..f184b08e 100644
--- a/sys-kernel/linux-image/files/drop_ancient-and-wrong-msg.patch
+++ b/sys-kernel/linux-sources-redcore/files/drop_ancient-and-wrong-msg.patch
diff --git a/sys-kernel/linux-image/files/enable_alx_wol.patch b/sys-kernel/linux-sources-redcore/files/enable_alx_wol.patch
index f9347bfa..f9347bfa 100644
--- a/sys-kernel/linux-image/files/enable_alx_wol.patch
+++ b/sys-kernel/linux-sources-redcore/files/enable_alx_wol.patch
diff --git a/sys-kernel/linux-image/files/linux-hardened.patch b/sys-kernel/linux-sources-redcore/files/linux-hardened.patch
index 94b56b85..94b56b85 100644
--- a/sys-kernel/linux-image/files/linux-hardened.patch
+++ b/sys-kernel/linux-sources-redcore/files/linux-hardened.patch
diff --git a/sys-kernel/linux-image/files/mute-pps_state_mismatch.patch b/sys-kernel/linux-sources-redcore/files/mute-pps_state_mismatch.patch
index 5bc1eff7..5bc1eff7 100644
--- a/sys-kernel/linux-image/files/mute-pps_state_mismatch.patch
+++ b/sys-kernel/linux-sources-redcore/files/mute-pps_state_mismatch.patch
diff --git a/sys-kernel/linux-image/files/nouveau-pascal-backlight.patch b/sys-kernel/linux-sources-redcore/files/nouveau-pascal-backlight.patch
index 754d982a..754d982a 100644
--- a/sys-kernel/linux-image/files/nouveau-pascal-backlight.patch
+++ b/sys-kernel/linux-sources-redcore/files/nouveau-pascal-backlight.patch
diff --git a/sys-kernel/linux-image/files/redcore-amd64.config b/sys-kernel/linux-sources-redcore/files/redcore-amd64.config
index 69121c88..69121c88 100644
--- a/sys-kernel/linux-image/files/redcore-amd64.config
+++ b/sys-kernel/linux-sources-redcore/files/redcore-amd64.config
diff --git a/sys-kernel/linux-image/files/uksm-for-linux-hardened.patch b/sys-kernel/linux-sources-redcore/files/uksm-for-linux-hardened.patch
index 733618de..733618de 100644
--- a/sys-kernel/linux-image/files/uksm-for-linux-hardened.patch
+++ b/sys-kernel/linux-sources-redcore/files/uksm-for-linux-hardened.patch
diff --git a/sys-kernel/linux-headers/linux-headers-4.16.1.ebuild b/sys-kernel/linux-sources-redcore/linux-sources-redcore-4.16.1.ebuild
index 9aaf8db0..632d55b4 100644
--- a/sys-kernel/linux-headers/linux-headers-4.16.1.ebuild
+++ b/sys-kernel/linux-sources-redcore/linux-sources-redcore-4.16.1.ebuild
@@ -29,6 +29,7 @@ PATCHES=( "${FILESDIR}"/enable_alx_wol.patch
"${FILESDIR}"/0001-Revert-ath10k-activate-user-space-firmware-loading-a.patch
"${FILESDIR}"/0001-Revert-swiotlb-remove-various-exports.patch
"${FILESDIR}"/0001-Revert-x86-ACPI-cstate-Allow-ACPI-C1-FFH-MWAIT-use-o.patch
+ "${FILESDIR}"/0001-Make-it-possible-to-disable-SWIOTLB-code-on-admgpu-a.patch
"${FILESDIR}"/mute-pps_state_mismatch.patch
"${FILESDIR}"/drop_ancient-and-wrong-msg.patch
"${FILESDIR}"/nouveau-pascal-backlight.patch