diff options
-rw-r--r-- | src/i830.h | 4 | ||||
-rw-r--r-- | src/i830_dri.c | 101 | ||||
-rw-r--r-- | src/i830_driver.c | 16 | ||||
-rw-r--r-- | src/i830_memory.c | 9 |
4 files changed, 62 insertions, 68 deletions
@@ -695,7 +695,9 @@ extern Bool I830DRIFinishScreenInit(ScreenPtr pScreen); extern void I830DRIUnlock(ScrnInfoPtr pScrn); extern Bool I830DRILock(ScrnInfoPtr pScrn); extern Bool I830DRISetVBlankInterrupt (ScrnInfoPtr pScrn, Bool on); -Bool i830_update_dri_buffers(ScrnInfoPtr pScrn); +extern Bool i830_update_dri_buffers(ScrnInfoPtr pScrn); +extern Bool I830DRISetHWS(ScrnInfoPtr pScrn); +extern Bool I830DRIInstIrqHandler(ScrnInfoPtr pScrn); #endif unsigned long intel_get_pixmap_offset(PixmapPtr pPix); diff --git a/src/i830_dri.c b/src/i830_dri.c index 3400b380..141b970f 100644 --- a/src/i830_dri.c +++ b/src/i830_dri.c @@ -236,18 +236,18 @@ I830SetParam(ScrnInfoPtr pScrn, int param, int value) return TRUE; } -static Bool -I830SetHWS(ScrnInfoPtr pScrn, int addr) +Bool +I830DRISetHWS(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); drmI830HWS hws; - hws.addr = addr; + hws.addr = pI830->hw_status->offset; if (drmCommandWrite(pI830->drmSubFD, DRM_I830_HWS_PAGE_ADDR, &hws, sizeof(drmI830HWS))) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "G33 status page initialization Failed\n"); + "hw status page initialization Failed\n"); return FALSE; } return TRUE; @@ -813,12 +813,6 @@ I830DRIDoMappings(ScreenPtr pScreen) return FALSE; } - if (HWS_NEED_GFX(pI830)) { - if (!I830SetHWS(pScrn, pI830->hw_status->offset)) { - DRICloseScreen(pScreen); - return FALSE; - } - } /* init to zero to be safe */ sarea->front_handle = 0; sarea->back_handle = 0; @@ -881,18 +875,12 @@ I830DRIDoMappings(ScreenPtr pScreen) } Bool -I830DRIResume(ScreenPtr pScreen) +I830DRIInstIrqHandler(ScrnInfoPtr pScrn) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; I830Ptr pI830 = I830PTR(pScrn); I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate; - DPRINTF(PFX, "I830DRIResume\n"); - - I830ResumeDma(pScrn); - - { - pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD, + pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD, #if XSERVER_LIBPCIACCESS ((pI830->PciInfo->domain << 8) | pI830->PciInfo->bus), @@ -908,19 +896,31 @@ I830DRIResume(ScreenPtr pScreen) #endif ); - if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[drm] failure adding irq handler\n"); - pI830DRI->irq = 0; - return FALSE; - } - else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] dma control initialized, using IRQ %d\n", - pI830DRI->irq); - } + if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] failure adding irq handler\n"); + pI830DRI->irq = 0; + return FALSE; + } else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] dma control initialized, using IRQ %d\n", + pI830DRI->irq); - return FALSE; + return TRUE; +} + +Bool +I830DRIResume(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + DPRINTF(PFX, "I830DRIResume\n"); + + I830ResumeDma(pScrn); + + I830DRIInstIrqHandler(pScrn); + + return TRUE; } void @@ -976,47 +976,16 @@ I830DestroyContext(ScreenPtr pScreen, drm_context_t hwContext, Bool I830DRIFinishScreenInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - I830Ptr pI830 = I830PTR(pScrn); - DPRINTF(PFX, "I830DRIFinishScreenInit\n"); if (!DRIFinishScreenInit(pScreen)) return FALSE; - /* Okay now initialize the dma engine */ - { - I830DRIPtr pI830DRI = (I830DRIPtr) pI830->pDRIInfo->devPrivate; - - pI830DRI->irq = drmGetInterruptFromBusID(pI830->drmSubFD, -#if XSERVER_LIBPCIACCESS - ((pI830->PciInfo->domain << 8) | - pI830->PciInfo->bus), - pI830->PciInfo->dev, - pI830->PciInfo->func -#else - ((pciConfigPtr) pI830-> - PciInfo->thisCard)->busnum, - ((pciConfigPtr) pI830-> - PciInfo->thisCard)->devnum, - ((pciConfigPtr) pI830-> - PciInfo->thisCard)->funcnum -#endif - ); - - if (drmCtlInstHandler(pI830->drmSubFD, pI830DRI->irq)) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, - "[drm] failure adding irq handler\n"); - pI830DRI->irq = 0; - DRICloseScreen(pScreen); - return FALSE; - } - else - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] dma control initialized, using IRQ %d\n", - pI830DRI->irq); - return TRUE; - } + /* move irq initialize later in EnterVT, as then we + * would finish binding possible hw status page, which + * requires irq ctrl ioctl not be called that early. + */ + return TRUE; } #ifdef DAMAGE diff --git a/src/i830_driver.c b/src/i830_driver.c index dffc6306..a3c64de5 100644 --- a/src/i830_driver.c +++ b/src/i830_driver.c @@ -3184,6 +3184,22 @@ I830EnterVT(int scrnIndex, int flags) #ifdef XF86DRI if (pI830->directRenderingEnabled) { + /* HW status is fixed, we need to set it up before any drm + * operation which accessing that page, like irq install, etc. + */ + if (pI830->starting) { + if (HWS_NEED_GFX(pI830) && !I830DRISetHWS(pScrn)) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Fail to setup hardware status page.\n"); + I830DRICloseScreen(pScrn->pScreen); + return FALSE; + } + if (!I830DRIInstIrqHandler(pScrn)) { + I830DRICloseScreen(pScrn->pScreen); + return FALSE; + } + } + /* Update buffer offsets in sarea and mappings, since buffer offsets * may have changed. */ diff --git a/src/i830_memory.c b/src/i830_memory.c index 8a5262f1..07e4010e 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -468,6 +468,9 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long offset, unsigned long size) /* Can't do TTM on stolen memory */ mmsize -= pI830->stolen_size; + if (HWS_NEED_GFX(pI830) && IS_IGD_GM(pI830)) + mmsize -= HWSTATUS_PAGE_SIZE; + /* Create the aperture allocation */ pI830->memory_manager = i830_allocate_aperture(pScrn, "DRI memory manager", @@ -1630,13 +1633,17 @@ static Bool i830_allocate_hwstatus(ScrnInfoPtr pScrn) { I830Ptr pI830 = I830PTR(pScrn); + int flags; /* The current DRM will leak the HWS mapping if we update the address * after init (at best), so allocate it fixed for its lifetime * (i.e. not through buffer objects). */ + flags = NEED_LIFETIME_FIXED; + if (IS_IGD_GM(pI830)) + flags |= NEED_NON_STOLEN; pI830->hw_status = i830_allocate_memory(pScrn, "HW status", - HWSTATUS_PAGE_SIZE, GTT_PAGE_SIZE, NEED_LIFETIME_FIXED); + HWSTATUS_PAGE_SIZE, GTT_PAGE_SIZE, flags); if (pI830->hw_status == NULL) { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Failed to allocate hw status page.\n"); |