Skip to content

Commit 9654fd0

Browse files
committed
Do not allocate grants for framebuffer by default
If glamor is not used (which is default), FBBasePriv seems to be unused. GUI agent doesn't share the root window with GUI daemon. If glamor is used, FBBasePriv probably unused in practice too, but at this time I'm not 100% sure about it (see qubes_create_screen_resources() - the "pixmap" of the root window is passed to glamor, and it isn't clear if it wouldn't end up used in some window that is handled by the GUI agent). Based on this observation, if glamor is not used, use normal memory for the framebuffer. The main benefit is not having the framebuffer mlock()-ed, which helps especially with small VMs. But also, allocating it as normal userspace memory gives the kernel more flexibility in finding memory for it (it doesn't need to be physically continuous, etc). Fixes QubesOS/qubes-issues#9992
1 parent 95eba6d commit 9654fd0

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

xf86-video-dummy/src/dummy_driver.c

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ qubes_create_screen_resources(ScreenPtr pScreen) {
912912

913913
Bool ret = dPtr->CreateScreenResources(pScreen);
914914

915-
if (ret) {
915+
if (ret && dPtr->FBBasePriv) {
916916
PixmapPtr pixmap = pScreen->GetScreenPixmap(pScreen);
917917
if (dPtr->glamor)
918918
glamor_egl_create_textured_pixmap_from_gbm_bo(pixmap, dPtr->front_bo, FALSE);
@@ -1015,10 +1015,17 @@ DUMMYScreenInit(SCREEN_INIT_ARGS_DECL)
10151015
return FALSE;
10161016
}
10171017

1018-
dPtr->FBBasePriv = qubes_alloc_pixmap_private(pScrn->videoRam * 1024);
1019-
if (dPtr->FBBasePriv == NULL)
1020-
return FALSE;
1021-
dPtr->FBBase = (void *) dPtr->FBBasePriv->data;
1018+
if (dPtr->glamor) {
1019+
dPtr->FBBasePriv = qubes_alloc_pixmap_private(pScrn->videoRam * 1024);
1020+
if (dPtr->FBBasePriv == NULL)
1021+
return FALSE;
1022+
dPtr->FBBase = (void *) dPtr->FBBasePriv->data;
1023+
} else {
1024+
dPtr->FBBase = calloc(1, pScrn->videoRam * 1024);
1025+
if (dPtr->FBBase == NULL)
1026+
return FALSE;
1027+
}
1028+
10221029

10231030
/*
10241031
* next we save the current state and setup the first mode
@@ -1290,8 +1297,12 @@ DUMMYCloseScreen(CLOSE_SCREEN_ARGS_DECL)
12901297
if (dPtr->FBBasePriv) {
12911298
xf86_qubes_free_pixmap_private(dPtr->FBBasePriv);
12921299
dPtr->FBBasePriv = NULL;
1293-
dPtr->FBBase = NULL;
1300+
} else {
1301+
if (dPtr->FBBase) {
1302+
free(dPtr->FBBase);
1303+
}
12941304
}
1305+
dPtr->FBBase = NULL;
12951306
}
12961307

12971308
if (dPtr->CursorInfo)

0 commit comments

Comments
 (0)