[Intel-gfx] [RFC] kill pI830->memory_manager checks
Jesse Barnes
jbarnes at virtuousgeek.org
Wed May 13 02:02:16 CEST 2009
This patch gets rid of the ugly KMS hack that messed with videoRam by
removing all of the pI830->memory_manager checks in favor of what we're
really looking for: GEM. Needs some review though; in some places we
might just be looking for any bufmgr, not just GEM...
--
Jesse Barnes, Intel Open Source Technology Center
diff --git a/src/i830.h b/src/i830.h
index 0d8726c..68bc0a5 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -405,6 +405,7 @@ typedef struct _I830Rec {
i830_memory *memory_manager; /**< DRI memory manager aperture */
+ Bool have_gem;
Bool need_mi_flush;
Bool tiling;
diff --git a/src/i830_batchbuffer.c b/src/i830_batchbuffer.c
index 5a9f9c5..a6d9c6e 100644
--- a/src/i830_batchbuffer.c
+++ b/src/i830_batchbuffer.c
@@ -179,7 +179,7 @@ intel_batch_flush(ScrnInfoPtr pScrn, Bool flushed)
return;
/* If we're not using GEM, then emit a flush after each batch buffer */
- if (pI830->memory_manager == NULL && !flushed) {
+ if (!pI830->have_gem && !flushed) {
int flags = MI_WRITE_DIRTY_STATE | MI_INVALIDATE_MAP_CACHE;
if (IS_I965G(pI830))
@@ -219,7 +219,7 @@ intel_batch_flush(ScrnInfoPtr pScrn, Bool flushed)
* blockhandler. We could set this less often, but it's probably not worth
* the work.
*/
- if (pI830->memory_manager != NULL)
+ if (pI830->have_gem)
pI830->need_mi_flush = TRUE;
if (pI830->batch_flush_notify)
diff --git a/src/i830_debug.c b/src/i830_debug.c
index 5a8c3eb..f070978 100644
--- a/src/i830_debug.c
+++ b/src/i830_debug.c
@@ -1882,7 +1882,7 @@ i830_check_error_state(ScrnInfoPtr pScrn)
errors++;
}
temp = INREG(LP_RING + RING_LEN);
- if (!pI830->memory_manager && (temp & 1)) {
+ if (!pI830->have_gem && (temp & 1)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"PRB0_CTL (0x%08lx) indicates ring buffer enabled\n", temp);
errors++;
diff --git a/src/i830_driver.c b/src/i830_driver.c
index aaf5a20..ef90123 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -611,7 +611,7 @@ i830_update_front_offset(ScrnInfoPtr pScrn)
/* If we are still in ScreenInit, there is no screen pixmap to be updated
* yet. We'll fix it up at CreateScreenResources.
*/
- if (!pI830->memory_manager) {
+ if (!pI830->have_gem) {
data = pI830->FbBase + pScrn->fbOffset; /* default to legacy */
} else {
dri_bo *bo = pI830->front_buffer->bo;
@@ -1444,6 +1444,7 @@ I830DrmModeInit(ScrnInfoPtr pScrn)
}
pI830->directRenderingType = DRI_NONE;
+ pI830->have_gem = TRUE;
i830_init_bufmgr(pScrn);
@@ -2227,7 +2228,7 @@ I830BlockHandler(int i,
* fashion.
*/
intel_batch_flush(pScrn, flushed);
- if (pI830->memory_manager)
+ if (pI830->have_gem)
drmCommandNone(pI830->drmSubFD, DRM_I915_GEM_THROTTLE);
pI830->need_mi_flush = FALSE;
@@ -2370,7 +2371,7 @@ i830_init_bufmgr(ScrnInfoPtr pScrn)
if (pI830->bufmgr)
return;
- if (pI830->memory_manager || pI830->use_drm_mode) {
+ if (pI830->have_gem) {
int batch_size;
batch_size = 4096 * 4;
@@ -2556,12 +2557,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#endif
}
- if (pI830->use_drm_mode) {
- pI830->stolen_size = 0;
- pScrn->videoRam = ~0UL / KB(1);
- } else {
- I830AdjustMemory(pScreen);
- }
+ I830AdjustMemory(pScreen);
#ifdef DRI2
if (pI830->directRenderingType == DRI_NONE && I830DRI2ScreenInit(pScreen))
@@ -2651,7 +2647,7 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
if (pI830->accel != ACCEL_NONE && !pI830->use_drm_mode) {
- if (pI830->memory_manager == NULL && pI830->ring.mem->size == 0) {
+ if (!pI830->have_gem && pI830->ring.mem->size == 0) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"Disabling acceleration because the ring buffer "
"allocation failed.\n");
@@ -2875,11 +2871,10 @@ I830LeaveVT(int scrnIndex, int flags)
/* Evict everything from the bufmgr, as we're about to lose ownership of
* the graphics memory.
*/
- if (!pI830->memory_manager)
+ if (!pI830->have_gem) {
intel_bufmgr_fake_evict_all(pI830->bufmgr);
-
- if (!pI830->memory_manager)
i830_stop_ring(pScrn, TRUE);
+ }
if (pI830->debug_modes) {
i830CompareRegsToSnapshot(pScrn, "After LeaveVT");
@@ -2891,7 +2886,7 @@ I830LeaveVT(int scrnIndex, int flags)
i830_unbind_all_memory(pScrn);
- if (pI830->memory_manager && !pI830->use_drm_mode) {
+ if (pI830->have_gem && !pI830->use_drm_mode) {
int ret;
/* Tell the kernel to evict all buffer objects and block GTT usage while
@@ -2968,7 +2963,7 @@ I830EnterVT(int scrnIndex, int flags)
if (!pI830->use_drm_mode)
i830_disable_render_standby(pScrn);
- if (pI830->memory_manager && !pI830->use_drm_mode) {
+ if (pI830->have_gem && !pI830->use_drm_mode) {
int ret;
/* Tell the kernel that we're back in control and ready for GTT
@@ -2999,7 +2994,7 @@ I830EnterVT(int scrnIndex, int flags)
}
/* Re-set up the ring. */
- if (!pI830->memory_manager) {
+ if (!pI830->have_gem) {
i830_stop_ring(pScrn, FALSE);
i830_start_ring(pScrn);
}
diff --git a/src/i830_exa.c b/src/i830_exa.c
index c1f512d..824f032 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -497,7 +497,7 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
intel_batch_flush(scrn, FALSE);
/* No VT sema or GEM? No GTT mapping. */
- if (!scrn->vtSema || !i830->memory_manager) {
+ if (!scrn->vtSema || !i830->have_gem) {
if (dri_bo_map(bo, access == UXA_ACCESS_RW) != 0)
return FALSE;
pixmap->devPrivate.ptr = bo->virtual;
@@ -535,7 +535,7 @@ i830_uxa_finish_access (PixmapPtr pixmap)
if (bo == i830->front_buffer->bo)
i830->need_flush = TRUE;
- if (!scrn->vtSema || !i830->memory_manager) {
+ if (!scrn->vtSema || !i830->have_gem) {
dri_bo_unmap(bo);
pixmap->devPrivate.ptr = NULL;
return;
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 18ddff4..2a1f211 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -407,6 +407,9 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
pI830->memory_list = start;
+ if (pI830->have_gem)
+ return TRUE;
+
has_gem = FALSE;
if (pI830->directRenderingType >= DRI_DRI2)
@@ -480,6 +483,7 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
i830_free_memory(pScrn, pI830->memory_manager);
pI830->memory_manager = NULL;
}
+ pI830->have_gem = TRUE;
i830_init_bufmgr(pScrn);
}
} else {
More information about the Intel-gfx
mailing list