Commit c399dfcb authored by Likun Gao's avatar Likun Gao Committed by Alex Deucher

drm/amdgpu: update SDMA 5.2 microcode init

Removed loading duplicate instances of SDMA FW for Sienna_Cichlid,
As sienna_cichlid only use a single image for all instances.
Signed-off-by: default avatarLikun Gao <Likun.Gao@amd.com>
Reviewed-by: default avatarJohn Clements <john.clements@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 5aa02350
...@@ -45,9 +45,6 @@ ...@@ -45,9 +45,6 @@
#include "sdma_v5_2.h" #include "sdma_v5_2.h"
MODULE_FIRMWARE("amdgpu/sienna_cichlid_sdma.bin"); MODULE_FIRMWARE("amdgpu/sienna_cichlid_sdma.bin");
MODULE_FIRMWARE("amdgpu/sienna_cichlid_sdma1.bin");
MODULE_FIRMWARE("amdgpu/sienna_cichlid_sdma2.bin");
MODULE_FIRMWARE("amdgpu/sienna_cichlid_sdma3.bin");
#define SDMA1_REG_OFFSET 0x600 #define SDMA1_REG_OFFSET 0x600
#define SDMA3_REG_OFFSET 0x400 #define SDMA3_REG_OFFSET 0x400
...@@ -94,6 +91,41 @@ static void sdma_v5_2_init_golden_registers(struct amdgpu_device *adev) ...@@ -94,6 +91,41 @@ static void sdma_v5_2_init_golden_registers(struct amdgpu_device *adev)
} }
} }
static int sdma_v5_2_init_inst_ctx(struct amdgpu_sdma_instance *sdma_inst)
{
int err = 0;
const struct sdma_firmware_header_v1_0 *hdr;
err = amdgpu_ucode_validate(sdma_inst->fw);
if (err)
return err;
hdr = (const struct sdma_firmware_header_v1_0 *)sdma_inst->fw->data;
sdma_inst->fw_version = le32_to_cpu(hdr->header.ucode_version);
sdma_inst->feature_version = le32_to_cpu(hdr->ucode_feature_version);
if (sdma_inst->feature_version >= 20)
sdma_inst->burst_nop = true;
return 0;
}
static void sdma_v5_2_destroy_inst_ctx(struct amdgpu_device *adev)
{
int i;
for (i = 0; i < adev->sdma.num_instances; i++) {
if (adev->sdma.instance[i].fw != NULL)
release_firmware(adev->sdma.instance[i].fw);
if (adev->asic_type == CHIP_SIENNA_CICHLID)
break;
}
memset((void*)adev->sdma.instance, 0,
sizeof(struct amdgpu_sdma_instance) * AMDGPU_MAX_SDMA_INSTANCES);
}
/** /**
* sdma_v5_2_init_microcode - load ucode images from disk * sdma_v5_2_init_microcode - load ucode images from disk
* *
...@@ -113,7 +145,6 @@ static int sdma_v5_2_init_microcode(struct amdgpu_device *adev) ...@@ -113,7 +145,6 @@ static int sdma_v5_2_init_microcode(struct amdgpu_device *adev)
int err = 0, i; int err = 0, i;
struct amdgpu_firmware_info *info = NULL; struct amdgpu_firmware_info *info = NULL;
const struct common_firmware_header *header = NULL; const struct common_firmware_header *header = NULL;
const struct sdma_firmware_header_v1_0 *hdr;
DRM_DEBUG("\n"); DRM_DEBUG("\n");
...@@ -125,26 +156,38 @@ static int sdma_v5_2_init_microcode(struct amdgpu_device *adev) ...@@ -125,26 +156,38 @@ static int sdma_v5_2_init_microcode(struct amdgpu_device *adev)
BUG(); BUG();
} }
for (i = 0; i < adev->sdma.num_instances; i++) { snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sdma.bin", chip_name);
if (i == 0)
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sdma.bin", chip_name); err = request_firmware(&adev->sdma.instance[0].fw, fw_name, adev->dev);
else if (err)
goto out;
err = sdma_v5_2_init_inst_ctx(&adev->sdma.instance[0]);
if (err)
goto out;
for (i = 1; i < adev->sdma.num_instances; i++) {
if (adev->asic_type == CHIP_SIENNA_CICHLID) {
memcpy((void*)&adev->sdma.instance[i],
(void*)&adev->sdma.instance[0],
sizeof(struct amdgpu_sdma_instance));
} else {
snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sdma%d.bin", chip_name, i); snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_sdma%d.bin", chip_name, i);
err = request_firmware(&adev->sdma.instance[i].fw, fw_name, adev->dev); err = request_firmware(&adev->sdma.instance[i].fw, fw_name, adev->dev);
if (err) if (err)
goto out; goto out;
err = amdgpu_ucode_validate(adev->sdma.instance[i].fw);
if (err) err = sdma_v5_2_init_inst_ctx(&adev->sdma.instance[0]);
goto out; if (err)
hdr = (const struct sdma_firmware_header_v1_0 *)adev->sdma.instance[i].fw->data; goto out;
adev->sdma.instance[i].fw_version = le32_to_cpu(hdr->header.ucode_version); }
adev->sdma.instance[i].feature_version = le32_to_cpu(hdr->ucode_feature_version); }
if (adev->sdma.instance[i].feature_version >= 20)
adev->sdma.instance[i].burst_nop = true; DRM_DEBUG("psp_load == '%s'\n",
DRM_DEBUG("psp_load == '%s'\n", adev->firmware.load_type == AMDGPU_FW_LOAD_PSP ? "true" : "false");
adev->firmware.load_type == AMDGPU_FW_LOAD_PSP ? "true" : "false");
if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) { for (i = 0; i < adev->sdma.num_instances; i++) {
info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i]; info = &adev->firmware.ucode[AMDGPU_UCODE_ID_SDMA0 + i];
info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i; info->ucode_id = AMDGPU_UCODE_ID_SDMA0 + i;
info->fw = adev->sdma.instance[i].fw; info->fw = adev->sdma.instance[i].fw;
...@@ -153,13 +196,11 @@ static int sdma_v5_2_init_microcode(struct amdgpu_device *adev) ...@@ -153,13 +196,11 @@ static int sdma_v5_2_init_microcode(struct amdgpu_device *adev)
ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE); ALIGN(le32_to_cpu(header->ucode_size_bytes), PAGE_SIZE);
} }
} }
out: out:
if (err) { if (err) {
DRM_ERROR("sdma_v5_2: Failed to load firmware \"%s\"\n", fw_name); DRM_ERROR("sdma_v5_2: Failed to load firmware \"%s\"\n", fw_name);
for (i = 0; i < adev->sdma.num_instances; i++) { sdma_v5_2_destroy_inst_ctx(adev);
release_firmware(adev->sdma.instance[i].fw);
adev->sdma.instance[i].fw = NULL;
}
} }
return err; return err;
} }
...@@ -1204,10 +1245,8 @@ static int sdma_v5_2_sw_init(void *handle) ...@@ -1204,10 +1245,8 @@ static int sdma_v5_2_sw_init(void *handle)
static int sdma_v5_2_sw_fini(void *handle) static int sdma_v5_2_sw_fini(void *handle)
{ {
struct amdgpu_device *adev = (struct amdgpu_device *)handle; struct amdgpu_device *adev = (struct amdgpu_device *)handle;
int i;
for (i = 0; i < adev->sdma.num_instances; i++) sdma_v5_2_destroy_inst_ctx(adev);
amdgpu_ring_fini(&adev->sdma.instance[i].ring);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment