drm/amdgpu: move apu flags initialization to the start of device init
authorHuang Rui <ray.huang@amd.com>
Tue, 22 Jun 2021 09:33:54 +0000 (17:33 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 1 Jul 2021 04:05:18 +0000 (00:05 -0400)
In some asics, we need to adjust the behavior according to the apu flags
at very early stage.

Signed-off-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Aaron Liu <aaron.liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/soc15.c

index b5cce56..d303e88 100644 (file)
@@ -1369,6 +1369,38 @@ def_value:
        adev->pm.smu_prv_buffer_size = 0;
 }
 
+static int amdgpu_device_init_apu_flags(struct amdgpu_device *adev)
+{
+       if (!(adev->flags & AMD_IS_APU) ||
+           adev->asic_type < CHIP_RAVEN)
+               return 0;
+
+       switch (adev->asic_type) {
+       case CHIP_RAVEN:
+               if (adev->pdev->device == 0x15dd)
+                       adev->apu_flags |= AMD_APU_IS_RAVEN;
+               if (adev->pdev->device == 0x15d8)
+                       adev->apu_flags |= AMD_APU_IS_PICASSO;
+               break;
+       case CHIP_RENOIR:
+               if ((adev->pdev->device == 0x1636) ||
+                   (adev->pdev->device == 0x164c))
+                       adev->apu_flags |= AMD_APU_IS_RENOIR;
+               else
+                       adev->apu_flags |= AMD_APU_IS_GREEN_SARDINE;
+               break;
+       case CHIP_VANGOGH:
+               adev->apu_flags |= AMD_APU_IS_VANGOGH;
+               break;
+       case CHIP_YELLOW_CARP:
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 /**
  * amdgpu_device_check_arguments - validate module params
  *
@@ -3386,6 +3418,10 @@ int amdgpu_device_init(struct amdgpu_device *adev,
        mutex_init(&adev->psp.mutex);
        mutex_init(&adev->notifier_lock);
 
+       r = amdgpu_device_init_apu_flags(adev);
+       if (r)
+               return r;
+
        r = amdgpu_device_check_arguments(adev);
        if (r)
                return r;
index 859e761..94a2c07 100644 (file)
@@ -1305,7 +1305,6 @@ static int nv_common_early_init(void *handle)
                break;
 
        case CHIP_VANGOGH:
-               adev->apu_flags |= AMD_APU_IS_VANGOGH;
                adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
                        AMD_CG_SUPPORT_GFX_MGLS |
                        AMD_CG_SUPPORT_GFX_CP_LS |
index de85577..b024364 100644 (file)
@@ -1360,10 +1360,7 @@ static int soc15_common_early_init(void *handle)
                break;
        case CHIP_RAVEN:
                adev->asic_funcs = &soc15_asic_funcs;
-               if (adev->pdev->device == 0x15dd)
-                       adev->apu_flags |= AMD_APU_IS_RAVEN;
-               if (adev->pdev->device == 0x15d8)
-                       adev->apu_flags |= AMD_APU_IS_PICASSO;
+
                if (adev->rev_id >= 0x8)
                        adev->apu_flags |= AMD_APU_IS_RAVEN2;
 
@@ -1455,11 +1452,6 @@ static int soc15_common_early_init(void *handle)
                break;
        case CHIP_RENOIR:
                adev->asic_funcs = &soc15_asic_funcs;
-               if ((adev->pdev->device == 0x1636) ||
-                   (adev->pdev->device == 0x164c))
-                       adev->apu_flags |= AMD_APU_IS_RENOIR;
-               else
-                       adev->apu_flags |= AMD_APU_IS_GREEN_SARDINE;
 
                if (adev->apu_flags & AMD_APU_IS_RENOIR)
                        adev->external_rev_id = adev->rev_id + 0x91;