Skip to contentSkip to conversation

drm/amdgpu: move some release handles into fail labels

PATCH In review Huang Rui 4 participants 6 messages Sep 12, 2016 – Sep 15, 2016 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Huang Rui

author
#0 lore raw

PATCH 1/1 drm/amdgpu: move some release handles into fail labels

Clean up the codes to move the release handles into fail labels.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +10 -11
index 5cc95f1..4a5c211 100644
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
 	const struct common_firmware_header *header = NULL;
 
 	err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true,
-			AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
+			       AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
 	if (err) {
 		dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
-		err = -ENOMEM;
 		goto failed;
 	}
 
 	err = amdgpu_bo_reserve(*bo, false);
 	if (err) {
-		amdgpu_bo_unref(bo);
 		dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
-		goto failed;
+		goto failed_reserve;
 	}
 
 	err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
 	if (err) {
-		amdgpu_bo_unreserve(*bo);
-		amdgpu_bo_unref(bo);
 		dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
-		goto failed;
+		goto failed_pin;
 	}
 
 	err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
 	if (err) {
 		dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
-		amdgpu_bo_unpin(*bo);
-		amdgpu_bo_unreserve(*bo);
-		amdgpu_bo_unref(bo);
-		goto failed;
+		goto failed_kmap;
 	}
 
 	amdgpu_bo_unreserve(*bo);
@@ -291,6 +284,12 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
 		}
 	}
 
+failed_kmap:
+	amdgpu_bo_unpin(*bo);
+failed_pin:
+	amdgpu_bo_unreserve(*bo);
+failed_reserve:
+	amdgpu_bo_unref(bo);
 failed:
 	if (err)
 		adev->firmware.smu_load = false;
Signature · 6 lines
2.7.4

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1473646581-25186-1-git-send-email-ray.huang-5C7GfCeVMHo@public.gmane.org

Reviewed-by Chunming Zhou
#2 lore raw
Quoted 3 lines · Huang Rui

Clean up the codes to move the release handles into fail labels.

Quoted 51 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 21 ++++++++++-----------
  1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +4 -11
index 5cc95f1..4a5c211 100644
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
  	const struct common_firmware_header *header = NULL;
 
  	err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true,
-			AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
+			       AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
  	if (err) {
  		dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
-		err = -ENOMEM;
  		goto failed;
  	}
 
  	err = amdgpu_bo_reserve(*bo, false);
  	if (err) {
-		amdgpu_bo_unref(bo);
  		dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
-		goto failed;
+		goto failed_reserve;
  	}
 
  	err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
  	if (err) {
-		amdgpu_bo_unreserve(*bo);
-		amdgpu_bo_unref(bo);
  		dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
-		goto failed;
+		goto failed_pin;
  	}
 
  	err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
  	if (err) {
  		dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
-		amdgpu_bo_unpin(*bo);
-		amdgpu_bo_unreserve(*bo);
-		amdgpu_bo_unref(bo);
-		goto failed;
+		goto failed_kmap;
  	}
 
  	amdgpu_bo_unreserve(*bo);
@@ -291,6 +284,12 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
  		}
  	}

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c int amdgpu_ucode_init_bo(struct amdgpu_device *adev) · line 295

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +6 -0
 
+failed_kmap:
+	amdgpu_bo_unpin(*bo);
+failed_pin:
+	amdgpu_bo_unreserve(*bo);
+failed_reserve:
+	amdgpu_bo_unref(bo);
  failed:
  	if (err)
  		adev->firmware.smu_load = false;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#3 lore raw
In reply to a message not in the archive

Am 12.09.2016 um 04:16 schrieb Huang Rui:

Quoted 3 lines

Clean up the codes to move the release handles into fail labels.

Quoted 51 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 21 ++++++++++-----------
  1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +4 -11
index 5cc95f1..4a5c211 100644
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
  	const struct common_firmware_header *header = NULL;
 
  	err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true,
-			AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
+			       AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
  	if (err) {
  		dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
-		err = -ENOMEM;
  		goto failed;
  	}
 
  	err = amdgpu_bo_reserve(*bo, false);
  	if (err) {
-		amdgpu_bo_unref(bo);
  		dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
-		goto failed;
+		goto failed_reserve;
  	}
 
  	err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
  	if (err) {
-		amdgpu_bo_unreserve(*bo);
-		amdgpu_bo_unref(bo);
  		dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
-		goto failed;
+		goto failed_pin;
  	}
 
  	err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
  	if (err) {
  		dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
-		amdgpu_bo_unpin(*bo);
-		amdgpu_bo_unreserve(*bo);
-		amdgpu_bo_unref(bo);
-		goto failed;
+		goto failed_kmap;
  	}
 
  	amdgpu_bo_unreserve(*bo);
@@ -291,6 +284,12 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
  		}
  	}

drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c int amdgpu_ucode_init_bo(struct amdgpu_device *adev) · line 295

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +6 -0
 
+failed_kmap:
+	amdgpu_bo_unpin(*bo);
+failed_pin:
+	amdgpu_bo_unreserve(*bo);
+failed_reserve:
+	amdgpu_bo_unref(bo);
  failed:
  	if (err)
  		adev->firmware.smu_load = false;

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
In reply to a message not in the archive

Hi,

This patch causes a massive performance drop (by a factor of 100) followed by GPU hangs with F1 2015 (it needs more than 3GB of memory, the card has 2GB). The game normally works really well (30+ FPS on Polaris11 2GB, 40+ FPS on Tonga 2GB).

It should be fixed or the commit should be reverted really quickly.

Marek

Quoted 67 lines · Huang Rui

Clean up the codes to move the release handles into fail labels.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +10 -12
index 5cc95f1..4a5c211 100644
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
        const struct common_firmware_header *header = NULL;
 
        err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true,
-                       AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
+                              AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
        if (err) {
                dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
-               err = -ENOMEM;
                goto failed;
        }
 
        err = amdgpu_bo_reserve(*bo, false);
        if (err) {
-               amdgpu_bo_unref(bo);
                dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
-               goto failed;
+               goto failed_reserve;
        }
 
        err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
        if (err) {
-               amdgpu_bo_unreserve(*bo);
-               amdgpu_bo_unref(bo);
                dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
-               goto failed;
+               goto failed_pin;
        }
 
        err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
        if (err) {
                dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
-               amdgpu_bo_unpin(*bo);
-               amdgpu_bo_unreserve(*bo);
-               amdgpu_bo_unref(bo);
-               goto failed;
+               goto failed_kmap;
        }
 
        amdgpu_bo_unreserve(*bo);
@@ -291,6 +284,12 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
                }
        }
 
+failed_kmap:
+       amdgpu_bo_unpin(*bo);
+failed_pin:
+       amdgpu_bo_unreserve(*bo);
+failed_reserve:
+       amdgpu_bo_unref(bo);
 failed:
        if (err)
                adev->firmware.smu_load = false;
--

2.7.4

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): CAAxE2A7UfeHkWjxpxVQ2Gz7qbLWJ_YKp9Y-k7W__3y+d4aqYhw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#6 lore raw

Thanks for that info, I was busy most of the day bisecting this regression as well.

Yeah, the bug is rather obvious, there is a "return 0;" in the good case missing here.

So after loading the firmware we release it again. I will hack together a patch, just give me a minute.

Christian.

Am 14.09.2016 um 16:21 schrieb Marek Olšák:

Quoted 80 lines

Hi,

This patch causes a massive performance drop (by a factor of 100) followed by GPU hangs with F1 2015 (it needs more than 3GB of memory, the card has 2GB). The game normally works really well (30+ FPS on Polaris11 2GB, 40+ FPS on Tonga 2GB).

It should be fixed or the commit should be reverted really quickly.

Marek

Quoted 67 lines · Huang Rui

Clean up the codes to move the release handles into fail labels.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 21 ++++++++++-----------
  1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +10 -12
index 5cc95f1..4a5c211 100644
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
         const struct common_firmware_header *header = NULL;
 
         err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true,
-                       AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
+                              AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
         if (err) {
                 dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
-               err = -ENOMEM;
                 goto failed;
         }
 
         err = amdgpu_bo_reserve(*bo, false);
         if (err) {
-               amdgpu_bo_unref(bo);
                 dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
-               goto failed;
+               goto failed_reserve;
         }
 
         err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
         if (err) {
-               amdgpu_bo_unreserve(*bo);
-               amdgpu_bo_unref(bo);
                 dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
-               goto failed;
+               goto failed_pin;
         }
 
         err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
         if (err) {
                 dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
-               amdgpu_bo_unpin(*bo);
-               amdgpu_bo_unreserve(*bo);
-               amdgpu_bo_unref(bo);
-               goto failed;
+               goto failed_kmap;
         }
 
         amdgpu_bo_unreserve(*bo);
@@ -291,6 +284,12 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
                 }
         }
 
+failed_kmap:
+       amdgpu_bo_unpin(*bo);
+failed_pin:
+       amdgpu_bo_unreserve(*bo);
+failed_reserve:
+       amdgpu_bo_unref(bo);
  failed:
         if (err)
                 adev->firmware.smu_load = false;
--

2.7.4

Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1181c308-e04a-583f-1c72-341284974e4a-5C7GfCeVMHo@public.gmane.org

author
#8 lore raw

Ah, sorry, this is my mistake to miss the "return 0;". Marek, thanks a lot to point out. I will take care next time.

Christian, I see you already send the patch to fix it. Thanks.

Thanks,
Rui

Quoted 92 lines · Christian

Thanks for that info, I was busy most of the day bisecting this regression as well.

Yeah, the bug is rather obvious, there is a "return 0;" in the good case missing here.

So after loading the firmware we release it again. I will hack together a patch, just give me a minute.

Christian.

Am 14.09.2016 um 16:21 schrieb Marek Olšák:

Quoted 80 lines

Hi,

This patch causes a massive performance drop (by a factor of 100) followed by GPU hangs with F1 2015 (it needs more than 3GB of memory, the card has 2GB). The game normally works really well (30+ FPS on Polaris11 2GB, 40+ FPS on Tonga 2GB).

It should be fixed or the commit should be reverted really quickly.

Marek

Quoted 67 lines · Huang Rui

Clean up the codes to move the release handles into fail labels.

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 21 ++++++++++-----------
  1 file changed, 10 insertions(+), 11 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c +10 -12
index 5cc95f1..4a5c211 100644
@@ -247,35 +247,28 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
         const struct common_firmware_header *header = NULL;
 
         err = amdgpu_bo_create(adev, adev->firmware.fw_size, PAGE_SIZE, true,
-                       AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
+                              AMDGPU_GEM_DOMAIN_GTT, 0, NULL, NULL, bo);
         if (err) {
                 dev_err(adev->dev, "(%d) Firmware buffer allocate failed\n", err);
-               err = -ENOMEM;
                 goto failed;
         }
 
         err = amdgpu_bo_reserve(*bo, false);
         if (err) {
-               amdgpu_bo_unref(bo);
                 dev_err(adev->dev, "(%d) Firmware buffer reserve failed\n", err);
-               goto failed;
+               goto failed_reserve;
         }
 
         err = amdgpu_bo_pin(*bo, AMDGPU_GEM_DOMAIN_GTT, &fw_mc_addr);
         if (err) {
-               amdgpu_bo_unreserve(*bo);
-               amdgpu_bo_unref(bo);
                 dev_err(adev->dev, "(%d) Firmware buffer pin failed\n", err);
-               goto failed;
+               goto failed_pin;
         }
 
         err = amdgpu_bo_kmap(*bo, &fw_buf_ptr);
         if (err) {
                 dev_err(adev->dev, "(%d) Firmware buffer kmap failed\n", err);
-               amdgpu_bo_unpin(*bo);
-               amdgpu_bo_unreserve(*bo);
-               amdgpu_bo_unref(bo);
-               goto failed;
+               goto failed_kmap;
         }
 
         amdgpu_bo_unreserve(*bo);
@@ -291,6 +284,12 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
                 }
         }
 
+failed_kmap:
+       amdgpu_bo_unpin(*bo);
+failed_pin:
+       amdgpu_bo_unreserve(*bo);
+failed_reserve:
+       amdgpu_bo_unref(bo);
  failed:
         if (err)
                 adev->firmware.smu_load = false;
--

2.7.4

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx