mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mario Limonciello <mario.limonciello@amd.com>
To: Alex Deucher <alexander.deucher@amd.com>, <linux-kernel@vger.kernel.org>
Cc: Javier Martinez Canillas <javierm@redhat.com>,
	Carlos Soriano Sanchez <csoriano@redhat.com>,
	<amd-gfx@lists.freedesktop.org>,
	<dri-devel@lists.freedesktop.org>,
	David Airlie <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>, <christian.koenig@amd.com>,
	Lazar Lijo <Lijo.Lazar@amd.com>,
	Mario Limonciello <mario.limonciello@amd.com>,
	"Pan, Xinhui" <Xinhui.Pan@amd.com>
Subject: [PATCH v4 23/27] drm/amd: Use `amdgpu_ucode_load` helper for PSP
Date: Tue, 3 Jan 2023 16:18:42 -0600	[thread overview]
Message-ID: <20230103221852.22813-24-mario.limonciello@amd.com> (raw)
In-Reply-To: <20230103221852.22813-1-mario.limonciello@amd.com>

The `amdgpu_ucode_load` helper will ensure that the return code for
missing firmware is -ENODEV so that early_init can fail.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v3->v4:
 * New patch
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 42 ++++++-------------------
 drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h |  3 +-
 2 files changed, 11 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index 3b0644600a1f..f45362dd8228 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -2912,11 +2912,7 @@ int psp_init_asd_microcode(struct psp_context *psp, char *ucode_prefix)
 	int err = 0;
 
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_asd.bin", ucode_prefix);
-	err = request_firmware(&adev->psp.asd_fw, fw_name, adev->dev);
-	if (err)
-		goto out;
-
-	err = amdgpu_ucode_validate(adev->psp.asd_fw);
+	err = amdgpu_ucode_load(adev, &adev->psp.asd_fw, fw_name);
 	if (err)
 		goto out;
 
@@ -2928,7 +2924,6 @@ int psp_init_asd_microcode(struct psp_context *psp, char *ucode_prefix)
 				le32_to_cpu(asd_hdr->header.ucode_array_offset_bytes);
 	return 0;
 out:
-	dev_err(adev->dev, "fail to initialize asd microcode\n");
 	release_firmware(adev->psp.asd_fw);
 	adev->psp.asd_fw = NULL;
 	return err;
@@ -2942,11 +2937,7 @@ int psp_init_toc_microcode(struct psp_context *psp, char *ucode_prefix)
 	int err = 0;
 
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_toc.bin", ucode_prefix);
-	err = request_firmware(&adev->psp.toc_fw, fw_name, adev->dev);
-	if (err)
-		goto out;
-
-	err = amdgpu_ucode_validate(adev->psp.toc_fw);
+	err = amdgpu_ucode_load(adev, &adev->psp.toc_fw, fw_name);
 	if (err)
 		goto out;
 
@@ -2958,7 +2949,6 @@ int psp_init_toc_microcode(struct psp_context *psp, char *ucode_prefix)
 				le32_to_cpu(toc_hdr->header.ucode_array_offset_bytes);
 	return 0;
 out:
-	dev_err(adev->dev, "fail to request/validate toc microcode\n");
 	release_firmware(adev->psp.toc_fw);
 	adev->psp.toc_fw = NULL;
 	return err;
@@ -3105,11 +3095,7 @@ int psp_init_sos_microcode(struct psp_context *psp, char *ucode_prefix)
 	int fw_index = 0;
 
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sos.bin", ucode_prefix);
-	err = request_firmware(&adev->psp.sos_fw, fw_name, adev->dev);
-	if (err)
-		goto out;
-
-	err = amdgpu_ucode_validate(adev->psp.sos_fw);
+	err = amdgpu_ucode_load(adev, &adev->psp.sos_fw, fw_name);
 	if (err)
 		goto out;
 
@@ -3181,8 +3167,6 @@ int psp_init_sos_microcode(struct psp_context *psp, char *ucode_prefix)
 
 	return 0;
 out:
-	dev_err(adev->dev,
-		"failed to init sos firmware\n");
 	release_firmware(adev->psp.sos_fw);
 	adev->psp.sos_fw = NULL;
 
@@ -3340,10 +3324,7 @@ int psp_init_ta_microcode(struct psp_context *psp, char *ucode_prefix)
 	int err;
 
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_ta.bin", ucode_prefix);
-	err = request_firmware(&adev->psp.ta_fw, fw_name, adev->dev);
-	if (err)
-		return err;
-	err = amdgpu_ucode_validate(adev->psp.ta_fw);
+	err = amdgpu_ucode_load(adev, &adev->psp.ta_fw, fw_name);
 	if (err)
 		return err;
 
@@ -3383,17 +3364,14 @@ int psp_init_cap_microcode(struct psp_context *psp, char *ucode_prefix)
 	}
 
 	snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_cap.bin", ucode_prefix);
-	err = request_firmware(&adev->psp.cap_fw, fw_name, adev->dev);
-	if (err) {
-		dev_warn(adev->dev, "cap microcode does not exist, skip\n");
-		err = 0;
-		goto out;
-	}
-
-	err = amdgpu_ucode_validate(adev->psp.cap_fw);
+	err = amdgpu_ucode_load(adev, &adev->psp.cap_fw, fw_name);
 	if (err) {
+		if (err == -ENODEV) {
+			dev_warn(adev->dev, "cap microcode does not exist, skip\n");
+			err = 0;
+			goto out;
+		}
 		dev_err(adev->dev, "fail to initialize cap microcode\n");
-		goto out;
 	}
 
 	info = &adev->firmware.ucode[AMDGPU_UCODE_ID_CAP];
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
index 47b88233bf94..415d32306b9a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h
@@ -506,8 +506,7 @@ int psp_init_asd_microcode(struct psp_context *psp, char *ucode_prefix);
 int psp_init_toc_microcode(struct psp_context *psp, char *ucode_prefix);
 int psp_init_sos_microcode(struct psp_context *psp, char *ucode_prefix);
 int psp_init_ta_microcode(struct psp_context *psp, char *ucode_prefix);
-int psp_init_cap_microcode(struct psp_context *psp,
-			  const char *chip_name);
+int psp_init_cap_microcode(struct psp_context *psp, char *ucode_prefix);
 int psp_get_fw_attestation_records_addr(struct psp_context *psp,
 					uint64_t *output_ptr);
 
-- 
2.34.1


  parent reply	other threads:[~2023-01-03 22:22 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03 22:18 [PATCH v4 00/27] Recover from failure to probe GPU Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 01/27] drm/amd: Delay removal of the firmware framebuffer Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 02/27] drm/amd: Add a legacy mapping to "amdgpu_ucode_ip_version_decode" Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 03/27] drm/amd: Convert SMUv11 microcode to use `amdgpu_ucode_ip_version_decode` Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 04/27] drm/amd: Convert SMUv13 " Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 05/27] drm/amd: Add a new helper for loading/validating microcode Mario Limonciello
2023-01-04  4:53   ` Lazar, Lijo
2023-01-04  9:37     ` Christian König
2023-01-03 22:18 ` [PATCH v4 06/27] drm/amd: Use `amdgpu_ucode_load` helper for SDMA Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 07/27] drm/amd: Convert SDMA to use `amdgpu_ucode_ip_version_decode` Mario Limonciello
2023-01-04  4:54   ` Lazar, Lijo
2023-01-03 22:18 ` [PATCH v4 08/27] drm/amd: Make SDMA firmware load failures less noisy Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 09/27] drm/amd: Use `amdgpu_ucode_load` helper for VCN Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 10/27] drm/amd: Load VCN microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 11/27] drm/amd: Load MES " Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 12/27] drm/amd: Use `amdgpu_ucode_load` helper for MES Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 13/27] drm/amd: Remove superfluous assignment for `adev->mes.adev` Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 14/27] drm/amd: Use `amdgpu_ucode_load` helper for GFX9 Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 15/27] drm/amd: Load GFX9 microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 16/27] drm/amd: Use `amdgpu_ucode_load` helper for GFX10 Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 17/27] drm/amd: Load GFX10 microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 18/27] drm/amd: Use `amdgpu_ucode_load` helper for GFX11 Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 19/27] drm/amd: Load GFX11 microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 20/27] drm/amd: Parse both v1 and v2 TA microcode headers using same function Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 21/27] drm/amd: Avoid BUG() for case of SRIOV missing IP version Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 22/27] drm/amd: Load PSP microcode during early_init Mario Limonciello
2023-01-03 22:18 ` Mario Limonciello [this message]
2023-01-03 22:18 ` [PATCH v4 24/27] drm/amd/display: Load DMUB " Mario Limonciello
2023-01-04 15:52   ` Harry Wentland
2023-01-03 22:18 ` [PATCH v4 25/27] drm/amd: Use `amdgpu_ucode_load` helper for SMU Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 26/27] drm/amd: Load SMU microcode during early_init Mario Limonciello
2023-01-03 22:18 ` [PATCH v4 27/27] drm/amd: Optimize SRIOV switch/case for PSP microcode load Mario Limonciello
2023-01-04 13:18   ` Christian König
2023-01-04 15:42     ` Limonciello, Mario

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230103221852.22813-24-mario.limonciello@amd.com \
    --to=mario.limonciello@amd.com \
    --cc=Lijo.Lazar@amd.com \
    --cc=Xinhui.Pan@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=csoriano@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=javierm@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®