Skip to contentSkip to conversation

drm/amdgpu: return an error instead of BUG() for CSA bo_va

PATCH In review Alex Deucher 3 participants 32 messages Jul 7 – Jul 8

Subsystems (3)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/30 drm/amdgpu: return an error instead of BUG() for CSA bo_va

If the bo_va is not present, return an error rather than crashing the kernel.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +2 -1
index a0ca6ab358c55..dc263553e216b 100644
@@ -1121,7 +1121,8 @@ static int amdgpu_cs_vm_handling(struct amdgpu_cs_parser *p)
 
 	if (fpriv->csa_va) {
 		bo_va = fpriv->csa_va;
-		BUG_ON(!bo_va);
+		if (!bo_va)
+			return -ENOMEM;
 		r = amdgpu_vm_bo_update(adev, bo_va, false);
 		if (r)
 			return r;
Signature · 1 line
2.55.0
author maintainer
#1 lore raw

PATCH 2/30 drm/amdgpu/gfx11: WARN() rather than BUG() for invalid SDMA engine

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v11.c +2 -1
index aaccf0b9947d4..d32ea91eeb343 100644
@@ -139,7 +139,8 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
 				regSDMA1_QUEUE0_RB_CNTL) - regSDMA0_QUEUE0_RB_CNTL;
 		break;
 	default:
-		BUG();
+		WARN(1, "Invalid SDMA engine id %d\n", engine_id);
+		break;
 	}
 
 	sdma_rlc_reg_offset = sdma_engine_reg_base
Signature · 1 line
2.55.0
author maintainer
#2 lore raw

PATCH 3/30 drm/amdgpu/gfx12: WARN() rather than BUG() for invalid SDMA engine

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12.c +2 -1
index e0ceab400b2da..f37d51ed9a6b0 100644
@@ -90,7 +90,8 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
 				regSDMA1_QUEUE0_RB_CNTL) - regSDMA0_QUEUE0_RB_CNTL;
 		break;
 	default:
-		BUG();
+		WARN(1, "Invalid SDMA engine id %d\n", engine_id);
+		break;
 	}
 
 	sdma_rlc_reg_offset = sdma_engine_reg_base
Signature · 1 line
2.55.0
author maintainer
#3 lore raw

PATCH 4/30 drm/amdgpu/gfx12.1: WARN() rather than BUG() for invalid SDMA engine

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v12_1.c +2 -1
index bcb180f9d3ff8..38ca1aea33b2f 100644
@@ -93,7 +93,8 @@ static uint32_t get_sdma_rlc_reg_offset(struct amdgpu_device *adev,
 				regSDMA1_SDMA_QUEUE0_RB_CNTL) - regSDMA0_SDMA_QUEUE0_RB_CNTL;
 		break;
 	default:
-		BUG();
+		WARN(1, "Invalid SDMA engine id %d\n", engine_id);
+		break;
 	}
 
 	sdma_rlc_reg_offset = sdma_engine_reg_base
Signature · 1 line
2.55.0
author maintainer
#4 lore raw

PATCH 5/30 drm/amdgpu/atomfirmware: WARN() rather than BUG()

In reply to Alex Deucher

There's no need to crash the kernel for this case. Just return an error.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c +0 -2
index 6860a3a4d4667..1e21e3444802b 100644
@@ -917,8 +917,6 @@ int amdgpu_atomfirmware_get_clock_info(struct amdgpu_device *adev)
 				   (crev != 6)) {
 				spll->reference_freq = le32_to_cpu(gfx_info->v22.rlc_gpu_timer_refclk);
 				ret = 0;
-			} else {
-				BUG();
 			}
 		}
 	}
Signature · 1 line
2.55.0
author maintainer
#5 lore raw

PATCH 6/30 drm/amdgpu/cgs: WARN() rather than BUG()

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +3 -5
index 09c8942c22d3b..b90ed81be420a 100644
@@ -76,10 +76,9 @@ static uint32_t amdgpu_cgs_read_ind_register(struct cgs_device *cgs_device,
 		DRM_ERROR("audio endpt register access not implemented.\n");
 		return 0;
 	default:
-		BUG();
+		WARN(1, "Invalid indirect register space");
+		return 0;
 	}
-	WARN(1, "Invalid indirect register space");
-	return 0;
 }
 
 static void amdgpu_cgs_write_ind_register(struct cgs_device *cgs_device,
@@ -104,9 +103,8 @@ static void amdgpu_cgs_write_ind_register(struct cgs_device *cgs_device,
 		DRM_ERROR("audio endpt register access not implemented.\n");
 		return;
 	default:
-		BUG();
+		WARN(1, "Invalid indirect register space");
 	}
-	WARN(1, "Invalid indirect register space");
 }
 
 static uint32_t fw_type_convert(struct cgs_device *cgs_device, uint32_t fw_type)
Signature · 1 line
2.55.0
author maintainer
#6 lore raw

PATCH 7/30 drm/amdgpu/ucode: WARN() rather than BUG()

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +2 -1
index 6d9e96fabd581..4f1c711df5bd7 100644
@@ -1478,7 +1478,8 @@ void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type,
 		ip_name = "isp";
 		break;
 	default:
-		BUG();
+		WARN(1, "invalid HWIP %d\n", block_type);
+		return;
 	}
 
 	maj = IP_VERSION_MAJ(version);
Signature · 1 line
2.55.0
author maintainer
#7 lore raw

PATCH 8/30 drm/amdgpu/cik_sdma: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +2 -1
index b703ef1fe3406..b951328d94cfb 100644
@@ -125,7 +125,8 @@ static int cik_sdma_init_microcode(struct amdgpu_device *adev)
 	case CHIP_MULLINS:
 		chip_name = "mullins";
 		break;
-	default: BUG();
+	default:
+		return -EINVAL;
 	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
Signature · 1 line
2.55.0
author maintainer
#8 lore raw

PATCH 9/30 drm/amdgpu/sdma2.4: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +1 -1
index 397b08c7173ab..c7253b908351c 100644
@@ -138,7 +138,7 @@ static int sdma_v2_4_init_microcode(struct amdgpu_device *adev)
 		chip_name = "topaz";
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
Signature · 1 line
2.55.0
author maintainer
#9 lore raw

PATCH 10/30 drm/amdgpu/sdma3.0: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +2 -1
index 8ac1c9dae72e7..05cce4bde73eb 100644
@@ -298,7 +298,8 @@ static int sdma_v3_0_init_microcode(struct amdgpu_device *adev)
 	case CHIP_STONEY:
 		chip_name = "stoney";
 		break;
-	default: BUG();
+	default:
+		return -EINVAL;
 	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
Signature · 1 line
2.55.0
author maintainer
#10 lore raw

PATCH 11/30 drm/amdgpu/si: drop BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/si.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/si.c +2 -2
index 6e455ad66d626..7100f30ffeffa 100644
@@ -2218,7 +2218,7 @@ static void si_init_golden_registers(struct amdgpu_device *adev)
 
 
 	default:
-		BUG();
+		break;
 	}
 }
 
@@ -2735,7 +2735,7 @@ int si_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_device_ip_block_add(adev, &amdgpu_vkms_ip_block);
 		break;
 	default:
-		BUG();
+		break;
 	}
 	return 0;
 }
Signature · 1 line
2.55.0
author maintainer
#11 lore raw

PATCH 12/30 drm/amdgpu/gmc6: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +1 -1
index a914dd8183b58..b49098931d197 100644
@@ -124,7 +124,7 @@ static int gmc_v6_0_init_microcode(struct amdgpu_device *adev)
 		chip_name = "hainan";
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	/* this memory configuration requires special firmware */
Signature · 1 line
2.55.0
author maintainer
#12 lore raw

PATCH 13/30 drm/amdgpu/imu11: WARN() rather than BUG()

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/imu_v11_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/imu_v11_0.c +2 -1
index 05b164f38c97a..138eb822ba137 100644
@@ -377,7 +377,8 @@ static void imu_v11_0_program_rlc_ram(struct amdgpu_device *adev)
 		imu_v11_0_3_program_rlc_ram(adev);
 		break;
 	default:
-		BUG();
+		WARN(1, "Invalid GFX/IMU IP version 0x%08x\n",
+		     amdgpu_ip_version(adev, GC_HWIP, 0));
 		break;
 	}
 
Signature · 1 line
2.55.0
author maintainer
#13 lore raw

PATCH 14/30 drm/amdgpu/imu12: WARN() rather than BUG()

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/imu_v12_0.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/imu_v12_0.c +2 -1
index 58cd87db80619..2943ec9521eee 100644
@@ -382,7 +382,8 @@ static void imu_v12_0_program_rlc_ram(struct amdgpu_device *adev)
 				(const u32)ARRAY_SIZE(imu_rlc_ram_golden_12_0_1));
 		break;
 	default:
-		BUG();
+		WARN(1, "Invalid GFX/IMU IP version 0x%08x\n",
+		     amdgpu_ip_version(adev, GC_HWIP, 0));
 		break;
 	}
 
Signature · 1 line
2.55.0
author maintainer
#14 lore raw

PATCH 15/30 drm/amdgpu/mes11: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +10 -7
index 72ca7302bbfbc..ee5229ae3d75e 100644
@@ -86,7 +86,7 @@ static void mes_v11_0_ring_set_wptr(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG();
+		dev_warn(adev->dev, "mes_v11_0_ring_set_wptr() requires doorbell!\n");
 	}
 }
 
@@ -97,12 +97,15 @@ static u64 mes_v11_0_ring_get_rptr(struct amdgpu_ring *ring)
 
 static u64 mes_v11_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "mes_v11_0_ring_get_wptr() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -294,7 +297,7 @@ static int convert_to_mes_queue_type(int queue_type)
 	else if (queue_type == AMDGPU_RING_TYPE_SDMA)
 		return MES_QUEUE_TYPE_SDMA;
 	else
-		BUG();
+		WARN(1, "Invalid queue type %d\n", queue_type);
 	return -1;
 }
 
@@ -1544,7 +1547,7 @@ static int mes_v11_0_queue_init(struct amdgpu_device *adev,
 	else if (pipe == AMDGPU_MES_SCHED_PIPE)
 		ring = &adev->mes.ring[0];
 	else
-		BUG();
+		WARN(1, "Invalid MES pipe %d\n", pipe);
 
 	if ((pipe == AMDGPU_MES_SCHED_PIPE) &&
 	    (amdgpu_in_reset(adev) || adev->in_suspend)) {
@@ -1627,7 +1630,7 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev,
 	else if (pipe == AMDGPU_MES_SCHED_PIPE)
 		ring = &adev->mes.ring[0];
 	else
-		BUG();
+		return -EINVAL;
 
 	if (ring->mqd_obj)
 		return 0;
Signature · 1 line
2.55.0
#15 lore raw

Re: [PATCH 15/30] drm/amdgpu/mes11: drop all BUG()s

Quoted 12 lines · Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/mes_v11_0.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +0 -0
index 72ca7302bbfbc..ee5229ae3d75e 100644

drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static void mes_v11_0_ring_set_wptr(struct amdgpu_ring *ring) · line 89

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +1 -1
@@ -86,7 +86,7 @@ static void mes_v11_0_ring_set_wptr(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG();
+		dev_warn(adev->dev, "mes_v11_0_ring_set_wptr() requires doorbell!\n");

Per scripts/checkpatch.pl:

WARNING: Prefer using '"%s...", __func__' to using 'mes_v11_0_ring_set_wptr', this function's name, in a string

Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +0 -0
 	}
 }
 
@@ -97,12 +97,15 @@ static u64 mes_v11_0_ring_get_rptr(struct amdgpu_ring *ring)
 
 static u64 mes_v11_0_ring_get_wptr(struct amdgpu_ring *ring)
 {

drivers/gpu/drm/amd/amdgpu/mes_v11_0.c static u64 mes_v11_0_ring_get_rptr(struct amdgpu_ring *ring) · line 106

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +4 -3
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "mes_v11_0_ring_get_wptr() requires doorbell!\n");

See above. Interestingly, scripts/checkpatch.pl doesn't catch this one.

There are additional prints like this in the series.

Thanks,
John

Quoted 32 lines
drivers/gpu/drm/amd/amdgpu/mes_v11_0.c +5 -3
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -294,7 +297,7 @@ static int convert_to_mes_queue_type(int queue_type)
 	else if (queue_type == AMDGPU_RING_TYPE_SDMA)
 		return MES_QUEUE_TYPE_SDMA;
 	else
-		BUG();
+		WARN(1, "Invalid queue type %d\n", queue_type);
 	return -1;
 }
 
@@ -1544,7 +1547,7 @@ static int mes_v11_0_queue_init(struct amdgpu_device *adev,
 	else if (pipe == AMDGPU_MES_SCHED_PIPE)
 		ring = &adev->mes.ring[0];
 	else
-		BUG();
+		WARN(1, "Invalid MES pipe %d\n", pipe);
 
 	if ((pipe == AMDGPU_MES_SCHED_PIPE) &&
 	    (amdgpu_in_reset(adev) || adev->in_suspend)) {
@@ -1627,7 +1630,7 @@ static int mes_v11_0_mqd_sw_init(struct amdgpu_device *adev,
 	else if (pipe == AMDGPU_MES_SCHED_PIPE)
 		ring = &adev->mes.ring[0];
 	else
-		BUG();
+		return -EINVAL;
 
 	if (ring->mqd_obj)
 		return 0;
author maintainer
#16 lore raw

PATCH 16/30 drm/amdgpu/mes12: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/mes_v12_0.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_0.c +8 -5
index 04465804c2544..322743b257702 100644
@@ -59,7 +59,7 @@ static void mes_v12_0_ring_set_wptr(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG();
+		dev_warn(adev->dev, "mes_v12_0_ring_set_wptr() requires doorbell!\n");
 	}
 }
 
@@ -70,12 +70,15 @@ static u64 mes_v12_0_ring_get_rptr(struct amdgpu_ring *ring)
 
 static u64 mes_v12_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "mes_v12_0_ring_get_wptr() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -279,7 +282,7 @@ static int convert_to_mes_queue_type(int queue_type)
 	else if (queue_type == AMDGPU_RING_TYPE_MES)
 		return MES_QUEUE_TYPE_SCHQ;
 	else
-		BUG();
+		WARN(1, "Invalid queue type %d\n", queue_type);
 	return -1;
 }
 
Signature · 1 line
2.55.0
author maintainer
#17 lore raw

PATCH 17/30 drm/amdgpu/mes12.1: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/mes_v12_1.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/mes_v12_1.c +9 -5
index dbdb9ba02a5fc..c034b6946c7e8 100644
@@ -61,7 +61,7 @@ static void mes_v12_1_ring_set_wptr(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG();
+		dev_warn(adev->dev, "mes_v12_1_ring_set_wptr() requires doorbell!\n");
 	}
 }
 
@@ -72,12 +72,16 @@ static u64 mes_v12_1_ring_get_rptr(struct amdgpu_ring *ring)
 
 static u64 mes_v12_1_ring_get_wptr(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "mes_v12_1_ring_get_wptr() requires doorbell!\n");
+		wptr = 0;
+
+	}
 	return wptr;
 }
 
@@ -278,7 +282,7 @@ static int convert_to_mes_queue_type(int queue_type)
 	else if (queue_type == AMDGPU_RING_TYPE_MES)
 		return MES_QUEUE_TYPE_SCHQ;
 	else
-		BUG();
+		WARN(1, "Invalid queue type %d\n", queue_type);
 	return -1;
 }
 
Signature · 1 line
2.55.0
author maintainer
#18 lore raw

PATCH 18/30 drm/amdgpu/psp11: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/psp_v11_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +1 -1
index 479690c44f0d5..ca36d434cfe1e 100644
@@ -136,7 +136,7 @@ static int psp_v11_0_init_microcode(struct psp_context *psp)
 		err = psp_init_toc_microcode(psp, ucode_prefix);
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	return err;
Signature · 1 line
2.55.0
author maintainer
#19 lore raw

PATCH 19/30 drm/amdgpu/psp13: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/psp_v13_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +1 -1
index 00b4a34e6601f..4b0ab1025c2fb 100644
@@ -133,7 +133,7 @@ static int psp_v13_0_init_microcode(struct psp_context *psp)
 			return err;
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	return 0;
Signature · 1 line
2.55.0
author maintainer
#20 lore raw

PATCH 20/30 drm/amdgpu/psp13.0.4: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/psp_v13_0_4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/psp_v13_0_4.c +1 -1
index 3d5e26b3fa00a..caaeeef27544c 100644
@@ -50,7 +50,7 @@ static int psp_v13_0_4_init_microcode(struct psp_context *psp)
 			return err;
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	return 0;
Signature · 1 line
2.55.0
author maintainer
#21 lore raw

PATCH 21/30 drm/amdgpu/psp14: replace BUG() with an error

In reply to Alex Deucher

There's no need to crash the kernel for this case.

---
 drivers/gpu/drm/amd/amdgpu/psp_v14_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/psp_v14_0.c +1 -1
index 040a61aefa866..7ed5f41969330 100644
@@ -85,7 +85,7 @@ static int psp_v14_0_init_microcode(struct psp_context *psp)
 			return err;
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	return 0;
Signature · 1 line
2.55.0
author maintainer
#22 lore raw

PATCH 22/30 drm/amdgpu/gfx6: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +3 -6
index ac90d8e9d86a8..4ba9ff7c3b3f6 100644
@@ -347,7 +347,8 @@ static int gfx_v6_0_init_microcode(struct amdgpu_device *adev)
 	case CHIP_HAINAN:
 		chip_name = "hainan";
 		break;
-	default: BUG();
+	default:
+		return -EINVAL;
 	}
 
 	err = amdgpu_ucode_request(adev, &adev->gfx.pfp_fw,
@@ -1736,7 +1737,6 @@ static void gfx_v6_0_constants_init(struct amdgpu_device *adev)
 		gb_addr_config = HAINAN_GB_ADDR_CONFIG_GOLDEN;
 		break;
 	default:
-		BUG();
 		break;
 	}
 
@@ -2202,7 +2202,7 @@ static u64 gfx_v6_0_ring_get_wptr(struct amdgpu_ring *ring)
 	else if (ring == &adev->gfx.compute_ring[1])
 		return RREG32(mmCP_RB2_WPTR);
 	else
-		BUG();
+		return 0;
 }
 
 static void gfx_v6_0_ring_set_wptr_gfx(struct amdgpu_ring *ring)
@@ -2223,8 +2223,6 @@ static void gfx_v6_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
 	} else if (ring == &adev->gfx.compute_ring[1]) {
 		WREG32(mmCP_RB2_WPTR, lower_32_bits(ring->wptr));
 		(void)RREG32(mmCP_RB2_WPTR);
-	} else {
-		BUG();
 	}
 
 }
@@ -3310,7 +3308,6 @@ static void gfx_v6_0_set_compute_eop_interrupt_state(struct amdgpu_device *adev,
 		}
 
 	default:
-		BUG();
 		break;
 
 	}
Signature · 1 line
2.55.0
author maintainer
#23 lore raw

PATCH 23/30 drm/amdgpu/gfx7: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c +1 -1
index 65b8497ad5f02..4a020323469c3 100644
@@ -933,7 +933,7 @@ static int gfx_v7_0_init_microcode(struct amdgpu_device *adev)
 		chip_name = "mullins";
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	err = amdgpu_ucode_request(adev, &adev->gfx.pfp_fw,
Signature · 1 line
2.55.0
author maintainer
#24 lore raw

PATCH 24/30 drm/amdgpu/gfx8: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
index 9e0840df88497..15084c0c98c85 100644
@@ -977,7 +977,7 @@ static int gfx_v8_0_init_microcode(struct amdgpu_device *adev)
 		chip_name = "vegam";
 		break;
 	default:
-		BUG();
+		return -EINVAL;
 	}
 
 	if (adev->asic_type >= CHIP_POLARIS10 && adev->asic_type <= CHIP_POLARIS12) {
Signature · 1 line
2.55.0
author maintainer
#25 lore raw

PATCH 25/30 drm/amdgpu/gfx9: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +9 -7
index 556e5cb3f4cd0..7e13023c324b9 100644
@@ -2107,8 +2107,7 @@ static int gfx_v9_0_gpu_early_init(struct amdgpu_device *adev)
 			return err;
 		break;
 	default:
-		BUG();
-		break;
+		return -EINVAL;
 	}
 
 	adev->gfx.config.gb_addr_config = gb_addr_config;
@@ -5681,13 +5680,16 @@ static u64 gfx_v9_0_ring_get_rptr_compute(struct amdgpu_ring *ring)
 
 static u64 gfx_v9_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
 	/* XXX check if swapping is necessary on BE */
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "gfx_v9_0_ring_get_wptr_compute() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -5699,8 +5701,8 @@ static void gfx_v9_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
 	if (ring->use_doorbell) {
 		atomic64_set((atomic64_t *)ring->wptr_cpu_addr, ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
-	} else{
-		BUG(); /* only DOORBELL method supported on gfx9 now */
+	} else {
+		dev_warn(adev->dev, "gfx_v9_0_ring_set_wptr_compute() requires doorbell!\n");
 	}
 }
 
Signature · 1 line
2.55.0
author maintainer
#26 lore raw

PATCH 26/30 drm/amdgpu/gfx9.4.3: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +10 -4
index 44d38b76cb4f7..cab29f58601a5 100644
@@ -3029,13 +3029,18 @@ static u64 gfx_v9_4_3_ring_get_rptr_compute(struct amdgpu_ring *ring)
 
 static u64 gfx_v9_4_3_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
 	/* XXX check if swapping is necessary on BE */
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)&ring->adev->wb.wb[ring->wptr_offs]);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev,
+			 "gfx_v9_4_3_ring_get_wptr_compute() requires doorbell!\n");
+		wptr = 0;
+
+	}
 	return wptr;
 }
 
@@ -3048,7 +3053,8 @@ static void gfx_v9_4_3_ring_set_wptr_compute(struct amdgpu_ring *ring)
 		atomic64_set((atomic64_t *)&adev->wb.wb[ring->wptr_offs], ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG(); /* only DOORBELL method supported on gfx9 now */
+		dev_warn(adev->dev,
+			 "gfx_v9_4_3_ring_set_wptr_compute() requires doorbell!\n");
 	}
 }
 
Signature · 1 line
2.55.0
author maintainer
#27 lore raw

PATCH 27/30 drm/amdgpu/gfx10: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +10 -8
index fa3deae20b29f..2f06230dfe4eb 100644
@@ -4580,7 +4580,7 @@ static const struct amdgpu_gfx_funcs gfx_v10_0_gfx_funcs = {
 
 static void gfx_v10_0_gpu_early_init(struct amdgpu_device *adev)
 {
-	u32 gb_addr_config;
+	u32 gb_addr_config = 0;
 
 	switch (amdgpu_ip_version(adev, GC_HWIP, 0)) {
 	case IP_VERSION(10, 1, 10):
@@ -4620,7 +4620,6 @@ static void gfx_v10_0_gpu_early_init(struct amdgpu_device *adev)
 		gb_addr_config = CYAN_SKILLFISH_GB_ADDR_CONFIG_GOLDEN;
 		break;
 	default:
-		BUG();
 		break;
 	}
 
@@ -8599,13 +8598,16 @@ static u64 gfx_v10_0_ring_get_rptr_compute(struct amdgpu_ring *ring)
 
 static u64 gfx_v10_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
 	/* XXX check if swapping is necessary on BE */
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "gfx_v10_0_ring_get_wptr_compute() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -8618,7 +8620,7 @@ static void gfx_v10_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG(); /* only DOORBELL method supported on gfx10 now */
+		dev_warn(adev->dev, "gfx_v10_0_ring_set_wptr_compute() requires doorbell!\n");
 	}
 }
 
@@ -9376,7 +9378,7 @@ static void gfx_v10_0_handle_priv_fault(struct amdgpu_device *adev,
 		}
 		break;
 	default:
-		BUG();
+		break;
 	}
 }
 
@@ -9446,7 +9448,7 @@ static int gfx_v10_0_kiq_set_interrupt_state(struct amdgpu_device *adev,
 		}
 		break;
 	default:
-		BUG(); /* kiq only support GENERIC2_INT now */
+		/* kiq only support GENERIC2_INT now */
 		break;
 	}
 	return 0;
Signature · 1 line
2.55.0
author maintainer
#28 lore raw

PATCH 28/30 drm/amdgpu/gfx11: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +9 -8
index d5cb653639a64..a286aee31f72f 100644
@@ -1145,8 +1145,7 @@ static int gfx_v11_0_gpu_early_init(struct amdgpu_device *adev)
 		adev->gfx.config.sc_earlyz_tile_fifo_size = 0x300;
 		break;
 	default:
-		BUG();
-		break;
+		return -EINVAL;
 	}
 
 	return 0;
@@ -5958,13 +5957,16 @@ static u64 gfx_v11_0_ring_get_rptr_compute(struct amdgpu_ring *ring)
 
 static u64 gfx_v11_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
 	/* XXX check if swapping is necessary on BE */
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "gfx_v11_0_ring_get_wptr_compute() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -5978,7 +5980,7 @@ static void gfx_v11_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG(); /* only DOORBELL method supported on gfx11 now */
+		dev_warn(adev->dev, "gfx_v11_0_ring_set_wptr_compute() requires doorbell!\n");
 	}
 }
 
@@ -6751,7 +6753,6 @@ static void gfx_v11_0_handle_priv_fault(struct amdgpu_device *adev,
 			}
 			break;
 		default:
-			BUG();
 			break;
 		}
 	}
@@ -6836,7 +6837,7 @@ static int gfx_v11_0_kiq_set_interrupt_state(struct amdgpu_device *adev,
 		}
 		break;
 	default:
-		BUG(); /* kiq only support GENERIC2_INT now */
+		/* kiq only support GENERIC2_INT now */
 		break;
 	}
 	return 0;
Signature · 1 line
2.55.0
author maintainer
#29 lore raw

PATCH 29/30 drm/amdgpu/gfx12: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c +8 -7
index dbf0cbbbe8561..995e8caa054b8 100644
@@ -964,8 +964,7 @@ static int gfx_v12_0_gpu_early_init(struct amdgpu_device *adev)
 		adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
 		break;
 	default:
-		BUG();
-		break;
+		return -EINVAL;
 	}
 
 	return 0;
@@ -4469,13 +4468,16 @@ static u64 gfx_v12_0_ring_get_rptr_compute(struct amdgpu_ring *ring)
 
 static u64 gfx_v12_0_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
 	/* XXX check if swapping is necessary on BE */
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "gfx_v12_0_ring_get_wptr_compute() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -4489,7 +4491,7 @@ static void gfx_v12_0_ring_set_wptr_compute(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG(); /* only DOORBELL method supported on gfx12 now */
+		dev_warn(adev->dev, "gfx_v12_0_ring_set_wptr_compute() requires doorbell!\n");
 	}
 }
 
@@ -5084,7 +5086,6 @@ static void gfx_v12_0_handle_priv_fault(struct amdgpu_device *adev,
 			}
 			break;
 		default:
-			BUG();
 			break;
 		}
 	}
Signature · 1 line
2.55.0
author maintainer
#30 lore raw

PATCH 30/30 drm/amdgpu/gfx12.1: drop all BUG()s

In reply to Alex Deucher

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +8 -6
index b73f2c7d88be5..cefc2d03f0c69 100644
@@ -891,8 +891,7 @@ static int gfx_v12_1_gpu_early_init(struct amdgpu_device *adev)
 		adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
 		break;
 	default:
-		BUG();
-		break;
+		return -EINVAL;
 	}
 
 	return 0;
@@ -3671,13 +3670,16 @@ static u64 gfx_v12_1_ring_get_rptr_compute(struct amdgpu_ring *ring)
 
 static u64 gfx_v12_1_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+	struct amdgpu_device *adev = ring->adev;
 	u64 wptr;
 
 	/* XXX check if swapping is necessary on BE */
-	if (ring->use_doorbell)
+	if (ring->use_doorbell) {
 		wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-	else
-		BUG();
+	} else {
+		dev_warn(adev->dev, "gfx_v12_1_ring_get_wptr_compute() requires doorbell!\n");
+		wptr = 0;
+	}
 	return wptr;
 }
 
@@ -3691,7 +3693,7 @@ static void gfx_v12_1_ring_set_wptr_compute(struct amdgpu_ring *ring)
 			     ring->wptr);
 		WDOORBELL64(ring->doorbell_index, ring->wptr);
 	} else {
-		BUG(); /* only DOORBELL method supported on gfx12 now */
+		dev_warn(adev->dev, "gfx_v12_1_ring_set_wptr_compute() requires doorbell!\n");
 	}
 }
 
Signature · 1 line
2.55.0
Reviewed-by on v1 30/30
#31 lore raw

RE: [PATCH 30/30] drm/amdgpu/gfx12.1: drop all BUG()s

AMD General

Looks good. Series is

Kent

Quoted 66 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Alex Deucher
Sent: July 7, 2026 11:42 AM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>
Subject: [PATCH 30/30] drm/amdgpu/gfx12.1: drop all BUG()s

There's no need to crash the kernel for these cases.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -2
index b73f2c7d88be5..cefc2d03f0c69 100644
@@ -891,8 +891,7 @@ static int gfx_v12_1_gpu_early_init(struct
 amdgpu_device *adev)
              adev->gfx.config.sc_earlyz_tile_fifo_size = 0x4C0;
              break;
      default:
-             BUG();
-             break;
+             return -EINVAL;
      }
 
      return 0;
drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +6 -3
@@ -3671,13 +3670,16 @@ static u64 gfx_v12_1_ring_get_rptr_compute(struct
 amdgpu_ring *ring)
 
 static u64 gfx_v12_1_ring_get_wptr_compute(struct amdgpu_ring *ring)
 {
+     struct amdgpu_device *adev = ring->adev;
      u64 wptr;
 
      /* XXX check if swapping is necessary on BE */
-     if (ring->use_doorbell)
+     if (ring->use_doorbell) {
              wptr = atomic64_read((atomic64_t *)ring->wptr_cpu_addr);
-     else
-             BUG();
+     } else {
+             dev_warn(adev->dev, "gfx_v12_1_ring_get_wptr_compute()
 requires doorbell!\n");
+             wptr = 0;
+     }
      return wptr;

}

drivers/gpu/drm/amd/amdgpu/gfx_v12_1.c +1 -1
@@ -3691,7 +3693,7 @@ static void gfx_v12_1_ring_set_wptr_compute(struct
 amdgpu_ring *ring)
                           ring->wptr);
              WDOORBELL64(ring->doorbell_index, ring->wptr);
      } else {
-             BUG(); /* only DOORBELL method supported on gfx12 now */
+             dev_warn(adev->dev, "gfx_v12_1_ring_set_wptr_compute()
 requires doorbell!\n");
      }

}

--
2.55.0