From: Frank Min <Frank.Min@amd.com>
To: <amd-gfx@lists.freedesktop.org>
Cc: Frank Min <Frank.Min@amd.com>, Kevin Wang <kevin.wang@amd.com>
Subject: [PATCH 5/9] drm/amdgpu: add lsdma v8 fw loading support
Date: Fri, 4 Dec 2026 22:24:04 +0800 [thread overview]
Message-ID: <20261204142408.988734-5-Frank.Min@amd.com> (raw)
In-Reply-To: <20261204142408.988734-1-Frank.Min@amd.com>
Add lsdma v8 fw loading support.
Signed-off-by: Frank Min <Frank.Min@amd.com>
Reviewed-by: Kevin Wang <kevin.wang@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.c | 51 +++++++++++++++++++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.h | 5 +++
drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c | 3 ++
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 12 ++++++
drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h | 10 +++++
drivers/gpu/drm/amd/amdgpu/lsdma_v8_0.c | 2 +
drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c | 3 ++
drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c | 7 ++++
8 files changed, 93 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.c
index 1f83d9b69135b..5d093e25cac6d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.c
@@ -21,6 +21,7 @@
*
*/
+#include <linux/firmware.h>
#include "amdgpu.h"
#include "amdgpu_lsdma.h"
@@ -146,3 +147,53 @@ int amdgpu_lsdma_selftest(struct amdgpu_device *adev)
return r;
}
+
+void amdgpu_lsdma_fini_microcode(struct amdgpu_device *adev)
+{
+ amdgpu_ucode_release(&adev->lsdma.fw);
+ adev->lsdma.fw_version = 0;
+ adev->lsdma.feature_version = 0;
+}
+
+int amdgpu_lsdma_init_microcode(struct amdgpu_device *adev)
+{
+ const struct lsdma_firmware_header_v1_0 *hdr;
+ struct amdgpu_firmware_info *info;
+ char ucode_prefix[30];
+ int err;
+
+ /* LSDMA before v8 has no firmware */
+ if (amdgpu_ip_version(adev, LSDMA_HWIP, 0) < IP_VERSION(8, 0, 0))
+ return 0;
+
+ amdgpu_ucode_ip_version_decode(adev, LSDMA_HWIP, ucode_prefix, sizeof(ucode_prefix));
+ err = amdgpu_ucode_request(adev, &adev->lsdma.fw, AMDGPU_UCODE_REQUIRED,
+ "amdgpu/%s.bin", ucode_prefix);
+ if (err)
+ goto out;
+
+ hdr = (const struct lsdma_firmware_header_v1_0 *)adev->lsdma.fw->data;
+ switch (le16_to_cpu(hdr->header.header_version_major)) {
+ case 1:
+ break;
+ default:
+ err = -EINVAL;
+ goto out;
+ }
+
+ adev->lsdma.fw_version = le32_to_cpu(hdr->header.ucode_version);
+ adev->lsdma.feature_version = le32_to_cpu(hdr->ucode_feature_version);
+
+ if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
+ info = &adev->firmware.ucode[AMDGPU_UCODE_ID_LSDMA];
+ info->ucode_id = AMDGPU_UCODE_ID_LSDMA;
+ info->fw = adev->lsdma.fw;
+ adev->firmware.fw_size +=
+ ALIGN(le32_to_cpu(hdr->ucode_size_bytes), PAGE_SIZE);
+ }
+
+out:
+ if (err)
+ amdgpu_lsdma_fini_microcode(adev);
+ return err;
+}
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.h
index f0a5eeb3529fb..79ac16e352d71 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_lsdma.h
@@ -30,6 +30,9 @@ struct amdgpu_lsdma {
struct mutex lock;
const struct amdgpu_lsdma_funcs *funcs;
uint32_t inst_mask;
+ const struct firmware *fw;
+ uint32_t fw_version;
+ uint32_t feature_version;
};
struct amdgpu_lsdma_funcs {
@@ -47,5 +50,7 @@ int amdgpu_lsdma_fill_mem(struct amdgpu_device *adev, uint64_t dst_addr,
int amdgpu_lsdma_wait_for(struct amdgpu_device *adev, uint32_t reg_index,
uint32_t reg_val, uint32_t mask);
int amdgpu_lsdma_selftest(struct amdgpu_device *adev);
+int amdgpu_lsdma_init_microcode(struct amdgpu_device *adev);
+void amdgpu_lsdma_fini_microcode(struct amdgpu_device *adev);
#endif
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
index da4672707755c..9624b3dc95bfe 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -3759,6 +3759,9 @@ int amdgpu_psp_get_fw_type(struct amdgpu_firmware_info *ucode,
case AMDGPU_UCODE_ID_SDMA_UCODE_TH1:
*type = GFX_FW_TYPE_SDMA_UCODE_TH1;
break;
+ case AMDGPU_UCODE_ID_LSDMA:
+ *type = GFX_FW_TYPE_LSDMA;
+ break;
case AMDGPU_UCODE_ID_IMU_I:
*type = GFX_FW_TYPE_IMU_I;
break;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
index d2ce526dd95cc..c6b9078570456 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
@@ -729,6 +729,8 @@ const char *amdgpu_ucode_name(enum AMDGPU_UCODE_ID ucode_id)
return "JPEG";
case AMDGPU_UCODE_ID_SDMA_RS64:
return "RS64_SDMA";
+ case AMDGPU_UCODE_ID_LSDMA:
+ return "LSDMA";
case AMDGPU_UCODE_ID_CP_RS64_PFP:
return "RS64_PFP";
case AMDGPU_UCODE_ID_CP_RS64_ME:
@@ -878,6 +880,7 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
const struct mes_firmware_header_v1_0 *mes_hdr = NULL;
const struct sdma_firmware_header_v2_0 *sdma_hdr = NULL;
const struct sdma_firmware_header_v3_0 *sdmav3_hdr = NULL;
+ const struct lsdma_firmware_header_v1_0 *lsdma_hdr = NULL;
const struct imu_firmware_header_v1_0 *imu_hdr = NULL;
const struct vpe_firmware_header_v1_0 *vpe_hdr = NULL;
const struct umsch_mm_firmware_header_v1_0 *umsch_mm_hdr = NULL;
@@ -900,6 +903,7 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
mes_hdr = (const struct mes_firmware_header_v1_0 *)ucode->fw->data;
sdma_hdr = (const struct sdma_firmware_header_v2_0 *)ucode->fw->data;
sdmav3_hdr = (const struct sdma_firmware_header_v3_0 *)ucode->fw->data;
+ lsdma_hdr = (const struct lsdma_firmware_header_v1_0 *)ucode->fw->data;
imu_hdr = (const struct imu_firmware_header_v1_0 *)ucode->fw->data;
vpe_hdr = (const struct vpe_firmware_header_v1_0 *)ucode->fw->data;
umsch_mm_hdr = (const struct umsch_mm_firmware_header_v1_0 *)ucode->fw->data;
@@ -921,6 +925,11 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
ucode_addr = (u8 *)ucode->fw->data +
le32_to_cpu(sdmav3_hdr->header.ucode_array_offset_bytes);
break;
+ case AMDGPU_UCODE_ID_LSDMA:
+ ucode->ucode_size = le32_to_cpu(lsdma_hdr->ucode_size_bytes);
+ ucode_addr = (u8 *)ucode->fw->data +
+ le32_to_cpu(lsdma_hdr->header.ucode_array_offset_bytes);
+ break;
case AMDGPU_UCODE_ID_CP_MEC1:
case AMDGPU_UCODE_ID_CP_MEC2:
ucode->ucode_size = le32_to_cpu(header->ucode_size_bytes) -
@@ -1500,6 +1509,9 @@ void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type,
case SDMA0_HWIP:
ip_name = "sdma";
break;
+ case LSDMA_HWIP:
+ ip_name = "lsdma";
+ break;
case MP0_HWIP:
ip_name = "psp";
break;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
index 7c809692807fc..f8a57ff454c58 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.h
@@ -375,6 +375,14 @@ struct sdma_firmware_header_v3_0 {
uint32_t ucode_size_bytes;
};
+/* version_major=1, version_minor=0 */
+struct lsdma_firmware_header_v1_0 {
+ struct common_firmware_header header;
+ uint32_t ucode_feature_version;
+ uint32_t ucode_offset_bytes;
+ uint32_t ucode_size_bytes;
+};
+
/* gpu info payload */
struct gpu_info_firmware_v1_0 {
uint32_t gc_num_se;
@@ -463,6 +471,7 @@ union amdgpu_firmware_header {
struct sdma_firmware_header_v1_1 sdma_v1_1;
struct sdma_firmware_header_v2_0 sdma_v2_0;
struct sdma_firmware_header_v3_0 sdma_v3_0;
+ struct lsdma_firmware_header_v1_0 lsdma;
struct gpu_info_firmware_header_v1_0 gpu_info;
struct dmcu_firmware_header_v1_0 dmcu;
struct dmcub_firmware_header_v1_0 dmcub;
@@ -489,6 +498,7 @@ enum AMDGPU_UCODE_ID {
AMDGPU_UCODE_ID_SDMA_UCODE_TH0,
AMDGPU_UCODE_ID_SDMA_UCODE_TH1,
AMDGPU_UCODE_ID_SDMA_RS64,
+ AMDGPU_UCODE_ID_LSDMA,
AMDGPU_UCODE_ID_CP_CE,
AMDGPU_UCODE_ID_CP_PFP,
AMDGPU_UCODE_ID_CP_ME,
diff --git a/drivers/gpu/drm/amd/amdgpu/lsdma_v8_0.c b/drivers/gpu/drm/amd/amdgpu/lsdma_v8_0.c
index d19d7f8add50e..722c85b2ccf3b 100644
--- a/drivers/gpu/drm/amd/amdgpu/lsdma_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/lsdma_v8_0.c
@@ -29,6 +29,8 @@
#include "lsdma/lsdma_8_0_1_offset.h"
#include "lsdma/lsdma_8_0_1_sh_mask.h"
+MODULE_FIRMWARE("amdgpu/lsdma_8_0_1.bin");
+
static int lsdma_v8_0_wait_pio_status(struct amdgpu_device *adev)
{
u32 error_mask;
diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c b/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c
index a7c7dcb74d989..3c77db281068d 100644
--- a/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/psp_v15_0_3.c
@@ -684,6 +684,9 @@ static int psp_v15_0_3_get_fw_type(struct amdgpu_firmware_info *ucode,
case AMDGPU_UCODE_ID_SDMA_RS64:
*type = GFX_FW_TYPE_SDMA0;
break;
+ case AMDGPU_UCODE_ID_LSDMA:
+ *type = GFX_FW_TYPE_LSDMA;
+ break;
case AMDGPU_UCODE_ID_CP_MES:
*type = GFX_FW_TYPE_CP_MES;
break;
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c
index 58b85fbba2ca3..e39a005b0faf4 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v8_0.c
@@ -1293,6 +1293,12 @@ static int sdma_v8_0_early_init(struct amdgpu_ip_block *ip_block)
return r;
}
+ r = amdgpu_lsdma_init_microcode(adev);
+ if (r) {
+ DRM_ERROR("Failed to init lsdma firmware!\n");
+ return r;
+ }
+
sdma_v8_0_set_ring_funcs(adev);
amdgpu_sdma_set_vm_pte_scheds(adev, &sdma_v8_0_vm_pte_funcs);
sdma_v8_0_set_irq_funcs(adev);
@@ -1377,6 +1383,7 @@ static int sdma_v8_0_sw_fini(struct amdgpu_ip_block *ip_block)
amdgpu_sdma_sysfs_reset_mask_fini(adev);
amdgpu_sdma_destroy_inst_ctx(adev, true);
+ amdgpu_lsdma_fini_microcode(adev);
if (adev->firmware.load_type == AMDGPU_FW_LOAD_DIRECT)
sdma_v8_0_0_free_ucode_buffer(adev);
--
2.43.0
next prev parent reply other threads:[~2026-12-04 14:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 14:24 [PATCH 1/9] drm/amdgpu: skip vm inv for kiq ring Frank Min
2026-12-04 14:24 ` [PATCH 2/9] drm/amdgpu: disable gfx 13 pipe 1 ring Frank Min
2026-12-04 14:55 ` sashiko-bot
2026-12-04 16:05 ` Alex Deucher
2026-12-04 14:24 ` [PATCH 3/9] drm/amdgpu: update table info retrieval from discovery binary Frank Min
2026-12-04 15:14 ` sashiko-bot
2026-12-04 16:19 ` Alex Deucher
2026-12-04 14:24 ` [PATCH 4/9] drm/amdgpu: add lsdma v8 fw query interface Frank Min
2026-12-04 15:25 ` sashiko-bot
2026-12-04 16:21 ` Alex Deucher
2026-12-04 14:24 ` Frank Min [this message]
2026-12-04 15:47 ` [PATCH 5/9] drm/amdgpu: add lsdma v8 fw loading support sashiko-bot
2026-12-04 14:24 ` [PATCH 6/9] drm/amdgpu: Fix system aperture size for gfx13 Frank Min
2026-12-04 16:01 ` sashiko-bot
2026-12-04 14:24 ` [PATCH 7/9] drm/amdgpu: remove the unused ring parameter in update_spm_vmid() " Frank Min
2026-12-04 16:03 ` Alex Deucher
2026-12-04 16:11 ` sashiko-bot
2026-12-04 14:24 ` [PATCH 8/9] drm/amdgpu: enable uni-mes " Frank Min
2026-12-04 16:41 ` sashiko-bot
2026-12-04 17:24 ` Alex Deucher
2026-12-04 14:24 ` [PATCH 9/9] drm/amdgpu: fix mutex unlock position for ucode loading Frank Min
2026-12-04 16:12 ` Alex Deucher
2026-12-04 16:52 ` sashiko-bot
2026-12-04 14:41 ` [PATCH 1/9] drm/amdgpu: skip vm inv for kiq ring sashiko-bot
2026-12-04 16:16 ` Alex Deucher
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=20261204142408.988734-5-Frank.Min@amd.com \
--to=frank.min@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=kevin.wang@amd.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.