diff options
author | Alex Deucher <alexander.deucher@amd.com> | 2015-11-11 19:45:06 -0500 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2015-12-21 16:42:32 -0500 |
commit | d0dd7f0cc345fc8757148004639e1993ba183bd6 (patch) | |
tree | 690623b5708ceaa59fd0fe9657c4f15d8ec342ac | |
parent | 60d8edd415e9da63599c7601707ca78ad74a927e (diff) |
drm/amdgpu: store pcie gen mask and link width
We'll need this later for pcie dpm.
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu.h | 4 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 78 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/cik.c | 24 | ||||
-rw-r--r-- | drivers/gpu/drm/amd/amdgpu/vi.c | 13 |
4 files changed, 99 insertions, 20 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 637eff393bc7..26d9134f7c0d 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h | |||
@@ -1637,8 +1637,12 @@ struct amdgpu_pm { | |||
1637 | const struct firmware *fw; /* SMC firmware */ | 1637 | const struct firmware *fw; /* SMC firmware */ |
1638 | uint32_t fw_version; | 1638 | uint32_t fw_version; |
1639 | const struct amdgpu_dpm_funcs *funcs; | 1639 | const struct amdgpu_dpm_funcs *funcs; |
1640 | uint32_t pcie_gen_mask; | ||
1641 | uint32_t pcie_mlw_mask; | ||
1640 | }; | 1642 | }; |
1641 | 1643 | ||
1644 | void amdgpu_get_pcie_info(struct amdgpu_device *adev); | ||
1645 | |||
1642 | /* | 1646 | /* |
1643 | * UVD | 1647 | * UVD |
1644 | */ | 1648 | */ |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 587ff7145361..65531463f88e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "amdgpu_i2c.h" | 38 | #include "amdgpu_i2c.h" |
39 | #include "atom.h" | 39 | #include "atom.h" |
40 | #include "amdgpu_atombios.h" | 40 | #include "amdgpu_atombios.h" |
41 | #include "amd_pcie.h" | ||
41 | #ifdef CONFIG_DRM_AMDGPU_CIK | 42 | #ifdef CONFIG_DRM_AMDGPU_CIK |
42 | #include "cik.h" | 43 | #include "cik.h" |
43 | #endif | 44 | #endif |
@@ -1932,6 +1933,83 @@ retry: | |||
1932 | return r; | 1933 | return r; |
1933 | } | 1934 | } |
1934 | 1935 | ||
1936 | void amdgpu_get_pcie_info(struct amdgpu_device *adev) | ||
1937 | { | ||
1938 | u32 mask; | ||
1939 | int ret; | ||
1940 | |||
1941 | if (pci_is_root_bus(adev->pdev->bus)) | ||
1942 | return; | ||
1943 | |||
1944 | if (amdgpu_pcie_gen2 == 0) | ||
1945 | return; | ||
1946 | |||
1947 | if (adev->flags & AMD_IS_APU) | ||
1948 | return; | ||
1949 | |||
1950 | ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); | ||
1951 | if (!ret) { | ||
1952 | adev->pm.pcie_gen_mask = (CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1 | | ||
1953 | CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN2 | | ||
1954 | CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN3); | ||
1955 | |||
1956 | if (mask & DRM_PCIE_SPEED_25) | ||
1957 | adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1; | ||
1958 | if (mask & DRM_PCIE_SPEED_50) | ||
1959 | adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2; | ||
1960 | if (mask & DRM_PCIE_SPEED_80) | ||
1961 | adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3; | ||
1962 | } | ||
1963 | ret = drm_pcie_get_max_link_width(adev->ddev, &mask); | ||
1964 | if (!ret) { | ||
1965 | switch (mask) { | ||
1966 | case 32: | ||
1967 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 | | ||
1968 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 | | ||
1969 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 | | ||
1970 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | | ||
1971 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | | ||
1972 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | | ||
1973 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); | ||
1974 | break; | ||
1975 | case 16: | ||
1976 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 | | ||
1977 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 | | ||
1978 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | | ||
1979 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | | ||
1980 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | | ||
1981 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); | ||
1982 | break; | ||
1983 | case 12: | ||
1984 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 | | ||
1985 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | | ||
1986 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | | ||
1987 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | | ||
1988 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); | ||
1989 | break; | ||
1990 | case 8: | ||
1991 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | | ||
1992 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | | ||
1993 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | | ||
1994 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); | ||
1995 | break; | ||
1996 | case 4: | ||
1997 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | | ||
1998 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | | ||
1999 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); | ||
2000 | break; | ||
2001 | case 2: | ||
2002 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | | ||
2003 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); | ||
2004 | break; | ||
2005 | case 1: | ||
2006 | adev->pm.pcie_mlw_mask = CAIL_PCIE_LINK_WIDTH_SUPPORT_X1; | ||
2007 | break; | ||
2008 | default: | ||
2009 | break; | ||
2010 | } | ||
2011 | } | ||
2012 | } | ||
1935 | 2013 | ||
1936 | /* | 2014 | /* |
1937 | * Debugfs | 2015 | * Debugfs |
diff --git a/drivers/gpu/drm/amd/amdgpu/cik.c b/drivers/gpu/drm/amd/amdgpu/cik.c index c7c298b88170..fd9c9588ef46 100644 --- a/drivers/gpu/drm/amd/amdgpu/cik.c +++ b/drivers/gpu/drm/amd/amdgpu/cik.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "amdgpu_vce.h" | 32 | #include "amdgpu_vce.h" |
33 | #include "cikd.h" | 33 | #include "cikd.h" |
34 | #include "atom.h" | 34 | #include "atom.h" |
35 | #include "amd_pcie.h" | ||
35 | 36 | ||
36 | #include "cik.h" | 37 | #include "cik.h" |
37 | #include "gmc_v7_0.h" | 38 | #include "gmc_v7_0.h" |
@@ -1595,8 +1596,8 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1595 | { | 1596 | { |
1596 | struct pci_dev *root = adev->pdev->bus->self; | 1597 | struct pci_dev *root = adev->pdev->bus->self; |
1597 | int bridge_pos, gpu_pos; | 1598 | int bridge_pos, gpu_pos; |
1598 | u32 speed_cntl, mask, current_data_rate; | 1599 | u32 speed_cntl, current_data_rate; |
1599 | int ret, i; | 1600 | int i; |
1600 | u16 tmp16; | 1601 | u16 tmp16; |
1601 | 1602 | ||
1602 | if (pci_is_root_bus(adev->pdev->bus)) | 1603 | if (pci_is_root_bus(adev->pdev->bus)) |
@@ -1608,23 +1609,20 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1608 | if (adev->flags & AMD_IS_APU) | 1609 | if (adev->flags & AMD_IS_APU) |
1609 | return; | 1610 | return; |
1610 | 1611 | ||
1611 | ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); | 1612 | if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | |
1612 | if (ret != 0) | 1613 | CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) |
1613 | return; | ||
1614 | |||
1615 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) | ||
1616 | return; | 1614 | return; |
1617 | 1615 | ||
1618 | speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL); | 1616 | speed_cntl = RREG32_PCIE(ixPCIE_LC_SPEED_CNTL); |
1619 | current_data_rate = (speed_cntl & PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK) >> | 1617 | current_data_rate = (speed_cntl & PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE_MASK) >> |
1620 | PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT; | 1618 | PCIE_LC_SPEED_CNTL__LC_CURRENT_DATA_RATE__SHIFT; |
1621 | if (mask & DRM_PCIE_SPEED_80) { | 1619 | if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { |
1622 | if (current_data_rate == 2) { | 1620 | if (current_data_rate == 2) { |
1623 | DRM_INFO("PCIE gen 3 link speeds already enabled\n"); | 1621 | DRM_INFO("PCIE gen 3 link speeds already enabled\n"); |
1624 | return; | 1622 | return; |
1625 | } | 1623 | } |
1626 | DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); | 1624 | DRM_INFO("enabling PCIE gen 3 link speeds, disable with amdgpu.pcie_gen2=0\n"); |
1627 | } else if (mask & DRM_PCIE_SPEED_50) { | 1625 | } else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) { |
1628 | if (current_data_rate == 1) { | 1626 | if (current_data_rate == 1) { |
1629 | DRM_INFO("PCIE gen 2 link speeds already enabled\n"); | 1627 | DRM_INFO("PCIE gen 2 link speeds already enabled\n"); |
1630 | return; | 1628 | return; |
@@ -1640,7 +1638,7 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1640 | if (!gpu_pos) | 1638 | if (!gpu_pos) |
1641 | return; | 1639 | return; |
1642 | 1640 | ||
1643 | if (mask & DRM_PCIE_SPEED_80) { | 1641 | if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) { |
1644 | /* re-try equalization if gen3 is not already enabled */ | 1642 | /* re-try equalization if gen3 is not already enabled */ |
1645 | if (current_data_rate != 2) { | 1643 | if (current_data_rate != 2) { |
1646 | u16 bridge_cfg, gpu_cfg; | 1644 | u16 bridge_cfg, gpu_cfg; |
@@ -1735,9 +1733,9 @@ static void cik_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1735 | 1733 | ||
1736 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); | 1734 | pci_read_config_word(adev->pdev, gpu_pos + PCI_EXP_LNKCTL2, &tmp16); |
1737 | tmp16 &= ~0xf; | 1735 | tmp16 &= ~0xf; |
1738 | if (mask & DRM_PCIE_SPEED_80) | 1736 | if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3) |
1739 | tmp16 |= 3; /* gen3 */ | 1737 | tmp16 |= 3; /* gen3 */ |
1740 | else if (mask & DRM_PCIE_SPEED_50) | 1738 | else if (adev->pm.pcie_gen_mask & CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2) |
1741 | tmp16 |= 2; /* gen2 */ | 1739 | tmp16 |= 2; /* gen2 */ |
1742 | else | 1740 | else |
1743 | tmp16 |= 1; /* gen1 */ | 1741 | tmp16 |= 1; /* gen1 */ |
@@ -2450,6 +2448,8 @@ static int cik_common_early_init(void *handle) | |||
2450 | return -EINVAL; | 2448 | return -EINVAL; |
2451 | } | 2449 | } |
2452 | 2450 | ||
2451 | amdgpu_get_pcie_info(adev); | ||
2452 | |||
2453 | return 0; | 2453 | return 0; |
2454 | } | 2454 | } |
2455 | 2455 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/vi.c b/drivers/gpu/drm/amd/amdgpu/vi.c index e51070e9697a..25d620790607 100644 --- a/drivers/gpu/drm/amd/amdgpu/vi.c +++ b/drivers/gpu/drm/amd/amdgpu/vi.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "amdgpu_vce.h" | 31 | #include "amdgpu_vce.h" |
32 | #include "amdgpu_ucode.h" | 32 | #include "amdgpu_ucode.h" |
33 | #include "atom.h" | 33 | #include "atom.h" |
34 | #include "amd_pcie.h" | ||
34 | 35 | ||
35 | #include "gmc/gmc_8_1_d.h" | 36 | #include "gmc/gmc_8_1_d.h" |
36 | #include "gmc/gmc_8_1_sh_mask.h" | 37 | #include "gmc/gmc_8_1_sh_mask.h" |
@@ -1052,9 +1053,6 @@ static int vi_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk) | |||
1052 | 1053 | ||
1053 | static void vi_pcie_gen3_enable(struct amdgpu_device *adev) | 1054 | static void vi_pcie_gen3_enable(struct amdgpu_device *adev) |
1054 | { | 1055 | { |
1055 | u32 mask; | ||
1056 | int ret; | ||
1057 | |||
1058 | if (pci_is_root_bus(adev->pdev->bus)) | 1056 | if (pci_is_root_bus(adev->pdev->bus)) |
1059 | return; | 1057 | return; |
1060 | 1058 | ||
@@ -1064,11 +1062,8 @@ static void vi_pcie_gen3_enable(struct amdgpu_device *adev) | |||
1064 | if (adev->flags & AMD_IS_APU) | 1062 | if (adev->flags & AMD_IS_APU) |
1065 | return; | 1063 | return; |
1066 | 1064 | ||
1067 | ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); | 1065 | if (!(adev->pm.pcie_gen_mask & (CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2 | |
1068 | if (ret != 0) | 1066 | CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3))) |
1069 | return; | ||
1070 | |||
1071 | if (!(mask & (DRM_PCIE_SPEED_50 | DRM_PCIE_SPEED_80))) | ||
1072 | return; | 1067 | return; |
1073 | 1068 | ||
1074 | /* todo */ | 1069 | /* todo */ |
@@ -1473,6 +1468,8 @@ static int vi_common_early_init(void *handle) | |||
1473 | if (amdgpu_smc_load_fw && smc_enabled) | 1468 | if (amdgpu_smc_load_fw && smc_enabled) |
1474 | adev->firmware.smu_load = true; | 1469 | adev->firmware.smu_load = true; |
1475 | 1470 | ||
1471 | amdgpu_get_pcie_info(adev); | ||
1472 | |||
1476 | return 0; | 1473 | return 0; |
1477 | } | 1474 | } |
1478 | 1475 | ||