diff options
author | Egbert Eich <eich@freedesktop.org> | 2008-07-18 12:12:33 +0200 |
---|---|---|
committer | Egbert Eich <eich@freedesktop.org> | 2008-07-18 18:54:57 +0200 |
commit | 21764225ce9ec90cefa8ba8c7642e2c9e777a796 (patch) | |
tree | 7c9aae6576156f9f998f30ba229c5c6c6636b619 | |
parent | 537700cba0ae794705c1eca55d33b721e94f708d (diff) |
MC: Make sure MC engine is all idle before setting up the MC.
In the RandR case we accidentally missed to shut down the CRTCs
before calling SetupMC().
Use ASSERTS to make sure the code doesn't get broken accidentally.
-rw-r--r-- | src/rhd.h | 21 | ||||
-rw-r--r-- | src/rhd_crtc.c | 2 | ||||
-rw-r--r-- | src/rhd_driver.c | 55 | ||||
-rw-r--r-- | src/rhd_mc.c | 105 | ||||
-rw-r--r-- | src/rhd_randr.c | 10 | ||||
-rw-r--r-- | src/rhd_vga.c | 4 |
6 files changed, 69 insertions, 128 deletions
@@ -333,23 +333,24 @@ typedef struct RHDRec { /* rhd_driver.c */ /* Some handy functions that makes life so much more readable */ -unsigned int RHDReadPCIBios(RHDPtr rhdPtr, unsigned char **prt); -Bool RHDScalePolicy(struct rhdMonitor *Monitor, struct rhdConnector *Connector); -CARD32 _RHDRegRead(int scrnIndex, CARD16 offset); +extern unsigned int RHDReadPCIBios(RHDPtr rhdPtr, unsigned char **prt); +extern Bool RHDScalePolicy(struct rhdMonitor *Monitor, struct rhdConnector *Connector); +extern void RHDAllIdle(ScrnInfoPtr pScrn); +extern CARD32 _RHDRegRead(int scrnIndex, CARD16 offset); #define RHDRegRead(ptr, offset) _RHDRegRead((ptr)->scrnIndex, (offset)) -void _RHDRegWrite(int scrnIndex, CARD16 offset, CARD32 value); +extern void _RHDRegWrite(int scrnIndex, CARD16 offset, CARD32 value); #define RHDRegWrite(ptr, offset, value) _RHDRegWrite((ptr)->scrnIndex, (offset), (value)) -void _RHDRegMask(int scrnIndex, CARD16 offset, CARD32 value, CARD32 mask); +extern void _RHDRegMask(int scrnIndex, CARD16 offset, CARD32 value, CARD32 mask); #define RHDRegMask(ptr, offset, value, mask) _RHDRegMask((ptr)->scrnIndex, (offset), (value), (mask)) -CARD32 _RHDReadMC(int scrnIndex, CARD32 addr); +extern CARD32 _RHDReadMC(int scrnIndex, CARD32 addr); #define RHDReadMC(ptr,addr) _RHDReadMC((ptr)->scrnIndex,(addr)) -void _RHDWriteMC(int scrnIndex, CARD32 addr, CARD32 data); +extern void _RHDWriteMC(int scrnIndex, CARD32 addr, CARD32 data); #define RHDWriteMC(ptr,addr,value) _RHDWriteMC((ptr)->scrnIndex,(addr),(value)) -CARD32 _RHDReadPLL(int scrnIndex, CARD16 offset); +extern CARD32 _RHDReadPLL(int scrnIndex, CARD16 offset); #define RHDReadPLL(ptr, off) _RHDReadPLL((ptr)->scrnIndex,(off)) -void _RHDWritePLL(int scrnIndex, CARD16 offset, CARD32 data); +extern void _RHDWritePLL(int scrnIndex, CARD16 offset, CARD32 data); #define RHDWritePLL(ptr, off, value) _RHDWritePLL((ptr)->scrnIndex,(off),(value)) -unsigned int RHDAllocFb(RHDPtr rhdPtr, unsigned int size, const char *name); +extern unsigned int RHDAllocFb(RHDPtr rhdPtr, unsigned int size, const char *name); /* rhd_id.c */ enum RHD_FAMILIES RHDFamily(enum RHD_CHIPSETS chipset); diff --git a/src/rhd_crtc.c b/src/rhd_crtc.c index 8b364da..da53ccd 100644 --- a/src/rhd_crtc.c +++ b/src/rhd_crtc.c @@ -1037,6 +1037,7 @@ D1CRTCDisable(struct rhdCrtc *Crtc) int i; RHDRegMask(Crtc, D1CRTC_CONTROL, 0, 0x00000301); + (void)RHDRegRead(Crtc, D1CRTC_CONTROL); for (i = 0; i < CRTC_SYNC_WAIT; i++) if (!(RHDRegRead(Crtc, D1CRTC_CONTROL) & 0x00010000)) { @@ -1061,6 +1062,7 @@ D2CRTCDisable(struct rhdCrtc *Crtc) int i; RHDRegMask(Crtc, D2CRTC_CONTROL, 0, 0x00000301); + (void)RHDRegRead(Crtc, D2CRTC_CONTROL); for (i = 0; i < CRTC_SYNC_WAIT; i++) if (!(RHDRegRead(Crtc, D2CRTC_CONTROL) & 0x00010000)) { diff --git a/src/rhd_driver.c b/src/rhd_driver.c index 0c08761..01ad554 100644 --- a/src/rhd_driver.c +++ b/src/rhd_driver.c @@ -1120,6 +1120,29 @@ RHDScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) return TRUE; } +void +RHDAllIdle(ScrnInfoPtr pScrn) +{ + RHDPtr rhdPtr = RHDPTR(pScrn); + int i; + struct rhdCrtc *Crtc; + + /* stop scanout */ + for (i = 0; i < 2; i++) { + Crtc = rhdPtr->Crtc[i]; + if (pScrn->scrnIndex == Crtc->scrnIndex) + Crtc->Power(Crtc, RHD_POWER_RESET); + } + + /* TODO: Invalidate the cached acceleration registers */ + if ((rhdPtr->ChipSet < RHD_R600) && rhdPtr->TwoDInfo) + R5xx2DIdle(pScrn); + + if (!RHDMCIdle(rhdPtr, 1000)) + xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "MC not idle\n"); +} + + /* Mandatory */ static Bool RHDCloseScreen(int scrnIndex, ScreenPtr pScreen) @@ -1128,25 +1151,11 @@ RHDCloseScreen(int scrnIndex, ScreenPtr pScreen) RHDPtr rhdPtr = RHDPTR(pScrn); if(pScrn->vtSema) { - struct rhdCrtc *Crtc; - int i; if (rhdPtr->dri) RHDDRICloseScreen(pScreen); - /* stop scanout */ - for (i = 0; i < 2; i++) { - Crtc = rhdPtr->Crtc[i]; - if (scrnIndex == Crtc->scrnIndex) - Crtc->Power(Crtc, RHD_POWER_RESET); - } - - /* TODO: Invalidate the cached acceleration registers */ - if ((rhdPtr->ChipSet < RHD_R600) && rhdPtr->TwoDInfo) - R5xx2DIdle(pScrn); - - if (!RHDMCIdle(rhdPtr, 1000)) - xf86DrvMsg(scrnIndex, X_WARNING, "MC not idle\n"); + RHDAllIdle(pScrn); rhdRestore(rhdPtr); } @@ -1217,27 +1226,13 @@ RHDLeaveVT(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; RHDPtr rhdPtr = RHDPTR(pScrn); - struct rhdCrtc *Crtc; - int i; RHDFUNC(rhdPtr); if (rhdPtr->dri) RHDDRILeaveVT(pScrn->pScreen); - /* stop scanout */ - for (i = 0; i < 2; i++) { - Crtc = rhdPtr->Crtc[i]; - if (scrnIndex == Crtc->scrnIndex) - Crtc->Power(Crtc, RHD_POWER_RESET); - } - - /* TODO: Invalidate the cached acceleration registers */ - if ((rhdPtr->ChipSet < RHD_R600) && rhdPtr->TwoDInfo) - R5xx2DIdle(pScrn); - - if (!RHDMCIdle(rhdPtr, 1000)) - xf86DrvMsg(scrnIndex, X_WARNING, "MC not idle\n"); + RHDAllIdle(pScrn); rhdRestore(rhdPtr); } diff --git a/src/rhd_mc.c b/src/rhd_mc.c index b71495b..d240c92 100644 --- a/src/rhd_mc.c +++ b/src/rhd_mc.c @@ -39,12 +39,7 @@ #include "rhd_regs.h" #include "r5xx_accel.h" -Bool -RHDMCIdle(RHDPtr rhdPtr, CARD32 count); -static void -RHDMCPrepareForUpdate(RHDPtr rhdPtr); -static void -RHDMCFinishUpdate(RHDPtr rhdPtr); +Bool RHDMCIdle(RHDPtr rhdPtr, CARD32 count); struct rhdMC { CARD32 FbLocation; @@ -56,8 +51,6 @@ struct rhdMC { Bool (*MCIdle)(RHDPtr rhdPtr); Bool RV515Variant; - - CARD32 d1_vga, d2_vga, d1_crtc, d2_crtc; }; /* @@ -412,13 +405,17 @@ RHDMCSetup(RHDPtr rhdPtr) if (!MC) return; - - RHDMCPrepareForUpdate(rhdPtr); + /* + * make sure the hw is in a state such that we can update + * the MC - ie no subsystem is currently accessing memory. + */ + ASSERT((RHDRegRead(rhdPtr, D1VGA_CONTROL) & D1VGA_MODE_ENABLE) != D1VGA_MODE_ENABLE); + ASSERT((RHDRegRead(rhdPtr, D2VGA_CONTROL) & D2VGA_MODE_ENABLE) != D2VGA_MODE_ENABLE); + ASSERT((RHDRegRead(rhdPtr, D1CRTC_CONTROL) & 0x1) != 0x1); + ASSERT((RHDRegRead(rhdPtr, D2CRTC_CONTROL) & 0x1) != 0x1); + ASSERT(RHDMCIdle(rhdPtr, 1)); MC->SetupMC(rhdPtr); - - RHDMCFinishUpdate(rhdPtr); - } /* @@ -553,81 +550,17 @@ RHDRestoreMC(RHDPtr rhdPtr) "%s: trying to restore uninitialized values.\n",__func__); return; } - - RHDMCPrepareForUpdate(rhdPtr); + /* + * make sure the hw is in a state such that we can update + * the MC - ie no subsystem is currently accessing memory. + */ + ASSERT((RHDRegRead(rhdPtr, D1VGA_CONTROL) & D1VGA_MODE_ENABLE) != D1VGA_MODE_ENABLE); + ASSERT((RHDRegRead(rhdPtr, D2VGA_CONTROL) & D2VGA_MODE_ENABLE) != D2VGA_MODE_ENABLE); + ASSERT((RHDRegRead(rhdPtr, D1CRTC_CONTROL) & 0x1) != 0x1); + ASSERT((RHDRegRead(rhdPtr, D2CRTC_CONTROL) & 0x1) != 0x1); + ASSERT(RHDMCIdle(rhdPtr, 1)); MC->RestoreMC(rhdPtr); - - RHDMCFinishUpdate(rhdPtr); - -} - -/* - * make sure the hw is in a state such that we can update the MC - */ -static void -RHDMCPrepareForUpdate(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - ScrnInfoPtr pScrn = xf86Screens[rhdPtr->scrnIndex]; - - RHDFUNC(rhdPtr); - if (!MC) - return; - - /* if accel, idle engine */ - if ((rhdPtr->ChipSet < RHD_R600) && rhdPtr->TwoDInfo) - R5xx2DIdle(pScrn); - - /* disable vga */ - MC->d1_vga = RHDRegRead(rhdPtr, D1VGA_CONTROL); - RHDRegWrite(rhdPtr, D1VGA_CONTROL, MC->d1_vga & ~D1VGA_MODE_ENABLE); - MC->d2_vga = RHDRegRead(rhdPtr, D2VGA_CONTROL); - RHDRegWrite(rhdPtr, D2VGA_CONTROL, MC->d2_vga & ~D2VGA_MODE_ENABLE); - - /* Stop display & memory access */ - MC->d1_crtc = RHDRegRead(rhdPtr, D1CRTC_CONTROL); - RHDRegWrite(rhdPtr, D1CRTC_CONTROL, MC->d1_crtc & ~1); - MC->d2_crtc = RHDRegRead(rhdPtr, D2CRTC_CONTROL); - RHDRegWrite(rhdPtr, D2CRTC_CONTROL, MC->d2_crtc & ~1); - (void)RHDRegRead(rhdPtr, D2CRTC_CONTROL); - - usleep(10000); - - if (!RHDMCIdle(rhdPtr, 1000000)) - xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "MC not idle\n"); - -} - -static void -RHDMCFinishUpdate(RHDPtr rhdPtr) -{ - struct rhdMC *MC = rhdPtr->MC; - ScrnInfoPtr pScrn = xf86Screens[rhdPtr->scrnIndex]; - - RHDFUNC(rhdPtr); - if (!MC) - return; - - usleep(10000); - - if (!RHDMCIdle(rhdPtr, 1000000)) - xf86DrvMsg(rhdPtr->scrnIndex, X_WARNING, "MC not idle\n"); - - /* restore vga */ - RHDRegWrite(rhdPtr, D1VGA_CONTROL, MC->d1_vga); - RHDRegWrite(rhdPtr, D2VGA_CONTROL, MC->d2_vga); - - /* restore display & memory access */ - RHDRegWrite(rhdPtr, D1CRTC_CONTROL, MC->d1_crtc); - RHDRegWrite(rhdPtr, D2CRTC_CONTROL, MC->d2_crtc); - - usleep(10000); - - /* if accel, reset engine */ - if ((rhdPtr->ChipSet < RHD_R600) && rhdPtr->TwoDInfo) - R5xx2DSetup(pScrn); - } /* diff --git a/src/rhd_randr.c b/src/rhd_randr.c index c1b7dac..4817577 100644 --- a/src/rhd_randr.c +++ b/src/rhd_randr.c @@ -821,6 +821,8 @@ rhdRROutputModeSet(xf86OutputPtr out, rhdRandrOutputPtr rout = (rhdRandrOutputPtr) out->driver_private; struct rhdCrtc *Crtc = (struct rhdCrtc *) out->crtc->driver_private; + RHDFUNC(rhdPtr); + /* RandR may give us a mode without a name... (xf86RandRModeConvert) */ if (!Mode->name && out->crtc->mode.name) Mode->name = xstrdup(out->crtc->mode.name); @@ -1509,11 +1511,19 @@ RHDRandrModeInit(ScrnInfoPtr pScrn) Bool ret; RHDPtr rhdPtr = RHDPTR(pScrn); +<<<<<<< HEAD:src/rhd_randr.c +======= + RHDFUNC(rhdPtr); + +>>>>>>> edb7245... MC: Make sure MC engine is all idle before setting up the MC.:src/rhd_randr.c /* Stop crap from being shown: gets reenabled through SaveScreen */ rhdPtr->Crtc[0]->Blank(rhdPtr->Crtc[0], TRUE); rhdPtr->Crtc[1]->Blank(rhdPtr->Crtc[1], TRUE); RHDVGADisable(rhdPtr); + + RHDAllIdle(pScrn); + RHDMCSetup(rhdPtr); ret = xf86SetDesiredModes(pScrn); diff --git a/src/rhd_vga.c b/src/rhd_vga.c index 78fdc5e..9986462 100644 --- a/src/rhd_vga.c +++ b/src/rhd_vga.c @@ -169,8 +169,8 @@ RHDVGADisable(RHDPtr rhdPtr) RHDRegMask(rhdPtr, VGA_RENDER_CONTROL, 0, 0x00030000); RHDRegMask(rhdPtr, VGA_MODE_CONTROL, 0, 0x00000030); RHDRegMask(rhdPtr, VGA_HDP_CONTROL, 0x00010010, 0x00010010); - RHDRegMask(rhdPtr, D1VGA_CONTROL, 0, 0x00000001); - RHDRegMask(rhdPtr, D2VGA_CONTROL, 0, 0x00000001); + RHDRegMask(rhdPtr, D1VGA_CONTROL, 0, D1VGA_MODE_ENABLE); + RHDRegMask(rhdPtr, D2VGA_CONTROL, 0, D2VGA_MODE_ENABLE); } /* |