Skip to contentSkip to conversation

Some cleanups related to missing microcode

PATCH In review Mario Limonciello 2 participants 10 messages Sep 25, 2023

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

cover Some cleanups related to missing microcode

I recently found a noisier experience than I expected with missing microcode. As a result I found that some microcode wasn't being loaded in early_init and some messages were unnecessary.

Mario Limonciello (8):
drm/amd: Drop error message about failing to load DMUB firmware drm/amd: Drop error message about failing to load SDMA firmware drm/amd: Move microcode init from sw_init to early_init for SDMA v5.0 drm/amd: Move microcode init from sw_init to early_init for SDMA v6.0 drm/amd: Move microcode init from sw_init to early_init for SDMA v5.2 drm/amd: Move microcode init from sw_init to early_init for SDMA v3.0 drm/amd: Move microcode init from sw_init to early_init for SDMA v2.4 drm/amd: Move microcode init from sw_init to early_init for CIK SDMA

 drivers/gpu/drm/amd/amdgpu/cik_sdma.c             | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c            |  4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c          |  4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c            | 11 +++++------
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 --
 9 files changed, 32 insertions(+), 44 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/8 drm/amd: Drop error message about failing to load DMUB firmware

The error path for DMUB firmware loading is unnecessarily noisy. When a firmware is missing 3 errors show up:

```
amdgpu 0000:07:00.0: Direct firmware load for amdgpu/green_sardine_dmcub.bin failed with error -2
[drm:dm_early_init [amdgpu]] *ERROR* DMUB firmware loading failed: -19
[drm:amdgpu_device_init [amdgpu]] *ERROR* early_init of IP block <dm> failed -19
```

The error code for the device init is bubbled up already, remove the second one.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -2
index f06136a0bba9..7e6a693d6369 100644
@@ -4758,8 +4758,6 @@ static int dm_init_microcode(struct amdgpu_device *adev)
 		return 0;
 	}
 	r = amdgpu_ucode_request(adev, &adev->dm.dmub_fw, fw_name_dmub);
-	if (r)
-		DRM_ERROR("DMUB firmware loading failed: %d\n", r);
 	return r;
 }
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/8 drm/amd: Drop error message about failing to load SDMA firmware

In reply to Mario Limonciello

The error path for SDMA firmware loading is unnecessarily noisy. When a firmware is missing 3 errors show up:

```
amdgpu 0000:07:00.0: Direct firmware load for amdgpu/green_sardine_sdma.bin failed with error -2
[drm:sdma_v4_0_early_init [amdgpu]] *ERROR* Failed to load sdma firmware!
[drm:amdgpu_device_init [amdgpu]] *ERROR* early_init of IP block <sdma_v4_0> failed -19
```

The error code for the device init is bubbled up already, remove the second one.

---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c    | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c   | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c   | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c   | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c   | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c   | 4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c   | 4 +---
 8 files changed, 8 insertions(+), 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +1 -3
index 52598fbc9b39..4193289ae82f 100644
@@ -943,10 +943,8 @@ static int cik_sdma_sw_init(void *handle)
 	int r, i;
 
 	r = cik_sdma_init_microcode(adev);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	/* SDMA trap event */
 	r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 224,
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +1 -3
index 51afc92994a8..4dd944a93cf1 100644
@@ -852,10 +852,8 @@ static int sdma_v2_4_sw_init(void *handle)
 		return r;
 
 	r = sdma_v2_4_init_microcode(adev);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +1 -3
index 344202870aeb..dc7aab68ed66 100644
@@ -1130,10 +1130,8 @@ static int sdma_v3_0_sw_init(void *handle)
 		return r;
 
 	r = sdma_v3_0_init_microcode(adev);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +1 -3
index 8562ac7f7ff0..dff66e1ae7ea 100644
@@ -1720,10 +1720,8 @@ static int sdma_v4_0_early_init(void *handle)
 	int r;
 
 	r = sdma_v4_0_init_microcode(adev);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	/* TODO: Page queue breaks driver reload under SRIOV */
 	if ((amdgpu_ip_version(adev, SDMA0_HWIP, 0) == IP_VERSION(4, 0, 0)) &&
drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c +1 -3
index 1cadd3cb26a9..3b6990ef403a 100644
@@ -1246,10 +1246,8 @@ static int sdma_v4_4_2_early_init(void *handle)
 	int r;
 
 	r = sdma_v4_4_2_init_microcode(adev);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	/* TODO: Page queue breaks driver reload under SRIOV */
 	if (sdma_v4_4_2_fw_support_paging_queue(adev))
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +1 -3
index e0527e5ed7d1..7e837acffa6e 100644
@@ -1368,10 +1368,8 @@ static int sdma_v5_0_sw_init(void *handle)
 		return r;
 
 	r = sdma_v5_0_init_microcode(adev);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +1 -3
index 0ccb7523bc55..86661f9653fa 100644
@@ -1232,10 +1232,8 @@ static int sdma_v5_2_sw_init(void *handle)
 	}
 
 	r = amdgpu_sdma_init_microcode(adev, 0, true);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +1 -3
index 4d6de77d289e..2c0c2e9f2783 100644
@@ -1283,10 +1283,8 @@ static int sdma_v6_0_sw_init(void *handle)
 		return r;
 
 	r = amdgpu_sdma_init_microcode(adev, 0, true);
-	if (r) {
-		DRM_ERROR("Failed to load sdma firmware!\n");
+	if (r)
 		return r;
-	}
 
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/8 drm/amd: Move microcode init from sw_init to early_init for SDMA v5.0

In reply to Mario Limonciello

As part of IP discovery early_init is run for all HW IP blocks. During this phase all firmware is supposed to be identified that may be missing so that the driver can avoid releasing resources used by the EFI framebuffer or simpledrm until the last possible moment.

Move microcode loading from sw_init to early_init.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c +5 -4
index 7e837acffa6e..c1ff5eda8961 100644
@@ -1336,6 +1336,11 @@ static void sdma_v5_0_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
 static int sdma_v5_0_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
+
+	r = sdma_v5_0_init_microcode(adev);
+	if (r)
+		return r;
 
 	sdma_v5_0_set_ring_funcs(adev);
 	sdma_v5_0_set_buffer_funcs(adev);
@@ -1367,10 +1372,6 @@ static int sdma_v5_0_sw_init(void *handle)
 	if (r)
 		return r;
 
-	r = sdma_v5_0_init_microcode(adev);
-	if (r)
-		return r;
-
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
 		ring->ring_obj = NULL;
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/8 drm/amd: Move microcode init from sw_init to early_init for SDMA v6.0

In reply to Mario Limonciello

As part of IP discovery early_init is run for all HW IP blocks. During this phase all firmware is supposed to be identified that may be missing so that the driver can avoid releasing resources used by the EFI framebuffer or simpledrm until the last possible moment.

Move microcode loading from sw_init to early_init.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c +5 -4
index 2c0c2e9f2783..1f8122fd1ad7 100644
@@ -1258,6 +1258,11 @@ static void sdma_v6_0_set_ras_funcs(struct amdgpu_device *adev)
 static int sdma_v6_0_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
+
+	r = amdgpu_sdma_init_microcode(adev, 0, true);
+	if (r)
+		return r;
 
 	sdma_v6_0_set_ring_funcs(adev);
 	sdma_v6_0_set_buffer_funcs(adev);
@@ -1282,10 +1287,6 @@ static int sdma_v6_0_sw_init(void *handle)
 	if (r)
 		return r;
 
-	r = amdgpu_sdma_init_microcode(adev, 0, true);
-	if (r)
-		return r;
-
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
 		ring->ring_obj = NULL;
Signature · 1 line
2.34.1
#5 lore raw

PATCH 5/8 drm/amd: Move microcode init from sw_init to early_init for SDMA v5.2

In reply to Mario Limonciello

As part of IP discovery early_init is run for all HW IP blocks. During this phase all firmware is supposed to be identified that may be missing so that the driver can avoid releasing resources used by the EFI framebuffer or simpledrm until the last possible moment.

Move microcode loading from sw_init to early_init.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c +5 -4
index 86661f9653fa..7d1e57189c8c 100644
@@ -1172,6 +1172,11 @@ static void sdma_v5_2_ring_emit_reg_write_reg_wait(struct amdgpu_ring *ring,
 static int sdma_v5_2_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
+
+	r = amdgpu_sdma_init_microcode(adev, 0, true);
+	if (r)
+		return r;
 
 	sdma_v5_2_set_ring_funcs(adev);
 	sdma_v5_2_set_buffer_funcs(adev);
@@ -1231,10 +1236,6 @@ static int sdma_v5_2_sw_init(void *handle)
 			return r;
 	}
 
-	r = amdgpu_sdma_init_microcode(adev, 0, true);
-	if (r)
-		return r;
-
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
 		ring->ring_obj = NULL;
Signature · 1 line
2.34.1
#6 lore raw

PATCH 6/8 drm/amd: Move microcode init from sw_init to early_init for SDMA v3.0

In reply to Mario Limonciello

As part of IP discovery early_init is run for all HW IP blocks. During this phase all firmware is supposed to be identified that may be missing so that the driver can avoid releasing resources used by the EFI framebuffer or simpledrm until the last possible moment.

Move microcode loading from sw_init to early_init.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c +5 -4
index dc7aab68ed66..c5ea32687eb5 100644
@@ -1087,6 +1087,7 @@ static void sdma_v3_0_ring_emit_wreg(struct amdgpu_ring *ring,
 static int sdma_v3_0_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
 
 	switch (adev->asic_type) {
 	case CHIP_STONEY:
@@ -1097,6 +1098,10 @@ static int sdma_v3_0_early_init(void *handle)
 		break;
 	}
 
+	r = sdma_v3_0_init_microcode(adev);
+	if (r)
+		return r;
+
 	sdma_v3_0_set_ring_funcs(adev);
 	sdma_v3_0_set_buffer_funcs(adev);
 	sdma_v3_0_set_vm_pte_funcs(adev);
@@ -1129,10 +1134,6 @@ static int sdma_v3_0_sw_init(void *handle)
 	if (r)
 		return r;
 
-	r = sdma_v3_0_init_microcode(adev);
-	if (r)
-		return r;
-
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
 		ring->ring_obj = NULL;
Signature · 1 line
2.34.1
#7 lore raw

PATCH 7/8 drm/amd: Move microcode init from sw_init to early_init for SDMA v2.4

In reply to Mario Limonciello

As part of IP discovery early_init is run for all HW IP blocks. During this phase all firmware is supposed to be identified that may be missing so that the driver can avoid releasing resources used by the EFI framebuffer or simpledrm until the last possible moment.

Move microcode loading from sw_init to early_init.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c +5 -4
index 4dd944a93cf1..b58a13bd75db 100644
@@ -816,6 +816,11 @@ static void sdma_v2_4_ring_emit_wreg(struct amdgpu_ring *ring,
 static int sdma_v2_4_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
+
+	r = sdma_v2_4_init_microcode(adev);
+	if (r)
+		return r;
 
 	adev->sdma.num_instances = SDMA_MAX_INSTANCE;
 
@@ -851,10 +856,6 @@ static int sdma_v2_4_sw_init(void *handle)
 	if (r)
 		return r;
 
-	r = sdma_v2_4_init_microcode(adev);
-	if (r)
-		return r;
-
 	for (i = 0; i < adev->sdma.num_instances; i++) {
 		ring = &adev->sdma.instance[i].ring;
 		ring->ring_obj = NULL;
Signature · 1 line
2.34.1
#8 lore raw

PATCH 8/8 drm/amd: Move microcode init from sw_init to early_init for CIK SDMA

In reply to Mario Limonciello

As part of IP discovery early_init is run for all HW IP blocks. During this phase all firmware is supposed to be identified that may be missing so that the driver can avoid releasing resources used by the EFI framebuffer or simpledrm until the last possible moment.

Move microcode loading from sw_init to early_init.

---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/cik_sdma.c +5 -4
index 4193289ae82f..ee5dce6f6043 100644
@@ -925,9 +925,14 @@ static void cik_enable_sdma_mgls(struct amdgpu_device *adev,
 static int cik_sdma_early_init(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
 
 	adev->sdma.num_instances = SDMA_MAX_INSTANCE;
 
+	r = cik_sdma_init_microcode(adev);
+	if (r)
+		return r;
+
 	cik_sdma_set_ring_funcs(adev);
 	cik_sdma_set_irq_funcs(adev);
 	cik_sdma_set_buffer_funcs(adev);
@@ -942,10 +947,6 @@ static int cik_sdma_sw_init(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 	int r, i;
 
-	r = cik_sdma_init_microcode(adev);
-	if (r)
-		return r;
-
 	/* SDMA trap event */
 	r = amdgpu_irq_add_id(adev, AMDGPU_IRQ_CLIENTID_LEGACY, 224,
 			      &adev->sdma.trap_irq);
Signature · 1 line
2.34.1
Reviewed-by on the v1 series
#9 lore raw
In reply to Mario Limonciello
Quoted 4 lines · Mario Limonciello

I recently found a noisier experience than I expected with missing microcode. As a result I found that some microcode wasn't being loaded in early_init and some messages were unnecessary.

Series is:

Quoted 25 lines

Mario Limonciello (8):
drm/amd: Drop error message about failing to load DMUB firmware drm/amd: Drop error message about failing to load SDMA firmware drm/amd: Move microcode init from sw_init to early_init for SDMA v5.0 drm/amd: Move microcode init from sw_init to early_init for SDMA v6.0 drm/amd: Move microcode init from sw_init to early_init for SDMA v5.2 drm/amd: Move microcode init from sw_init to early_init for SDMA v3.0 drm/amd: Move microcode init from sw_init to early_init for SDMA v2.4 drm/amd: Move microcode init from sw_init to early_init for CIK SDMA

 drivers/gpu/drm/amd/amdgpu/cik_sdma.c             | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c            |  4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_4_2.c          |  4 +---
 drivers/gpu/drm/amd/amdgpu/sdma_v5_0.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v5_2.c            | 11 +++++------
 drivers/gpu/drm/amd/amdgpu/sdma_v6_0.c            | 11 +++++------
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 --
 9 files changed, 32 insertions(+), 44 deletions(-)

--
2.34.1