From 55c26d8e4d110b689aea9d806e9d4fa7bbbdd32a Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 13 Aug 2009 16:37:00 +1000 Subject: [PATCH 01/10] Xext: fix up wrong conditions for negative sync transitions. If the counter had a value higher than the trigger value for a negative transition, the trigger value did not get set. The correct sequence of checks is: if (positive transition) if (counter value < trigger value) set up trigger if (negative transition) if (counter value > trigger value) set up trigger Red Hat Bug 501601 Signed-off-by: Peter Hutterer (cherry picked from commit db568f9eabf3450d8a023597ff007df355b13ea8) --- Xext/sync.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/Xext/sync.c b/Xext/sync.c index 424361ee5..a006ae95b 100644 --- a/Xext/sync.c +++ b/Xext/sync.c @@ -1168,28 +1168,24 @@ SyncComputeBracketValues(pCounter, startOver) pnewltval = &psci->bracket_less; } } - else if ( (pTrigger->test_type == XSyncPositiveTransition && + else if (pTrigger->test_type == XSyncNegativeTransition && ct != XSyncCounterNeverIncreases) - || - (pTrigger->test_type == XSyncNegativeTransition && - ct != XSyncCounterNeverDecreases) - ) { - if (XSyncValueLessThan(pCounter->value, pTrigger->test_value)) + if (XSyncValueGreaterThan(pCounter->value, pTrigger->test_value) && + XSyncValueGreaterThan(pTrigger->test_value, psci->bracket_less)) { - if (XSyncValueLessThan(pTrigger->test_value, - psci->bracket_greater)) - { - psci->bracket_greater = pTrigger->test_value; - pnewgtval = &psci->bracket_greater; - } - else - if (XSyncValueGreaterThan(pTrigger->test_value, - psci->bracket_less)) - { - psci->bracket_less = pTrigger->test_value; - pnewltval = &psci->bracket_less; - } + psci->bracket_less = pTrigger->test_value; + pnewltval = &psci->bracket_less; + } + } + else if (pTrigger->test_type == XSyncPositiveTransition && + ct != XSyncCounterNeverDecreases) + { + if (XSyncValueLessThan(pCounter->value, pTrigger->test_value) && + XSyncValueLessThan(pTrigger->test_value, psci->bracket_greater)) + { + psci->bracket_greater = pTrigger->test_value; + pnewgtval = &psci->bracket_greater; } } } /* end for each trigger */ From 397f7c42cd775f1dbfced58bc1dfaead48e86440 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 14 Aug 2009 09:48:45 +1000 Subject: [PATCH 02/10] config: don't shutdown the libhal ctx if it failed to initialize (#23213) Regression introduced by b1c3dc6ae226db178420e3b5f297b94afc87c94c. Shutting down the libhal_ctx if the init failed may cause an abort. This can happen if hald is not yet running at server startup. X.Org Bug 23213 Tested-by: Stefan Dirsch Signed-off-by: Peter Hutterer (cherry picked from commit 49046088f10cceaea7da97401d742d3fb59371f5) --- config/hal.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/config/hal.c b/config/hal.c index 59bff6613..28f55a02f 100644 --- a/config/hal.c +++ b/config/hal.c @@ -489,13 +489,13 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info) if (!libhal_ctx_set_dbus_connection(info->hal_ctx, info->system_bus)) { LogMessage(X_ERROR, "config/hal: couldn't associate HAL context with bus\n"); - goto out_ctx; + goto out_err; } if (!libhal_ctx_init(info->hal_ctx, &error)) { LogMessage(X_ERROR, "config/hal: couldn't initialise context: %s (%s)\n", error.name ? error.name : "unknown error", error.message ? error.message : "null"); - goto out_ctx; + goto out_err; } if (!libhal_device_property_watch_all(info->hal_ctx, &error)) { LogMessage(X_ERROR, "config/hal: couldn't watch all properties: %s (%s)\n", @@ -526,19 +526,20 @@ connect_and_register(DBusConnection *connection, struct config_hal_info *info) out_ctx: dbus_error_free(&error); - if (info->hal_ctx) { - if (!libhal_ctx_shutdown(info->hal_ctx, &error)) { - LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n", - error.name ? error.name : "unknown error", - error.message ? error.message : "null"); - dbus_error_free(&error); - } - libhal_ctx_free(info->hal_ctx); + if (!libhal_ctx_shutdown(info->hal_ctx, &error)) { + LogMessage(X_WARNING, "config/hal: couldn't shut down context: %s (%s)\n", + error.name ? error.name : "unknown error", + error.message ? error.message : "null"); + dbus_error_free(&error); } out_err: dbus_error_free(&error); + if (info->hal_ctx) { + libhal_ctx_free(info->hal_ctx); + } + info->hal_ctx = NULL; info->system_bus = NULL; From af7e62a913c3c5b9639b4557b31537853f3f58bb Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Sun, 16 Aug 2009 18:07:49 -0700 Subject: [PATCH 03/10] xfree86: Link libselinux with Xorg system libraries Put the reference to -lselinux in XORG_SYS_LIBS so it isn't added as a make dependency for libxorg.la. Otherwise, make goes looking for a file -lselinux in the current directory, which it obviously won't find. Signed-off-by: Dan Nicholson Tested-by: Justin P. Mattock (cherry picked from commit c73cd3b265c301b8a54ffe484d6c696f2abefb46) --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index fe7978ff9..b8a3385b8 100644 --- a/configure.ac +++ b/configure.ac @@ -1239,7 +1239,7 @@ if test "x$XORG" = xyes; then XORG_OSINCS='-I$(top_srcdir)/hw/xfree86/os-support -I$(top_srcdir)/hw/xfree86/os-support/bus -I$(top_srcdir)/os' XORG_INCS="$XORG_DDXINCS $XORG_OSINCS" XORG_CFLAGS="$XORGSERVER_CFLAGS -DHAVE_XORG_CONFIG_H" - XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB $SELINUX_LIB" + XORG_LIBS="$COMPOSITE_LIB $FIXES_LIB $XEXTXORG_LIB $GLX_LIBS $RANDR_LIB $RENDER_LIB $DAMAGE_LIB $MIEXT_DAMAGE_LIB $MIEXT_SHADOW_LIB $XI_LIB $XKB_LIB" PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0]) SAVE_LIBS=$LIBS @@ -1250,7 +1250,7 @@ if test "x$XORG" = xyes; then AC_CHECK_FUNCS([pci_device_enable]) LIBS=$SAVE_LIBS CFLAGS=$SAVE_CFLAGS - XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS" + XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS $SELINUX_LIB" XORG_CFLAGS="$XORG_CFLAGS $PCIACCESS_CFLAGS" case $host_os in From 32115e690f43fde619234722aa674ff1ae1b44ae Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Fri, 14 Aug 2009 11:48:54 +1000 Subject: [PATCH 04/10] dix: update the sprite trace for all masters && floating slaves (#23257) When the windows are restructured, CheckMotion needs to be called for all masters and floating slaves to update the spriteTrace. X.Org Bug 23257 (cherry picked from commit 6c292d17053eb2a7e7054e51210f423dbc0cb7e8) Tested-by: Thomas Jaeger Signed-off-by: Peter Hutterer Signed-off-by: Keith Packard --- dix/events.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dix/events.c b/dix/events.c index 17868272a..f9448ba76 100644 --- a/dix/events.c +++ b/dix/events.c @@ -2661,8 +2661,8 @@ WindowsRestructured(void) DeviceIntPtr pDev = inputInfo.devices; while(pDev) { - if (DevHasCursor(pDev)) - CheckMotion((xEvent *)NULL, pDev); + if (pDev->isMaster || !pDev->u.master) + CheckMotion(NULL, pDev); pDev = pDev->next; } } From a32d717ac64b21e15a5736ae4981cdd32f2da56b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Mon, 17 Aug 2009 09:15:32 +0100 Subject: [PATCH 05/10] Do not reset lastDeviceEventTime when we do dixSaveScreens When we turn off DPMS with DPMSModeOff and do dixSaveScreens, don't reset the event time else session clients using IDLETIME will be reset. Signed-off-by: Peter Hutterer (cherry picked from commit 6b5978dcf1f7ac3ecc2f22df06f7000f360e2066) --- dix/window.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/dix/window.c b/dix/window.c index a9d00f91b..e0b0decce 100644 --- a/dix/window.c +++ b/dix/window.c @@ -3169,8 +3169,6 @@ dixSaveScreens(ClientPtr client, int on, int mode) if (on == SCREEN_SAVER_FORCER) { - UpdateCurrentTimeIf(); - lastDeviceEventTime = currentTime; if (mode == ScreenSaverReset) what = SCREEN_SAVER_OFF; else From fad2de1cca057586a88fb20ebf9a9964f8e3e298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Thu, 14 May 2009 11:46:41 +0200 Subject: [PATCH 06/10] glx: If a destroyed window is bound to the current context, make it not current. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoids subsequent crashes due to stale pointers to the DrawableRec, see https://bugs.freedesktop.org/show_bug.cgi?id=21132#c15 and previous comments. Signed-off-by: Michel Dänzer (cherry picked from commit 2075d4bf9e53b8baef0b919da6c44771220cd4a5) --- glx/glxext.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glx/glxext.c b/glx/glxext.c index fe99e4e80..c1a1ac9e3 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -127,6 +127,10 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) __GLXcontext *c; for (c = glxAllContexts; c; c = c->next) { + if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) { + (*c->loseCurrent)(c); + __glXFlushContextCache(); + } if (c->drawPriv == glxPriv) c->drawPriv = NULL; if (c->readPriv == glxPriv) From 5848fca11f3c5b65bb6634816c0df6aeb6eda87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Tue, 23 Jun 2009 16:45:40 +0200 Subject: [PATCH 07/10] glx: Clean up more thoroughly if the drawable of a current context goes away. Fixes crash when restarting compiz, due to cl->currentContexts[x] being stale. (cherry picked from commit 3020b1d43e34fca08cd51f7c7c8ed51497d49ef3) --- glx/glxext.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/glx/glxext.c b/glx/glxext.c index c1a1ac9e3..ca1d2ec8d 100644 --- a/glx/glxext.c +++ b/glx/glxext.c @@ -128,8 +128,31 @@ static Bool DrawableGone(__GLXdrawable *glxPriv, XID xid) for (c = glxAllContexts; c; c = c->next) { if (c->isCurrent && (c->drawPriv == glxPriv || c->readPriv == glxPriv)) { + int i; + (*c->loseCurrent)(c); - __glXFlushContextCache(); + c->isCurrent = GL_FALSE; + if (c == __glXLastContext) + __glXFlushContextCache(); + + for (i = 1; i < currentMaxClients; i++) { + if (clients[i]) { + __GLXclientState *cl = glxGetClient(clients[i]); + + if (cl->inUse) { + int j; + + for (j = 0; j < cl->numCurrentContexts; j++) { + if (cl->currentContexts[j] == c) + cl->currentContexts[j] = NULL; + } + } + } + } + + if (!c->idExists) { + __glXFreeContext(c); + } } if (c->drawPriv == glxPriv) c->drawPriv = NULL; From cebc0a7aa7a368b2ade3a808195d2e738fda83e9 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 25 Aug 2009 16:54:16 -0700 Subject: [PATCH 08/10] xf86_reload_cursors: fix cursor position to eliminate jumping after mode set xf86_reload_cursors restores the cursor to the correct position, but that must adjust for cursor hot spot and frame before calling down to the hardware function, otherwise the cursor jumps to the wrong position until it is repositioned by the user. Signed-off-by: Keith Packard (cherry picked from commit 4aab05e3b3231f1ec9795a66a075d17a722634a7) --- hw/xfree86/modes/xf86Cursors.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Cursors.c b/hw/xfree86/modes/xf86Cursors.c index 3106f051b..fbd61e9fd 100644 --- a/hw/xfree86/modes/xf86Cursors.c +++ b/hw/xfree86/modes/xf86Cursors.c @@ -640,9 +640,11 @@ xf86_reload_cursors (ScreenPtr screen) (*cursor_info->LoadCursorARGB) (scrn, cursor); else if (src) #endif - (*cursor_info->LoadCursorImage)(cursor_info->pScrn, src); + (*cursor_info->LoadCursorImage)(scrn, src); - (*cursor_info->SetCursorPosition)(cursor_info->pScrn, x, y); + x += scrn->frameX0 + cursor_screen_priv->HotX; + y += scrn->frameY0 + cursor_screen_priv->HotY; + (*cursor_info->SetCursorPosition)(scrn, x, y); } } From 31dc4fe0be57da4e9458ee490811fbd92598b7a7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 25 Aug 2009 16:58:07 -0700 Subject: [PATCH 09/10] Perform rotation redisplay before calling driver block handler (which may flush rendering) The rotation block handler uses regular driver rendering functions to repaint the screen, if those functions queue commands in the driver, it's important that the driver block handler be invoked after the rotated image is drawn. Signed-off-by: Keith Packard (cherry picked from commit 1740cda7a37abc7d0a169ab4555b446adaa62211) --- hw/xfree86/modes/xf86Rotate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 6be77d556..0af96c285 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -263,11 +263,12 @@ xf86RotateBlockHandler(int screenNum, pointer blockData, ScreenPtr pScreen = screenInfo.screens[screenNum]; ScrnInfoPtr pScrn = xf86Screens[screenNum]; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); + Bool rotation_active; + rotation_active = xf86RotateRedisplay(pScreen); pScreen->BlockHandler = xf86_config->BlockHandler; (*pScreen->BlockHandler) (screenNum, blockData, pTimeout, pReadmask); - if (xf86RotateRedisplay(pScreen)) - { + if (rotation_active) { /* Re-wrap if rotation is still happening */ xf86_config->BlockHandler = pScreen->BlockHandler; pScreen->BlockHandler = xf86RotateBlockHandler; From 76a1839b0a7dcb82e46c43533d252288677c6dbb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 25 Aug 2009 18:07:00 -0700 Subject: [PATCH 10/10] Ensure that rotation updates happen frequently The smart scheduler is designed to minimize scheduler overhead by increasing the interval between WaitForSomething calls when a single client is running. However, the software rotation code depends on its BlockHandler being invoked for screen updates; the long delays caused by the smart scheduler optimizations means that screen updates can be delayed a long time as well. The change is simple -- prevent the smart scheduler from increasing the scheduling interval while any screen is using software rotation. (cherry picked from commit e7dd1efef408effe52d0bd3d3aa0b5d4ee10ed90) Signed-off-by: Keith Packard --- dix/dispatch.c | 22 +++++++++++++++++++++- hw/xfree86/modes/xf86Rotate.c | 2 ++ include/dix.h | 6 ++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/dix/dispatch.c b/dix/dispatch.c index 1ca08b641..7e16589da 100644 --- a/dix/dispatch.c +++ b/dix/dispatch.c @@ -247,6 +247,7 @@ long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL; long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE; long SmartScheduleTime; +int SmartScheduleLatencyLimited = 0; static ClientPtr SmartLastClient; static int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1]; @@ -317,7 +318,7 @@ SmartScheduleClient (int *clientReady, int nready) /* * Adjust slice */ - if (nready == 1) + if (nready == 1 && SmartScheduleLatencyLimited == 0) { /* * If it's been a long time since another client @@ -337,6 +338,23 @@ SmartScheduleClient (int *clientReady, int nready) return best; } +void +EnableLimitedSchedulingLatency(void) +{ + ++SmartScheduleLatencyLimited; + SmartScheduleSlice = SmartScheduleInterval; +} + +void +DisableLimitedSchedulingLatency(void) +{ + --SmartScheduleLatencyLimited; + + /* protect against bugs */ + if (SmartScheduleLatencyLimited < 0) + SmartScheduleLatencyLimited = 0; +} + #define MAJOROP ((xReq *)client->requestBuffer)->reqType void @@ -356,6 +374,7 @@ Dispatch(void) if (!clientReady) return; + SmartScheduleSlice = SmartScheduleInterval; while (!dispatchException) { if (*icheck[0] != *icheck[1]) @@ -466,6 +485,7 @@ Dispatch(void) KillAllClients(); xfree(clientReady); dispatchException &= ~DE_RESET; + SmartScheduleLatencyLimited = 0; } #undef MAJOROP diff --git a/hw/xfree86/modes/xf86Rotate.c b/hw/xfree86/modes/xf86Rotate.c index 0af96c285..bb17df431 100644 --- a/hw/xfree86/modes/xf86Rotate.c +++ b/hw/xfree86/modes/xf86Rotate.c @@ -198,6 +198,7 @@ xf86RotatePrepare (ScreenPtr pScreen) DamageRegister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, xf86_config->rotation_damage); xf86_config->rotation_damage_registered = TRUE; + EnableLimitedSchedulingLatency(); } xf86CrtcDamageShadow (crtc); @@ -308,6 +309,7 @@ xf86RotateDestroy (xf86CrtcPtr crtc) DamageUnregister (&(*pScreen->GetScreenPixmap)(pScreen)->drawable, xf86_config->rotation_damage); xf86_config->rotation_damage_registered = FALSE; + DisableLimitedSchedulingLatency(); } DamageDestroy (xf86_config->rotation_damage); xf86_config->rotation_damage = NULL; diff --git a/include/dix.h b/include/dix.h index 66af953b2..9c2c73fb7 100644 --- a/include/dix.h +++ b/include/dix.h @@ -229,6 +229,12 @@ extern void WakeupHandler( int /*result*/, pointer /*pReadmask*/); +void +EnableLimitedSchedulingLatency(void); + +void +DisableLimitedSchedulingLatency(void); + typedef void (* WakeupHandlerProcPtr)( pointer /* blockData */, int /* result */,