drm: add drm_pcie_get_max_link_width helper
Subsystems (3)
PATCH 1/5 drm: add drm_pcie_get_max_link_width helper
Add a helper to get the make link width of the port. Similar to the helper to get the max link speed.
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/drm_pci.c | 20 ++++++++++++++++++++ include/drm/drmP.h | 1 + 2 files changed, 21 insertions(+)
drivers/gpu/drm/drm_pci.c +20 -0
@@ -410,6 +410,26 @@ int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask) }EXPORT_SYMBOL (drm_pcie_get_speed_cap_mask); +int drm_pcie_get_max_link_width (struct drm_device *dev,u32 *mlw) +{ +struct pci_dev *root; +u32 lnkcap; + + *mlw =0 ; +if (!dev->pdev) +return -EINVAL ; + + root = dev->pdev->bus->self; + +pcie_capability_read_dword (root,PCI_EXP_LNKCAP , &lnkcap); + + *mlw = (lnkcap &PCI_EXP_LNKCAP_MLW ) >>4 ; + +DRM_INFO ("probing mlw for device %x:%x = %x\n" , root->vendor, root->device, lnkcap); +return 0 ; +} +EXPORT_SYMBOL (drm_pcie_get_max_link_width); +#else int drm_pci_init (struct drm_driver *driver,struct pci_driver *pdriver)
include/drm/drmP.h +1 -0
@@ -1098,6 +1098,7 @@ static inline int drm_pci_set_busid(struct drm_device *dev,#define DRM_PCIE_SPEED_80 4extern int drm_pcie_get_speed_cap_mask (struct drm_device *dev,u32 *speed_mask); +extern int drm_pcie_get_max_link_width (struct drm_device *dev,u32 *mlw);/* platform section */ extern int drm_platform_init (struct drm_driver *driver,struct platform_device *platform_device);
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/5 drm/amdgpu: store pcie gen mask and link width
We'll need this later for pcie dpm.
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 ++ drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 78 ++++++++++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/cik.c | 24 ++++----- drivers/gpu/drm/amd/amdgpu/vi.c | 13 ++--- 4 files changed, 99 insertions(+), 20 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu.h +4 -0
@@ -1591,8 +1591,12 @@ struct amdgpu_pm {const struct firmware *fw;/* SMC firmware */ uint32_t fw_version;const struct amdgpu_dpm_funcs *funcs; +uint32_t pcie_gen_mask; +uint32_t pcie_mlw_mask; }; +void amdgpu_get_pcie_info (struct amdgpu_device *adev); +/* * UVD */
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +78 -0
90 lines not on this page · raw message
drivers/gpu/drm/amd/amdgpu/cik.c +12 -12
@@ -32,6 +32,7 @@#include "amdgpu_vce.h" #include "cikd.h" #include "atom.h" +#include "amd_pcie.h" #include "cik.h" #include "gmc_v7_0.h"
@@ -1564,8 +1565,8 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) {struct pci_dev *root = adev->pdev->bus->self;int bridge_pos, gpu_pos; -u32 speed_cntl, mask, current_data_rate; -int ret, i; +u32 speed_cntl, current_data_rate; +int i;u16 tmp16;if (pci_is_root_bus (adev->pdev->bus))
@@ -1577,23 +1578,20 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)if (adev->flags &AMD_IS_APU )return ; - ret =drm_pcie_get_speed_cap_mask (adev->ddev, &mask); -if (ret !=0 ) -return ; - -if (!(mask & (DRM_PCIE_SPEED_50 |DRM_PCIE_SPEED_80 ))) +if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | +CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 )))return ; speed_cntl =RREG32_PCIE (ixPCIE_LC_SPEED_CNTL); current_data_rate = (speed_cntl &PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK ) >>PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT ; -if (mask &DRM_PCIE_SPEED_80 ) { +if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) {if (current_data_rate ==2 ) {DRM_INFO ("PCIE gen 3 link speeds already enabled\n" );return ; }DRM_INFO ("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n" ); - }else if (mask &DRM_PCIE_SPEED_50 ) { + }else if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 ) {if (current_data_rate ==1 ) {DRM_INFO ("PCIE gen 2 link speeds already enabled\n" );return ;
@@ -1609,7 +1607,7 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)if (!gpu_pos)return ; -if (mask &DRM_PCIE_SPEED_80 ) { +if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) {/* re-try equalization if gen3 is not already enabled */ if (current_data_rate !=2 ) {u16 bridge_cfg, gpu_cfg;
@@ -1704,9 +1702,9 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev)pci_read_config_word (adev->pdev, gpu_pos +PCI_EXP_LNKCTL2 , &tmp16); tmp16 &= ~0xf ; -if (mask &DRM_PCIE_SPEED_80 ) +if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) tmp16 |=3 ;/* gen3 */ -else if (mask &DRM_PCIE_SPEED_50 ) +else if (adev->pm.pcie_gen_mask &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 ) tmp16 |=2 ;/* gen2 */ else tmp16 |=1 ;/* gen1 */
@@ -2418,6 +2416,8 @@ static int cik_common_early_init(void *handle)return -EINVAL ; } +amdgpu_get_pcie_info (adev); +return 0 ; }
drivers/gpu/drm/amd/amdgpu/vi.c +5 -8
@@ -31,6 +31,7 @@#include "amdgpu_vce.h" #include "amdgpu_ucode.h" #include "atom.h" +#include "amd_pcie.h" #include "gmc/gmc_8_1_d.h" #include "gmc/gmc_8_1_sh_mask.h"
@@ -1020,9 +1021,6 @@ static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)static void vi_pcie_gen3_enable (struct amdgpu_device *adev) { -u32 mask; -int ret; -if (pci_is_root_bus (adev->pdev->bus))return ;
@@ -1032,11 +1030,8 @@ static void vi_pcie_gen3_enable(struct amdgpu_device *adev)if (adev->flags &AMD_IS_APU )return ; - ret =drm_pcie_get_speed_cap_mask (adev->ddev, &mask); -if (ret !=0 ) -return ; - -if (!(mask & (DRM_PCIE_SPEED_50 |DRM_PCIE_SPEED_80 ))) +if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | +CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 )))return ;/* todo */
@@ -1443,6 +1438,8 @@ static int vi_common_early_init(void *handle)if (amdgpu_smc_load_fw && smc_enabled) adev->firmware.smu_load = true; +amdgpu_get_pcie_info (adev); +return 0 ; }
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/5 drm/amdgpu/cgs: add sys info query for pcie gen and link width
In reply to Alex DeucherNeeded by powerplay to properly handle pcie dpm switching.
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 6 ++++++ drivers/gpu/drm/amd/include/cgs_common.h | 2 ++ 2 files changed, 8 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +6 -0
@@ -754,6 +754,12 @@ static int amdgpu_cgs_query_system_info(void *cgs_device,case CGS_SYSTEM_INFO_ADAPTER_BDF_ID : sys_info->value = adev->pdev->devfn | (adev->pdev->bus->number <<8 );break ; +case CGS_SYSTEM_INFO_PCIE_GEN_INFO : + sys_info->value = adev->pm.pcie_gen_mask; +break ; +case CGS_SYSTEM_INFO_PCIE_MLW : + sys_info->value = adev->pm.pcie_mlw_mask; +break ;default :return -ENODEV ; }
drivers/gpu/drm/amd/include/cgs_common.h +2 -0
@@ -107,6 +107,8 @@ enum cgs_ucode_id {enum cgs_system_info_id {CGS_SYSTEM_INFO_ADAPTER_BDF_ID =1 , +CGS_SYSTEM_INFO_PCIE_GEN_INFO , +CGS_SYSTEM_INFO_PCIE_MLW ,CGS_SYSTEM_INFO_ID_MAXIMUM , };
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 4/5 drm/amdgpu/powerplay/tonga: query supported pcie info from cgs (v2)
In reply to Alex DeucherRather than hardcode it.
v2: integrate spc fix from Rex
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c +18 -2
@@ -4559,14 +4559,30 @@ int tonga_hwmgr_backend_init(struct pp_hwmgr *hwmgr) data->vddc_phase_shed_control =0 ;if (0 == result) { +struct cgs_system_info sys_info = {0 }; + data->is_tlu_enabled =0 ; hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =TONGA_MAX_HARDWARE_POWERLEVELS ; hwmgr->platform_descriptor.hardwarePerformanceLevels =2 ; hwmgr->platform_descriptor.minimumClocksReductionPercentage =50 ; - data->pcie_gen_cap =0x30007 ; - data->pcie_lane_cap =0x2f0000 ; + sys_info.size =sizeof (struct cgs_system_info ); + sys_info.info_id =CGS_SYSTEM_INFO_PCIE_GEN_INFO ; + result =cgs_query_system_info (hwmgr->device, &sys_info); +if (result) + data->pcie_gen_cap =0x30007 ; +else + data->pcie_gen_cap = (uint32_t )sys_info.value; +if (data->pcie_gen_cap &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) + data->pcie_spc_cap =20 ; + sys_info.size =sizeof (struct cgs_system_info ); + sys_info.info_id =CGS_SYSTEM_INFO_PCIE_MLW ; + result =cgs_query_system_info (hwmgr->device, &sys_info); +if (result) + data->pcie_lane_cap =0x2f0000 ; +else + data->pcie_lane_cap = (uint32_t )sys_info.value; }else {/* Ignore return value in here, we are cleaning up a mess. */ tonga_hwmgr_backend_fini (hwmgr);
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 5/5 drm/amdgpu/powerplay/fiji: query supported pcie info from cgs (v2)
In reply to Alex DeucherRather than hardcode it.
v2: integrate spc fix from Rex
Signed-off-by Alex Deucher <[email protected]>
--- drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/powerplay/hwmgr/fiji_hwmgr.c +18 -2
@@ -684,14 +684,30 @@ static int fiji_hwmgr_backend_init(struct pp_hwmgr *hwmgr) PHM_PlatformCaps_StayInBootState);if (0 == result) { +struct cgs_system_info sys_info = {0 }; + data->is_tlu_enabled =0 ; hwmgr->platform_descriptor.hardwareActivityPerformanceLevels =FIJI_MAX_HARDWARE_POWERLEVELS ; hwmgr->platform_descriptor.hardwarePerformanceLevels =2 ; hwmgr->platform_descriptor.minimumClocksReductionPercentage =50 ; - data->pcie_gen_cap =0x30007 ; - data->pcie_lane_cap =0x2f0000 ; + sys_info.size =sizeof (struct cgs_system_info ); + sys_info.info_id =CGS_SYSTEM_INFO_PCIE_GEN_INFO ; + result =cgs_query_system_info (hwmgr->device, &sys_info); +if (result) + data->pcie_gen_cap =0x30007 ; +else + data->pcie_gen_cap = (uint32_t )sys_info.value; +if (data->pcie_gen_cap &CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 ) + data->pcie_spc_cap =20 ; + sys_info.size =sizeof (struct cgs_system_info ); + sys_info.info_id =CGS_SYSTEM_INFO_PCIE_MLW ; + result =cgs_query_system_info (hwmgr->device, &sys_info); +if (result) + data->pcie_lane_cap =0x2f0000 ; +else + data->pcie_lane_cap = (uint32_t )sys_info.value; }else {/* Ignore return value in here, we are cleaning up a mess. */ tonga_hwmgr_backend_fini (hwmgr);
Signature · 6 lines
1.8.3.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel