drm/amdgpu: get_fw_version isn't ASIC specific
authorAmber Lin <Amber.Lin@amd.com>
Fri, 12 Apr 2019 15:07:16 +0000 (11:07 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 19 Apr 2019 16:32:40 +0000 (11:32 -0500)
Method of getting firmware version is the same across ASICs, so remove
them from ASIC-specific files and create one in amdgpu_amdkfd.c. This new
created get_fw_version simply reads fw_version from adev->gfx than parsing
the ucode header.

Signed-off-by: Amber Lin <Amber.Lin@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
drivers/gpu/drm/amd/amdkfd/kfd_device.c
drivers/gpu/drm/amd/include/kgd_kfd_interface.h

index acf8ae0cee9a43fdc72caacaf541d7f36f263a27..aeead072fa7957c5080fbeef02f41e5f159c6631 100644 (file)
@@ -335,6 +335,43 @@ void amdgpu_amdkfd_free_gtt_mem(struct kgd_dev *kgd, void *mem_obj)
        amdgpu_bo_unref(&(bo));
 }
 
+uint32_t amdgpu_amdkfd_get_fw_version(struct kgd_dev *kgd,
+                                     enum kgd_engine_type type)
+{
+       struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
+
+       switch (type) {
+       case KGD_ENGINE_PFP:
+               return adev->gfx.pfp_fw_version;
+
+       case KGD_ENGINE_ME:
+               return adev->gfx.me_fw_version;
+
+       case KGD_ENGINE_CE:
+               return adev->gfx.ce_fw_version;
+
+       case KGD_ENGINE_MEC1:
+               return adev->gfx.mec_fw_version;
+
+       case KGD_ENGINE_MEC2:
+               return adev->gfx.mec2_fw_version;
+
+       case KGD_ENGINE_RLC:
+               return adev->gfx.rlc_fw_version;
+
+       case KGD_ENGINE_SDMA1:
+               return adev->sdma.instance[0].fw_version;
+
+       case KGD_ENGINE_SDMA2:
+               return adev->sdma.instance[1].fw_version;
+
+       default:
+               return 0;
+       }
+
+       return 0;
+}
+
 void amdgpu_amdkfd_get_local_mem_info(struct kgd_dev *kgd,
                                      struct kfd_local_mem_info *mem_info)
 {
index 775f815f9521bd429a7970eac871641f8af1c44d..4e37fa7e85b1b01f22c82600904ffbc430fcea99 100644 (file)
@@ -81,6 +81,18 @@ struct amdgpu_kfd_dev {
        uint64_t vram_used;
 };
 
+enum kgd_engine_type {
+       KGD_ENGINE_PFP = 1,
+       KGD_ENGINE_ME,
+       KGD_ENGINE_CE,
+       KGD_ENGINE_MEC1,
+       KGD_ENGINE_MEC2,
+       KGD_ENGINE_RLC,
+       KGD_ENGINE_SDMA1,
+       KGD_ENGINE_SDMA2,
+       KGD_ENGINE_MAX
+};
+
 struct amdgpu_amdkfd_fence *amdgpu_amdkfd_fence_create(u64 context,
                                                       struct mm_struct *mm);
 bool amdkfd_fence_check_mm(struct dma_fence *f, struct mm_struct *mm);
@@ -142,6 +154,8 @@ int amdgpu_amdkfd_alloc_gtt_mem(struct kgd_dev *kgd, size_t size,
                                void **mem_obj, uint64_t *gpu_addr,
                                void **cpu_ptr, bool mqd_gfx9);
 void amdgpu_amdkfd_free_gtt_mem(struct kgd_dev *kgd, void *mem_obj);
+uint32_t amdgpu_amdkfd_get_fw_version(struct kgd_dev *kgd,
+                                     enum kgd_engine_type type);
 void amdgpu_amdkfd_get_local_mem_info(struct kgd_dev *kgd,
                                      struct kfd_local_mem_info *mem_info);
 uint64_t amdgpu_amdkfd_get_gpu_clock_counter(struct kgd_dev *kgd);
index ff7fac7df34b5be7b7e46cabc1f743e3775a8761..fa09e11a600c8df59ab61c545eafb25ab7c5fff1 100644 (file)
 
 #include <linux/fdtable.h>
 #include <linux/uaccess.h>
-#include <linux/firmware.h>
 #include <linux/mmu_context.h>
 #include <drm/drmP.h>
 #include "amdgpu.h"
 #include "amdgpu_amdkfd.h"
 #include "cikd.h"
 #include "cik_sdma.h"
-#include "amdgpu_ucode.h"
 #include "gfx_v7_0.h"
 #include "gca/gfx_7_2_d.h"
 #include "gca/gfx_7_2_enum.h"
@@ -139,7 +137,6 @@ static bool get_atc_vmid_pasid_mapping_valid(struct kgd_dev *kgd, uint8_t vmid);
 static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
                                                        uint8_t vmid);
 
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
 static void set_scratch_backing_va(struct kgd_dev *kgd,
                                        uint64_t va, uint32_t vmid);
 static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid,
@@ -191,7 +188,6 @@ static const struct kfd2kgd_calls kfd2kgd = {
        .address_watch_get_offset = kgd_address_watch_get_offset,
        .get_atc_vmid_pasid_mapping_pasid = get_atc_vmid_pasid_mapping_pasid,
        .get_atc_vmid_pasid_mapping_valid = get_atc_vmid_pasid_mapping_valid,
-       .get_fw_version = get_fw_version,
        .set_scratch_backing_va = set_scratch_backing_va,
        .get_tile_config = get_tile_config,
        .set_vm_context_page_table_base = set_vm_context_page_table_base,
@@ -792,63 +788,6 @@ static void set_scratch_backing_va(struct kgd_dev *kgd,
        unlock_srbm(kgd);
 }
 
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
-       const union amdgpu_firmware_header *hdr;
-
-       switch (type) {
-       case KGD_ENGINE_PFP:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.pfp_fw->data;
-               break;
-
-       case KGD_ENGINE_ME:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.me_fw->data;
-               break;
-
-       case KGD_ENGINE_CE:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.ce_fw->data;
-               break;
-
-       case KGD_ENGINE_MEC1:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.mec_fw->data;
-               break;
-
-       case KGD_ENGINE_MEC2:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.mec2_fw->data;
-               break;
-
-       case KGD_ENGINE_RLC:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.rlc_fw->data;
-               break;
-
-       case KGD_ENGINE_SDMA1:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->sdma.instance[0].fw->data;
-               break;
-
-       case KGD_ENGINE_SDMA2:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->sdma.instance[1].fw->data;
-               break;
-
-       default:
-               return 0;
-       }
-
-       if (hdr == NULL)
-               return 0;
-
-       /* Only 12 bit in use*/
-       return hdr->common.ucode_version;
-}
-
 static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid,
                        uint64_t page_table_base)
 {
index 56ea929f524b5c31831abdb8d50233aa01929636..fec3a6aa1de61b119b4256f58edfcd4ab4149d8c 100644 (file)
 #include <linux/module.h>
 #include <linux/fdtable.h>
 #include <linux/uaccess.h>
-#include <linux/firmware.h>
 #include <linux/mmu_context.h>
 #include <drm/drmP.h>
 #include "amdgpu.h"
 #include "amdgpu_amdkfd.h"
-#include "amdgpu_ucode.h"
 #include "gfx_v8_0.h"
 #include "gca/gfx_8_0_sh_mask.h"
 #include "gca/gfx_8_0_d.h"
@@ -95,7 +93,6 @@ static bool get_atc_vmid_pasid_mapping_valid(struct kgd_dev *kgd,
                uint8_t vmid);
 static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
                uint8_t vmid);
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
 static void set_scratch_backing_va(struct kgd_dev *kgd,
                                        uint64_t va, uint32_t vmid);
 static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid,
@@ -148,7 +145,6 @@ static const struct kfd2kgd_calls kfd2kgd = {
                        get_atc_vmid_pasid_mapping_pasid,
        .get_atc_vmid_pasid_mapping_valid =
                        get_atc_vmid_pasid_mapping_valid,
-       .get_fw_version = get_fw_version,
        .set_scratch_backing_va = set_scratch_backing_va,
        .get_tile_config = get_tile_config,
        .set_vm_context_page_table_base = set_vm_context_page_table_base,
@@ -751,63 +747,6 @@ static void set_scratch_backing_va(struct kgd_dev *kgd,
        unlock_srbm(kgd);
 }
 
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
-       const union amdgpu_firmware_header *hdr;
-
-       switch (type) {
-       case KGD_ENGINE_PFP:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.pfp_fw->data;
-               break;
-
-       case KGD_ENGINE_ME:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.me_fw->data;
-               break;
-
-       case KGD_ENGINE_CE:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.ce_fw->data;
-               break;
-
-       case KGD_ENGINE_MEC1:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.mec_fw->data;
-               break;
-
-       case KGD_ENGINE_MEC2:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.mec2_fw->data;
-               break;
-
-       case KGD_ENGINE_RLC:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->gfx.rlc_fw->data;
-               break;
-
-       case KGD_ENGINE_SDMA1:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->sdma.instance[0].fw->data;
-               break;
-
-       case KGD_ENGINE_SDMA2:
-               hdr = (const union amdgpu_firmware_header *)
-                                               adev->sdma.instance[1].fw->data;
-               break;
-
-       default:
-               return 0;
-       }
-
-       if (hdr == NULL)
-               return 0;
-
-       /* Only 12 bit in use*/
-       return hdr->common.ucode_version;
-}
-
 static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid,
                uint64_t page_table_base)
 {
index 5c51d4910650934752d22c5bd2b0f06c768708ee..ef3d93b995b2ed8772612581eb8da0d9ad3752c3 100644 (file)
 #include <linux/module.h>
 #include <linux/fdtable.h>
 #include <linux/uaccess.h>
-#include <linux/firmware.h>
 #include <linux/mmu_context.h>
 #include <drm/drmP.h>
 #include "amdgpu.h"
 #include "amdgpu_amdkfd.h"
-#include "amdgpu_ucode.h"
 #include "soc15_hw_ip.h"
 #include "gc/gc_9_0_offset.h"
 #include "gc/gc_9_0_sh_mask.h"
@@ -111,7 +109,6 @@ static uint16_t get_atc_vmid_pasid_mapping_pasid(struct kgd_dev *kgd,
                uint8_t vmid);
 static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid,
                uint64_t page_table_base);
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type);
 static void set_scratch_backing_va(struct kgd_dev *kgd,
                                        uint64_t va, uint32_t vmid);
 static int invalidate_tlbs(struct kgd_dev *kgd, uint16_t pasid);
@@ -158,7 +155,6 @@ static const struct kfd2kgd_calls kfd2kgd = {
                        get_atc_vmid_pasid_mapping_pasid,
        .get_atc_vmid_pasid_mapping_valid =
                        get_atc_vmid_pasid_mapping_valid,
-       .get_fw_version = get_fw_version,
        .set_scratch_backing_va = set_scratch_backing_va,
        .get_tile_config = amdgpu_amdkfd_get_tile_config,
        .set_vm_context_page_table_base = set_vm_context_page_table_base,
@@ -874,56 +870,6 @@ static void set_scratch_backing_va(struct kgd_dev *kgd,
         */
 }
 
-/* FIXME: Does this need to be ASIC-specific code? */
-static uint16_t get_fw_version(struct kgd_dev *kgd, enum kgd_engine_type type)
-{
-       struct amdgpu_device *adev = (struct amdgpu_device *) kgd;
-       const union amdgpu_firmware_header *hdr;
-
-       switch (type) {
-       case KGD_ENGINE_PFP:
-               hdr = (const union amdgpu_firmware_header *)adev->gfx.pfp_fw->data;
-               break;
-
-       case KGD_ENGINE_ME:
-               hdr = (const union amdgpu_firmware_header *)adev->gfx.me_fw->data;
-               break;
-
-       case KGD_ENGINE_CE:
-               hdr = (const union amdgpu_firmware_header *)adev->gfx.ce_fw->data;
-               break;
-
-       case KGD_ENGINE_MEC1:
-               hdr = (const union amdgpu_firmware_header *)adev->gfx.mec_fw->data;
-               break;
-
-       case KGD_ENGINE_MEC2:
-               hdr = (const union amdgpu_firmware_header *)adev->gfx.mec2_fw->data;
-               break;
-
-       case KGD_ENGINE_RLC:
-               hdr = (const union amdgpu_firmware_header *)adev->gfx.rlc_fw->data;
-               break;
-
-       case KGD_ENGINE_SDMA1:
-               hdr = (const union amdgpu_firmware_header *)adev->sdma.instance[0].fw->data;
-               break;
-
-       case KGD_ENGINE_SDMA2:
-               hdr = (const union amdgpu_firmware_header *)adev->sdma.instance[1].fw->data;
-               break;
-
-       default:
-               return 0;
-       }
-
-       if (hdr == NULL)
-               return 0;
-
-       /* Only 12 bit in use*/
-       return hdr->common.ucode_version;
-}
-
 static void set_vm_context_page_table_base(struct kgd_dev *kgd, uint32_t vmid,
                uint64_t page_table_base)
 {
index b3cdbf79f47b3d7ea3ebfa66a14aa0ee252210d4..aaa5989e9831b989b27f36880919a5b6fd6c7a1c 100644 (file)
@@ -493,9 +493,9 @@ bool kgd2kfd_device_init(struct kfd_dev *kfd,
 {
        unsigned int size;
 
-       kfd->mec_fw_version = kfd->kfd2kgd->get_fw_version(kfd->kgd,
+       kfd->mec_fw_version = amdgpu_amdkfd_get_fw_version(kfd->kgd,
                        KGD_ENGINE_MEC1);
-       kfd->sdma_fw_version = kfd->kfd2kgd->get_fw_version(kfd->kgd,
+       kfd->sdma_fw_version = amdgpu_amdkfd_get_fw_version(kfd->kgd,
                        KGD_ENGINE_SDMA1);
        kfd->shared_resources = *gpu_resources;
 
index 5f3c10ebff080b53b8fd7c7801cb680c2c6214a7..b897aca9b4c92778155a3dde87a1fcdbd4eb5743 100644 (file)
@@ -85,18 +85,6 @@ enum kgd_memory_pool {
        KGD_POOL_FRAMEBUFFER = 3,
 };
 
-enum kgd_engine_type {
-       KGD_ENGINE_PFP = 1,
-       KGD_ENGINE_ME,
-       KGD_ENGINE_CE,
-       KGD_ENGINE_MEC1,
-       KGD_ENGINE_MEC2,
-       KGD_ENGINE_RLC,
-       KGD_ENGINE_SDMA1,
-       KGD_ENGINE_SDMA2,
-       KGD_ENGINE_MAX
-};
-
 /**
  * enum kfd_sched_policy
  *
@@ -230,8 +218,6 @@ struct tile_config {
  * @hqd_sdma_destroy: Destructs and preempts the SDMA queue assigned to that
  * SDMA hqd slot.
  *
- * @get_fw_version: Returns FW versions from the header
- *
  * @set_scratch_backing_va: Sets VA for scratch backing memory of a VMID.
  * Only used for no cp scheduling mode
  *
@@ -311,8 +297,6 @@ struct kfd2kgd_calls {
                                        struct kgd_dev *kgd,
                                        uint8_t vmid);
 
-       uint16_t (*get_fw_version)(struct kgd_dev *kgd,
-                               enum kgd_engine_type type);
        void (*set_scratch_backing_va)(struct kgd_dev *kgd,
                                uint64_t va, uint32_t vmid);
        int (*get_tile_config)(struct kgd_dev *kgd, struct tile_config *config);