radeon: fix pll/ctrc mapping on dce2 and dce3 hardware
Subsystems (2)
PATCH 1/1 radeon: fix pll/ctrc mapping on dce2 and dce3 hardware
From: Jerome Glisse <[email protected]>
This fix black screen on resume issue that some people are experiencing. There is a bug in the atombios code regarding pll/crtc mapping. The atombios code reverse the logic for the pll and crtc mapping.
--- drivers/gpu/drm/radeon/atombios_crtc.c | 54 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 34 deletions(-)
drivers/gpu/drm/radeon/atombios_crtc.c +20 -34
@@ -1696,42 +1696,28 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)return ATOM_PPLL2 ;DRM_ERROR ("unable to allocate a PPLL\n" );return ATOM_PPLL_INVALID ; - }else if (ASIC_IS_AVIVO (rdev)) { -/* in DP mode, the DP ref clock can come from either PPLL -* depending on the asic: -* DCE3: PPLL1 or PPLL2 -*/ -if (ENCODER_MODE_IS_DP (atombios_get_encoder_mode (radeon_crtc->encoder))) { -/* use the same PPLL for all DP monitors */ - pll =radeon_get_shared_dp_ppll (crtc); -if (pll !=ATOM_PPLL_INVALID ) -return pll; - }else { -/* use the same PPLL for all monitors with the same clock */ - pll =radeon_get_shared_nondp_ppll (crtc); -if (pll !=ATOM_PPLL_INVALID ) -return pll; - } -/* all other cases */ - pll_in_use =radeon_get_pll_use_mask (crtc); -/* the order shouldn't matter here, but we probably -* need this until we have atomic modeset -*/ -if (rdev->flags &RADEON_IS_IGP ) { -if (!(pll_in_use & (1 <<ATOM_PPLL1 ))) -return ATOM_PPLL1 ; -if (!(pll_in_use & (1 <<ATOM_PPLL2 ))) -return ATOM_PPLL2 ; - }else { -if (!(pll_in_use & (1 <<ATOM_PPLL2 ))) -return ATOM_PPLL2 ; -if (!(pll_in_use & (1 <<ATOM_PPLL1 ))) -return ATOM_PPLL1 ; - } -DRM_ERROR ("unable to allocate a PPLL\n" ); -return ATOM_PPLL_INVALID ; }else {/* on pre-R5xx asics, the crtc to pll mapping is hardcoded */ +/* some atombios (observed in some DCE2/DCE3) code have a bug, +* the matching btw pll and crtc is done through +* PCLK_CRTC[1|2]_CNTL (0x480/0x484) but atombios code use the +* pll (1 or 2) to select which register to write. ie if using +* pll1 it will use PCLK_CRTC1_CNTL (0x480) and if using pll2 +* it will use PCLK_CRTC2_CNTL (0x484), it then use crtc id to +* choose which value to write. Which is reverse order from +* register logic. So only case that works is when pllid is +* same as crtcid or when both pll and crtc are enabled and +* both use same clock. +* +* So just return crtc id as if crtc and pll were hard linked +* together even if they aren't +*/ +if (radeon_crtc->crtc_id >1 ) { +/* crtc other than crtc1 and crtc2 can only be use for +* DP those doesn't need a valid pll to work. +*/ +return ATOM_PPLL_INVALID ; + }return radeon_crtc->crtc_id; } }
Signature · 1 line
1.7.11.7
Quoted 66 lines · On Tue, Nov 27, 2012 at 4:12 PM, <[email protected]> wrote:
From: Jerome Glisse <[email protected]>
This fix black screen on resume issue that some people are experiencing. There is a bug in the atombios code regarding pll/crtc mapping. The atombios code reverse the logic for the pll and crtc mapping.
Signed-off-by Jerome Glisse <[email protected]>--- drivers/gpu/drm/radeon/atombios_crtc.c | 54 +++++++++++++--------------------- 1 file changed, 20 insertions(+), 34 deletions(-)drivers/gpu/drm/radeon/atombios_crtc.c +10
-34@@ -1696,42 +1696,28 @@ static int radeon_atom_pick_pll(struct drm_crtc *crtc)return ATOM_PPLL2 ;DRM_ERROR ("unable to allocate a PPLL\n" );return ATOM_PPLL_INVALID ; - }else if (ASIC_IS_AVIVO (rdev)) { -/* in DP mode, the DP ref clock can come from either PPLL -* depending on the asic: -* DCE3: PPLL1 or PPLL2 -*/ -if (ENCODER_MODE_IS_DP (atombios_get_encoder_mode (radeon_crtc->encoder))) { -/* use the same PPLL for all DP monitors */ - pll =radeon_get_shared_dp_ppll (crtc); -if (pll !=ATOM_PPLL_INVALID ) -return pll; - }else { -/* use the same PPLL for all monitors with the same clock */ - pll =radeon_get_shared_nondp_ppll (crtc); -if (pll !=ATOM_PPLL_INVALID ) -return pll; - } -/* all other cases */ - pll_in_use =radeon_get_pll_use_mask (crtc); -/* the order shouldn't matter here, but we probably -* need this until we have atomic modeset -*/ -if (rdev->flags &RADEON_IS_IGP ) { -if (!(pll_in_use & (1 <<ATOM_PPLL1 ))) -return ATOM_PPLL1 ; -if (!(pll_in_use & (1 <<ATOM_PPLL2 ))) -return ATOM_PPLL2 ; - }else { -if (!(pll_in_use & (1 <<ATOM_PPLL2 ))) -return ATOM_PPLL2 ; -if (!(pll_in_use & (1 <<ATOM_PPLL1 ))) -return ATOM_PPLL1 ; - } -DRM_ERROR ("unable to allocate a PPLL\n" ); -return ATOM_PPLL_INVALID ; }else {/* on pre-R5xx asics, the crtc to pll mapping is hardcoded */ +/* some atombios (observed in some DCE2/DCE3) code have a bug, +* the matching btw pll and crtc is done through +* PCLK_CRTC[1|2]_CNTL (0x480/0x484) but atombios code use the +* pll (1 or 2) to select which register to write. ie if using +* pll1 it will use PCLK_CRTC1_CNTL (0x480) and if using pll2 +* it will use PCLK_CRTC2_CNTL (0x484), it then use crtc id to +* choose which value to write. Which is reverse order from +* register logic. So only case that works is when pllid is +* same as crtcid or when both pll and crtc are enabled and +* both use same clock.
drivers/gpu/drm/radeon/atombios_crtc.c static int radeon_atom_pick_pll(struct drm_crtc *crtc) · line 1720
Quoted 10 lines
drivers/gpu/drm/radeon/atombios_crtc.c +10
-0+* +* So just return crtc id as if crtc and pll were hard linked +* together even if they aren't +*/ +if (radeon_crtc->crtc_id >1 ) { +/* crtc other than crtc1 and crtc2 can only be use for +* DP those doesn't need a valid pll to work. +*/ +return ATOM_PPLL_INVALID ; + }
We can drop the check above as pre-DCE4 asics never have more than 2 crtcs. Other than that, looks good.
Quoted 10 lines
drivers/gpu/drm/radeon/atombios_crtc.c +0
-1return radeon_crtc->crtc_id; } } --1.7.11.7
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel