summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/i830_driver.c8
-rw-r--r--src/i830_memory.c135
2 files changed, 72 insertions, 71 deletions
diff --git a/src/i830_driver.c b/src/i830_driver.c
index e5e5fd7a..fe2565c0 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -2674,8 +2674,8 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!pI830->use_drm_mode)
I830MapMMIO(pScrn);
- /* Need FB mapped to set up the fake bufmgr if we end up doing that
- * in i830_memory_init() -> i830_allocator_init().
+ /* Need FB mapped to access non-GEM objects like
+ * a UMS frame buffer, or the fake bufmgr.
*/
if (!pI830->use_drm_mode) {
if (!I830MapMem(pScrn))
@@ -2701,10 +2701,6 @@ I830ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!miSetPixmapDepths())
return FALSE;
- i830_init_bufmgr(pScrn);
-
- pScrn->fbOffset = pI830->front_buffer->offset;
-
if (!pI830->use_drm_mode) {
vgaHWSetMmioFuncs(hwp, pI830->MMIOBase, 0);
vgaHWGetIOBase(hwp);
diff --git a/src/i830_memory.c b/src/i830_memory.c
index 2953f3bd..556b5119 100644
--- a/src/i830_memory.c
+++ b/src/i830_memory.c
@@ -334,10 +334,8 @@ i830_reset_allocations(ScrnInfoPtr pScrn)
}
/* Free any allocations in buffer objects */
- if (pI830->memory_manager) {
- while (pI830->bo_list != NULL)
- i830_free_memory(pScrn, pI830->bo_list);
- }
+ while (pI830->bo_list != NULL)
+ i830_free_memory(pScrn, pI830->bo_list);
/* Null out the pointers for all the allocations we just freed. This is
* kind of gross, but at least it's just one place now.
@@ -405,12 +403,14 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
pI830->memory_list = start;
- /* Now that we have our manager set up, initialize the kernel MM if
- * possible, covering almost all of the aperture. We need libdri interface
- * 5.4 or newer so we can rely on the lock being held after DRIScreenInit,
- * rather than after DRIFinishScreenInit.
+ /* Now that we have our manager set up, give the kernel a piece of the
+ * aperture for GEM buffer object mapping. This is only needed for UXA
+ * and/or DRI2 when the kernel hasn't already managed this itself under
+ * KMS. We need libdri interface5.4 or newer so we can rely on the lock
+ * being held after DRIScreenInit, rather than after DRIFinishScreenInit.
*/
- if (pI830->directRenderingType == DRI_DRI2) {
+
+ if (!pI830->use_drm_mode) {
int mmsize;
/* Take over all of the graphics aperture minus enough to for
@@ -426,53 +426,49 @@ i830_allocator_init(ScrnInfoPtr pScrn, unsigned long size)
}
if (pI830->CursorNeedsPhysical) {
mmsize -= 2 * (ROUND_TO(HWCURSOR_SIZE, GTT_PAGE_SIZE) +
- ROUND_TO(HWCURSOR_SIZE_ARGB, GTT_PAGE_SIZE));
+ ROUND_TO(HWCURSOR_SIZE_ARGB, GTT_PAGE_SIZE));
}
if (pI830->fb_compression)
mmsize -= MB(6) + ROUND_TO_PAGE(FBC_LL_SIZE + FBC_LL_PAD);
+
/* Can't do GEM on stolen memory */
mmsize -= pI830->stolen_size;
/* Create the aperture allocation */
pI830->memory_manager =
- i830_allocate_aperture(pScrn, "DRI memory manager",
- mmsize, 0, GTT_PAGE_SIZE,
- ALIGN_BOTH_ENDS | NEED_NON_STOLEN,
- TILE_NONE);
+ i830_allocate_aperture(pScrn, "DRI memory manager",
+ mmsize, 0, GTT_PAGE_SIZE,
+ ALIGN_BOTH_ENDS | NEED_NON_STOLEN,
+ TILE_NONE);
if (pI830->memory_manager != NULL) {
- if (!pI830->use_drm_mode) {
- struct drm_i915_gem_init init;
- int ret;
-
- sp.param = I915_SETPARAM_NUM_USED_FENCES;
- sp.value = 0; /* kernel gets them all */
-
- ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
- &sp, sizeof(sp));
- if (ret == 0)
- pI830->kernel_exec_fencing = TRUE;
-
- init.gtt_start = pI830->memory_manager->offset;
- init.gtt_end = pI830->memory_manager->offset +
- pI830->memory_manager->size;
-
- /* Tell the kernel to manage it */
- ret = ioctl(pI830->drmSubFD, DRM_IOCTL_I915_GEM_INIT, &init);
- if (ret != 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Failed to initialize kernel memory manager\n");
- i830_free_memory(pScrn, pI830->memory_manager);
- pI830->memory_manager = NULL;
- }
+ struct drm_i915_gem_init init;
+ int ret;
+
+ sp.param = I915_SETPARAM_NUM_USED_FENCES;
+ sp.value = 0; /* kernel gets them all */
+
+ ret = drmCommandWrite(pI830->drmSubFD, DRM_I915_SETPARAM,
+ &sp, sizeof(sp));
+ if (ret == 0)
+ pI830->kernel_exec_fencing = TRUE;
+ init.gtt_start = pI830->memory_manager->offset;
+ init.gtt_end = pI830->memory_manager->offset + pI830->memory_manager->size;
+
+ /* Tell the kernel to manage it */
+ ret = ioctl(pI830->drmSubFD, DRM_IOCTL_I915_GEM_INIT, &init);
+ if (ret == 0) {
pI830->have_gem = TRUE;
i830_init_bufmgr(pScrn);
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Failed to initialize kernel memory manager\n");
+ i830_free_memory(pScrn, pI830->memory_manager);
+ pI830->memory_manager = NULL;
}
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Failed to allocate space for kernel memory manager\n");
- i830_free_memory(pScrn, pI830->memory_manager);
- pI830->memory_manager = NULL;
}
}
@@ -842,9 +838,15 @@ i830_allocate_memory(ScrnInfoPtr pScrn, const char *name,
size = i830_get_fence_size(pI830, size);
alignment = i830_get_fence_alignment(pI830, size);
}
- if (pI830->use_drm_mode || (pI830->memory_manager &&
- !(flags & NEED_PHYSICAL_ADDR) &&
- !(flags & NEED_LIFETIME_FIXED)))
+ /*
+ * Create a kernel buffer object when suitable.
+ * Under KMS, all graphics memory must be managed by the
+ * kernel. Under UMS, we separately reserve space for
+ * a few objects (overlays, power context, cursors, etc).
+ */
+ if (pI830->have_gem &&
+ (pI830->use_drm_mode ||
+ !(flags & (NEED_PHYSICAL_ADDR|NEED_LIFETIME_FIXED))))
{
return i830_allocate_memory_bo(pScrn, name, size, pitch, alignment, flags, tile_format);
} else
@@ -917,31 +919,33 @@ i830_describe_allocations(ScrnInfoPtr pScrn, int verbosity, const char *prefix)
"%s0x%08lx: end of aperture\n",
prefix, pI830->FbMapSize);
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+ "%sBO memory allocation layout:\n", prefix);
if (pI830->memory_manager) {
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sBO memory allocation layout:\n", prefix);
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
"%s0x%08lx: start of memory manager\n",
prefix, pI830->memory_manager->offset);
- for (mem = pI830->bo_list; mem != NULL; mem = mem->next) {
- char *tile_suffix = "";
-
- if (mem->tiling == TILE_XMAJOR)
- tile_suffix = " X tiled";
- else if (mem->tiling == TILE_YMAJOR)
- tile_suffix = " Y tiled";
-
- if (mem->bound) {
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%s0x%08lx-0x%08lx: %s (%ld kB)%s\n", prefix,
- mem->offset, mem->end - 1, mem->name,
- mem->size / 1024, tile_suffix);
- } else {
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
- "%sunpinned : %s (%ld kB)%s\n", prefix,
- mem->name, mem->size / 1024, tile_suffix);
- }
+ }
+ for (mem = pI830->bo_list; mem != NULL; mem = mem->next) {
+ char *tile_suffix = "";
+
+ if (mem->tiling == TILE_XMAJOR)
+ tile_suffix = " X tiled";
+ else if (mem->tiling == TILE_YMAJOR)
+ tile_suffix = " Y tiled";
+
+ if (mem->bound) {
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+ "%s0x%08lx-0x%08lx: %s (%ld kB)%s\n", prefix,
+ mem->offset, mem->end - 1, mem->name,
+ mem->size / 1024, tile_suffix);
+ } else {
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
+ "%sunpinned : %s (%ld kB)%s\n", prefix,
+ mem->name, mem->size / 1024, tile_suffix);
}
+ }
+ if (pI830->memory_manager) {
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, verbosity,
"%s0x%08lx: end of memory manager\n",
prefix, pI830->memory_manager->end);
@@ -953,7 +957,7 @@ i830_allocate_ringbuffer(ScrnInfoPtr pScrn)
{
I830Ptr pI830 = I830PTR(pScrn);
- if (pI830->memory_manager || pI830->ring.mem != NULL)
+ if (pI830->have_gem || pI830->ring.mem != NULL)
return TRUE;
/* We don't have any mechanism in the DRM yet to alert it that we've moved
@@ -1277,7 +1281,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
return FALSE;
}
- if (pI830->memory_manager == NULL) {
+ if (!pI830->have_gem) {
pI830->fake_bufmgr_mem = i830_allocate_memory(pScrn, "fake bufmgr",
MB(8), PITCH_NONE, GTT_PAGE_SIZE, 0,
TILE_NONE);
@@ -1286,6 +1290,7 @@ i830_allocate_2d_memory(ScrnInfoPtr pScrn)
"Failed to allocate fake bufmgr space.\n");
return FALSE;
}
+ i830_init_bufmgr(pScrn);
}
if (!pI830->use_drm_mode)