Add ISP Generic PM Domain (genpd) support
Subsystems (3)
cover Add ISP Generic PM Domain (genpd) support
This patch series adds support to control ISP power and clocks using the Generic PM Domain (genpd). Its required to control the ISP HW power from external I2C driver to successfully probe the sensor device. Instead of using an exported symbols from ISP driver, enabling Generic PM Domain (genpd) support in amdgpu_isp device allows its child devices (amd_isp_capture, amd_isp_i2c_designware) to set power and clocks directly using PM method.
We need to add support in amdgpu_smu as well for amdgpu_isp device to set power / clocks when invoked from genpd. Though the below SMU messages are defined, the actual support to configure ISP is missing in SMU interface.
PPSMC_MSG_PowerDownIspByTilePPSMC_MSG_PowerUpIspByTilePPSMC_MSG_SetHardMinIspiclkByFreqPPSMC_MSG_SetHardMinIspxclkByFreq
Added support in SMU to control ISP power / clocks by updating the existing amdgpu_dpm_set_powergating_by_smu() and amdgpu_dpm_set_soft_freq_range(); and the underlying SOC specific SMU implementation for isp v4.1.
Pratap Nirujogi (4):
drm/amd/pm: Add support to set ISP Power drm/amd/pm: Add support to set min ISP clocks drm/amd/amdgpu: Add ISP Generic PM Domain (genpd) support drm/amd/amdgpu: Refine isp_v4_1_1 logging
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h | 3 + drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 173 ++++++++++++++++-- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 15 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41 ++++- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 9 +- .../inc/pmfw_if/smu14_driver_if_v14_0_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 2 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 60 ++++-- 9 files changed, 264 insertions(+), 42 deletions(-)
Signature · 1 line
2.43.0
PATCH 1/4 drm/amd/pm: Add support to set ISP Power
Add support to set ISP power for SMU v14.0.0. ISP driver uses amdgpu_dpm_set_powergating_by_smu() API to enable / disable power via SMU interface than communicating with PMFW directly.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 1 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 27 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ .../inc/pmfw_if/smu14_driver_if_v14_0_0.h | 1 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 9 +++++++ 5 files changed, 45 insertions(+)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1 -0
@@ -98,6 +98,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,case AMD_IP_BLOCK_TYPE_GMC :case AMD_IP_BLOCK_TYPE_ACP :case AMD_IP_BLOCK_TYPE_VPE : +case AMD_IP_BLOCK_TYPE_ISP :if (pp_funcs && pp_funcs->set_powergating_by_smu) ret = (pp_funcs->set_powergating_by_smu ( (adev)->powerplay.pp_handle, block_type, gate,0 ));
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +27 -0
@@ -307,6 +307,26 @@ static int smu_dpm_set_vpe_enable(struct smu_context *smu,return ret; } +static int smu_dpm_set_isp_enable (struct smu_context *smu, +bool enable) +{ +struct smu_power_context *smu_power = &smu->smu_power; +struct smu_power_gate *power_gate = &smu_power->power_gate; +int ret; + +if (!smu->ppt_funcs->dpm_set_isp_enable) +return 0 ; + +if (atomic_read (&power_gate->isp_gated) ^ enable) +return 0 ; + + ret = smu->ppt_funcs->dpm_set_isp_enable (smu, enable); +if (!ret) +atomic_set (&power_gate->isp_gated, !enable); + +return ret; +} +static int smu_dpm_set_umsch_mm_enable (struct smu_context *smu,bool enable) {
@@ -408,6 +428,12 @@ static int smu_dpm_set_power_gate(void *handle,dev_err (smu->adev->dev,"Failed to power %s VPE!\n" , gate ?"gate" :"ungate" );break ; +case AMD_IP_BLOCK_TYPE_ISP : + ret =smu_dpm_set_isp_enable (smu, !gate); +if (ret) +dev_err (smu->adev->dev,"Failed to power %s ISP!\n" , + gate ?"gate" :"ungate" ); +break ;default :dev_err (smu->adev->dev,"Unsupported block type!\n" );return -EINVAL ;
@@ -1300,6 +1326,7 @@ static int smu_sw_init(struct amdgpu_ip_block *ip_block)atomic_set (&smu->smu_power.power_gate.vcn_gated[i],1 );atomic_set (&smu->smu_power.power_gate.jpeg_gated,1 );atomic_set (&smu->smu_power.power_gate.vpe_gated,1 ); +atomic_set (&smu->smu_power.power_gate.isp_gated,1 );atomic_set (&smu->smu_power.power_gate.umsch_mm_gated,1 );smu_init_power_profile (smu);
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +7 -0
@@ -402,6 +402,7 @@ struct smu_power_gate {atomic_t vcn_gated[AMDGPU_MAX_VCN_INSTANCES ];atomic_t jpeg_gated;atomic_t vpe_gated; +atomic_t isp_gated;atomic_t umsch_mm_gated; };
@@ -1435,6 +1436,12 @@ struct pptable_funcs {*/ int (*dpm_set_vpe_enable)(struct smu_context *smu,bool enable); +/** +* @dpm_set_isp_enable: Enable/disable ISP engine dynamic power +* management. +*/ +int (*dpm_set_isp_enable)(struct smu_context *smu,bool enable); +/** * @dpm_set_umsch_mm_enable: Enable/disable UMSCH engine dynamic power * management.
drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu14_driver_if_v14_0_0.h +1 -0
@@ -106,6 +106,7 @@ typedef struct {#define NUM_FCLK_DPM_LEVELS 8#define NUM_MEM_PSTATE_LEVELS 4 +#define ISP_ALL_TILES_MASK 0x7FF typedef struct { uint32_t UClk;
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +9 -0
@@ -1533,6 +1533,14 @@ static int smu_v14_0_0_set_vpe_enable(struct smu_context *smu, 0, NULL); } +static int smu_v14_0_0_set_isp_enable (struct smu_context *smu, +bool enable) +{ +return smu_cmn_send_smc_msg_with_param (smu, enable ? + SMU_MSG_PowerUpIspByTile : SMU_MSG_PowerDownIspByTile, +ISP_ALL_TILES_MASK ,NULL ); +} +static int smu_v14_0_0_set_umsch_mm_enable (struct smu_context *smu,bool enable) {
@@ -1669,6 +1677,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = { .set_fine_grain_gfx_freq_parameters = smu_v14_0_common_set_fine_grain_gfx_freq_parameters, .set_gfx_power_up_by_imu = smu_v14_0_set_gfx_power_up_by_imu, .dpm_set_vpe_enable = smu_v14_0_0_set_vpe_enable, + .dpm_set_isp_enable = smu_v14_0_0_set_isp_enable, .dpm_set_umsch_mm_enable = smu_v14_0_0_set_umsch_mm_enable, .get_dpm_clock_table = smu_v14_0_common_get_dpm_table, .set_mall_enable = smu_v14_0_common_set_mall_enable,
Signature · 1 line
2.43.0
Re: [PATCH 1/4] drm/amd/pm: Add support to set ISP Power
Quoted 6 lines · Pratap Nirujogi
Add support to set ISP power for SMU v14.0.0. ISP driver uses
amdgpu_dpm_set_powergating_by_smu()API to enable / disable power via SMU interface than communicating with PMFW directly.Signed-off-by Pratap Nirujogi <[email protected]>
Thanks,
Lijo
Quoted 136 lines
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 1 + drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 27 +++++++++++++++++++ drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 7 +++++ .../inc/pmfw_if/smu14_driver_if_v14_0_0.h | 1 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 9 +++++++ 5 files changed, 45 insertions(+)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +1
-0@@ -98,6 +98,7 @@ int amdgpu_dpm_set_powergating_by_smu(struct amdgpu_device *adev,case AMD_IP_BLOCK_TYPE_GMC :case AMD_IP_BLOCK_TYPE_ACP :case AMD_IP_BLOCK_TYPE_VPE : +case AMD_IP_BLOCK_TYPE_ISP :if (pp_funcs && pp_funcs->set_powergating_by_smu) ret = (pp_funcs->set_powergating_by_smu ( (adev)->powerplay.pp_handle, block_type, gate,0 ));drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +27
-0@@ -307,6 +307,26 @@ static int smu_dpm_set_vpe_enable(struct smu_context *smu,return ret; } +static int smu_dpm_set_isp_enable (struct smu_context *smu, +bool enable) +{ +struct smu_power_context *smu_power = &smu->smu_power; +struct smu_power_gate *power_gate = &smu_power->power_gate; +int ret; + +if (!smu->ppt_funcs->dpm_set_isp_enable) +return 0 ; + +if (atomic_read (&power_gate->isp_gated) ^ enable) +return 0 ; + + ret = smu->ppt_funcs->dpm_set_isp_enable (smu, enable); +if (!ret) +atomic_set (&power_gate->isp_gated, !enable); + +return ret; +} +static int smu_dpm_set_umsch_mm_enable (struct smu_context *smu,bool enable) {@@ -408,6 +428,12 @@ static int smu_dpm_set_power_gate(void *handle,dev_err (smu->adev->dev,"Failed to power %s VPE!\n" , gate ?"gate" :"ungate" );break ; +case AMD_IP_BLOCK_TYPE_ISP : + ret =smu_dpm_set_isp_enable (smu, !gate); +if (ret) +dev_err (smu->adev->dev,"Failed to power %s ISP!\n" , + gate ?"gate" :"ungate" ); +break ;default :dev_err (smu->adev->dev,"Unsupported block type!\n" );return -EINVAL ;@@ -1300,6 +1326,7 @@ static int smu_sw_init(struct amdgpu_ip_block *ip_block)atomic_set (&smu->smu_power.power_gate.vcn_gated[i],1 );atomic_set (&smu->smu_power.power_gate.jpeg_gated,1 );atomic_set (&smu->smu_power.power_gate.vpe_gated,1 ); +atomic_set (&smu->smu_power.power_gate.isp_gated,1 );atomic_set (&smu->smu_power.power_gate.umsch_mm_gated,1 );smu_init_power_profile (smu);drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +7
-0@@ -402,6 +402,7 @@ struct smu_power_gate {atomic_t vcn_gated[AMDGPU_MAX_VCN_INSTANCES ];atomic_t jpeg_gated;atomic_t vpe_gated; +atomic_t isp_gated;atomic_t umsch_mm_gated; };@@ -1435,6 +1436,12 @@ struct pptable_funcs {*/ int (*dpm_set_vpe_enable)(struct smu_context *smu,bool enable); +/** +* @dpm_set_isp_enable: Enable/disable ISP engine dynamic power +* management. +*/ +int (*dpm_set_isp_enable)(struct smu_context *smu,bool enable); +/** * @dpm_set_umsch_mm_enable: Enable/disable UMSCH engine dynamic power * management. drivers/gpu/drm/amd/pm/swsmu/inc/pmfw_if/smu14_driver_if_v14_0_0.h +1
-0@@ -106,6 +106,7 @@ typedef struct {#define NUM_FCLK_DPM_LEVELS 8#define NUM_MEM_PSTATE_LEVELS 4 +#define ISP_ALL_TILES_MASK 0x7FF typedef struct { uint32_t UClk;drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +9
-0@@ -1533,6 +1533,14 @@ static int smu_v14_0_0_set_vpe_enable(struct smu_context *smu, 0, NULL); } +static int smu_v14_0_0_set_isp_enable (struct smu_context *smu, +bool enable) +{ +return smu_cmn_send_smc_msg_with_param (smu, enable ? + SMU_MSG_PowerUpIspByTile : SMU_MSG_PowerDownIspByTile, +ISP_ALL_TILES_MASK ,NULL ); +} +static int smu_v14_0_0_set_umsch_mm_enable (struct smu_context *smu,bool enable) {@@ -1669,6 +1677,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = { .set_fine_grain_gfx_freq_parameters = smu_v14_0_common_set_fine_grain_gfx_freq_parameters, .set_gfx_power_up_by_imu = smu_v14_0_set_gfx_power_up_by_imu, .dpm_set_vpe_enable = smu_v14_0_0_set_vpe_enable, + .dpm_set_isp_enable = smu_v14_0_0_set_isp_enable, .dpm_set_umsch_mm_enable = smu_v14_0_0_set_umsch_mm_enable, .get_dpm_clock_table = smu_v14_0_common_get_dpm_table, .set_mall_enable = smu_v14_0_common_set_mall_enable,
PATCH 2/4 drm/amd/pm: Add support to set min ISP clocks
In reply to Pratap NirujogiAdd support to set ISP clocks for SMU v14.0.0. ISP driver uses amdgpu_dpm_set_soft_freq_range() API to set clocks via SMU interface than communicating with PMFW directly.
amdgpu_dpm_set_soft_freq_range() is updated to take in any pp_clock_type than limiting to support only PP_SCLK to allow ISP and other driver modules to set the min/max clocks. Any clock specific restrictions are expected to be taken care in SOC specific SMU implementations instead of generic amdgpu_dpm and amdgpu_smu interfaces.
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 14 ++--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 14 ++++- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 2 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 51 ++++++++++++------- 6 files changed, 56 insertions(+), 29 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -0
@@ -108,6 +108,8 @@ enum pp_clock_type {PP_VCLK1 ,PP_DCLK ,PP_DCLK1 , +PP_ISPICLK , +PP_ISPXCLK ,OD_SCLK ,OD_MCLK , OD_VDDC_CURVE,
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4 -10
@@ -853,22 +853,16 @@ int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev, uint32_t max) {struct smu_context *smu = adev->powerplay.pp_handle; -int ret =0 ; - -if (type !=PP_SCLK ) -return -EINVAL ;if (!is_support_sw_smu (adev))return -EOPNOTSUPP ; -mutex_lock (&adev->pm.mutex); - ret =smu_set_soft_freq_range (smu, -SMU_SCLK , +guard (mutex)(&adev->pm.mutex); + +return smu_set_soft_freq_range (smu, + type, min, max); -mutex_unlock (&adev->pm.mutex); - -return ret; }int amdgpu_dpm_write_watermarks_table (struct amdgpu_device *adev)
drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +13 -1
@@ -76,6 +76,7 @@ static void smu_power_profile_mode_get(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile_mode);static void smu_power_profile_mode_put (struct smu_context *smu,enum PP_SMC_POWER_PROFILE profile_mode); +static enum smu_clk_type smu_convert_to_smuclk (enum pp_clock_type type);static int smu_sys_get_pp_feature_mask (void *handle,char *buf)
@@ -134,12 +135,17 @@ int smu_get_status_gfxoff(struct smu_context *smu, uint32_t *value) }int smu_set_soft_freq_range (struct smu_context *smu, -enum smu_clk_type clk_type, +enum pp_clock_type type,uint32_t min,uint32_t max) { +enum smu_clk_type clk_type;int ret =0 ; + clk_type =smu_convert_to_smuclk (type); +if (clk_type ==SMU_CLK_COUNT ) +return -EINVAL ; +if (smu->ppt_funcs->set_soft_freq_limited_range) ret = smu->ppt_funcs->set_soft_freq_limited_range(smu, clk_type,
@@ -2980,6 +2986,12 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type) clk_type =SMU_DCLK ;break ;case PP_DCLK1 : clk_type =SMU_DCLK1 ;break ; +case PP_ISPICLK : + clk_type =SMU_ISPICLK ; +break ; +case PP_ISPXCLK : + clk_type =SMU_ISPXCLK ; +break ;case OD_SCLK : clk_type =SMU_OD_SCLK ;break ;case OD_MCLK :
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1 -1
@@ -1642,7 +1642,7 @@ int smu_write_watermarks_table(struct smu_context *smu);int smu_get_dpm_freq_range (struct smu_context *smu,enum smu_clk_type clk_type,uint32_t *min,uint32_t *max); -int smu_set_soft_freq_range (struct smu_context *smu,enum smu_clk_type clk_type, +int smu_set_soft_freq_range (struct smu_context *smu,enum pp_clock_type clk_type,uint32_t min,uint32_t max);int smu_set_gfx_power_up_by_imu (struct smu_context *smu);
drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2 -0
@@ -305,6 +305,8 @@ enum smu_clk_type {SMU_MCLK ,SMU_PCIE ,SMU_LCLK , +SMU_ISPICLK , +SMU_ISPXCLK ,SMU_OD_CCLK ,SMU_OD_SCLK , SMU_OD_MCLK,
drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +34 -17
123 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 2/4] drm/amd/pm: Add support to set min ISP clocks
Thanks,
Xiaojian
Quoted 273 lines · Pratap Nirujogi
Add support to set ISP clocks for SMU v14.0.0. ISP driver uses
amdgpu_dpm_set_soft_freq_range()API to set clocks via SMU interface than communicating with PMFW directly.
amdgpu_dpm_set_soft_freq_range()is updated to take in anypp_clock_typethan limiting to support onlyPP_SCLKto allow ISP and other driver modules to set the min/max clocks. Any clock specific restrictions are expected to be taken care in SOC specific SMU implementations instead of genericamdgpu_dpmandamdgpu_smuinterfaces.Signed-off-by Pratap Nirujogi <[email protected]>--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 14 ++--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 14 ++++- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 2 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 51 ++++++++++++------- 6 files changed, 56 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-0@@ -108,6 +108,8 @@ enum pp_clock_type {PP_VCLK1 ,PP_DCLK ,PP_DCLK1 , +PP_ISPICLK , +PP_ISPXCLK ,OD_SCLK ,OD_MCLK , OD_VDDC_CURVE,drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-10@@ -853,22 +853,16 @@ int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev, uint32_t max) {struct smu_context *smu = adev->powerplay.pp_handle; -int ret =0 ; - -if (type !=PP_SCLK ) -return -EINVAL ;if (!is_support_sw_smu (adev))return -EOPNOTSUPP ; -mutex_lock (&adev->pm.mutex); - ret =smu_set_soft_freq_range (smu, -SMU_SCLK , +guard (mutex)(&adev->pm.mutex); + +return smu_set_soft_freq_range (smu, + type, min, max); -mutex_unlock (&adev->pm.mutex); - -return ret; }int amdgpu_dpm_write_watermarks_table (struct amdgpu_device *adev)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +13
-1@@ -76,6 +76,7 @@ static void smu_power_profile_mode_get(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile_mode);static void smu_power_profile_mode_put (struct smu_context *smu,enum PP_SMC_POWER_PROFILE profile_mode); +static enum smu_clk_type smu_convert_to_smuclk (enum pp_clock_type type);static int smu_sys_get_pp_feature_mask (void *handle,char *buf)@@ -134,12 +135,17 @@ int smu_get_status_gfxoff(struct smu_context *smu, uint32_t *value) }int smu_set_soft_freq_range (struct smu_context *smu, -enum smu_clk_type clk_type, +enum pp_clock_type type,uint32_t min,uint32_t max) { +enum smu_clk_type clk_type;int ret =0 ; + clk_type =smu_convert_to_smuclk (type); +if (clk_type ==SMU_CLK_COUNT ) +return -EINVAL ; +if (smu->ppt_funcs->set_soft_freq_limited_range) ret = smu->ppt_funcs->set_soft_freq_limited_range(smu, clk_type,@@ -2980,6 +2986,12 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type) clk_type =SMU_DCLK ;break ;case PP_DCLK1 : clk_type =SMU_DCLK1 ;break ; +case PP_ISPICLK : + clk_type =SMU_ISPICLK ; +break ; +case PP_ISPXCLK : + clk_type =SMU_ISPXCLK ; +break ;case OD_SCLK : clk_type =SMU_OD_SCLK ;break ;case OD_MCLK :drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -1642,7 +1642,7 @@ int smu_write_watermarks_table(struct smu_context *smu);int smu_get_dpm_freq_range (struct smu_context *smu,enum smu_clk_type clk_type,uint32_t *min,uint32_t *max); -int smu_set_soft_freq_range (struct smu_context *smu,enum smu_clk_type clk_type, +int smu_set_soft_freq_range (struct smu_context *smu,enum pp_clock_type clk_type,uint32_t min,uint32_t max);int smu_set_gfx_power_up_by_imu (struct smu_context *smu);drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2
-0@@ -305,6 +305,8 @@ enum smu_clk_type {SMU_MCLK ,SMU_PCIE ,SMU_LCLK , +SMU_ISPICLK , +SMU_ISPXCLK ,SMU_OD_CCLK ,SMU_OD_SCLK , SMU_OD_MCLK,drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +34
-17@@ -1207,11 +1207,13 @@ static int smu_v14_0_0_print_clk_levels(struct smu_context *smu,static int smu_v14_0_0_set_soft_freq_limited_range (struct smu_context *smu,enum smu_clk_type clk_type, -uint32_t min, -uint32_t max) +u32 min, +u32 max, +bool __always_unused automatic) { -enum smu_message_type msg_set_min, msg_set_max; -int ret =0 ; +enum smu_message_type msg_set_min =SMU_MSG_MAX_COUNT ; +enum smu_message_type msg_set_max =SMU_MSG_MAX_COUNT ; +int ret = -EINVAL ;if (!smu_v14_0_0_clk_dpm_is_enabled (smu, clk_type))return -EINVAL ;@@ -1240,16 +1242,23 @@ static int smu_v14_0_0_set_soft_freq_limited_range(struct smu_context *smu, msg_set_min = SMU_MSG_SetHardMinVcn1; msg_set_max = SMU_MSG_SetSoftMaxVcn1;break ; +case SMU_ISPICLK : + msg_set_min = SMU_MSG_SetHardMinIspiclkByFreq; +break ; +case SMU_ISPXCLK : + msg_set_min = SMU_MSG_SetHardMinIspxclkByFreq; +break ;default :return -EINVAL ; } - ret =smu_cmn_send_smc_msg_with_param (smu, msg_set_min, min,NULL ); -if (ret) -return ret; +if (min && msg_set_min !=SMU_MSG_MAX_COUNT ) + ret =smu_cmn_send_smc_msg_with_param (smu, msg_set_min, min,NULL ); + +if (max && msg_set_max !=SMU_MSG_MAX_COUNT ) + ret =smu_cmn_send_smc_msg_with_param (smu, msg_set_max, max,NULL ); -return smu_cmn_send_smc_msg_with_param (smu, msg_set_max, - max,NULL ); +return ret; } static int smu_v14_0_0_force_clk_levels(struct smu_context *smu,@@ -1278,7 +1287,7 @@ static int smu_v14_0_0_force_clk_levels(struct smu_context *smu,if (ret)break ; - ret =smu_v14_0_0_set_soft_freq_limited_range (smu, clk_type, min_freq, max_freq); + ret =smu_v14_0_0_set_soft_freq_limited_range (smu, clk_type, min_freq, max_freq, false);break ;default : ret = -EINVAL ;@@ -1426,7 +1435,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_SCLK , sclk_min, - sclk_max); + sclk_max, + false);if (ret)return ret;@@ -1438,7 +1448,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_FCLK , fclk_min, - fclk_max); + fclk_max, + false);if (ret)return ret; }@@ -1447,7 +1458,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_SOCCLK , socclk_min, - socclk_max); + socclk_max, + false);if (ret)return ret; }@@ -1456,7 +1468,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_VCLK , vclk_min, - vclk_max); + vclk_max, + false);if (ret)return ret; }@@ -1465,7 +1478,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_VCLK1 , vclk1_min, - vclk1_max); + vclk1_max, + false);if (ret)return ret; }@@ -1474,7 +1488,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_DCLK , dclk_min, - dclk_max); + dclk_max, + false);if (ret)return ret; }@@ -1483,7 +1498,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_DCLK1 , dclk1_min, - dclk1_max); + dclk1_max, + false);if (ret)return ret; }@@ -1670,6 +1686,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = { .gfx_off_control = smu_v14_0_gfx_off_control, .mode2_reset = smu_v14_0_0_mode2_reset, .get_dpm_ultimate_freq = smu_v14_0_common_get_dpm_ultimate_freq, + .set_soft_freq_limited_range = smu_v14_0_0_set_soft_freq_limited_range, .od_edit_dpm_table = smu_v14_0_od_edit_dpm_table, .print_clk_levels = smu_v14_0_0_print_clk_levels, .force_clk_levels = smu_v14_0_0_force_clk_levels,
Re: [PATCH 2/4] drm/amd/pm: Add support to set min ISP clocks
In reply to Pratap NirujogiQuoted 4 lines · Pratap Nirujogi
Add support to set ISP clocks for SMU v14.0.0. ISP driver uses
amdgpu_dpm_set_soft_freq_range()API to set clocks via SMU interface than communicating with PMFW directly.
Quoted 8 lines
amdgpu_dpm_set_soft_freq_range()is updated to take in anypp_clock_typethan limiting to support onlyPP_SCLKto allow ISP and other driver modules to set the min/max clocks. Any clock specific restrictions are expected to be taken care in SOC specific SMU implementations instead of genericamdgpu_dpmandamdgpu_smuinterfaces.Signed-off-by Pratap Nirujogi <[email protected]>
Thanks,
Lijo
Quoted 261 lines
--- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 14 ++--- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 14 ++++- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 2 +- drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 2 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 51 ++++++++++++------- 6 files changed, 56 insertions(+), 29 deletions(-)drivers/gpu/drm/amd/include/kgd_pp_interface.h +2
-0@@ -108,6 +108,8 @@ enum pp_clock_type {PP_VCLK1 ,PP_DCLK ,PP_DCLK1 , +PP_ISPICLK , +PP_ISPXCLK ,OD_SCLK ,OD_MCLK , OD_VDDC_CURVE,drivers/gpu/drm/amd/pm/amdgpu_dpm.c +4
-10@@ -853,22 +853,16 @@ int amdgpu_dpm_set_soft_freq_range(struct amdgpu_device *adev, uint32_t max) {struct smu_context *smu = adev->powerplay.pp_handle; -int ret =0 ; - -if (type !=PP_SCLK ) -return -EINVAL ;if (!is_support_sw_smu (adev))return -EOPNOTSUPP ; -mutex_lock (&adev->pm.mutex); - ret =smu_set_soft_freq_range (smu, -SMU_SCLK , +guard (mutex)(&adev->pm.mutex); + +return smu_set_soft_freq_range (smu, + type, min, max); -mutex_unlock (&adev->pm.mutex); - -return ret; }int amdgpu_dpm_write_watermarks_table (struct amdgpu_device *adev)drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c +13
-1@@ -76,6 +76,7 @@ static void smu_power_profile_mode_get(struct smu_context *smu, enum PP_SMC_POWER_PROFILE profile_mode);static void smu_power_profile_mode_put (struct smu_context *smu,enum PP_SMC_POWER_PROFILE profile_mode); +static enum smu_clk_type smu_convert_to_smuclk (enum pp_clock_type type);static int smu_sys_get_pp_feature_mask (void *handle,char *buf)@@ -134,12 +135,17 @@ int smu_get_status_gfxoff(struct smu_context *smu, uint32_t *value) }int smu_set_soft_freq_range (struct smu_context *smu, -enum smu_clk_type clk_type, +enum pp_clock_type type,uint32_t min,uint32_t max) { +enum smu_clk_type clk_type;int ret =0 ; + clk_type =smu_convert_to_smuclk (type); +if (clk_type ==SMU_CLK_COUNT ) +return -EINVAL ; +if (smu->ppt_funcs->set_soft_freq_limited_range) ret = smu->ppt_funcs->set_soft_freq_limited_range(smu, clk_type,@@ -2980,6 +2986,12 @@ static enum smu_clk_type smu_convert_to_smuclk(enum pp_clock_type type) clk_type =SMU_DCLK ;break ;case PP_DCLK1 : clk_type =SMU_DCLK1 ;break ; +case PP_ISPICLK : + clk_type =SMU_ISPICLK ; +break ; +case PP_ISPXCLK : + clk_type =SMU_ISPXCLK ; +break ;case OD_SCLK : clk_type =SMU_OD_SCLK ;break ;case OD_MCLK :drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h +1
-1@@ -1642,7 +1642,7 @@ int smu_write_watermarks_table(struct smu_context *smu);int smu_get_dpm_freq_range (struct smu_context *smu,enum smu_clk_type clk_type,uint32_t *min,uint32_t *max); -int smu_set_soft_freq_range (struct smu_context *smu,enum smu_clk_type clk_type, +int smu_set_soft_freq_range (struct smu_context *smu,enum pp_clock_type clk_type,uint32_t min,uint32_t max);int smu_set_gfx_power_up_by_imu (struct smu_context *smu);drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h +2
-0@@ -305,6 +305,8 @@ enum smu_clk_type {SMU_MCLK ,SMU_PCIE ,SMU_LCLK , +SMU_ISPICLK , +SMU_ISPXCLK ,SMU_OD_CCLK ,SMU_OD_SCLK , SMU_OD_MCLK,drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c +34
-17@@ -1207,11 +1207,13 @@ static int smu_v14_0_0_print_clk_levels(struct smu_context *smu,static int smu_v14_0_0_set_soft_freq_limited_range (struct smu_context *smu,enum smu_clk_type clk_type, -uint32_t min, -uint32_t max) +u32 min, +u32 max, +bool __always_unused automatic) { -enum smu_message_type msg_set_min, msg_set_max; -int ret =0 ; +enum smu_message_type msg_set_min =SMU_MSG_MAX_COUNT ; +enum smu_message_type msg_set_max =SMU_MSG_MAX_COUNT ; +int ret = -EINVAL ;if (!smu_v14_0_0_clk_dpm_is_enabled (smu, clk_type))return -EINVAL ;@@ -1240,16 +1242,23 @@ static int smu_v14_0_0_set_soft_freq_limited_range(struct smu_context *smu, msg_set_min = SMU_MSG_SetHardMinVcn1; msg_set_max = SMU_MSG_SetSoftMaxVcn1;break ; +case SMU_ISPICLK : + msg_set_min = SMU_MSG_SetHardMinIspiclkByFreq; +break ; +case SMU_ISPXCLK : + msg_set_min = SMU_MSG_SetHardMinIspxclkByFreq; +break ;default :return -EINVAL ; } - ret =smu_cmn_send_smc_msg_with_param (smu, msg_set_min, min,NULL ); -if (ret) -return ret; +if (min && msg_set_min !=SMU_MSG_MAX_COUNT ) + ret =smu_cmn_send_smc_msg_with_param (smu, msg_set_min, min,NULL ); + +if (max && msg_set_max !=SMU_MSG_MAX_COUNT ) + ret =smu_cmn_send_smc_msg_with_param (smu, msg_set_max, max,NULL ); -return smu_cmn_send_smc_msg_with_param (smu, msg_set_max, - max,NULL ); +return ret; } static int smu_v14_0_0_force_clk_levels(struct smu_context *smu,@@ -1278,7 +1287,7 @@ static int smu_v14_0_0_force_clk_levels(struct smu_context *smu,if (ret)break ; - ret =smu_v14_0_0_set_soft_freq_limited_range (smu, clk_type, min_freq, max_freq); + ret =smu_v14_0_0_set_soft_freq_limited_range (smu, clk_type, min_freq, max_freq, false);break ;default : ret = -EINVAL ;@@ -1426,7 +1435,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_SCLK , sclk_min, - sclk_max); + sclk_max, + false);if (ret)return ret;@@ -1438,7 +1448,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_FCLK , fclk_min, - fclk_max); + fclk_max, + false);if (ret)return ret; }@@ -1447,7 +1458,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_SOCCLK , socclk_min, - socclk_max); + socclk_max, + false);if (ret)return ret; }@@ -1456,7 +1468,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_VCLK , vclk_min, - vclk_max); + vclk_max, + false);if (ret)return ret; }@@ -1465,7 +1478,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_VCLK1 , vclk1_min, - vclk1_max); + vclk1_max, + false);if (ret)return ret; }@@ -1474,7 +1488,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_DCLK , dclk_min, - dclk_max); + dclk_max, + false);if (ret)return ret; }@@ -1483,7 +1498,8 @@ static int smu_v14_0_common_set_performance_level(struct smu_context *smu, ret =smu_v14_0_0_set_soft_freq_limited_range (smu,SMU_DCLK1 , dclk1_min, - dclk1_max); + dclk1_max, + false);if (ret)return ret; }@@ -1670,6 +1686,7 @@ static const struct pptable_funcs smu_v14_0_0_ppt_funcs = { .gfx_off_control = smu_v14_0_gfx_off_control, .mode2_reset = smu_v14_0_0_mode2_reset, .get_dpm_ultimate_freq = smu_v14_0_common_get_dpm_ultimate_freq, + .set_soft_freq_limited_range = smu_v14_0_0_set_soft_freq_limited_range, .od_edit_dpm_table = smu_v14_0_od_edit_dpm_table, .print_clk_levels = smu_v14_0_0_print_clk_levels, .force_clk_levels = smu_v14_0_0_force_clk_levels,
PATCH 3/4 drm/amd/amdgpu: Add ISP Generic PM Domain (genpd) support
In reply to Pratap NirujogiAMDISP I2C device requires to power on ISP HW to probe the sensor device. Instead of using the exported symbols from ISP driver to control the power and clocks remotely,added Generic PM Domain (genpd) support in amdgpu_isp device for its child devices (amd_isp_capture, amd_isp_i2c_designware) to set power and clocks using PM methods.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h | 3 + drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 155 +++++++++++++++++++++++- 2 files changed, 157 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h +3 -0
@@ -28,6 +28,8 @@#ifndef __AMDGPU_ISP_H__#define __AMDGPU_ISP_H__ +#include <linux/pm_domain.h> +#define ISP_REGS_OFFSET_END 0x629A4struct amdgpu_isp ;
@@ -54,6 +56,7 @@ struct amdgpu_isp {struct isp_platform_data *isp_pdata;unsigned int harvest_config;const struct firmware *fw; +struct generic_pm_domain ispgpd; };extern const struct amdgpu_ip_block_version isp_v4_1_0_ip_block;
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +154 -1
191 lines not on this page · raw message
Signature · 1 line
2.43.0
PATCH 4/4 drm/amd/amdgpu: Refine isp_v4_1_1 logging
In reply to Pratap NirujogiReplace DRM_ERROR with drm_err function and update log messages to drop __func__ and print return value.
--- drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c +6 -12
@@ -220,8 +220,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp) isp->isp_cell =kcalloc (3 ,sizeof (struct mfd_cell ),GFP_KERNEL );if (!isp->isp_cell) { r = -ENOMEM ; -drm_err (&adev->ddev, -"%s: isp mfd cell alloc failed\n" , __func__); +drm_err (&adev->ddev,"isp mfd cell alloc failed (%d)\n" , r); goto failure; }
@@ -231,16 +230,14 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp) GFP_KERNEL);if (!isp->isp_res) { r = -ENOMEM ; -drm_err (&adev->ddev, -"%s: isp mfd res alloc failed\n" , __func__); +drm_err (&adev->ddev,"isp mfd resource alloc failed (%d)\n" , r); goto failure; } isp->isp_pdata =kzalloc (sizeof (*isp->isp_pdata),GFP_KERNEL );if (!isp->isp_pdata) { r = -ENOMEM ; -drm_err (&adev->ddev, -"%s: isp platform data alloc failed\n" , __func__); +drm_err (&adev->ddev,"isp platform data alloc failed (%d)\n" , r); goto failure; }
@@ -278,8 +275,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp) isp->isp_i2c_res =kcalloc (1 ,sizeof (struct resource ),GFP_KERNEL );if (!isp->isp_i2c_res) { r = -ENOMEM ; -drm_err (&adev->ddev, -"%s: isp mfd res alloc failed\n" , __func__); +drm_err (&adev->ddev,"isp mfd res alloc failed (%d)\n" , r); goto failure; }
@@ -298,8 +294,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp) isp->isp_gpio_res =kcalloc (1 ,sizeof (struct resource ),GFP_KERNEL );if (!isp->isp_gpio_res) { r = -ENOMEM ; -drm_err (&adev->ddev, -"%s: isp gpio res alloc failed\n" , __func__); +drm_err (&adev->ddev,"isp gpio resource alloc failed (%d)\n" , r); goto failure; }
@@ -318,8 +313,7 @@ static int isp_v4_1_1_hw_init(struct amdgpu_isp *isp)/* add only amd_isp_capture and amd_isp_i2c_designware to genpd */ r =mfd_add_hotplug_devices (isp->parent, isp->isp_cell,2 );if (r) { -drm_err (&adev->ddev, -"%s: add mfd hotplug device failed\n" , __func__); +drm_err (&adev->ddev,"add mfd hotplug device failed (%d)\n" , r); goto failure; }
Signature · 1 line
2.43.0
Quoted 26 lines · Pratap Nirujogi
This patch series adds support to control ISP power and clocks using the Generic PM Domain (genpd). Its required to control the ISP HW power from external I2C driver to successfully probe the sensor device. Instead of using an exported symbols from ISP driver, enabling Generic PM Domain (genpd) support in
amdgpu_ispdevice allows its child devices (amd_isp_capture,amd_isp_i2c_designware) to set power and clocks directly using PM method.We need to add support in
amdgpu_smuas well foramdgpu_ispdevice to set power / clocks when invoked from genpd. Though the below SMU messages are defined, the actual support to configure ISP is missing in SMU interface.
PPSMC_MSG_PowerDownIspByTilePPSMC_MSG_PowerUpIspByTilePPSMC_MSG_SetHardMinIspiclkByFreqPPSMC_MSG_SetHardMinIspxclkByFreqAdded support in SMU to control ISP power / clocks by updating the existing
amdgpu_dpm_set_powergating_by_smu()andamdgpu_dpm_set_soft_freq_range(); and the underlying SOC specific SMU implementation for isp v4.1.Pratap Nirujogi (4):
drm/amd/pm: Add support to set ISP Power drm/amd/pm: Add support to set min ISP clocks drm/amd/amdgpu: Add ISP Generic PM Domain (genpd) support drm/amd/amdgpu: Refineisp_v4_1_1logging
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_isp.h | 3 + drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 173 ++++++++++++++++-- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 15 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41 ++++- drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h | 9 +- .../inc/pmfw_if/smu14_driver_if_v14_0_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 2 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 60 ++++-- 9 files changed, 264 insertions(+), 42 deletions(-)
Thanks Mario, Lijo and Xiaojian for reviewing the patches.
Quoted 40 lines · Mario Limonciello
Quoted 35 lines · Pratap Nirujogi
This patch series adds support to control ISP power and clocks using the Generic PM Domain (genpd). Its required to control the ISP HW power from external I2C driver to successfully probe the sensor device. Instead of using an exported symbols from ISP driver, enabling Generic PM Domain (genpd) support in
amdgpu_ispdevice allows its child devices (amd_isp_capture,amd_isp_i2c_designware) to set power and clocks directly using PM method.We need to add support in
amdgpu_smuas well foramdgpu_ispdevice to set power / clocks when invoked from genpd. Though the below SMU messages are defined, the actual support to configure ISP is missing in SMU interface.
PPSMC_MSG_PowerDownIspByTilePPSMC_MSG_PowerUpIspByTilePPSMC_MSG_SetHardMinIspiclkByFreqPPSMC_MSG_SetHardMinIspxclkByFreqAdded support in SMU to control ISP power / clocks by updating the existing
amdgpu_dpm_set_powergating_by_smu()andamdgpu_dpm_set_soft_freq_range(); and the underlying SOC specific SMU implementation for isp v4.1.Pratap Nirujogi (4):
drm/amd/pm: Add support to set ISP Power drm/amd/pm: Add support to set min ISP clocks drm/amd/amdgpu: Add ISP Generic PM Domain (genpd) support drm/amd/amdgpu: Refineisp_v4_1_1loggingdrivers/gpu/drm/amd/amdgpu/amdgpu_isp.h | 3 + drivers/gpu/drm/amd/amdgpu/isp_v4_1_1.c | 173 ++++++++++++++++-- .../gpu/drm/amd/include/kgd_pp_interface.h | 2 + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 15 +- drivers/gpu/drm/amd/pm/swsmu/amdgpu_smu.c | 41 ++++-
drivers/gpu/drm/amd/pm/swsmu/inc/amdgpu_smu.h| 9 +- .../inc/pmfw_if/smu14_driver_if_v14_0_0.h | 1 + drivers/gpu/drm/amd/pm/swsmu/inc/smu_types.h | 2 + .../drm/amd/pm/swsmu/smu14/smu_v14_0_0_ppt.c | 60 ++++--Quoted 2 lines
9 files changed, 264 insertions(+), 42 deletions(-)Reviewed-by Mario Limonciello <[email protected]>