Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amd/pm: Add ppt1 support

Add ppt1 support for smu_v15_0_8

Signed-off-by: Asad Kamal <asad.kamal@amd.com>
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Asad Kamal and committed by
Alex Deucher
a6c2ecd9 bc296e6c

+74 -1
+74 -1
drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
··· 1715 1715 return 0; 1716 1716 } 1717 1717 1718 + static int smu_v15_0_8_set_power_limit(struct smu_context *smu, 1719 + enum smu_ppt_limit_type limit_type, 1720 + uint32_t limit) 1721 + { 1722 + struct smu_table_context *smu_table = &smu->smu_table; 1723 + PPTable_t *pptable = (PPTable_t *)smu_table->driver_pptable; 1724 + int ret; 1725 + 1726 + if (limit_type == SMU_FAST_PPT_LIMIT) { 1727 + if (!pptable->PPT1Max) 1728 + return -EOPNOTSUPP; 1729 + 1730 + if (limit > pptable->PPT1Max || limit < pptable->PPT1Min) { 1731 + dev_err(smu->adev->dev, 1732 + "New PPT1 limit (%d) should be between min %d and max %d\n", 1733 + limit, pptable->PPT1Min, pptable->PPT1Max); 1734 + return -EINVAL; 1735 + } 1736 + 1737 + ret = smu_cmn_send_smc_msg_with_param(smu, SMU_MSG_SetFastPptLimit, 1738 + limit, NULL); 1739 + if (ret) 1740 + dev_err(smu->adev->dev, "Set fast PPT limit failed!\n"); 1741 + 1742 + return ret; 1743 + } 1744 + 1745 + return smu_v15_0_set_power_limit(smu, limit_type, limit); 1746 + } 1747 + 1748 + static int smu_v15_0_8_get_ppt_limit(struct smu_context *smu, 1749 + uint32_t *ppt_limit, 1750 + enum smu_ppt_limit_type type, 1751 + enum smu_ppt_limit_level level) 1752 + { 1753 + struct smu_table_context *smu_table = &smu->smu_table; 1754 + PPTable_t *pptable = (PPTable_t *)smu_table->driver_pptable; 1755 + int ret = 0; 1756 + 1757 + if (!ppt_limit) 1758 + return -EINVAL; 1759 + 1760 + if (type == SMU_FAST_PPT_LIMIT) { 1761 + if (!pptable->PPT1Max) 1762 + return -EOPNOTSUPP; 1763 + 1764 + switch (level) { 1765 + case SMU_PPT_LIMIT_MAX: 1766 + *ppt_limit = pptable->PPT1Max; 1767 + break; 1768 + case SMU_PPT_LIMIT_CURRENT: 1769 + ret = smu_cmn_send_smc_msg(smu, SMU_MSG_GetFastPptLimit, 1770 + ppt_limit); 1771 + if (ret) 1772 + dev_err(smu->adev->dev, 1773 + "Get fast PPT limit failed!\n"); 1774 + break; 1775 + case SMU_PPT_LIMIT_DEFAULT: 1776 + *ppt_limit = pptable->PPT1Default; 1777 + break; 1778 + case SMU_PPT_LIMIT_MIN: 1779 + *ppt_limit = pptable->PPT1Min; 1780 + break; 1781 + default: 1782 + return -EOPNOTSUPP; 1783 + } 1784 + return ret; 1785 + } 1786 + 1787 + return -EOPNOTSUPP; 1788 + } 1789 + 1718 1790 static const struct pptable_funcs smu_v15_0_8_ppt_funcs = { 1719 1791 .init_allowed_features = smu_v15_0_8_init_allowed_features, 1720 1792 .set_default_dpm_table = smu_v15_0_8_set_default_dpm_table, ··· 1813 1741 .get_gpu_metrics = smu_v15_0_8_get_gpu_metrics, 1814 1742 .get_unique_id = smu_v15_0_8_get_unique_id, 1815 1743 .get_power_limit = smu_v15_0_8_get_power_limit, 1816 - .set_power_limit = smu_v15_0_set_power_limit, 1744 + .set_power_limit = smu_v15_0_8_set_power_limit, 1745 + .get_ppt_limit = smu_v15_0_8_get_ppt_limit, 1817 1746 .emit_clk_levels = smu_v15_0_8_emit_clk_levels, 1818 1747 .populate_umd_state_clk = smu_v15_0_8_populate_umd_state_clk, 1819 1748 .set_performance_level = smu_v15_0_8_set_performance_level,