From 60bc04ac4f73c58f604bb2a80d65fca2c9059482 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luis=20Guzm=C3=A1n?= <ark@switnet.org>
Date: Wed, 9 Mar 2022 21:48:37 +0000
Subject: [PATCH] ni.c hwe enable blobless 10.0

---
 .../silent-accept-firmware.patch              | 82 -------------------
 .../silent-accept-firmware.patch              | 82 -------------------
 helpers/make-linux-hwe-5.13                   |  5 +-
 helpers/make-linux-hwe-5.8                    |  5 +-
 4 files changed, 8 insertions(+), 166 deletions(-)

diff --git a/helpers/DATA/linux-hwe-5.13/silent-accept-firmware.patch b/helpers/DATA/linux-hwe-5.13/silent-accept-firmware.patch
index bc33bb357..2db482cd5 100644
--- a/helpers/DATA/linux-hwe-5.13/silent-accept-firmware.patch
+++ b/helpers/DATA/linux-hwe-5.13/silent-accept-firmware.patch
@@ -682,88 +682,6 @@ diff -ru a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
  		release_firmware(rdev->pfp_fw);
  		rdev->pfp_fw = NULL;
  		release_firmware(rdev->me_fw);
-diff -ru a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
---- a/drivers/gpu/drm/radeon/ni.c	2021-06-14 01:15:31.736706702 +0200
-+++ b/drivers/gpu/drm/radeon/ni.c	2021-06-14 01:16:26.480820708 +0200
-@@ -770,15 +770,15 @@
- 	default: BUG();
- 	}
- 
--	DRM_INFO("Loading %s Microcode\n", chip_name);
-+	DRM_INFO("Loading Microcode\n");
- 
- 	snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
- 	err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
- 	if (err)
- 		goto out;
- 	if (rdev->pfp_fw->size != pfp_req_size) {
--		pr_err("ni_cp: Bogus length %zu in firmware \"%s\"\n",
--		       rdev->pfp_fw->size, fw_name);
-+		pr_err("ni_cp: Bogus length %zu in firmware\n",
-+		       rdev->pfp_fw->size);
- 		err = -EINVAL;
- 		goto out;
- 	}
-@@ -788,8 +788,8 @@
- 	if (err)
- 		goto out;
- 	if (rdev->me_fw->size != me_req_size) {
--		pr_err("ni_cp: Bogus length %zu in firmware \"%s\"\n",
--		       rdev->me_fw->size, fw_name);
-+		pr_err("ni_cp: Bogus length %zu in firmware\n",
-+		       rdev->me_fw->size);
- 		err = -EINVAL;
- 	}
- 
-@@ -798,8 +798,8 @@
- 	if (err)
- 		goto out;
- 	if (rdev->rlc_fw->size != rlc_req_size) {
--		pr_err("ni_rlc: Bogus length %zu in firmware \"%s\"\n",
--		       rdev->rlc_fw->size, fw_name);
-+		pr_err("ni_rlc: Bogus length %zu in firmware\n",
-+		       rdev->rlc_fw->size);
- 		err = -EINVAL;
- 	}
- 
-@@ -810,8 +810,8 @@
- 		if (err)
- 			goto out;
- 		if (rdev->mc_fw->size != mc_req_size) {
--			pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
--			       rdev->mc_fw->size, fw_name);
-+			pr_err("ni_mc: Bogus length %zu in firmware\n",
-+			       rdev->mc_fw->size);
- 			err = -EINVAL;
- 		}
- 	}
-@@ -820,13 +820,13 @@
- 		snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
- 		err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
- 		if (err) {
--			pr_err("smc: error loading firmware \"%s\"\n", fw_name);
-+			pr_err("smc: error loading firmware\n");
- 			release_firmware(rdev->smc_fw);
- 			rdev->smc_fw = NULL;
- 			err = 0;
- 		} else if (rdev->smc_fw->size != smc_req_size) {
--			pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
--			       rdev->mc_fw->size, fw_name);
-+			pr_err("ni_mc: Bogus length %zu in firmware\n",
-+			       rdev->mc_fw->size);
- 			err = -EINVAL;
- 		}
- 	}
-@@ -834,8 +834,7 @@
- out:
- 	if (err) {
- 		if (err != -EINVAL)
--			pr_err("ni_cp: Failed to load firmware \"%s\"\n",
--			       fw_name);
-+			pr_err("ni_cp: Failed to load firmware\n");
- 		release_firmware(rdev->pfp_fw);
- 		rdev->pfp_fw = NULL;
- 		release_firmware(rdev->me_fw);
 diff -ru a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
 --- a/drivers/gpu/drm/radeon/r100.c	2021-06-14 01:15:31.736706702 +0200
 +++ b/drivers/gpu/drm/radeon/r100.c	2021-06-14 01:37:19.785010983 +0200
diff --git a/helpers/DATA/linux-hwe-5.8/silent-accept-firmware.patch b/helpers/DATA/linux-hwe-5.8/silent-accept-firmware.patch
index 25fe17448..eca2a2432 100644
--- a/helpers/DATA/linux-hwe-5.8/silent-accept-firmware.patch
+++ b/helpers/DATA/linux-hwe-5.8/silent-accept-firmware.patch
@@ -679,88 +679,6 @@ diff -ru a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
  		release_firmware(rdev->pfp_fw);
  		rdev->pfp_fw = NULL;
  		release_firmware(rdev->me_fw);
-diff -ru a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
---- a/drivers/gpu/drm/radeon/ni.c	2021-06-14 01:15:31.736706702 +0200
-+++ b/drivers/gpu/drm/radeon/ni.c	2021-06-14 01:16:26.480820708 +0200
-@@ -770,15 +770,15 @@
- 	default: BUG();
- 	}
- 
--	DRM_INFO("Loading %s Microcode\n", chip_name);
-+	DRM_INFO("Loading Microcode\n");
- 
- 	snprintf(fw_name, sizeof(fw_name), "radeon/%s_pfp.bin", chip_name);
- 	err = request_firmware(&rdev->pfp_fw, fw_name, rdev->dev);
- 	if (err)
- 		goto out;
- 	if (rdev->pfp_fw->size != pfp_req_size) {
--		pr_err("ni_cp: Bogus length %zu in firmware \"%s\"\n",
--		       rdev->pfp_fw->size, fw_name);
-+		pr_err("ni_cp: Bogus length %zu in firmware\n",
-+		       rdev->pfp_fw->size);
- 		err = -EINVAL;
- 		goto out;
- 	}
-@@ -788,8 +788,8 @@
- 	if (err)
- 		goto out;
- 	if (rdev->me_fw->size != me_req_size) {
--		pr_err("ni_cp: Bogus length %zu in firmware \"%s\"\n",
--		       rdev->me_fw->size, fw_name);
-+		pr_err("ni_cp: Bogus length %zu in firmware\n",
-+		       rdev->me_fw->size);
- 		err = -EINVAL;
- 	}
- 
-@@ -798,8 +798,8 @@
- 	if (err)
- 		goto out;
- 	if (rdev->rlc_fw->size != rlc_req_size) {
--		pr_err("ni_rlc: Bogus length %zu in firmware \"%s\"\n",
--		       rdev->rlc_fw->size, fw_name);
-+		pr_err("ni_rlc: Bogus length %zu in firmware\n",
-+		       rdev->rlc_fw->size);
- 		err = -EINVAL;
- 	}
- 
-@@ -810,8 +810,8 @@
- 		if (err)
- 			goto out;
- 		if (rdev->mc_fw->size != mc_req_size) {
--			pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
--			       rdev->mc_fw->size, fw_name);
-+			pr_err("ni_mc: Bogus length %zu in firmware\n",
-+			       rdev->mc_fw->size);
- 			err = -EINVAL;
- 		}
- 	}
-@@ -820,13 +820,13 @@
- 		snprintf(fw_name, sizeof(fw_name), "radeon/%s_smc.bin", chip_name);
- 		err = request_firmware(&rdev->smc_fw, fw_name, rdev->dev);
- 		if (err) {
--			pr_err("smc: error loading firmware \"%s\"\n", fw_name);
-+			pr_err("smc: error loading firmware\n");
- 			release_firmware(rdev->smc_fw);
- 			rdev->smc_fw = NULL;
- 			err = 0;
- 		} else if (rdev->smc_fw->size != smc_req_size) {
--			pr_err("ni_mc: Bogus length %zu in firmware \"%s\"\n",
--			       rdev->mc_fw->size, fw_name);
-+			pr_err("ni_mc: Bogus length %zu in firmware\n",
-+			       rdev->mc_fw->size);
- 			err = -EINVAL;
- 		}
- 	}
-@@ -834,8 +834,7 @@
- out:
- 	if (err) {
- 		if (err != -EINVAL)
--			pr_err("ni_cp: Failed to load firmware \"%s\"\n",
--			       fw_name);
-+			pr_err("ni_cp: Failed to load firmware\n");
- 		release_firmware(rdev->pfp_fw);
- 		rdev->pfp_fw = NULL;
- 		release_firmware(rdev->me_fw);
 diff -ru a/drivers/gpu/drm/radeon/r100.c b/drivers/gpu/drm/radeon/r100.c
 --- a/drivers/gpu/drm/radeon/r100.c	2021-06-14 01:15:31.736706702 +0200
 +++ b/drivers/gpu/drm/radeon/r100.c	2021-06-14 01:37:19.785010983 +0200
diff --git a/helpers/make-linux-hwe-5.13 b/helpers/make-linux-hwe-5.13
index dd9e33347..88c5aaea8 100644
--- a/helpers/make-linux-hwe-5.13
+++ b/helpers/make-linux-hwe-5.13
@@ -20,7 +20,7 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=2
+VERSION=3
 
 . ./config
 
@@ -58,6 +58,9 @@ for DIR in $PRESERVEDIRS; do
   cp $DIR $TMPDIR --parents -a
 done
 
+# Enable blobless activation - https://libreplanet.org/wiki/Group:Hardware/research/gpu/radeon
+rm $TMPDIR/drivers/gpu/drm/radeon/ni.c
+
 sh $DATA/deblob-5.13
 
 echo "Reverting deblobbing for files patched by silent-accept-firmware"
diff --git a/helpers/make-linux-hwe-5.8 b/helpers/make-linux-hwe-5.8
index 275a46ab2..19cbdb5d1 100644
--- a/helpers/make-linux-hwe-5.8
+++ b/helpers/make-linux-hwe-5.8
@@ -20,7 +20,7 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=4
+VERSION=5
 
 . ./config
 
@@ -57,6 +57,9 @@ for DIR in $PRESERVEDIRS; do
   cp $DIR $TMPDIR --parents -a
 done
 
+# Enable blobless activation - https://libreplanet.org/wiki/Group:Hardware/research/gpu/radeon
+rm $TMPDIR/drivers/gpu/drm/radeon/ni.c
+
 sh $DATA/deblob-5.8
 
 echo "Reverting deblobbing for files patched by silent-accept-firmware"
-- 
GitLab