drm/radeon: Fix PCIe lane width calculation
Subsystems (3)
PATCH 1/2 drm/radeon: Fix PCIe lane width calculation
From: Paul Parsons <[email protected]>
Two years ago I tried an AMD Radeon E8860 embedded GPU with the drm driver. The dmesg output included driver warnings about an invalid PCIe lane width. Tracking the problem back led to si_set_pcie_lane_width_in_smc(). The calculation of the lane widths via ATOM_PPLIB_PCIE_LINK_WIDTH_MASK and ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT macros did not increment the resulting value, per the comment in pptable.h ("lanes - 1"), and per usage elsewhere. Applying the increment silenced the warnings.
The code has not changed since, so either my analysis was incorrect or the bug has gone unnoticed. Hence submitting this as an RFC.
--- drivers/gpu/drm/radeon/si_dpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/radeon/si_dpm.c +2 -2
@@ -5912,9 +5912,9 @@ static void si_set_pcie_lane_width_in_smc(struct radeon_device *rdev, {u32 lane_width;u32 new_lane_width = - (radeon_new_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ; + ((radeon_new_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ) +1 ;u32 current_lane_width = - (radeon_current_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ; + ((radeon_current_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ) +1 ;if (new_lane_width != current_lane_width) {radeon_set_pcie_lanes (rdev, new_lane_width);
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: Fix PCIe lane width calculation
In reply to a message not in the archiveThe calculation of the lane widths via ATOM_PPLIB_PCIE_LINK_WIDTH_MASK and ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT macros did not increment the resulting value, per the comment in pptable.h ("lanes - 1"), and per usage elsewhere. Port of the radeon fix to amdgpu.
--- drivers/gpu/drm/amd/amdgpu/si_dpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/si_dpm.c +2 -2
@@ -6372,9 +6372,9 @@ static void si_set_pcie_lane_width_in_smc(struct amdgpu_device *adev, {u32 lane_width;u32 new_lane_width = - (amdgpu_new_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ; + ((amdgpu_new_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ) +1 ;u32 current_lane_width = - (amdgpu_current_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ; + ((amdgpu_current_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ) +1 ;if (new_lane_width != current_lane_width) {amdgpu_set_pcie_lanes (adev, new_lane_width);
Signature · 6 lines
2.13.6 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 2/2] drm/amdgpu: Fix PCIe lane width calculation
Quoted 28 lines · Alex Deucher
The calculation of the lane widths via
ATOM_PPLIB_PCIE_LINK_WIDTH_MASKandATOM_PPLIB_PCIE_LINK_WIDTH_SHIFTmacros did not increment the resulting value, per the comment inpptable.h("lanes - 1"), and per usage elsewhere. Port of the radeon fix to amdgpu.Signed-off-by Alex Deucher <[email protected]>--- drivers/gpu/drm/amd/amdgpu/si_dpm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/si_dpm.c +2
-2@@ -6372,9 +6372,9 @@ static void si_set_pcie_lane_width_in_smc(struct amdgpu_device *adev, {u32 lane_width;u32 new_lane_width = - (amdgpu_new_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ; + ((amdgpu_new_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ) +1 ;u32 current_lane_width = - (amdgpu_current_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ; + ((amdgpu_current_state->caps &ATOM_PPLIB_PCIE_LINK_WIDTH_MASK ) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT ) +1 ;if (new_lane_width != current_lane_width) {amdgpu_set_pcie_lanes (adev, new_lane_width);
Christian König
Acked-byRe: [PATCH 2/2] drm/amdgpu: Fix PCIe lane width calculation
In reply to a message not in the archiveBut I think you should get Rex or somebody else who can confirm that this is correct to take a look as well.
Christian.
Am 03.04.2018 um 04:46 schrieb zhoucm1:
Quoted 38 lines
Quoted 25 lines · Alex Deucher
The calculation of the lane widths via
ATOM_PPLIB_PCIE_LINK_WIDTH_MASKandATOM_PPLIB_PCIE_LINK_WIDTH_SHIFTmacros did not increment the resulting value, per the comment inpptable.h("lanes - 1"), and per usage elsewhere. Port of the radeon fix to amdgpu.Signed-off-by Alex Deucher <[email protected]>---
drivers/gpu/drm/amd/amdgpu/si_dpm.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/si_dpm.c +0
-0@@ -6372,9 +6372,9 @@ static void si_set_pcie_lane_width_in_smc(struct amdgpu_device *adev, { u32 lane_width;u32
new_lane_width=
- (amdgpu_new_state->caps&ATOM_PPLIB_PCIE_LINK_WIDTH_MASK)Quoted 1 line
Quoted 1 line
ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT;+ ((
amdgpu_new_state->caps&ATOM_PPLIB_PCIE_LINK_WIDTH_MASK)Quoted 1 line
Quoted 1 line
ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT) + 1;Quoted 8 lines
u32
current_lane_width=
- (amdgpu_current_state->caps&ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT; + ((amdgpu_current_state->caps&ATOM_PPLIB_PCIE_LINK_WIDTH_MASK) >>ATOM_PPLIB_PCIE_LINK_WIDTH_SHIFT)
+ 1;
if (new_lane_width!=current_lane_width) {amdgpu_set_pcie_lanes(adev, new_lane_width);
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx