Combine the platform and GPU caps like we do for PCIe Gen.
This aligns properly with expectations and documentation
for the interface.

Link: https://gitlab.freedesktop.org/drm/amd/-/issues/3820
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
index f908355df07c2..2c76bc5e25d92 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
@@ -867,7 +867,7 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
        case AMDGPU_INFO_DEV_INFO: {
                struct drm_amdgpu_info_device *dev_info;
                uint64_t vm_size;
-               uint32_t pcie_gen_mask;
+               uint32_t pcie_gen_mask, pcie_width_mask;
 
                dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
                if (!dev_info)
@@ -955,15 +955,18 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
                dev_info->tcc_disabled_mask = 
adev->gfx.config.tcc_disabled_mask;
 
                /* Combine the chip gen mask with the platform (CPU/mobo) mask. 
*/
-               pcie_gen_mask = adev->pm.pcie_gen_mask & 
(adev->pm.pcie_gen_mask >> 16);
+               pcie_gen_mask = adev->pm.pcie_gen_mask &
+                       (adev->pm.pcie_gen_mask >> 
CAIL_PCIE_LINK_SPEED_SUPPORT_SHIFT);
+               pcie_width_mask = adev->pm.pcie_mlw_mask &
+                       (adev->pm.pcie_mlw_mask >> 
CAIL_PCIE_LINK_WIDTH_SUPPORT_SHIFT);
                dev_info->pcie_gen = fls(pcie_gen_mask);
                dev_info->pcie_num_lanes =
-                       adev->pm.pcie_mlw_mask & 
CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 ? 32 :
-                       adev->pm.pcie_mlw_mask & 
CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 ? 16 :
-                       adev->pm.pcie_mlw_mask & 
CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 ? 12 :
-                       adev->pm.pcie_mlw_mask & 
CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 ? 8 :
-                       adev->pm.pcie_mlw_mask & 
CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 ? 4 :
-                       adev->pm.pcie_mlw_mask & 
CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 ? 2 : 1;
+                       pcie_width_mask & CAIL_ASIC_PCIE_LINK_WIDTH_SUPPORT_X32 
? 32 :
+                       pcie_width_mask & CAIL_ASIC_PCIE_LINK_WIDTH_SUPPORT_X16 
? 16 :
+                       pcie_width_mask & CAIL_ASIC_PCIE_LINK_WIDTH_SUPPORT_X12 
? 12 :
+                       pcie_width_mask & CAIL_ASIC_PCIE_LINK_WIDTH_SUPPORT_X8 
? 8 :
+                       pcie_width_mask & CAIL_ASIC_PCIE_LINK_WIDTH_SUPPORT_X4 
? 4 :
+                       pcie_width_mask & CAIL_ASIC_PCIE_LINK_WIDTH_SUPPORT_X2 
? 2 : 1;
 
                dev_info->tcp_cache_size = adev->gfx.config.gc_tcp_l1_size;
                dev_info->num_sqc_per_wgp = adev->gfx.config.gc_num_sqc_per_wgp;
-- 
2.47.1

Reply via email to