aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
diff options
context:
space:
mode:
authorHarish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>2019-02-01 17:57:48 -0500
committerAlex Deucher <alexander.deucher@amd.com>2019-02-07 14:03:18 -0500
commitc53134577c185533ca7e0b958bafc77539d41fd9 (patch)
treeaed8ac7a34aff0b5248003aba606af2201aefd11 /drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
parent2c850b7b9e7d0fb36e0bd1ad1238ff55e5c4dcdc (diff)
drm/amdgpu: Fix pci platform speed and width
The new Vega series GPU cards have in-built bridges. To get the pcie speed and width supported by the platform walk the hierarchy and get the slowest link. Signed-off-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com> Acked-by: Christian König <christian.koenig@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_device.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_device.c58
1 files changed, 46 insertions, 12 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d7dddb936f84..fcab1fe9bb68 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3618,6 +3618,38 @@ retry: /* Rest of adevs pre asic reset from XGMI hive. */
3618 return r; 3618 return r;
3619} 3619}
3620 3620
3621static void amdgpu_device_get_min_pci_speed_width(struct amdgpu_device *adev,
3622 enum pci_bus_speed *speed,
3623 enum pcie_link_width *width)
3624{
3625 struct pci_dev *pdev = adev->pdev;
3626 enum pci_bus_speed cur_speed;
3627 enum pcie_link_width cur_width;
3628
3629 *speed = PCI_SPEED_UNKNOWN;
3630 *width = PCIE_LNK_WIDTH_UNKNOWN;
3631
3632 while (pdev) {
3633 cur_speed = pcie_get_speed_cap(pdev);
3634 cur_width = pcie_get_width_cap(pdev);
3635
3636 if (cur_speed != PCI_SPEED_UNKNOWN) {
3637 if (*speed == PCI_SPEED_UNKNOWN)
3638 *speed = cur_speed;
3639 else if (cur_speed < *speed)
3640 *speed = cur_speed;
3641 }
3642
3643 if (cur_width != PCIE_LNK_WIDTH_UNKNOWN) {
3644 if (*width == PCIE_LNK_WIDTH_UNKNOWN)
3645 *width = cur_width;
3646 else if (cur_width < *width)
3647 *width = cur_width;
3648 }
3649 pdev = pci_upstream_bridge(pdev);
3650 }
3651}
3652
3621/** 3653/**
3622 * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot 3654 * amdgpu_device_get_pcie_info - fence pcie info about the PCIE slot
3623 * 3655 *
@@ -3630,8 +3662,8 @@ retry: /* Rest of adevs pre asic reset from XGMI hive. */
3630static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev) 3662static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)
3631{ 3663{
3632 struct pci_dev *pdev; 3664 struct pci_dev *pdev;
3633 enum pci_bus_speed speed_cap; 3665 enum pci_bus_speed speed_cap, platform_speed_cap;
3634 enum pcie_link_width link_width; 3666 enum pcie_link_width platform_link_width;
3635 3667
3636 if (amdgpu_pcie_gen_cap) 3668 if (amdgpu_pcie_gen_cap)
3637 adev->pm.pcie_gen_mask = amdgpu_pcie_gen_cap; 3669 adev->pm.pcie_gen_mask = amdgpu_pcie_gen_cap;
@@ -3648,6 +3680,12 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)
3648 return; 3680 return;
3649 } 3681 }
3650 3682
3683 if (adev->pm.pcie_gen_mask && adev->pm.pcie_mlw_mask)
3684 return;
3685
3686 amdgpu_device_get_min_pci_speed_width(adev, &platform_speed_cap,
3687 &platform_link_width);
3688
3651 if (adev->pm.pcie_gen_mask == 0) { 3689 if (adev->pm.pcie_gen_mask == 0) {
3652 /* asic caps */ 3690 /* asic caps */
3653 pdev = adev->pdev; 3691 pdev = adev->pdev;
@@ -3673,22 +3711,20 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)
3673 adev->pm.pcie_gen_mask |= CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1; 3711 adev->pm.pcie_gen_mask |= CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1;
3674 } 3712 }
3675 /* platform caps */ 3713 /* platform caps */
3676 pdev = adev->ddev->pdev->bus->self; 3714 if (platform_speed_cap == PCI_SPEED_UNKNOWN) {
3677 speed_cap = pcie_get_speed_cap(pdev);
3678 if (speed_cap == PCI_SPEED_UNKNOWN) {
3679 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 | 3715 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 |
3680 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2); 3716 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2);
3681 } else { 3717 } else {
3682 if (speed_cap == PCIE_SPEED_16_0GT) 3718 if (platform_speed_cap == PCIE_SPEED_16_0GT)
3683 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 | 3719 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 |
3684 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | 3720 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |
3685 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 | 3721 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3 |
3686 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4); 3722 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN4);
3687 else if (speed_cap == PCIE_SPEED_8_0GT) 3723 else if (platform_speed_cap == PCIE_SPEED_8_0GT)
3688 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 | 3724 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 |
3689 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | 3725 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 |
3690 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3); 3726 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3);
3691 else if (speed_cap == PCIE_SPEED_5_0GT) 3727 else if (platform_speed_cap == PCIE_SPEED_5_0GT)
3692 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 | 3728 adev->pm.pcie_gen_mask |= (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1 |
3693 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2); 3729 CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2);
3694 else 3730 else
@@ -3697,12 +3733,10 @@ static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev)
3697 } 3733 }
3698 } 3734 }
3699 if (adev->pm.pcie_mlw_mask == 0) { 3735 if (adev->pm.pcie_mlw_mask == 0) {
3700 pdev = adev->ddev->pdev->bus->self; 3736 if (platform_link_width == PCIE_LNK_WIDTH_UNKNOWN) {
3701 link_width = pcie_get_width_cap(pdev);
3702 if (link_width == PCIE_LNK_WIDTH_UNKNOWN) {
3703 adev->pm.pcie_mlw_mask |= AMDGPU_DEFAULT_PCIE_MLW_MASK; 3737 adev->pm.pcie_mlw_mask |= AMDGPU_DEFAULT_PCIE_MLW_MASK;
3704 } else { 3738 } else {
3705 switch (link_width) { 3739 switch (platform_link_width) {
3706 case PCIE_LNK_X32: 3740 case PCIE_LNK_X32:
3707 adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 | 3741 adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 |
3708 CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 | 3742 CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |