drm/amd/pm: defer UCLK DPM on selected Apple Navi GPUs
Subsystems (3)
Alex Deucher
maintainerPATCH v5 1/1 drm/amd/pm: defer UCLK DPM on selected Apple Navi GPUs
From: Atharva Tiwari <[email protected]>
Apple Navi GPUs intermittently time out during SMU initialization when EnableAllSmuFeatures includes UCLK DPM. Leave UCLK out of that early request and enable it from Navi post-init, after display hardware init and before the UMC workaround and UMD clock setup.
Read back the enabled features before rebuilding the memory clock table and sustainable clock limits. Also check the PPT memory states used by display initialization before late enablement. Keep memory-voltage DPM and respect the user's memory-DPM setting and the secure Navi 10 exclusion.
This builds on Atharva Tiwari's submitted 0219 delayed-UCLK patch and Guna's diagnosis. Ed Schofield moved the enable point into the Navi callback, added state validation and clock-table refresh, and extended the board matching.
Independent tests of the related T2 implementation support improved boot reliability on 0219 and 021a; those are not tests of this exact AMD patch.
---
v5: Apply to all navi1x Macs.
.../gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+)
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c +88 -0
@@ -60,6 +60,25 @@static int navi10_init_ppt_limits (struct smu_context *smu); +static bool is_asic_secure (struct smu_context *smu); + +static bool navi10_apple_needs_late_uclk (struct smu_context *smu) +{ +struct amdgpu_device *adev = smu->adev; +struct pci_dev *pdev = adev->pdev; + +if (!(adev->pm.pp_feature &PP_MCLK_DPM_MASK )) +return false; + +/* Preserve the existing secure Navi 10 memory-DPM exclusion. */ +if (is_asic_secure (smu) && +amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (11 ,0 ,0 ) && + adev->rev_id ==0 ) +return false; + +return pdev->subsystem_vendor ==PCI_VENDOR_ID_APPLE ; +} +static const struct smu_feature_bits navi10_dpm_features = { .bits = {SMU_FEATURE_BIT_INIT (FEATURE_DPM_PREFETCHER_BIT ),
@@ -356,6 +375,11 @@ navi10_init_allowed_features(struct smu_context *smu)smu_feature_list_set_bit (smu,SMU_FEATURE_LIST_ALLOWED ,FEATURE_MEM_MVDD_SCALING_BIT ); } +/* Defer UCLK on the selected Apple boards until IP late init. */ +if (navi10_apple_needs_late_uclk (smu)) +smu_feature_list_clear_bit (smu,SMU_FEATURE_LIST_ALLOWED , +FEATURE_DPM_UCLK_BIT ); +if (is_asic_secure (smu) && (amdgpu_ip_version (adev,MP1_HWIP ,0 ) ==IP_VERSION (11 ,0 ,0 )) && (adev->rev_id ==0 ))
@@ -470,6 +494,25 @@ static int navi10_store_powerplay_table(struct smu_context *smu)return 0 ; } +/* DCN20 consumes these PPT states before the post-init UCLK enable. */ +static int navi10_apple_check_uclk_states (struct smu_context *smu) +{ +PPTable_t *ppt = smu->smu_table.driver_pptable; +unsigned int count, i; + +if (!navi10_apple_needs_late_uclk (smu)) +return 0 ; + + count = ppt->DpmDescriptor[PPCLK_UCLK ].NumDiscreteLevels; +if (!count || count >ARRAY_SIZE (ppt->FreqTableUclk)) +return -EINVAL ; +for (i =0 ; i < count; i++) { +if (!ppt->FreqTableUclk[i]) +return -EINVAL ; + } +return 0 ; +} +static int navi10_setup_pptable (struct smu_context *smu) {int ret =0 ;
@@ -490,6 +533,10 @@ static int navi10_setup_pptable(struct smu_context *smu)if (ret)return ret; + ret =navi10_apple_check_uclk_states (smu); +if (ret) +return ret; +return navi10_init_ppt_limits (smu); }
@@ -3219,6 +3266,41 @@ static int navi10_enable_mgpu_fan_boost(struct smu_context *smu) NULL); } +/* IP late init follows display hw_init; refresh clocks before UMC/UMD setup. */ +static int navi10_apple_late_uclk_enable (struct smu_context *smu) +{ +struct smu_11_0_dpm_context *dpm = smu->smu_dpm.dpm_context; +struct smu_dpm_table *table = &dpm->dpm_tables.uclk_table; +PPTable_t *ppt = smu->smu_table.driver_pptable; +struct smu_feature_bits enabled; +int ret; + +if (!navi10_apple_needs_late_uclk (smu)) +return 0 ; + + ret =smu_cmn_feature_set_enabled (smu,SMU_FEATURE_DPM_UCLK_BIT , true); +if (ret) +return ret; + ret =smu_cmn_get_enabled_mask (smu, &enabled); +if (ret) +return ret; +if (!smu_feature_bits_is_set (&enabled,FEATURE_DPM_UCLK_BIT )) +return -EIO ; + +smu_feature_list_set_bit (smu,SMU_FEATURE_LIST_SUPPORTED , +FEATURE_DPM_UCLK_BIT ); + table->clk_type =SMU_UCLK ; + ret =smu_v11_0_set_single_dpm_table (smu,SMU_UCLK , table); +if (ret) +return ret; +if (!table->count) +return -EINVAL ; +if (!ppt->DpmDescriptor[PPCLK_UCLK ].SnapToDiscrete) + table->flags |=SMU_DPM_TABLE_FINE_GRAINED ; + +return smu_v11_0_init_max_sustainable_clocks (smu); +} +static int navi10_post_smu_init (struct smu_context *smu) {struct amdgpu_device *adev = smu->adev;
@@ -3227,6 +3309,12 @@ static int navi10_post_smu_init(struct smu_context *smu)if (amdgpu_sriov_vf (adev))return 0 ; + ret =navi10_apple_late_uclk_enable (smu); +if (ret) { +dev_err (adev->dev,"Failed to enable late UCLK DPM: %d\n" , ret); +return ret; + } + ret =navi10_run_umc_cdr_workaround (smu);if (ret)dev_err (adev->dev,"Failed to apply umc cdr workaround!\n" );
Signature · 1 line
2.56.0