Skip to contentSkip to conversation

drm/amdgpu: validate if sw_init is defined or NULL

PATCH New Sunil Khatri 1 participant 2 messages Oct 9, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 drm/amdgpu: validate if sw_init is defined or NULL

Before making a function call to sw_init, validate the function pointer.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +6 -4
index 38a7423101f3..782f01ab39e2 100644
@@ -2851,11 +2851,13 @@ static int amdgpu_device_ip_init(struct amdgpu_device *adev)
 	for (i = 0; i < adev->num_ip_blocks; i++) {
 		if (!adev->ip_blocks[i].status.valid)
 			continue;
-		r = adev->ip_blocks[i].version->funcs->sw_init(&adev->ip_blocks[i]);
-		if (r) {
-			DRM_ERROR("sw_init of IP block <%s> failed %d\n",
+		if (adev->ip_blocks[i].version->funcs->sw_init) {
+			r = adev->ip_blocks[i].version->funcs->sw_init(&adev->ip_blocks[i]);
+			if (r) {
+				DRM_ERROR("sw_init of IP block <%s> failed %d\n",
 				  adev->ip_blocks[i].version->funcs->name, r);
-			goto init_failed;
+				goto init_failed;
+			}
 		}
 		adev->ip_blocks[i].status.sw = true;
 
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 2/2 drm/admgpu: clean the dummy sw_init functions

Remove the dummy sw_init functions and set the
corresponding functions to NULL.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c | 5 -----
 drivers/gpu/drm/amd/amdgpu/cik.c        | 7 +------
 drivers/gpu/drm/amd/amdgpu/si.c         | 7 +------
 3 files changed, 2 insertions(+), 17 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.c +0 -5
index adc0b80ca5db..4add6c412779 100644
@@ -33,11 +33,6 @@
 #include "isp_v4_1_0.h"
 #include "isp_v4_1_1.h"
 
-static int isp_sw_init(struct amdgpu_ip_block *ip_block)
-{
-	return 0;
-}
-
 static int isp_sw_fini(struct amdgpu_ip_block *ip_block)
 {
 	return 0;
drivers/gpu/drm/amd/amdgpu/cik.c +1 -6
index 6c18ab35cf69..bb961b274487 100644
@@ -2124,11 +2124,6 @@ static int cik_common_early_init(struct amdgpu_ip_block *ip_block)
 	return 0;
 }
 
-static int cik_common_sw_init(struct amdgpu_ip_block *ip_block)
-{
-	return 0;
-}
-
 static int cik_common_sw_fini(struct amdgpu_ip_block *ip_block)
 {
 	return 0;
@@ -2195,7 +2190,7 @@ static const struct amd_ip_funcs cik_common_ip_funcs = {
 	.name = "cik_common",
 	.early_init = cik_common_early_init,
 	.late_init = NULL,
-	.sw_init = cik_common_sw_init,
+	.sw_init = NULL,
 	.sw_fini = cik_common_sw_fini,
 	.hw_init = cik_common_hw_init,
 	.hw_fini = cik_common_hw_fini,
drivers/gpu/drm/amd/amdgpu/si.c +1 -6
index b9934661a92e..0578c7ce4dc5 100644
@@ -2148,11 +2148,6 @@ static int si_common_early_init(struct amdgpu_ip_block *ip_block)
 	return 0;
 }
 
-static int si_common_sw_init(struct amdgpu_ip_block *ip_block)
-{
-	return 0;
-}
-
 static int si_common_sw_fini(struct amdgpu_ip_block *ip_block)
 {
 	return 0;
@@ -2691,7 +2686,7 @@ static const struct amd_ip_funcs si_common_ip_funcs = {
 	.name = "si_common",
 	.early_init = si_common_early_init,
 	.late_init = NULL,
-	.sw_init = si_common_sw_init,
+	.sw_init = NULL,
 	.sw_fini = si_common_sw_fini,
 	.hw_init = si_common_hw_init,
 	.hw_fini = si_common_hw_fini,
Signature · 1 line
2.34.1