提交 cd474ba0 编写于 作者: A Alex Deucher

drm/amdgpu: add pcie cap module parameters (v2)

Allows the user to force the supported pcie gen and lane
config on both the asic and the chipset.
Useful for debugging pcie problems and for virtualization
where we may not be able to query the pcie bridge caps.

Default to:
gen: chipset 1/2, asic 1/2/3
lanes: 1/2/4/8/16

v2: fix bare metal case
Reviewed-by: Nmonk liu <monk.liu@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
上级 6739b3d7
...@@ -87,6 +87,8 @@ extern int amdgpu_sched_jobs; ...@@ -87,6 +87,8 @@ extern int amdgpu_sched_jobs;
extern int amdgpu_sched_hw_submission; extern int amdgpu_sched_hw_submission;
extern int amdgpu_enable_semaphores; extern int amdgpu_enable_semaphores;
extern int amdgpu_powerplay; extern int amdgpu_powerplay;
extern unsigned amdgpu_pcie_gen_cap;
extern unsigned amdgpu_pcie_lane_cap;
#define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000 #define AMDGPU_WAIT_IDLE_TIMEOUT_IN_MS 3000
#define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */ #define AMDGPU_MAX_USEC_TIMEOUT 100000 /* 100 ms */
......
...@@ -1933,80 +1933,97 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev) ...@@ -1933,80 +1933,97 @@ int amdgpu_gpu_reset(struct amdgpu_device *adev)
return r; return r;
} }
#define AMDGPU_DEFAULT_PCIE_GEN_MASK 0x30007 /* gen: chipset 1/2, asic 1/2/3 */
#define AMDGPU_DEFAULT_PCIE_MLW_MASK 0x2f0000 /* 1/2/4/8/16 lanes */
void amdgpu_get_pcie_info(struct amdgpu_device *adev) void amdgpu_get_pcie_info(struct amdgpu_device *adev)
{ {
u32 mask; u32 mask;
int ret; int ret;
if (pci_is_root_bus(adev->pdev->bus)) if (amdgpu_pcie_gen_cap)
return; adev->pm.pcie_gen_mask = amdgpu_pcie_gen_cap;
if (amdgpu_pcie_gen2 == 0) if (amdgpu_pcie_lane_cap)
return; adev->pm.pcie_mlw_mask = amdgpu_pcie_lane_cap;
if (adev->flags & AMD_IS_APU) /* covers APUs as well */
if (pci_is_root_bus(adev->pdev->bus)) {
if (adev->pm.pcie_gen_mask == 0)
adev->pm.pcie_gen_mask = AMDGPU_DEFAULT_PCIE_GEN_MASK;
if (adev->pm.pcie_mlw_mask == 0)
adev->pm.pcie_mlw_mask = AMDGPU_DEFAULT_PCIE_MLW_MASK;
return; return;
}
ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask); if (adev->pm.pcie_gen_mask == 0) {
if (!ret) { ret = drm_pcie_get_speed_cap_mask(adev->ddev, &mask);
adev->pm.pcie_gen_mask = (CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1 | if (!ret) {
CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN2 | adev->pm.pcie_gen_mask = (CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN1 |
CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN3); CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN2 |
CAIL_ASIC_PCIE_LINK_SPEED_SUPPORT_GEN3);
if (mask & DRM_PCIE_SPEED_25)
adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1; if (mask & DRM_PCIE_SPEED_25)
if (mask & DRM_PCIE_SPEED_50) adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN1;
adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2; if (mask & DRM_PCIE_SPEED_50)
if (mask & DRM_PCIE_SPEED_80) adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN2;
adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3; if (mask & DRM_PCIE_SPEED_80)
} adev->pm.pcie_gen_mask |= CAIL_PCIE_LINK_SPEED_SUPPORT_GEN3;
ret = drm_pcie_get_max_link_width(adev->ddev, &mask); } else {
if (!ret) { adev->pm.pcie_gen_mask = AMDGPU_DEFAULT_PCIE_GEN_MASK;
switch (mask) { }
case 32: }
adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 | if (adev->pm.pcie_mlw_mask == 0) {
CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 | ret = drm_pcie_get_max_link_width(adev->ddev, &mask);
CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 | if (!ret) {
CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | switch (mask) {
CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | case 32:
CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X32 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |
break; CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
case 16: CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | break;
CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | case 16:
CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X16 |
break; CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
case 12: CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | break;
CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); case 12:
break; adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X12 |
case 8: CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); break;
break; case 8:
case 4: adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X8 |
adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
break; break;
case 2: case 4:
adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 | adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X4 |
CAIL_PCIE_LINK_WIDTH_SUPPORT_X1); CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
break; CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
case 1: break;
adev->pm.pcie_mlw_mask = CAIL_PCIE_LINK_WIDTH_SUPPORT_X1; case 2:
break; adev->pm.pcie_mlw_mask = (CAIL_PCIE_LINK_WIDTH_SUPPORT_X2 |
default: CAIL_PCIE_LINK_WIDTH_SUPPORT_X1);
break; break;
case 1:
adev->pm.pcie_mlw_mask = CAIL_PCIE_LINK_WIDTH_SUPPORT_X1;
break;
default:
break;
}
} else {
adev->pm.pcie_mlw_mask = AMDGPU_DEFAULT_PCIE_MLW_MASK;
} }
} }
} }
......
...@@ -83,6 +83,8 @@ int amdgpu_sched_jobs = 32; ...@@ -83,6 +83,8 @@ int amdgpu_sched_jobs = 32;
int amdgpu_sched_hw_submission = 2; int amdgpu_sched_hw_submission = 2;
int amdgpu_enable_semaphores = 0; int amdgpu_enable_semaphores = 0;
int amdgpu_powerplay = -1; int amdgpu_powerplay = -1;
unsigned amdgpu_pcie_gen_cap = 0;
unsigned amdgpu_pcie_lane_cap = 0;
MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes"); MODULE_PARM_DESC(vramlimit, "Restrict VRAM for testing, in megabytes");
module_param_named(vramlimit, amdgpu_vram_limit, int, 0600); module_param_named(vramlimit, amdgpu_vram_limit, int, 0600);
...@@ -170,6 +172,12 @@ MODULE_PARM_DESC(powerplay, "Powerplay component (1 = enable, 0 = disable, -1 = ...@@ -170,6 +172,12 @@ MODULE_PARM_DESC(powerplay, "Powerplay component (1 = enable, 0 = disable, -1 =
module_param_named(powerplay, amdgpu_powerplay, int, 0444); module_param_named(powerplay, amdgpu_powerplay, int, 0444);
#endif #endif
MODULE_PARM_DESC(pcie_gen_cap, "PCIE Gen Caps (0: autodetect (default))");
module_param_named(pcie_gen_cap, amdgpu_pcie_gen_cap, uint, 0444);
MODULE_PARM_DESC(pcie_lane_cap, "PCIE Lane Caps (0: autodetect (default))");
module_param_named(pcie_lane_cap, amdgpu_pcie_lane_cap, uint, 0444);
static struct pci_device_id pciidlist[] = { static struct pci_device_id pciidlist[] = {
#ifdef CONFIG_DRM_AMDGPU_CIK #ifdef CONFIG_DRM_AMDGPU_CIK
/* Kaveri */ /* Kaveri */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册