[PATCH] drm/amd/powerplay: fix avfs state machine on fiji/polais.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 14, 2017 at 5:43 AM, Rex Zhu <Rex.Zhu at amd.com> wrote:
> Change-Id: I987a53e5185934bdf6926f9d6065d2ec6aca05bb
> Signed-off-by: Rex Zhu <Rex.Zhu at amd.com>

Acked-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c | 114 ++-------------------
>  .../drm/amd/powerplay/smumgr/polaris10_smumgr.c    |   5 +-
>  2 files changed, 10 insertions(+), 109 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
> index a1cb785..66d3ff8 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/fiji_smumgr.c
> @@ -194,22 +194,10 @@ static int fiji_start_avfs_btc(struct pp_smumgr *smumgr)
>         int result = 0;
>         struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend);
>
> -       priv->avfs.AvfsBtcStatus = AVFS_BTC_STARTED;
>         if (priv->avfs.AvfsBtcParam) {
>                 if (!smum_send_msg_to_smc_with_parameter(smumgr,
>                                 PPSMC_MSG_PerformBtc, priv->avfs.AvfsBtcParam)) {
> -                       if (!smum_send_msg_to_smc(smumgr, PPSMC_MSG_EnableAvfs)) {
> -                               priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_UNSAVED;
> -                               result = 0;
> -                       } else {
> -                               pr_err("[AVFS][fiji_start_avfs_btc] Attempt"
> -                                               " to Enable AVFS Failed!");
> -                               smum_send_msg_to_smc(smumgr, PPSMC_MSG_DisableAvfs);
> -                               result = -1;
> -                       }
> -               } else {
> -                       pr_err("[AVFS][fiji_start_avfs_btc] "
> -                                       "PerformBTC SMU msg failed");
> +                       pr_err("PerformBTC SMU msg failed \n");
>                         result = -1;
>                 }
>         }
> @@ -224,42 +212,6 @@ static int fiji_start_avfs_btc(struct pp_smumgr *smumgr)
>         return result;
>  }
>
> -static int fiji_setup_pm_fuse_for_avfs(struct pp_smumgr *smumgr)
> -{
> -       int result = 0;
> -       uint32_t table_start;
> -       uint32_t charz_freq_addr, inversion_voltage_addr, charz_freq;
> -       uint16_t inversion_voltage;
> -
> -       charz_freq = 0x30750000; /* In 10KHz units 0x00007530 Actual value */
> -       inversion_voltage = 0x1A04; /* mV Q14.2 0x41A Actual value */
> -
> -       PP_ASSERT_WITH_CODE(0 == smu7_read_smc_sram_dword(smumgr,
> -                       SMU7_FIRMWARE_HEADER_LOCATION + offsetof(SMU73_Firmware_Header,
> -                                       PmFuseTable), &table_start, 0x40000),
> -                       "[AVFS][Fiji_SetupGfxLvlStruct] SMU could not communicate "
> -                       "starting address of PmFuse structure",
> -                       return -1;);
> -
> -       charz_freq_addr = table_start +
> -                       offsetof(struct SMU73_Discrete_PmFuses, PsmCharzFreq);
> -       inversion_voltage_addr = table_start +
> -                       offsetof(struct SMU73_Discrete_PmFuses, InversionVoltage);
> -
> -       result = smu7_copy_bytes_to_smc(smumgr, charz_freq_addr,
> -                       (uint8_t *)(&charz_freq), sizeof(charz_freq), 0x40000);
> -       PP_ASSERT_WITH_CODE(0 == result,
> -                       "[AVFS][fiji_setup_pm_fuse_for_avfs] charz_freq could not "
> -                       "be populated.", return -1;);
> -
> -       result = smu7_copy_bytes_to_smc(smumgr, inversion_voltage_addr,
> -                       (uint8_t *)(&inversion_voltage), sizeof(inversion_voltage), 0x40000);
> -       PP_ASSERT_WITH_CODE(0 == result, "[AVFS][fiji_setup_pm_fuse_for_avfs] "
> -                       "charz_freq could not be populated.", return -1;);
> -
> -       return result;
> -}
> -
>  static int fiji_setup_graphics_level_structure(struct pp_smumgr *smumgr)
>  {
>         int32_t vr_config;
> @@ -298,67 +250,18 @@ static int fiji_setup_graphics_level_structure(struct pp_smumgr *smumgr)
>         return 0;
>  }
>
> -/* Work in Progress */
> -static int fiji_restore_vft_table(struct pp_smumgr *smumgr)
> -{
> -       struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend);
> -
> -       if (AVFS_BTC_COMPLETED_SAVED == priv->avfs.AvfsBtcStatus) {
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_RESTORED;
> -               return 0;
> -       } else
> -               return -EINVAL;
> -}
> -
> -/* Work in Progress */
> -static int fiji_save_vft_table(struct pp_smumgr *smumgr)
> -{
> -       struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend);
> -
> -       if (AVFS_BTC_COMPLETED_SAVED == priv->avfs.AvfsBtcStatus) {
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_RESTORED;
> -               return 0;
> -       } else
> -               return -EINVAL;
> -}
> -
>  static int fiji_avfs_event_mgr(struct pp_smumgr *smumgr, bool smu_started)
>  {
>         struct fiji_smumgr *priv = (struct fiji_smumgr *)(smumgr->backend);
>
>         switch (priv->avfs.AvfsBtcStatus) {
> -       case AVFS_BTC_COMPLETED_SAVED: /*S3 State - Pre SMU Start */
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_RESTOREVFT_FAILED;
> -               PP_ASSERT_WITH_CODE(0 == fiji_restore_vft_table(smumgr),
> -                               "[AVFS][fiji_avfs_event_mgr] Could not Copy Graphics "
> -                               "Level table over to SMU",
> -                               return -1;);
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_RESTORED;
> -               break;
> -       case AVFS_BTC_COMPLETED_RESTORED: /*S3 State - Post SMU Start*/
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_SMUMSG_ERROR;
> -               PP_ASSERT_WITH_CODE(0 == smum_send_msg_to_smc(smumgr,
> -                               0x666),
> -                               "[AVFS][fiji_avfs_event_mgr] SMU did not respond "
> -                               "correctly to VftTableIsValid Msg",
> -                               return -1;);
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_SMUMSG_ERROR;
> -               PP_ASSERT_WITH_CODE(0 == smum_send_msg_to_smc(smumgr,
> -                               PPSMC_MSG_EnableAvfs),
> -                               "[AVFS][fiji_avfs_event_mgr] SMU did not respond "
> -                               "correctly to EnableAvfs Message Msg",
> -                               return -1;);
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_SAVED;
> +       case AVFS_BTC_COMPLETED_PREVIOUSLY:
>                 break;
> +
>         case AVFS_BTC_BOOT: /*Cold Boot State - Post SMU Start*/
>                 if (!smu_started)
>                         break;
>                 priv->avfs.AvfsBtcStatus = AVFS_BTC_FAILED;
> -               PP_ASSERT_WITH_CODE(0 == fiji_setup_pm_fuse_for_avfs(smumgr),
> -                               "[AVFS][fiji_avfs_event_mgr] Failure at "
> -                               "fiji_setup_pm_fuse_for_avfs",
> -                               return -1;);
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_DPMTABLESETUP_FAILED;
>                 PP_ASSERT_WITH_CODE(0 == fiji_setup_graphics_level_structure(smumgr),
>                                 "[AVFS][fiji_avfs_event_mgr] Could not Copy Graphics Level"
>                                 " table over to SMU",
> @@ -373,18 +276,15 @@ static int fiji_avfs_event_mgr(struct pp_smumgr *smumgr, bool smu_started)
>                                 "[AVFS][fiji_avfs_event_mgr] Failure at "
>                                 "fiji_start_avfs_btc. AVFS Disabled",
>                                 return -1;);
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_SAVEVFT_FAILED;
> -               PP_ASSERT_WITH_CODE(0 == fiji_save_vft_table(smumgr),
> -                               "[AVFS][fiji_avfs_event_mgr] Could not save VFT Table",
> -                               return -1;);
> -               priv->avfs.AvfsBtcStatus = AVFS_BTC_COMPLETED_SAVED;
> +
> +               priv->avfs.AvfsBtcStatus =  AVFS_BTC_ENABLEAVFS;
>                 break;
>         case AVFS_BTC_DISABLED: /* Do nothing */
> -               break;
>         case AVFS_BTC_NOTSUPPORTED: /* Do nothing */
> +       case AVFS_BTC_ENABLEAVFS:
>                 break;
>         default:
> -               pr_err("[AVFS] Something is broken. See log!");
> +               pr_err("AVFS failed status is %x !\n", priv->avfs.AvfsBtcStatus);
>                 break;
>         }
>         return 0;
> diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
> index 9616ced..7e03470 100644
> --- a/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/smumgr/polaris10_smumgr.c
> @@ -200,15 +200,16 @@ static int polaris10_setup_graphics_level_structure(struct pp_smumgr *smumgr)
>                 PP_ASSERT_WITH_CODE(0 == polaris10_perform_btc(smumgr),
>                                         "[AVFS][Polaris10_AVFSEventMgr] Failure at SmuPolaris10_PerformBTC. AVFS Disabled",
>                                  return -1);
> -
> +               smu_data->avfs.avfs_btc_status = AVFS_BTC_ENABLEAVFS;
>                 break;
>
>         case AVFS_BTC_DISABLED:
> +       case AVFS_BTC_ENABLEAVFS:
>         case AVFS_BTC_NOTSUPPORTED:
>                 break;
>
>         default:
> -               pr_info("[AVFS] Something is broken. See log!");
> +               pr_err("AVFS failed status is %x!\n", smu_data->avfs.avfs_btc_status);
>                 break;
>         }
>
> --
> 1.9.1
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux