]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
Merge tag 'amd-drm-next-6.5-2023-06-09' of https://gitlab.freedesktop.org/agd5f/linux...
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_ucode.c
index 5cb62e6249c2312ec8806c92a60bd6adc524beb7..16807ff96dc9b4b195c3d3b194bcbeb7599db2f3 100644 (file)
@@ -126,19 +126,6 @@ void amdgpu_ucode_print_gfx_hdr(const struct common_firmware_header *hdr)
        }
 }
 
-void amdgpu_ucode_print_imu_hdr(const struct common_firmware_header *hdr)
-{
-       uint16_t version_major = le16_to_cpu(hdr->header_version_major);
-       uint16_t version_minor = le16_to_cpu(hdr->header_version_minor);
-
-       DRM_DEBUG("IMU\n");
-       amdgpu_ucode_print_common_hdr(hdr);
-
-       if (version_major != 1) {
-               DRM_ERROR("Unknown GFX ucode version: %u.%u\n", version_major, version_minor);
-       }
-}
-
 void amdgpu_ucode_print_rlc_hdr(const struct common_firmware_header *hdr)
 {
        uint16_t version_major = le16_to_cpu(hdr->header_version_major);
@@ -472,6 +459,12 @@ void amdgpu_ucode_print_psp_hdr(const struct common_firmware_header *hdr)
                                DRM_DEBUG("psp_dbg_drv_size_bytes: %u\n",
                                          le32_to_cpu(desc->size_bytes));
                                break;
+                       case PSP_FW_TYPE_PSP_RAS_DRV:
+                               DRM_DEBUG("psp_ras_drv_version: %u\n",
+                                         le32_to_cpu(desc->fw_version));
+                               DRM_DEBUG("psp_ras_drv_size_bytes: %u\n",
+                                         le32_to_cpu(desc->size_bytes));
+                               break;
                        default:
                                DRM_DEBUG("Unsupported PSP fw type: %d\n", desc->fw_type);
                                break;
@@ -504,7 +497,7 @@ void amdgpu_ucode_print_gpu_info_hdr(const struct common_firmware_header *hdr)
        }
 }
 
-int amdgpu_ucode_validate(const struct firmware *fw)
+static int amdgpu_ucode_validate(const struct firmware *fw)
 {
        const struct common_firmware_header *hdr =
                (const struct common_firmware_header *)fw->data;
@@ -669,6 +662,8 @@ const char *amdgpu_ucode_name(enum AMDGPU_UCODE_ID ucode_id)
                return "VCN1_RAM";
        case AMDGPU_UCODE_ID_DMCUB:
                return "DMCUB";
+       case AMDGPU_UCODE_ID_CAP:
+               return "CAP";
        default:
                return "UNKNOWN UCODE";
        }
@@ -753,7 +748,7 @@ static int amdgpu_ucode_init_single_fw(struct amdgpu_device *adev,
        const struct imu_firmware_header_v1_0 *imu_hdr = NULL;
        u8 *ucode_addr;
 
-       if (NULL == ucode->fw)
+       if (!ucode->fw)
                return 0;
 
        ucode->mc_addr = mc_addr;
@@ -977,7 +972,7 @@ static int amdgpu_ucode_patch_jt(struct amdgpu_firmware_info *ucode,
        uint8_t *src_addr = NULL;
        uint8_t *dst_addr = NULL;
 
-       if (NULL == ucode->fw)
+       if (!ucode->fw)
                return 0;
 
        comm_hdr = (const struct common_firmware_header *)ucode->fw->data;
@@ -1048,6 +1043,7 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
                        if (i == AMDGPU_UCODE_ID_CP_MEC1 &&
                            adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
                                const struct gfx_firmware_header_v1_0 *cp_hdr;
+
                                cp_hdr = (const struct gfx_firmware_header_v1_0 *)ucode->fw->data;
                                amdgpu_ucode_patch_jt(ucode,  adev->firmware.fw_buf_mc + fw_offset,
                                                    adev->firmware.fw_buf_ptr + fw_offset);
@@ -1059,12 +1055,229 @@ int amdgpu_ucode_init_bo(struct amdgpu_device *adev)
        return 0;
 }
 
+static const char *amdgpu_ucode_legacy_naming(struct amdgpu_device *adev, int block_type)
+{
+       if (block_type == MP0_HWIP) {
+               switch (adev->ip_versions[MP0_HWIP][0]) {
+               case IP_VERSION(9, 0, 0):
+                       switch (adev->asic_type) {
+                       case CHIP_VEGA10:
+                               return "vega10";
+                       case CHIP_VEGA12:
+                               return "vega12";
+                       default:
+                               return NULL;
+                       }
+               case IP_VERSION(10, 0, 0):
+               case IP_VERSION(10, 0, 1):
+                       if (adev->asic_type == CHIP_RAVEN) {
+                               if (adev->apu_flags & AMD_APU_IS_RAVEN2)
+                                       return "raven2";
+                               else if (adev->apu_flags & AMD_APU_IS_PICASSO)
+                                       return "picasso";
+                               return "raven";
+                       }
+                       break;
+               case IP_VERSION(11, 0, 0):
+                       return "navi10";
+               case IP_VERSION(11, 0, 2):
+                       return "vega20";
+               case IP_VERSION(11, 0, 3):
+                       return "renoir";
+               case IP_VERSION(11, 0, 4):
+                       return "arcturus";
+               case IP_VERSION(11, 0, 5):
+                       return "navi14";
+               case IP_VERSION(11, 0, 7):
+                       return "sienna_cichlid";
+               case IP_VERSION(11, 0, 9):
+                       return "navi12";
+               case IP_VERSION(11, 0, 11):
+                       return "navy_flounder";
+               case IP_VERSION(11, 0, 12):
+                       return "dimgrey_cavefish";
+               case IP_VERSION(11, 0, 13):
+                       return "beige_goby";
+               case IP_VERSION(11, 5, 0):
+                       return "vangogh";
+               case IP_VERSION(12, 0, 1):
+                       return "green_sardine";
+               case IP_VERSION(13, 0, 2):
+                       return "aldebaran";
+               case IP_VERSION(13, 0, 1):
+               case IP_VERSION(13, 0, 3):
+                       return "yellow_carp";
+               }
+       } else if (block_type == MP1_HWIP) {
+               switch (adev->ip_versions[MP1_HWIP][0]) {
+               case IP_VERSION(9, 0, 0):
+               case IP_VERSION(10, 0, 0):
+               case IP_VERSION(10, 0, 1):
+               case IP_VERSION(11, 0, 2):
+                       if (adev->asic_type == CHIP_ARCTURUS)
+                               return "arcturus_smc";
+                       return NULL;
+               case IP_VERSION(11, 0, 0):
+                       return "navi10_smc";
+               case IP_VERSION(11, 0, 5):
+                       return "navi14_smc";
+               case IP_VERSION(11, 0, 9):
+                       return "navi12_smc";
+               case IP_VERSION(11, 0, 7):
+                       return "sienna_cichlid_smc";
+               case IP_VERSION(11, 0, 11):
+                       return "navy_flounder_smc";
+               case IP_VERSION(11, 0, 12):
+                       return "dimgrey_cavefish_smc";
+               case IP_VERSION(11, 0, 13):
+                       return "beige_goby_smc";
+               case IP_VERSION(13, 0, 2):
+                       return "aldebaran_smc";
+               }
+       } else if (block_type == SDMA0_HWIP) {
+               switch (adev->ip_versions[SDMA0_HWIP][0]) {
+               case IP_VERSION(4, 0, 0):
+                       return "vega10_sdma";
+               case IP_VERSION(4, 0, 1):
+                       return "vega12_sdma";
+               case IP_VERSION(4, 1, 0):
+               case IP_VERSION(4, 1, 1):
+                       if (adev->apu_flags & AMD_APU_IS_RAVEN2)
+                               return "raven2_sdma";
+                       else if (adev->apu_flags & AMD_APU_IS_PICASSO)
+                               return "picasso_sdma";
+                       return "raven_sdma";
+               case IP_VERSION(4, 1, 2):
+                       if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                               return "renoir_sdma";
+                       return "green_sardine_sdma";
+               case IP_VERSION(4, 2, 0):
+                       return "vega20_sdma";
+               case IP_VERSION(4, 2, 2):
+                       return "arcturus_sdma";
+               case IP_VERSION(4, 4, 0):
+                       return "aldebaran_sdma";
+               case IP_VERSION(5, 0, 0):
+                       return "navi10_sdma";
+               case IP_VERSION(5, 0, 1):
+                       return "cyan_skillfish2_sdma";
+               case IP_VERSION(5, 0, 2):
+                       return "navi14_sdma";
+               case IP_VERSION(5, 0, 5):
+                       return "navi12_sdma";
+               case IP_VERSION(5, 2, 0):
+                       return "sienna_cichlid_sdma";
+               case IP_VERSION(5, 2, 2):
+                       return "navy_flounder_sdma";
+               case IP_VERSION(5, 2, 4):
+                       return "dimgrey_cavefish_sdma";
+               case IP_VERSION(5, 2, 5):
+                       return "beige_goby_sdma";
+               case IP_VERSION(5, 2, 3):
+                       return "yellow_carp_sdma";
+               case IP_VERSION(5, 2, 1):
+                       return "vangogh_sdma";
+               }
+       } else if (block_type == UVD_HWIP) {
+               switch (adev->ip_versions[UVD_HWIP][0]) {
+               case IP_VERSION(1, 0, 0):
+               case IP_VERSION(1, 0, 1):
+                       if (adev->apu_flags & AMD_APU_IS_RAVEN2)
+                               return "raven2_vcn";
+                       else if (adev->apu_flags & AMD_APU_IS_PICASSO)
+                               return "picasso_vcn";
+                       return "raven_vcn";
+               case IP_VERSION(2, 5, 0):
+                       return "arcturus_vcn";
+               case IP_VERSION(2, 2, 0):
+                       if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                               return "renoir_vcn";
+                       return "green_sardine_vcn";
+               case IP_VERSION(2, 6, 0):
+                       return "aldebaran_vcn";
+               case IP_VERSION(2, 0, 0):
+                       return "navi10_vcn";
+               case IP_VERSION(2, 0, 2):
+                       if (adev->asic_type == CHIP_NAVI12)
+                               return "navi12_vcn";
+                       return "navi14_vcn";
+               case IP_VERSION(3, 0, 0):
+               case IP_VERSION(3, 0, 64):
+               case IP_VERSION(3, 0, 192):
+                       if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 0))
+                               return "sienna_cichlid_vcn";
+                       return "navy_flounder_vcn";
+               case IP_VERSION(3, 0, 2):
+                       return "vangogh_vcn";
+               case IP_VERSION(3, 0, 16):
+                       return "dimgrey_cavefish_vcn";
+               case IP_VERSION(3, 0, 33):
+                       return "beige_goby_vcn";
+               case IP_VERSION(3, 1, 1):
+                       return "yellow_carp_vcn";
+               }
+       } else if (block_type == GC_HWIP) {
+               switch (adev->ip_versions[GC_HWIP][0]) {
+               case IP_VERSION(9, 0, 1):
+                       return "vega10";
+               case IP_VERSION(9, 2, 1):
+                       return "vega12";
+               case IP_VERSION(9, 4, 0):
+                       return "vega20";
+               case IP_VERSION(9, 2, 2):
+               case IP_VERSION(9, 1, 0):
+                       if (adev->apu_flags & AMD_APU_IS_RAVEN2)
+                               return "raven2";
+                       else if (adev->apu_flags & AMD_APU_IS_PICASSO)
+                               return "picasso";
+                       return "raven";
+               case IP_VERSION(9, 4, 1):
+                       return "arcturus";
+               case IP_VERSION(9, 3, 0):
+                       if (adev->apu_flags & AMD_APU_IS_RENOIR)
+                               return "renoir";
+                       return "green_sardine";
+               case IP_VERSION(9, 4, 2):
+                       return "aldebaran";
+               case IP_VERSION(10, 1, 10):
+                       return "navi10";
+               case IP_VERSION(10, 1, 1):
+                       return "navi14";
+               case IP_VERSION(10, 1, 2):
+                       return "navi12";
+               case IP_VERSION(10, 3, 0):
+                       return "sienna_cichlid";
+               case IP_VERSION(10, 3, 2):
+                       return "navy_flounder";
+               case IP_VERSION(10, 3, 1):
+                       return "vangogh";
+               case IP_VERSION(10, 3, 4):
+                       return "dimgrey_cavefish";
+               case IP_VERSION(10, 3, 5):
+                       return "beige_goby";
+               case IP_VERSION(10, 3, 3):
+                       return "yellow_carp";
+               case IP_VERSION(10, 1, 3):
+               case IP_VERSION(10, 1, 4):
+                       return "cyan_skillfish2";
+               }
+       }
+       return NULL;
+}
+
 void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type, char *ucode_prefix, int len)
 {
        int maj, min, rev;
        char *ip_name;
+       const char *legacy;
        uint32_t version = adev->ip_versions[block_type][0];
 
+       legacy = amdgpu_ucode_legacy_naming(adev, block_type);
+       if (legacy) {
+               snprintf(ucode_prefix, len, "%s", legacy);
+               return;
+       }
+
        switch (block_type) {
        case GC_HWIP:
                ip_name = "gc";
@@ -1091,3 +1304,39 @@ void amdgpu_ucode_ip_version_decode(struct amdgpu_device *adev, int block_type,
 
        snprintf(ucode_prefix, len, "%s_%d_%d_%d", ip_name, maj, min, rev);
 }
+
+/*
+ * amdgpu_ucode_request - Fetch and validate amdgpu microcode
+ *
+ * @adev: amdgpu device
+ * @fw: pointer to load firmware to
+ * @fw_name: firmware to load
+ *
+ * This is a helper that will use request_firmware and amdgpu_ucode_validate
+ * to load and run basic validation on firmware. If the load fails, remap
+ * the error code to -ENODEV, so that early_init functions will fail to load.
+ */
+int amdgpu_ucode_request(struct amdgpu_device *adev, const struct firmware **fw,
+                        const char *fw_name)
+{
+       int err = request_firmware(fw, fw_name, adev->dev);
+
+       if (err)
+               return -ENODEV;
+       err = amdgpu_ucode_validate(*fw);
+       if (err)
+               dev_dbg(adev->dev, "\"%s\" failed to validate\n", fw_name);
+
+       return err;
+}
+
+/*
+ * amdgpu_ucode_release - Release firmware microcode
+ *
+ * @fw: pointer to firmware to release
+ */
+void amdgpu_ucode_release(const struct firmware **fw)
+{
+       release_firmware(*fw);
+       *fw = NULL;
+}
This page took 0.048311 seconds and 4 git commands to generate.