diff --git a/0001-Allow-compile-time-selection-of-a-fallback-input-dri.patch b/0001-Allow-compile-time-selection-of-a-fallback-input-dri.patch deleted file mode 100644 index dfab269..0000000 --- a/0001-Allow-compile-time-selection-of-a-fallback-input-dri.patch +++ /dev/null @@ -1,155 +0,0 @@ -From a3922cf7f02feac88a80995cef5e843aafdd970b Mon Sep 17 00:00:00 2001 -From: Peter Hutterer -Date: Wed, 1 Jun 2016 14:38:54 +1000 -Subject: [PATCH xserver] Allow compile-time selection of a fallback input - driver - -A new --with-fallback-input-driver=foo option allows selecting a -fallback driver for the server if the driver configured for the device -is not found. Note that this only applies when the device has a driver -assigned and that module fails to load, devices without a driver are -ignored as usual. - -This avoids the situation where a configuration assigns e.g. the -synaptics driver but that driver is not available on the system, -resulting in a dead device. A fallback driver can at least provides some -functionality. - -This becomes more important as we move towards making other driver true -leaf nodes that can be installed/uninstalled as requested. Specifically, -wacom and synaptics, a config that assigns either driver should be -viable even when the driver itself is not (yet) installed on the system. - -It is up to the distributions to make sure that the fallback driver is -always installed. The fallback driver can be disabled with ---without-fallback-input-driver and is disabled by default on non-Linux -systems because we don't have generic drivers on those platforms. -Default driver on Linux is libinput, evdev is the only other serious -candidate here. - -Sample log output: -[ 3274.421] (II) config/udev: Adding input device SynPS/2 Synaptics TouchPad (/dev/input/event4) -[ 3274.421] (**) SynPS/2 Synaptics TouchPad: Applying InputClass "touchpad weird driver" -[ 3274.421] (II) LoadModule: "banana" -[ 3274.422] (WW) Warning, couldn't open module banana -[ 3274.422] (II) UnloadModule: "banana" -[ 3274.422] (II) Unloading banana -[ 3274.422] (EE) Failed to load module "banana" (module does not exist, 0) -[ 3274.422] (EE) No input driver matching `banana' -[ 3274.422] (II) Falling back to input driver `libinput' -.. server proceeds to assign libinput, init the device, world peace and rainbows -everywhere, truly what a sight. Shame about the banana though. - -Reviewed-by: Adam Jackson -Signed-off-by: Peter Hutterer -(cherry picked from commit c69bd15e00aea2610834d05f63777f9bf20eca34) ---- - configure.ac | 19 +++++++++++++++++++ - hw/xfree86/common/xf86Xinput.c | 39 +++++++++++++++++++++++++++++++-------- - include/xorg-config.h.in | 3 +++ - 3 files changed, 53 insertions(+), 8 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 868e859..dea8edd 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -493,6 +493,25 @@ AC_ARG_ENABLE(listen-local, AS_HELP_STRING([--disable-listen-local], - [Listen on local by default (default:enabled)]), - [LISTEN_LOCAL=$enableval], [LISTEN_LOCAL=yes]) - -+case $host_os in -+ linux*) -+ FALLBACK_INPUT_DRIVER="libinput" -+ ;; -+ *) -+ FALLBACK_INPUT_DRIVER="" -+ ;; -+esac -+AC_ARG_WITH(fallback-input-driver, -+ AC_HELP_STRING([--with-fallback-input-driver=$FALLBACK_INPUT_DRIVER], -+ [Input driver fallback if the requested driver for a device is unavailable]), -+ [ FALLBACK_INPUT_DRIVER=$withval ], []) -+if test "x$FALLBACK_INPUT_DRIVER" = "xno"; then -+ FALLBACK_INPUT_DRIVER="" -+fi -+AC_MSG_CHECKING([for fallback input driver]) -+AC_MSG_RESULT([$FALLBACK_INPUT_DRIVER]) -+AC_DEFINE_UNQUOTED(FALLBACK_INPUT_DRIVER, ["$FALLBACK_INPUT_DRIVER"], [ Fallback input driver ]) -+ - dnl Determine font path - XORG_FONTROOTDIR - XORG_FONTSUBDIR(FONTMISCDIR, fontmiscdir, misc) -diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c -index c56a2b9..44f4818 100644 ---- a/hw/xfree86/common/xf86Xinput.c -+++ b/hw/xfree86/common/xf86Xinput.c -@@ -819,6 +819,22 @@ xf86stat(const char *path, int *maj, int *min) - *min = minor(st.st_rdev); - } - -+static inline InputDriverPtr -+xf86LoadInputDriver(const char *driver_name) -+{ -+ InputDriverPtr drv = NULL; -+ -+ /* Memory leak for every attached device if we don't -+ * test if the module is already loaded first */ -+ drv = xf86LookupInputDriver(driver_name); -+ if (!drv) { -+ if (xf86LoadOneModule(driver_name, NULL)) -+ drv = xf86LookupInputDriver(driver_name); -+ } -+ -+ return drv; -+} -+ - /** - * Create a new input device, activate and enable it. - * -@@ -845,16 +861,23 @@ xf86NewInputDevice(InputInfoPtr pInfo, DeviceIntPtr *pdev, BOOL enable) - int rval; - char *path = NULL; - -- /* Memory leak for every attached device if we don't -- * test if the module is already loaded first */ -- drv = xf86LookupInputDriver(pInfo->driver); -- if (!drv) -- if (xf86LoadOneModule(pInfo->driver, NULL)) -- drv = xf86LookupInputDriver(pInfo->driver); -+ drv = xf86LoadInputDriver(pInfo->driver); - if (!drv) { - xf86Msg(X_ERROR, "No input driver matching `%s'\n", pInfo->driver); -- rval = BadName; -- goto unwind; -+ -+ if (strlen(FALLBACK_INPUT_DRIVER) > 0) { -+ xf86Msg(X_INFO, "Falling back to input driver `%s'\n", -+ FALLBACK_INPUT_DRIVER); -+ drv = xf86LoadInputDriver(FALLBACK_INPUT_DRIVER); -+ if (drv) { -+ free(pInfo->driver); -+ pInfo->driver = strdup(FALLBACK_INPUT_DRIVER); -+ } -+ } -+ if (!drv) { -+ rval = BadName; -+ goto unwind; -+ } - } - - path = xf86CheckStrOption(pInfo->options, "Device", NULL); -diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in -index 7c03126..2e2da45 100644 ---- a/include/xorg-config.h.in -+++ b/include/xorg-config.h.in -@@ -151,4 +151,7 @@ - /* Support APM/ACPI power management in the server */ - #undef XF86PM - -+/* Fallback input driver if the assigned driver fails */ -+#undef FALLBACK_INPUT_DRIVER -+ - #endif /* _XORG_CONFIG_H_ */ --- -2.7.4 - diff --git a/0001-dri-BC-hack-for-ati-and-openchrome.patch b/0001-dri-BC-hack-for-ati-and-openchrome.patch deleted file mode 100644 index 0ac558a..0000000 --- a/0001-dri-BC-hack-for-ati-and-openchrome.patch +++ /dev/null @@ -1,59 +0,0 @@ -From fbb5ac73cb51317bf395e4849e82837c39395bae Mon Sep 17 00:00:00 2001 -From: Adam Jackson -Date: Mon, 9 May 2016 10:58:47 -0400 -Subject: [PATCH] dri: BC hack for ati and openchrome - -DRICreatePCIBusID creates a string that is then passed into libdrm. It -only lives in the dri1 code for some reason, so move it to the dri2 -code. ---- - hw/xfree86/dri/dri.c | 12 ------------ - hw/xfree86/dri2/dri2.c | 12 ++++++++++++ - 2 files changed, 12 insertions(+), 12 deletions(-) - -diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c -index 0046e52..489f115 100644 ---- a/hw/xfree86/dri/dri.c -+++ b/hw/xfree86/dri/dri.c -@@ -2367,18 +2367,6 @@ DRIMoveBuffersHelper(ScreenPtr pScreen, - - } - --char * --DRICreatePCIBusID(const struct pci_device *dev) --{ -- char *busID; -- -- if (asprintf(&busID, "pci:%04x:%02x:%02x.%d", -- dev->domain, dev->bus, dev->dev, dev->func) == -1) -- return NULL; -- -- return busID; --} -- - static void - drmSIGIOHandler(int interrupt, void *closure) - { -diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c -index d55be19..f5907f0 100644 ---- a/hw/xfree86/dri2/dri2.c -+++ b/hw/xfree86/dri2/dri2.c -@@ -1712,3 +1712,15 @@ not_recognized: - *is_param_recognized = FALSE; - return Success; - } -+ -+char * -+DRICreatePCIBusID(const struct pci_device *dev) -+{ -+ char *busID; -+ -+ if (asprintf(&busID, "pci:%04x:%02x:%02x.%d", -+ dev->domain, dev->bus, dev->dev, dev->func) == -1) -+ return NULL; -+ -+ return busID; -+} --- -2.7.4 - diff --git a/0001-glx-Implement-GLX_EXT_libglvnd-v2.1.patch b/0001-glx-Implement-GLX_EXT_libglvnd-v2.1.patch deleted file mode 100644 index 3264578..0000000 --- a/0001-glx-Implement-GLX_EXT_libglvnd-v2.1.patch +++ /dev/null @@ -1,192 +0,0 @@ -From b9968515cc960ec7a95e32f63339eb7fd952bffc Mon Sep 17 00:00:00 2001 -From: Adam Jackson -Date: Wed, 16 Mar 2016 11:38:13 -0400 -Subject: [PATCH xserver] glx: Implement GLX_EXT_libglvnd (v2.1) - -For the dri2 backend, we depend on xfree86 already, so we can walk the -options for the screen looking for a vendor string from xorg.conf. For -the swrast backend we don't have that luxury, so just say mesa. This -extension isn't really meaningful on Windows or OSX yet (since libglvnd -isn't really functional there yet), so on those platforms we don't say -anything and return BadValue for the token from QueryServerString. - -v2: Use xnf* allocators when parsing options (Eric and Emil) -v2.1: Backport to 1.18 (ajax) - -Reviewed-by: Eric Anholt -Reviewed-by: Emil Velikov -Signed-off-by: Adam Jackson -(cherry picked from commit b08526eecf1e165ed9ec2e6b571a5a616a9b696e) ---- - glx/extension_string.c | 1 + - glx/extension_string.h | 1 + - glx/glxcmds.c | 10 ++++++++++ - glx/glxdri2.c | 25 +++++++++++++++++++++++++ - glx/glxdriswrast.c | 4 ++++ - glx/glxscreens.c | 1 + - glx/glxscreens.h | 2 ++ - hw/xfree86/man/xorg.conf.man | 6 ++++++ - 8 files changed, 50 insertions(+) - -diff --git a/glx/extension_string.c b/glx/extension_string.c -index 616c793..d729ccf 100644 ---- a/glx/extension_string.c -+++ b/glx/extension_string.c -@@ -85,6 +85,7 @@ static const struct extension_info known_glx_extensions[] = { - { GLX(EXT_fbconfig_packed_float), VER(0,0), N, }, - { GLX(EXT_framebuffer_sRGB), VER(0,0), N, }, - { GLX(EXT_import_context), VER(0,0), Y, }, -+ { GLX(EXT_libglvnd), VER(0,0), N, }, - { GLX(EXT_stereo_tree), VER(0,0), N, }, - { GLX(EXT_texture_from_pixmap), VER(0,0), Y, }, - { GLX(EXT_visual_info), VER(0,0), Y, }, -diff --git a/glx/extension_string.h b/glx/extension_string.h -index 425a805..a10d710 100644 ---- a/glx/extension_string.h -+++ b/glx/extension_string.h -@@ -47,6 +47,7 @@ enum { - EXT_create_context_es2_profile_bit, - EXT_fbconfig_packed_float_bit, - EXT_import_context_bit, -+ EXT_libglvnd_bit, - EXT_stereo_tree_bit, - EXT_texture_from_pixmap_bit, - EXT_visual_info_bit, -diff --git a/glx/glxcmds.c b/glx/glxcmds.c -index 561faeb..904e5f6 100644 ---- a/glx/glxcmds.c -+++ b/glx/glxcmds.c -@@ -2443,6 +2443,10 @@ __glXDisp_QueryExtensionsString(__GLXclientState * cl, GLbyte * pc) - return Success; - } - -+#ifndef GLX_VENDOR_NAMES_EXT -+#define GLX_VENDOR_NAMES_EXT 0x20F6 -+#endif -+ - int - __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) - { -@@ -2475,6 +2479,12 @@ __glXDisp_QueryServerString(__GLXclientState * cl, GLbyte * pc) - case GLX_EXTENSIONS: - ptr = pGlxScreen->GLXextensions; - break; -+ case GLX_VENDOR_NAMES_EXT: -+ if (pGlxScreen->glvnd) { -+ ptr = pGlxScreen->glvnd; -+ break; -+ } -+ /* else fall through */ - default: - return BadValue; - } -diff --git a/glx/glxdri2.c b/glx/glxdri2.c -index 58e60b9..cabc655 100644 ---- a/glx/glxdri2.c -+++ b/glx/glxdri2.c -@@ -943,6 +943,15 @@ initializeExtensions(__GLXDRIscreen * screen) - /* white lie */ - extern glx_func_ptr glXGetProcAddressARB(const char *); - -+enum { -+ GLXOPT_VENDOR_LIBRARY, -+}; -+ -+static const OptionInfoRec GLXOptions[] = { -+ { GLXOPT_VENDOR_LIBRARY, "GlxVendorLibrary", OPTV_STRING, {0}, FALSE }, -+ { -1, NULL, OPTV_NONE, {0}, FALSE }, -+}; -+ - static __GLXscreen * - __glXDRIscreenProbe(ScreenPtr pScreen) - { -@@ -950,6 +959,8 @@ __glXDRIscreenProbe(ScreenPtr pScreen) - __GLXDRIscreen *screen; - size_t buffer_size; - ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); -+ const char *glvnd = NULL; -+ OptionInfoPtr options; - - screen = calloc(1, sizeof *screen); - if (screen == NULL) -@@ -995,6 +1006,20 @@ __glXDRIscreenProbe(ScreenPtr pScreen) - GLX_PIXMAP_BIT | - GLX_PBUFFER_BIT); - -+ options = xnfalloc(sizeof(GLXOptions)); -+ memcpy(options, GLXOptions, sizeof(GLXOptions)); -+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options); -+ glvnd = xf86GetOptValString(options, GLXOPT_VENDOR_LIBRARY); -+ if (glvnd) -+ screen->base.glvnd = xnfstrdup(glvnd); -+ free(options); -+ -+ if (!screen->base.glvnd) -+ screen->base.glvnd = strdup("mesa"); -+ -+ if (screen->base.glvnd) -+ __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_libglvnd"); -+ - __glXScreenInit(&screen->base, pScreen); - - /* The first call simply determines the length of the extension string. -diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c -index 924067c..0c5b784 100644 ---- a/glx/glxdriswrast.c -+++ b/glx/glxdriswrast.c -@@ -487,6 +487,10 @@ __glXDRIscreenProbe(ScreenPtr pScreen) - GLX_PIXMAP_BIT | - GLX_PBUFFER_BIT); - -+#if !defined(XQUARTZ) && !defined(WIN32) -+ screen->base.glvnd = strdup("mesa"); -+ __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_libglvnd"); -+#endif - __glXScreenInit(&screen->base, pScreen); - - /* The first call simply determines the length of the extension string. -diff --git a/glx/glxscreens.c b/glx/glxscreens.c -index b0ad3b7..8d6b076 100644 ---- a/glx/glxscreens.c -+++ b/glx/glxscreens.c -@@ -418,6 +418,7 @@ __glXScreenInit(__GLXscreen * pGlxScreen, ScreenPtr pScreen) - void - __glXScreenDestroy(__GLXscreen * screen) - { -+ free(screen->glvnd); - free(screen->GLXextensions); - free(screen->GLextensions); - free(screen->visuals); -diff --git a/glx/glxscreens.h b/glx/glxscreens.h -index a905877..b1df222 100644 ---- a/glx/glxscreens.h -+++ b/glx/glxscreens.h -@@ -154,6 +154,8 @@ struct __GLXscreen { - unsigned GLXminor; - /*@} */ - -+ char *glvnd; -+ - Bool (*CloseScreen) (ScreenPtr pScreen); - }; - -diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man -index e33114d..13ee191 100644 ---- a/hw/xfree86/man/xorg.conf.man -+++ b/hw/xfree86/man/xorg.conf.man -@@ -2028,6 +2028,12 @@ Note that disabling an operation will have no effect if the operation is - not accelerated (whether due to lack of support in the hardware or in the - driver). - .TP 7 -+.BI "Option \*qGlxVendorLibrary\*q \*q" string \*q -+This option specifies a space-separated list of OpenGL vendor libraries to -+use for the screen. This may be used to select an alternate implementation -+for development, debugging, or alternate feature sets. -+Default: mesa. -+.TP 7 - .BI "Option \*qInitPrimary\*q \*q" boolean \*q - Use the Int10 module to initialize the primary graphics card. - Normally, only secondary cards are soft-booted using the Int10 module, as the --- -2.7.4 - diff --git a/commitid b/commitid index 3584473..00903f3 100644 --- a/commitid +++ b/commitid @@ -1 +1 @@ -d8b7a900cf912cadb5915b3924dd6ce5a74505e7 +453f813bb4afd39eb5b6b3c4a822894e04b6b11b diff --git a/sources b/sources index e415a3d..854d48a 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -d4842dfe3bd9a9d062f2fa1df9104a46 xorg-server-1.18.4.tar.bz2 +00b98dde4aaab2f3ba47d9a9fdebdc6b xorg-server-20160928.tar.xz diff --git a/xorg-x11-server-xwayland-backports.patch b/xorg-x11-server-xwayland-backports.patch deleted file mode 100644 index 9f08cd7..0000000 --- a/xorg-x11-server-xwayland-backports.patch +++ /dev/null @@ -1,713 +0,0 @@ -From d264f82a7dd601278b1d7099b1eb066eb65cac23 Mon Sep 17 00:00:00 2001 -From: Daniel Stone -Date: Fri, 20 Nov 2015 15:37:31 +0000 -Subject: [PATCH 01/11] XWayland: Use FocusIn events for keyboard enter - -wl_keyboard::enter is the equivalent of FocusIn + KeymapNotify: it -notifies us that the surface/window has now received the focus, and -provides us a set of keys which are currently down. - -We should use these keys to update the current state, but not to send -any events to clients. - -Signed-off-by: Daniel Stone -Reviewed-by: Peter Hutterer -Signed-off-by: Peter Hutterer -(cherry picked from commit fee0827a9a695600765f3d04376fc9babe497401) ---- - hw/xwayland/xwayland-input.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c -index 23e138d..f9e3255 100644 ---- a/hw/xwayland/xwayland-input.c -+++ b/hw/xwayland/xwayland-input.c -@@ -462,7 +462,7 @@ keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, - - wl_array_copy(&xwl_seat->keys, keys); - wl_array_for_each(k, &xwl_seat->keys) -- QueueKeyboardEvents(xwl_seat->keyboard, KeyPress, *k + 8); -+ QueueKeyboardEvents(xwl_seat->keyboard, KeymapNotify, *k + 8); - } - - static void -@@ -474,6 +474,10 @@ keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, - - xwl_seat->xwl_screen->serial = serial; - -+ /* Unlike keymap_handle_enter above, this time we _do_ want to trigger -+ * full release, as we don't know how long we'll be out of focus for. -+ * Notify clients that the keys have been released, disable autorepeat, -+ * etc. */ - wl_array_for_each(k, &xwl_seat->keys) - QueueKeyboardEvents(xwl_seat->keyboard, KeyRelease, *k + 8); - --- -2.7.4 - - -From 640692be7d8f61af2da04fea16ba5a97c53993c5 Mon Sep 17 00:00:00 2001 -From: Olivier Fourdan -Date: Wed, 11 May 2016 09:15:19 +0200 -Subject: [PATCH 02/11] xwayland: don't check events as early as InitInput - -If data is received during XWayland startup, it will be read early in -InitInput() before the connection data is initialized, causing a crash. - -Remove the wayland rountrips from InitInput() as this is done again in -xwl_screen_init() where it seems more appropriate. - -Signed-off-by: Olivier Fourdan -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95337 -Reviewed-by: Adam Jackson -(cherry picked from commit 984be789d5935bc7f695dc61234ef0251ed33679) ---- - hw/xwayland/xwayland-input.c | 5 ----- - 1 file changed, 5 deletions(-) - -diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c -index f9e3255..cbc1bf2 100644 ---- a/hw/xwayland/xwayland-input.c -+++ b/hw/xwayland/xwayland-input.c -@@ -899,11 +899,6 @@ InitInput(int argc, char *argv[]) - xwl_screen->input_registry = wl_display_get_registry(xwl_screen->display); - wl_registry_add_listener(xwl_screen->input_registry, &input_listener, - xwl_screen); -- -- xwl_screen->expecting_event = 0; -- wl_display_roundtrip(xwl_screen->display); -- while (xwl_screen->expecting_event) -- wl_display_roundtrip(xwl_screen->display); - } - - void --- -2.7.4 - - -From 9e19417ad6b78de4e6dede3713396b5030b1bf93 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jonas=20=C3=85dahl?= -Date: Tue, 24 May 2016 18:46:42 +0800 -Subject: [PATCH 03/11] xwayland: Use the CLOCK_MONOTONIC clock -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -By default the X server will try CLOCK_MONOTONIC_COARSE before -CLOCK_MONOTONIC, while A Wayland compositor may only support getting -their timestamps from the CLOCK_MONOTONIC clock. This causes various -issues since it may happen that a timestamp from CLOCK_MONOTONIC -retrieved before a sending an X request will still be "later" than the -timestamp the X server than gets after receiving the request, due to the -fact that CLOCK_MONOTONIC_COARSE has a lower resolution. - -To avoid these issues, make Xwayland always use CLOCK_MONOTONIC, so -that it becomes possible for Wayland compositor only supporting -CLOCK_MONOTONIC and X server to use the same clock. - -Signed-off-by: Jonas Ådahl -Acked-by: Daniel Stone -Tested-by: Olivier Fourdan -Signed-off-by: Peter Hutterer -(cherry picked from commit a779fda224bee0c4d27636503367e55ae93b33c2) ---- - configure.ac | 4 ++++ - hw/xwayland/xwayland.c | 2 ++ - include/os.h | 7 +++++++ - os/utils.c | 24 ++++++++++++++++++++++-- - 4 files changed, 35 insertions(+), 2 deletions(-) - -diff --git a/configure.ac b/configure.ac -index 868e859..c865bfa 100644 ---- a/configure.ac -+++ b/configure.ac -@@ -2487,6 +2487,10 @@ if test "x$XWAYLAND" = xyes; then - AC_SUBST([XWAYLAND_LIBS]) - AC_SUBST([XWAYLAND_SYS_LIBS]) - -+ if test "x$MONOTONIC_CLOCK" != xyes; then -+ AC_MSG_ERROR([Xwayland requires CLOCK_MONOTONIC support.]) -+ fi -+ - WAYLAND_PREFIX=`$PKG_CONFIG --variable=prefix wayland-client` - AC_PATH_PROG([WAYLAND_SCANNER], [wayland-scanner],, - [${WAYLAND_PREFIX}/bin$PATH_SEPARATOR$PATH]) -diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c -index 2d44d07..28dea2f 100644 ---- a/hw/xwayland/xwayland.c -+++ b/hw/xwayland/xwayland.c -@@ -32,6 +32,7 @@ - #include - #include - #include -+#include - - #ifdef XF86VIDMODE - #include -@@ -52,6 +53,7 @@ AbortDDX(enum ExitCode error) - void - OsVendorInit(void) - { -+ ForceClockId(CLOCK_MONOTONIC); - } - - void -diff --git a/include/os.h b/include/os.h -index 36074a4..11af73f 100644 ---- a/include/os.h -+++ b/include/os.h -@@ -51,6 +51,9 @@ SOFTWARE. - #include - #include - #include -+#ifdef MONOTONIC_CLOCK -+#include -+#endif - - #define SCREEN_SAVER_ON 0 - #define SCREEN_SAVER_OFF 1 -@@ -170,6 +173,10 @@ extern _X_EXPORT void ListenOnOpenFD(int /* fd */ , int /* noxauth */ ); - - extern _X_EXPORT Bool AddClientOnOpenFD(int /* fd */ ); - -+#ifdef MONOTONIC_CLOCK -+extern void ForceClockId(clockid_t /* forced_clockid */); -+#endif -+ - extern _X_EXPORT CARD32 GetTimeInMillis(void); - extern _X_EXPORT CARD64 GetTimeInMicros(void); - -diff --git a/os/utils.c b/os/utils.c -index b45719e..cc3bece 100644 ---- a/os/utils.c -+++ b/os/utils.c -@@ -211,6 +211,10 @@ sig_atomic_t inSignalContext = FALSE; - #define HAS_SAVED_IDS_AND_SETEUID - #endif - -+#ifdef MONOTONIC_CLOCK -+static clockid_t clockid; -+#endif -+ - OsSigHandlerPtr - OsSignal(int sig, OsSigHandlerPtr handler) - { -@@ -428,6 +432,24 @@ GiveUp(int sig) - errno = olderrno; - } - -+#ifdef MONOTONIC_CLOCK -+void -+ForceClockId(clockid_t forced_clockid) -+{ -+ struct timespec tp; -+ -+ BUG_RETURN (clockid); -+ -+ clockid = forced_clockid; -+ -+ if (clock_gettime(clockid, &tp) != 0) { -+ FatalError("Forced clock id failed to retrieve current time: %s\n", -+ strerror(errno)); -+ return; -+ } -+} -+#endif -+ - #if (defined WIN32 && defined __MINGW32__) || defined(__CYGWIN__) - CARD32 - GetTimeInMillis(void) -@@ -447,7 +469,6 @@ GetTimeInMillis(void) - - #ifdef MONOTONIC_CLOCK - struct timespec tp; -- static clockid_t clockid; - - if (!clockid) { - #ifdef CLOCK_MONOTONIC_COARSE -@@ -476,7 +497,6 @@ GetTimeInMicros(void) - struct timeval tv; - #ifdef MONOTONIC_CLOCK - struct timespec tp; -- static clockid_t clockid; - - if (!clockid) { - if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) --- -2.7.4 - - -From 619095a3d227f89ea938c3c55f34188ec3cd9e49 Mon Sep 17 00:00:00 2001 -From: Olivier Fourdan -Date: Thu, 12 May 2016 14:51:51 +0200 -Subject: [PATCH 04/11] xwayland: Restore wl_display_roundtrip() in InitInput - -This partially revert commit 984be78 - -The rountrip in Xwayland's InitInput() is unlikely the culprit for the -crash reported in bug 95337, even though it's triggered from -InitInput(). - -Startup goes like this: - - xwl_screen_init() - xwl_output_create() - wl_display_roundtrip() - InitInput() - wl_display_roundtrip() - ConnectionInfo initialized - -What happens in bug 95337 is that some output data is already available -when we reach InitInput()'s wl_display_roundtrip() and therefore we end -up trying to update the ConnectionInfo's data from RR routines before -ConnectionInfo is actually initialized. - -Removing the wl_display_roundtrip() from InitInput() will not fix the -issue (although it would make it less lileky to happen), because -xwl_screen_init() also does a wl_display_roundtrip() after creating the -output, so the race that led to bug 95337 remains. - -However, re-setting the xwl_screen->expecting_event to 0 again in -InitInput() still doesn't seem right. so this part is not restored -(thus a partial revert). - -Signed-off-by: Olivier Fourdan -Reviewed-by: Adam Jackson -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95337 -(cherry picked from commit 6a6bbc3b756706bdade01434f1ee8d8cbe7dd854) ---- - hw/xwayland/xwayland-input.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c -index cbc1bf2..6e95d7e 100644 ---- a/hw/xwayland/xwayland-input.c -+++ b/hw/xwayland/xwayland-input.c -@@ -899,6 +899,10 @@ InitInput(int argc, char *argv[]) - xwl_screen->input_registry = wl_display_get_registry(xwl_screen->display); - wl_registry_add_listener(xwl_screen->input_registry, &input_listener, - xwl_screen); -+ -+ wl_display_roundtrip(xwl_screen->display); -+ while (xwl_screen->expecting_event) -+ wl_display_roundtrip(xwl_screen->display); - } - - void --- -2.7.4 - - -From 173b3fb71e404a77402ed1c6884ef9cd184918e7 Mon Sep 17 00:00:00 2001 -From: Olivier Fourdan -Date: Fri, 13 May 2016 08:58:58 +0200 -Subject: [PATCH 05/11] randr: Do not update ConnectionInfo if NULL - -RRScreenSizeNotify() will update the connection information block, but -if this occurs during initialization before ConnectionInfo is even -initialized, this will lead to a crash. - -Simply check for ConnectionInfo prior to update it to avoid the crash. - -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95337 -Reviewed-by: Adam Jackson -Signed-off-by: Olivier Fourdan -(cherry picked from commit 941aeb3b92e644923bd112eef8023f033a140ee6) ---- - randr/rrscreen.c | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/randr/rrscreen.c b/randr/rrscreen.c -index d0ca91e..b5e2090 100644 ---- a/randr/rrscreen.c -+++ b/randr/rrscreen.c -@@ -41,6 +41,9 @@ RREditConnectionInfo(ScreenPtr pScreen) - int screen = 0; - int d; - -+ if (ConnectionInfo == NULL) -+ return; -+ - connSetup = (xConnSetup *) ConnectionInfo; - vendor = (char *) connSetup + sizeof(xConnSetup); - formats = (xPixmapFormat *) ((char *) vendor + --- -2.7.4 - - -From 813db111f5b41d07601f4e127b1fb3ce14744af6 Mon Sep 17 00:00:00 2001 -From: Jason Gerecke -Date: Fri, 17 Jun 2016 08:44:40 -0700 -Subject: [PATCH 06/11] xwayland: Use correct labels when initializing pointer - valuators - -Signed-off-by: Jason Gerecke -Reviewed-by: Olivier Fourdan -Signed-off-by: Peter Hutterer -(cherry picked from commit 72df6e2a3a5020696902b70fe940934ef0a681c4) ---- - hw/xwayland/xwayland-input.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c -index 6e95d7e..3413248 100644 ---- a/hw/xwayland/xwayland-input.c -+++ b/hw/xwayland/xwayland-input.c -@@ -78,7 +78,7 @@ xwl_pointer_proc(DeviceIntPtr device, int what) - axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_HWHEEL); - axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_WHEEL); - -- if (!InitValuatorClassDeviceStruct(device, NAXES, btn_labels, -+ if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels, - GetMotionHistorySize(), Absolute)) - return BadValue; - --- -2.7.4 - - -From e73279c5dca705e3ee595d254cd1b9fa0df43062 Mon Sep 17 00:00:00 2001 -From: Jason Gerecke -Date: Fri, 17 Jun 2016 08:44:41 -0700 -Subject: [PATCH 07/11] xwayland: Expose all NBUTTONS buttons on the pointer - -The call to 'InitButtonClassDeviceStruct' which initializes the pointer -buttons only results in the first three buttons being created due to a -hardcoded '3'. In order to expose all the buttons defined in the -btn_labels array, we subtitute 'NBUTTONS' in its place. - -Signed-off-by: Jason Gerecke -Reviewed-by: Olivier Fourdan -Signed-off-by: Peter Hutterer -(cherry picked from commit 6f2a5b8cdf7b1e913a1e0581e65195dd10f04ca3) ---- - hw/xwayland/xwayland-input.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c -index 3413248..433af9c 100644 ---- a/hw/xwayland/xwayland-input.c -+++ b/hw/xwayland/xwayland-input.c -@@ -98,7 +98,7 @@ xwl_pointer_proc(DeviceIntPtr device, int what) - if (!InitPtrFeedbackClassDeviceStruct(device, xwl_pointer_control)) - return BadValue; - -- if (!InitButtonClassDeviceStruct(device, 3, btn_labels, map)) -+ if (!InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map)) - return BadValue; - - return Success; --- -2.7.4 - - -From f77be59aa6f1c4b773488981d6736e26f9083a11 Mon Sep 17 00:00:00 2001 -From: Adam Jackson -Date: Fri, 8 Jul 2016 15:17:05 -0400 -Subject: [PATCH 08/11] xwayland: Only force monotonic clock once -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Otherwise on regeneration we get: - -(EE) BUG: triggered 'if (clockid)' -(EE) BUG: utils.c:440 in ForceClockId() -(EE) -(EE) Backtrace: -(EE) 0: ./hw/xwayland/Xwayland (ForceClockId+0x5c) [0x47713c] -(EE) 1: ./hw/xwayland/Xwayland (OsInit+0x25) [0x4763d5] -(EE) 2: ./hw/xwayland/Xwayland (dix_main+0x11c) [0x43e60c] -(EE) 3: /lib64/libc.so.6 (__libc_start_main+0xf1) [0x7f627b2f9731] -(EE) 4: ./hw/xwayland/Xwayland (_start+0x29) [0x4238e9] -(EE) 5: ? (?+0x29) [0x29] - -Signed-off-by: Adam Jackson -Reviewed-by: Jonas Ådahl -(cherry picked from commit 9fcb554e9bfdf3eed2c2250d89150e3e7b907f01) ---- - hw/xwayland/xwayland.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c -index 28dea2f..fdc0817 100644 ---- a/hw/xwayland/xwayland.c -+++ b/hw/xwayland/xwayland.c -@@ -53,7 +53,8 @@ AbortDDX(enum ExitCode error) - void - OsVendorInit(void) - { -- ForceClockId(CLOCK_MONOTONIC); -+ if (serverGeneration == 1) -+ ForceClockId(CLOCK_MONOTONIC); - } - - void --- -2.7.4 - - -From 8435f9e6dfbd7e07e694eb917e73aefec9a43207 Mon Sep 17 00:00:00 2001 -From: Olivier Fourdan -Date: Tue, 2 Aug 2016 11:24:41 +0200 -Subject: [PATCH 09/11] xwayland: Plug memleak in frame callbacks - -The frame callback set up via wl_surface_frame() needs to be freed with -wl_callback_destroy() or we'll leak memory. - -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97065 -Signed-off-by: Olivier Fourdan -Reviewed-by: Daniel Stone -(cherry picked from commit 4d586118c113f3c0a6e95ed2d3fc7f9d03a4e362) ---- - hw/xwayland/xwayland-cursor.c | 2 ++ - hw/xwayland/xwayland.c | 2 ++ - 2 files changed, 4 insertions(+) - -diff --git a/hw/xwayland/xwayland-cursor.c b/hw/xwayland/xwayland-cursor.c -index 74dfe4e..7d14a3d 100644 ---- a/hw/xwayland/xwayland-cursor.c -+++ b/hw/xwayland/xwayland-cursor.c -@@ -100,6 +100,8 @@ frame_callback(void *data, - uint32_t time) - { - struct xwl_seat *xwl_seat = data; -+ -+ wl_callback_destroy (xwl_seat->cursor_frame_cb); - xwl_seat->cursor_frame_cb = NULL; - if (xwl_seat->cursor_needs_update) { - xwl_seat->cursor_needs_update = FALSE; -diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c -index fdc0817..8143c4b 100644 ---- a/hw/xwayland/xwayland.c -+++ b/hw/xwayland/xwayland.c -@@ -362,6 +362,8 @@ frame_callback(void *data, - uint32_t time) - { - struct xwl_window *xwl_window = data; -+ -+ wl_callback_destroy (xwl_window->frame_callback); - xwl_window->frame_callback = NULL; - } - --- -2.7.4 - - -From 93f07a4c033bb4da00c33104a1cbbc69dcd46134 Mon Sep 17 00:00:00 2001 -From: Olivier Fourdan -Date: Mon, 8 Aug 2016 17:57:57 +0200 -Subject: [PATCH 10/11] xwayland: Avoid double free of RRCrtc and RROutput - -At shutdown, the Xserver will free all its resources which includes the -RRCrtc and RROutput created. - -Xwayland would do the same in its xwl_output_destroy() called from -xwl_close_screen(), leading to a double free of existing RRCrtc -RROutput: - - Invalid read of size 4 - at 0x4CDA10: RRCrtcDestroy (rrcrtc.c:689) - by 0x426E75: xwl_output_destroy (xwayland-output.c:301) - by 0x424144: xwl_close_screen (xwayland.c:117) - by 0x460E17: CursorCloseScreen (cursor.c:187) - by 0x4EB5A3: AnimCurCloseScreen (animcur.c:106) - by 0x4EF431: present_close_screen (present_screen.c:64) - by 0x556D40: dix_main (main.c:354) - by 0x6F0D290: (below main) (in /usr/lib/libc-2.24.so) - Address 0xbb1fc30 is 0 bytes inside a block of size 728 free'd - at 0x4C2BDB0: free (in -/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) - by 0x4CCE5F: RRCrtcDestroyResource (rrcrtc.c:719) - by 0x577541: doFreeResource (resource.c:895) - by 0x5787B5: FreeClientResources (resource.c:1161) - by 0x578862: FreeAllResources (resource.c:1176) - by 0x556C54: dix_main (main.c:323) - by 0x6F0D290: (below main) (in /usr/lib/libc-2.24.so) - Block was alloc'd at - at 0x4C2CA6A: calloc (in -/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) - by 0x4CC6DB: RRCrtcCreate (rrcrtc.c:76) - by 0x426D1C: xwl_output_create (xwayland-output.c:264) - by 0x4232EC: registry_global (xwayland.c:431) - by 0x76CB1C7: ffi_call_unix64 (in /usr/lib/libffi.so.6.0.4) - by 0x76CAC29: ffi_call (in /usr/lib/libffi.so.6.0.4) - by 0x556CEFD: wl_closure_invoke (connection.c:935) - by 0x5569CBF: dispatch_event.isra.4 (wayland-client.c:1310) - by 0x556AF13: dispatch_queue (wayland-client.c:1456) - by 0x556AF13: wl_display_dispatch_queue_pending -(wayland-client.c:1698) - by 0x556B33A: wl_display_roundtrip_queue (wayland-client.c:1121) - by 0x42371C: xwl_screen_init (xwayland.c:631) - by 0x552F60: AddScreen (dispatch.c:3864) - -And: - - Invalid read of size 4 - at 0x522890: RROutputDestroy (rroutput.c:348) - by 0x42684E: xwl_output_destroy (xwayland-output.c:302) - by 0x423CF4: xwl_close_screen (xwayland.c:118) - by 0x4B6377: CursorCloseScreen (cursor.c:187) - by 0x539503: AnimCurCloseScreen (animcur.c:106) - by 0x53D081: present_close_screen (present_screen.c:64) - by 0x43DBF0: dix_main (main.c:354) - by 0x7068730: (below main) (libc-start.c:289) - Address 0xc403190 is 0 bytes inside a block of size 154 free'd - at 0x4C2CD5A: free (vg_replace_malloc.c:530) - by 0x521DF3: RROutputDestroyResource (rroutput.c:389) - by 0x45DA61: doFreeResource (resource.c:895) - by 0x45ECFD: FreeClientResources (resource.c:1161) - by 0x45EDC2: FreeAllResources (resource.c:1176) - by 0x43DB04: dix_main (main.c:323) - by 0x7068730: (below main) (libc-start.c:289) - Block was alloc'd at - at 0x4C2BBAD: malloc (vg_replace_malloc.c:299) - by 0x52206B: RROutputCreate (rroutput.c:84) - by 0x426763: xwl_output_create (xwayland-output.c:270) - by 0x422EDC: registry_global (xwayland.c:432) - by 0x740FC57: ffi_call_unix64 (unix64.S:76) - by 0x740F6B9: ffi_call (ffi64.c:525) - by 0x5495A9D: wl_closure_invoke (connection.c:949) - by 0x549283F: dispatch_event.isra.4 (wayland-client.c:1274) - by 0x5493A13: dispatch_queue (wayland-client.c:1420) - by 0x5493A13: wl_display_dispatch_queue_pending -(wayland-client.c:1662) - by 0x5493D2E: wl_display_roundtrip_queue (wayland-client.c:1085) - by 0x4232EC: xwl_screen_init (xwayland.c:632) - by 0x439F50: AddScreen (dispatch.c:3864) - -Split xwl_output_destroy() into xwl_output_destroy() which frees the -wl_output and the xwl_output structure, and xwl_output_remove() which -does the RRCrtcDestroy() and RROutputDestroy() and call the latter only -when an output is effectively removed. - -An additional benefit, on top of avoiding a double free, is to avoid -updating the screen size at shutdown. - -Signed-off-by: Olivier Fourdan -Reviewed-by: Hans de Goede -(cherry picked from commit 4cbf1fb1f978ecd975770cebbb330dc10f712b77) ---- - hw/xwayland/xwayland-output.c | 12 +++++++++--- - hw/xwayland/xwayland.c | 2 +- - hw/xwayland/xwayland.h | 2 ++ - 3 files changed, 12 insertions(+), 4 deletions(-) - -diff --git a/hw/xwayland/xwayland-output.c b/hw/xwayland/xwayland-output.c -index b66da13..38c92a6 100644 ---- a/hw/xwayland/xwayland-output.c -+++ b/hw/xwayland/xwayland-output.c -@@ -292,20 +292,26 @@ err: - void - xwl_output_destroy(struct xwl_output *xwl_output) - { -+ wl_output_destroy(xwl_output->output); -+ free(xwl_output); -+} -+ -+void -+xwl_output_remove(struct xwl_output *xwl_output) -+{ - struct xwl_output *it; - struct xwl_screen *xwl_screen = xwl_output->xwl_screen; - int width = 0, height = 0; - -- wl_output_destroy(xwl_output->output); -- xorg_list_del(&xwl_output->link); - RRCrtcDestroy(xwl_output->randr_crtc); - RROutputDestroy(xwl_output->randr_output); -+ xorg_list_del(&xwl_output->link); - - xorg_list_for_each_entry(it, &xwl_screen->output_list, link) - output_get_new_size(it, &height, &width); - update_screen_size(xwl_output, width, height); - -- free(xwl_output); -+ xwl_output_destroy(xwl_output); - } - - static Bool -diff --git a/hw/xwayland/xwayland.c b/hw/xwayland/xwayland.c -index 8143c4b..959f616 100644 ---- a/hw/xwayland/xwayland.c -+++ b/hw/xwayland/xwayland.c -@@ -451,7 +451,7 @@ global_remove(void *data, struct wl_registry *registry, uint32_t name) - xorg_list_for_each_entry_safe(xwl_output, tmp_xwl_output, - &xwl_screen->output_list, link) { - if (xwl_output->server_output_id == name) { -- xwl_output_destroy(xwl_output); -+ xwl_output_remove(xwl_output); - break; - } - } -diff --git a/hw/xwayland/xwayland.h b/hw/xwayland/xwayland.h -index 232d9f4..4b97a2e 100644 ---- a/hw/xwayland/xwayland.h -+++ b/hw/xwayland/xwayland.h -@@ -170,6 +170,8 @@ struct xwl_output *xwl_output_create(struct xwl_screen *xwl_screen, - - void xwl_output_destroy(struct xwl_output *xwl_output); - -+void xwl_output_remove(struct xwl_output *xwl_output); -+ - RRModePtr xwayland_cvt(int HDisplay, int VDisplay, - float VRefresh, Bool Reduced, Bool Interlaced); - --- -2.7.4 - - -From fb96f3b1c5bace29193aeb44fcae2e4d1854f877 Mon Sep 17 00:00:00 2001 -From: Olivier Fourdan -Date: Mon, 8 Aug 2016 17:25:35 +0200 -Subject: [PATCH 11/11] present: Free the fake_present OsTimerPtr -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Plug a leak in present_fake_queue_vblank() where the OsTimer would not -be freed. - - 492,608 (482,816 direct, 9,792 indirect) bytes in 15,088 blocks -are definitely lost in loss record 3,954 of 3,954 - at 0x4C2ABDE: malloc (in vgpreload_memcheck-amd64-linux.so) - by 0x586B19: TimerSet (WaitFor.c:433) - by 0x4F1AA9: present_fake_queue_vblank (present_fake.c:108) - by 0x4F15E0: present_pixmap (present.c:954) - by 0x4F23B4: proc_present_pixmap (present_request.c:138) - by 0x552BCE: Dispatch (dispatch.c:430) - by 0x556C22: dix_main (main.c:300) - by 0x6F0D290: (below main) (in /usr/lib/libc-2.24.so) - -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=97065 -Signed-off-by: Olivier Fourdan -Reviewed-by: Michel Dänzer -(cherry picked from commit de5291c04b05772e6da599a475baa1b19dcae07a) ---- - present/present_fake.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/present/present_fake.c b/present/present_fake.c -index 4985c81..2350638 100644 ---- a/present/present_fake.c -+++ b/present/present_fake.c -@@ -64,6 +64,7 @@ present_fake_do_timer(OsTimerPtr timer, - - present_fake_notify(fake_vblank->screen, fake_vblank->event_id); - xorg_list_del(&fake_vblank->list); -+ TimerFree(fake_vblank->timer); - free(fake_vblank); - return 0; - } -@@ -75,7 +76,7 @@ present_fake_abort_vblank(ScreenPtr screen, uint64_t event_id, uint64_t msc) - - xorg_list_for_each_entry_safe(fake_vblank, tmp, &fake_vblank_queue, list) { - if (fake_vblank->event_id == event_id) { -- TimerCancel(fake_vblank->timer); -+ TimerFree(fake_vblank->timer); /* TimerFree will call TimerCancel() */ - xorg_list_del(&fake_vblank->list); - free (fake_vblank); - break; --- -2.7.4 - diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index 5bcd54a..61c3ef0 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -11,7 +11,7 @@ # X.org requires lazy relocations to work. %undefine _hardened_build -#global gitdate 20151027 +%global gitdate 20160928 %global stable_abi 1 %if !0%{?gitdate} || %{stable_abi} @@ -19,11 +19,11 @@ # source because rpm is a terrible language. %global ansic_major 0 %global ansic_minor 4 -%global videodrv_major 20 +%global videodrv_major 23 %global videodrv_minor 0 -%global xinput_major 22 +%global xinput_major 24 %global xinput_minor 1 -%global extension_major 9 +%global extension_major 10 %global extension_minor 0 %endif @@ -77,24 +77,16 @@ Source31: xserver-sdk-abi-requires.git # maintainer convenience script Source40: driver-abi-rebuild.sh -# xwayland backports from master -Patch0: xorg-x11-server-xwayland-backports.patch - -# prime fixes from master (and pending upstream review) -Patch1: xserver-prime-fixes.patch - -Patch10: 0001-glx-Implement-GLX_EXT_libglvnd-v2.1.patch +# Misc fixes pending merge into master +Patch0: xserver-1.19-pending-fixes.patch #Patch6044: xserver-1.6.99-hush-prerelease-warning.patch Patch7025: 0001-Always-install-vbe-and-int10-sdk-headers.patch -# do not upstream - do not even use here yet +# Submitted upstream, pending Patch7027: xserver-autobind-hotplug.patch -# Pick libinput as driver when the assigned module is missing -Patch7028: 0001-Allow-compile-time-selection-of-a-fallback-input-dri.patch - # because the display-managers are not ready yet, do not upstream Patch10000: 0001-Fedora-hack-Make-the-suid-root-wrapper-always-start-.patch @@ -132,7 +124,7 @@ BuildRequires: xorg-x11-font-utils >= 7.2-11 BuildRequires: dbus-devel libepoxy-devel systemd-devel BuildRequires: xorg-x11-xtrans-devel >= 1.3.2 -BuildRequires: libXfont-devel libXau-devel libxkbfile-devel libXres-devel +BuildRequires: libXfont2-devel libXau-devel libxkbfile-devel libXres-devel BuildRequires: libfontenc-devel libXtst-devel libXdmcp-devel BuildRequires: libX11-devel libXext-devel BuildRequires: libXinerama-devel libXi-devel @@ -141,11 +133,9 @@ BuildRequires: libXinerama-devel libXi-devel BuildRequires: libXt-devel libdmx-devel libXmu-devel libXrender-devel BuildRequires: libXi-devel libXpm-devel libXaw-devel libXfixes-devel -%if 0%{?fedora} > 20 BuildRequires: wayland-devel BuildRequires: pkgconfig(wayland-client) >= 1.3.0 BuildRequires: pkgconfig(epoxy) -%endif %if !0%{?rhel} BuildRequires: pkgconfig(xshmfence) >= 1.1 %endif @@ -214,30 +204,6 @@ Provides: xorg-x11-glamor = %{version}-%{release} Obsoletes: xorg-x11-drv-modesetting < %{version}-%{release} Provides: xorg-x11-drv-modesetting = %{version}-%{release} -%if 0%{?fedora} > 20 -# Dropped from F21 -Obsoletes: xorg-x11-drv-apm < 1.2.5-18 -Obsoletes: xorg-x11-drv-cirrus < 1.5.2-10 -Obsoletes: xorg-x11-drv-glint < 1.2.8-17 -Obsoletes: xorg-x11-drv-i128 < 1.3.6-18 -Obsoletes: xorg-x11-drv-i740 < 1.3.4-18 -Obsoletes: xorg-x11-drv-mach64 < 6.9.4-16 -Obsoletes: xorg-x11-drv-mga < 1.6.2-17 -Obsoletes: xorg-x11-drv-neomagic < 1.2.8-8 -Obsoletes: xorg-x11-drv-r128 < 6.9.2-2 -Obsoletes: xorg-x11-drv-rendition < 4.2.5-18 -Obsoletes: xorg-x11-drv-s3virge < 1.10.6-18 -Obsoletes: xorg-x11-drv-savage < 2.3.7-7 -Obsoletes: xorg-x11-drv-siliconmotion < 1.7.7-17 -Obsoletes: xorg-x11-drv-sis < 0.10.7-19 -Obsoletes: xorg-x11-drv-tdfx < 1.4.5-17 -Obsoletes: xorg-x11-drv-trident < 1.3.6-18 -%endif -%if 0%{?fedora} > 21 -# Dropped from F22 -Obsoletes: xorg-x11-drv-void < 1.4.1-2 -%endif - Requires: xorg-x11-server-common >= %{version}-%{release} Requires: system-setup-keyboard @@ -315,7 +281,6 @@ X protocol, and therefore supports the newer X extensions like Render and Composite. -%if 0%{?fedora} > 20 %package Xwayland Summary: Wayland X Server Group: User Interface/X @@ -323,7 +288,6 @@ Requires: xorg-x11-server-common >= %{version}-%{release} %description Xwayland Xwayland is an X server for running X clients under Wayland. -%endif %if %{with_hw_servers} @@ -415,11 +379,7 @@ test `getminor extension` == %{extension_minor} %if 0%{?fedora} %global bodhi_flags --with-vendor-name="Fedora Project" -%if 0%{?fedora} > 20 %global wayland --enable-xwayland -%else -%global wayland --disable-xwayland -%endif %endif # ick @@ -615,10 +575,8 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %{_bindir}/Xephyr %{_mandir}/man1/Xephyr.1* -%if 0%{?fedora} > 20 %files Xwayland %{_bindir}/Xwayland -%endif %if %{with_hw_servers} %files devel @@ -636,6 +594,11 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Wed Sep 28 2016 Hans de Goede - 1.18.99.901-1 +- Rebase to 1.18.99.901 (1.19-rc1) (+ git master patches uptill today) +- Drop Obsoletes for the driver packages removed from F21 (its been 2 + years since they have been removed now) + * Thu Sep 08 2016 Adam Jackson 1.18.4-6 - Backport GLX_EXT_libglvnd support from 1.19 diff --git a/xserver-1.19-pending-fixes.patch b/xserver-1.19-pending-fixes.patch new file mode 100644 index 0000000..f325ff9 --- /dev/null +++ b/xserver-1.19-pending-fixes.patch @@ -0,0 +1,827 @@ +From abe57372a111c27e6ca0865f9ad7c3d2d6022dfb Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 15 Sep 2016 14:28:35 +0200 +Subject: [PATCH xserver v2 01/14] modesetting: Fix reverse prime partial + update issues on secondary GPU outputs + +When using reverse prime we do 2 copies, 1 from the primary GPU's +framebuffer to a shared pixmap and 1 from the shared pixmap to the +secondary GPU's framebuffer. + +This means that on the primary GPU side the copy MUST be finished, +before we start the second copy (before the secondary GPU's driver +starts processing the damage on the shared pixmap). + +This fixes secondary outputs sometimes showning (some) old fb contents, +because of the 2 copies racing with each other, for an example of +what this looks like see: + +https://fedorapeople.org/~jwrdegoede/IMG_20160915_130555.jpg + +Signed-off-by: Hans de Goede +Reviewed-by: Dave Airlie +Reviewed-by: Eric Anholt +--- + hw/xfree86/drivers/modesetting/driver.c | 13 ++++++++++++- + 1 file changed, 12 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index a8e83b2..f98d6da 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -586,13 +586,24 @@ dispatch_slave_dirty(ScreenPtr pScreen) + static void + redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty) + { +- ++ modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen)); + RegionRec pixregion; + + PixmapRegionInit(&pixregion, dirty->slave_dst); + DamageRegionAppend(&dirty->slave_dst->drawable, &pixregion); + PixmapSyncDirtyHelper(dirty); + ++ if (!screen->isGPU) { ++ /* ++ * When copying from the master framebuffer to the shared pixmap, ++ * we must ensure the copy is complete before the slave starts a ++ * copy to its own framebuffer (some slaves scanout directly from ++ * the shared pixmap, but not all). ++ */ ++ if (ms->drmmode.glamor) ++ glamor_finish(screen); ++ } ++ + DamageRegionProcessPending(&dirty->slave_dst->drawable); + RegionUninit(&pixregion); + } +-- +2.9.3 + +From d445d873d322f50da163d5e8902049169ee91f8a Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 15 Sep 2016 14:35:52 +0200 +Subject: [PATCH xserver v2 02/14] modesetting: Fix reverse prime update + lagging on secondary GPU outputs + +When using secondary GPU outputs the primary GPU's blockhandler +will copy changes from its framebuffer to a pixmap shared with the +secondary GPU. + +In reverse prime setups the secondary GPU's blockhandler will do another +copy from the shared pixmap to its own framebuffer. + +Before this commit, if the primary GPU's blockhandler would run after +the secondary GPU's blockhandler and no events were pending, then the +secondary GPU's blockhandler would not run until some events came in +(WaitForSomething() would block in the poll call), resulting in the +secondary GPU output sometimes showing stale contents (e.g. a just closed +window) for easily up to 10 seconds. + +This commit fixes this by setting the timeout passed into the +blockhandler to 0 if any shared pixmaps were updated by the primary GPU, +forcing an immediate re-run of all blockhandlers. + +Signed-off-by: Hans de Goede +Reviewed-by: Dave Airlie +--- + hw/xfree86/drivers/modesetting/driver.c | 13 ++++++++----- + 1 file changed, 8 insertions(+), 5 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index f98d6da..d37a42a 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -584,7 +584,7 @@ dispatch_slave_dirty(ScreenPtr pScreen) + } + + static void +-redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty) ++redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty, int *timeout) + { + modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen)); + RegionRec pixregion; +@@ -602,6 +602,9 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty) + */ + if (ms->drmmode.glamor) + glamor_finish(screen); ++ /* Ensure the slave processes the damage immediately */ ++ if (timeout) ++ *timeout = 0; + } + + DamageRegionProcessPending(&dirty->slave_dst->drawable); +@@ -609,7 +612,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty) + } + + static void +-ms_dirty_update(ScreenPtr screen) ++ms_dirty_update(ScreenPtr screen, int *timeout) + { + modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(screen)); + +@@ -636,7 +639,7 @@ ms_dirty_update(ScreenPtr screen) + if (ppriv->defer_dirty_update) + continue; + +- redisplay_dirty(screen, ent); ++ redisplay_dirty(screen, ent, timeout); + DamageEmpty(ent->damage); + } + } +@@ -672,7 +675,7 @@ msBlockHandler(ScreenPtr pScreen, void *timeout) + else if (ms->dirty_enabled) + dispatch_dirty(pScreen); + +- ms_dirty_update(pScreen); ++ ms_dirty_update(pScreen, timeout); + } + + static void +@@ -1261,7 +1264,7 @@ msPresentSharedPixmap(PixmapPtr slave_dst) + RegionPtr region = DamageRegion(ppriv->dirty->damage); + + if (RegionNotEmpty(region)) { +- redisplay_dirty(ppriv->slave_src->drawable.pScreen, ppriv->dirty); ++ redisplay_dirty(ppriv->slave_src->drawable.pScreen, ppriv->dirty, NULL); + DamageEmpty(ppriv->dirty->damage); + + return TRUE; +-- +2.9.3 + +From 551f6497040b0b96ca4aaef49ef6de5287256763 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Sat, 17 Sep 2016 11:42:09 +0200 +Subject: [PATCH xserver v2 03/14] xf86RandR12: Move calculating of shift + inside init_one_component + +This is a preparation patch to allow easier usage of init_one_component +outside of xf86RandR12CrtcInitGamma. + +Signed-off-by: Hans de Goede +Reviewed-by: Alex Deucher +--- + hw/xfree86/modes/xf86RandR12.c | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c +index d34bce2..b1ca8b4 100644 +--- a/hw/xfree86/modes/xf86RandR12.c ++++ b/hw/xfree86/modes/xf86RandR12.c +@@ -1325,9 +1325,12 @@ xf86RandR12CrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr randr_crtc) + } + + static void +-init_one_component(CARD16 *comp, unsigned size, unsigned shift, float gamma) ++init_one_component(CARD16 *comp, unsigned size, float gamma) + { + int i; ++ unsigned shift; ++ ++ for (shift = 0; (size << shift) < (1 << 16); shift++); + + if (gamma == 1.0) { + for (i = 0; i < size; i++) +@@ -1344,7 +1347,7 @@ static Bool + xf86RandR12CrtcInitGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, + float gamma_blue) + { +- unsigned size = crtc->randr_crtc->gammaSize, shift; ++ unsigned size = crtc->randr_crtc->gammaSize; + CARD16 *red, *green, *blue; + + if (!crtc->funcs->gamma_set && +@@ -1358,11 +1361,9 @@ xf86RandR12CrtcInitGamma(xf86CrtcPtr crtc, float gamma_red, float gamma_green, + green = red + size; + blue = green + size; + +- for (shift = 0; (size << shift) < (1 << 16); shift++); +- +- init_one_component(red, size, shift, gamma_red); +- init_one_component(green, size, shift, gamma_green); +- init_one_component(blue, size, shift, gamma_blue); ++ init_one_component(red, size, gamma_red); ++ init_one_component(green, size, gamma_green); ++ init_one_component(blue, size, gamma_blue); + + RRCrtcGammaSet(crtc->randr_crtc, red, green, blue); + free(red); +-- +2.9.3 + +From 30679a8ec6a25604f1181bad5ebcb4b529b254c7 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Sat, 17 Sep 2016 11:33:13 +0200 +Subject: [PATCH xserver v2 04/14] xf86RandR12: Fix XF86VidModeSetGamma + triggering a BadImplementation error + +Commit b4e46c0444bb ("xfree86: Hook up colormaps and RandR 1.2 gamma code") +dropped the providing of a pScrn->ChangeGamma callback from the xf86RandR12 +code. Leaving pScrn->ChangeGamma NULL in most cases. + +This triggers the BadImplementation error in xf86ChangeGamma() : + + if (pScrn->ChangeGamma) + return (*pScrn->ChangeGamma) (pScrn, gamma); + + return BadImplementation; + +Which causes X-apps using XF86VidModeSetGamma to crash with a +X protocol error. + +This commit fixes this by re-introducing the xf86RandR12ChangeGamma +helper removed by the commit and adjusting it to work with the new +combined palette / gamma code. + +Fixes: b4e46c0444bb ("xfree86: Hook up colormaps and RandR 1.2 gamma code") +Signed-off-by: Hans de Goede +Reviewed-by: Alex Deucher +--- + hw/xfree86/modes/xf86RandR12.c | 30 ++++++++++++++++++++++++++++++ + 1 file changed, 30 insertions(+) + +diff --git a/hw/xfree86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c +index b1ca8b4..d834619 100644 +--- a/hw/xfree86/modes/xf86RandR12.c ++++ b/hw/xfree86/modes/xf86RandR12.c +@@ -1924,6 +1924,35 @@ xf86RandR12LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices, + } + } + ++/* ++ * Compatibility pScrn->ChangeGamma provider for ddx drivers which do not call ++ * xf86HandleColormaps(). Note such drivers really should be fixed to call ++ * xf86HandleColormaps() as this clobbers the per-CRTC gamma ramp of the CRTC ++ * assigned to the RandR compatibility output. ++ */ ++static int ++xf86RandR12ChangeGamma(ScrnInfoPtr pScrn, Gamma gamma) ++{ ++ RRCrtcPtr randr_crtc = xf86CompatRRCrtc(pScrn); ++ int size; ++ ++ if (!randr_crtc) ++ return Success; ++ ++ size = max(0, randr_crtc->gammaSize); ++ if (!size) ++ return Success; ++ ++ init_one_component(randr_crtc->gammaRed, size, gamma.red); ++ init_one_component(randr_crtc->gammaGreen, size, gamma.green); ++ init_one_component(randr_crtc->gammaBlue, size, gamma.blue); ++ xf86RandR12CrtcSetGamma(xf86ScrnToScreen(pScrn), randr_crtc); ++ ++ pScrn->gamma = gamma; ++ ++ return Success; ++} ++ + static Bool + xf86RandR12EnterVT(ScrnInfoPtr pScrn) + { +@@ -2123,6 +2152,7 @@ xf86RandR12Init12(ScreenPtr pScreen) + rp->rrProviderDestroy = xf86RandR14ProviderDestroy; + + pScrn->PointerMoved = xf86RandR12PointerMoved; ++ pScrn->ChangeGamma = xf86RandR12ChangeGamma; + + randrp->orig_EnterVT = pScrn->EnterVT; + pScrn->EnterVT = xf86RandR12EnterVT; +-- +2.9.3 + +From e5a9f1e6ea0b99462d8d305bf4836128f1b12562 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Fri, 1 Jul 2016 17:36:02 +0200 +Subject: [PATCH xserver v2 05/14] glx: Always enable EXT_texture_from_pixmap + for DRI swrast glx + +Prior to commit f95645c6f700 ("glx: Don't enable EXT_texture_from_pixmap +unconditionally") DRI glx would always advertise EXT_texture_from_pixmap. + +That commit moved the setting of the extension in the extension bits from +__glXInitExtensionEnableBits to its callers so that +__glXInitExtensionEnableBits can be used more generally, but at the same +time made the setting of EXT_texture_from_pixmap conditionally on +__DRI_TEX_BUFFER being present. + +This has result in an unintended behavior change which breaks e.g. +compositors running on llvmpipe. This commit makes the DRI swrast glx code +advertise EXT_texture_from_pixmap unconditionally again fixing this. + +Fixes: f95645c6f700 ("glx: Don't enable EXT_texture_from_pixmap unconditionally") +Signed-off-by: Hans de Goede +--- +Changes in v2: +-Only add unconditional advertising of GLX_EXT_texture_from_pixmap + to glxdriswrast.c, do not also add it to glxdri2.c +--- + glx/glxdriswrast.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/glx/glxdriswrast.c b/glx/glxdriswrast.c +index ac8bda8..f5c0c9f 100644 +--- a/glx/glxdriswrast.c ++++ b/glx/glxdriswrast.c +@@ -396,6 +396,7 @@ initializeExtensions(__GLXscreen * screen) + __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_framebuffer_sRGB"); + __glXEnableExtension(screen->glx_enable_bits, "GLX_ARB_fbconfig_float"); + __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_fbconfig_packed_float"); ++ __glXEnableExtension(screen->glx_enable_bits, "GLX_EXT_texture_from_pixmap"); + + extensions = dri->core->getExtensions(dri->driScreen); + +@@ -407,8 +408,6 @@ initializeExtensions(__GLXscreen * screen) + + if (strcmp(extensions[i]->name, __DRI_TEX_BUFFER) == 0) { + dri->texBuffer = (const __DRItexBufferExtension *) extensions[i]; +- __glXEnableExtension(screen->glx_enable_bits, +- "GLX_EXT_texture_from_pixmap\n"); + } + + #ifdef __DRI2_FLUSH_CONTROL +-- +2.9.3 + +From 42b9061808359916f8668d1247319246126c30db Mon Sep 17 00:00:00 2001 +From: Adam Jackson +Date: Tue, 5 Jul 2016 13:07:09 -0400 +Subject: [PATCH xserver v2 06/14] xephyr: Don't crash if the server advertises + zero xv adaptors + +Useless as an XVideo implementation with zero adaptors might be, it's +apparently a thing in the wild. Catch this case and bail out of xv init +if it happens. + +Signed-off-by: Adam Jackson +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +--- + hw/kdrive/ephyr/ephyrvideo.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/kdrive/ephyr/ephyrvideo.c b/hw/kdrive/ephyr/ephyrvideo.c +index 56a5ff1..31b1eee 100644 +--- a/hw/kdrive/ephyr/ephyrvideo.c ++++ b/hw/kdrive/ephyr/ephyrvideo.c +@@ -462,7 +462,7 @@ ephyrXVPrivQueryHostAdaptors(EphyrXVPriv * a_this) + + if (a_this->host_adaptors) + a_this->num_adaptors = a_this->host_adaptors->num_adaptors; +- if (a_this->num_adaptors < 0) { ++ if (a_this->num_adaptors <= 0) { + EPHYR_LOG_ERROR("failed to get number of host adaptors\n"); + goto out; + } +-- +2.9.3 + +From 6c232ba62aacaa7724faa8b2a0fc664bbe4d0c44 Mon Sep 17 00:00:00 2001 +From: David CARLIER +Date: Fri, 23 Sep 2016 14:17:12 +0300 +Subject: [PATCH xserver v2 07/14] xfree86: small memory leaks fixes + +A couple of memory leaks fixes and avoiding bit shifting on an +unitialized value. + +[hdegoede@redhat.com: Split out some non free fixes in separate patches] +[hdegoede@redhat.com: Don't touch ancient (and weird) os/rpcauth.c code] +Signed-off-by: Hans de Goede +--- + hw/xfree86/ddc/ddc.c | 2 +- + hw/xfree86/drivers/modesetting/driver.c | 3 ++- + hw/xfree86/utils/gtf/gtf.c | 2 ++ + 3 files changed, 5 insertions(+), 2 deletions(-) + +diff --git a/hw/xfree86/ddc/ddc.c b/hw/xfree86/ddc/ddc.c +index ee533db..b82dfc1 100644 +--- a/hw/xfree86/ddc/ddc.c ++++ b/hw/xfree86/ddc/ddc.c +@@ -149,7 +149,7 @@ GetEDID_DDC1(unsigned int *s_ptr) + return NULL; + s_end = s_ptr + NUM; + s_pos = s_ptr + s_start; +- d_block = malloc(EDID1_LEN); ++ d_block = calloc(1, EDID1_LEN); + if (!d_block) + return NULL; + d_pos = d_block; +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index d37a42a..216388f 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -847,7 +847,7 @@ ms_get_drm_master_fd(ScrnInfoPtr pScrn) + if (pEnt->location.type == BUS_PCI) { + ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); + if (ms->PciInfo) { +- BusID = malloc(64); ++ BusID = XNFalloc(64); + sprintf(BusID, "PCI:%d:%d:%d", + #if XSERVER_LIBPCIACCESS + ((ms->PciInfo->domain << 8) | ms->PciInfo->bus), +@@ -860,6 +860,7 @@ ms_get_drm_master_fd(ScrnInfoPtr pScrn) + ); + } + ms->fd = drmOpen(NULL, BusID); ++ free(BusID); + } + else { + const char *devicename; +diff --git a/hw/xfree86/utils/gtf/gtf.c b/hw/xfree86/utils/gtf/gtf.c +index e88387d..c31bc8f 100644 +--- a/hw/xfree86/utils/gtf/gtf.c ++++ b/hw/xfree86/utils/gtf/gtf.c +@@ -692,6 +692,8 @@ main(int argc, char *argv[]) + if (o->fbmode) + print_fb_mode(m); + ++ free(m); ++ + return 0; + + } +-- +2.9.3 + +From 74d881897119f84f8d1cd1333dd5496a6672e899 Mon Sep 17 00:00:00 2001 +From: Kyle Guinn +Date: Fri, 23 Sep 2016 15:03:34 +0300 +Subject: [PATCH xserver v2 08/14] xfree86: Fix null pointer dereference + +Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=93675 +Signed-off-by: Kyle Guinn +[hdegoede@redhat.com: Simplify by adding 2 if conds together with &&] +Signed-off-by: Hans de Goede +--- + hw/xfree86/i2c/xf86i2c.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/hw/xfree86/i2c/xf86i2c.c b/hw/xfree86/i2c/xf86i2c.c +index 2a8b8df..22109cf 100644 +--- a/hw/xfree86/i2c/xf86i2c.c ++++ b/hw/xfree86/i2c/xf86i2c.c +@@ -614,7 +614,7 @@ xf86CreateI2CDevRec(void) + void + xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc) + { +- if (d) { ++ if (d && d->pI2CBus) { + I2CDevPtr *p; + + /* Remove this from the list of active I2C devices. */ +@@ -628,10 +628,10 @@ xf86DestroyI2CDevRec(I2CDevPtr d, Bool unalloc) + xf86DrvMsg(d->pI2CBus->scrnIndex, X_INFO, + "I2C device \"%s:%s\" removed.\n", + d->pI2CBus->BusName, d->DevName); +- +- if (unalloc) +- free(d); + } ++ ++ if (unalloc) ++ free(d); + } + + /* I2C transmissions are related to an I2CDevRec you must link to a +-- +2.9.3 + +From 5476dc2b99a7ed52281a39f9fbae4032e35e1923 Mon Sep 17 00:00:00 2001 +From: Laszlo Ersek +Date: Wed, 7 Sep 2016 15:08:06 +0200 +Subject: [PATCH xserver v2 09/14] xfree86: recognize primary BUS_PCI device in + xf86IsPrimaryPlatform() + +The new platform bus code and the old PCI bus code overlap. Platform bus +can handle any type of device, including PCI devices, whereas the PCI code +can only handle PCI devices. Some drivers only support the old style +PCI-probe methods, but the primary device detection code is server based, +not driver based; so we might end up with a primary device which only has +a PCI bus-capable driver, but was detected as primary by the platform +code, or the other way around. + +(The above paragraph was shamelessly stolen from Hans de Goede, and +customized.) + +The latter case applies to QEMU's virtio-gpu-pci device: it is detected as +a BUS_PCI primary device, but we actually probe it first (with the +modesetting driver) through xf86platformProbeDev(). The +xf86IsPrimaryPlatform() function doesn't recognize the device as primary +(it bails out as soon as it sees BUS_PCI); instead, we add the device as a +secondary graphics card under "autoAddGPU". In turn, the success of this +automatic probing-as-GPU prevents xf86CallDriverProbe() from proceeding to +the PCI probing. + +The result is that the server exits with no primary devices detected. + +Commit cf66471353ac ("xfree86: use udev to provide device enumeration for +kms devices (v10)") added "cross-bus" matching to xf86IsPrimaryPci(). Port +that now to xf86IsPrimaryPlatform(), so that we can probe virtio-gpu-pci +as a primary card in platform bus code. + +Cc: Adam Jackson +Cc: Dave Airlie +Cc: Hans de Goede +Cc: Keith Packard +Cc: Marcin Juszkiewicz +Signed-off-by: Laszlo Ersek +Tested-By: Marcin Juszkiewicz +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index 96895a6..71f8df1 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -114,7 +114,15 @@ xf86_find_platform_device_by_devnum(int major, int minor) + static Bool + xf86IsPrimaryPlatform(struct xf86_platform_device *plat) + { +- return ((primaryBus.type == BUS_PLATFORM) && (plat == primaryBus.id.plat)); ++ if (primaryBus.type == BUS_PLATFORM) ++ return plat == primaryBus.id.plat; ++#ifdef XSERVER_LIBPCIACCESS ++ if (primaryBus.type == BUS_PCI) ++ if (plat->pdev) ++ if (MATCH_PCI_DEVICES(primaryBus.id.pci, plat->pdev)) ++ return TRUE; ++#endif ++ return FALSE; + } + + static void +-- +2.9.3 + +From 3790746a3135cb2dfcf3cb8a1b710c81821ae9dc Mon Sep 17 00:00:00 2001 +From: Qiang Yu +Date: Thu, 8 Sep 2016 21:24:58 +0800 +Subject: [PATCH xserver v2 10/14] config: fix GPUDevice fail when AutoAddGPU + off + BusID +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +This fix is for the following xorg.conf can work: + +Section "ServerFlags" + Option "AutoAddGPU" "off" +EndSection + +Section "Device" + Identifier "Amd" + Driver "ati" + BusID "PCI:1:0:0" +EndSection + +Section "Device" + Identifier "Intel" + Driver "modesetting" + BusID "pci:0:2:0" +EndSection + +Section "Screen" + Identifier "Screen0" + Device "Intel" + GPUDevice "Amd" +EndSection + +Without AutoAddGPU off, modesetting DDX will also be loaded +for GPUDevice. + +Signed-off-by: Qiang Yu +Reviewed-by: Michel Dänzer +Signed-off-by: Hans de Goede +--- + hw/xfree86/common/xf86platformBus.c | 18 +++++++++++++++--- + 1 file changed, 15 insertions(+), 3 deletions(-) + +diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c +index 71f8df1..39fb1dd 100644 +--- a/hw/xfree86/common/xf86platformBus.c ++++ b/hw/xfree86/common/xf86platformBus.c +@@ -426,6 +426,19 @@ probeSingleDevice(struct xf86_platform_device *dev, DriverPtr drvp, GDevPtr gdev + return foundScreen; + } + ++static Bool ++isGPUDevice(GDevPtr gdev) ++{ ++ int i; ++ ++ for (i = 0; i < gdev->myScreenSection->num_gpu_devices; i++) { ++ if (gdev == gdev->myScreenSection->gpu_devices[i]) ++ return TRUE; ++ } ++ ++ return FALSE; ++} ++ + int + xf86platformProbeDev(DriverPtr drvp) + { +@@ -458,9 +471,8 @@ xf86platformProbeDev(DriverPtr drvp) + if (j == xf86_num_platform_devices) + continue; + +- foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, devList[i], 0); +- if (!foundScreen) +- continue; ++ foundScreen = probeSingleDevice(&xf86_platform_devices[j], drvp, devList[i], ++ isGPUDevice(devList[i]) ? PLATFORM_PROBE_GPU_SCREEN : 0); + } + + /* if autoaddgpu devices is enabled then go find any unclaimed platform +-- +2.9.3 + +From 68fe9338a4c41863faa76357309cffd5805daeef Mon Sep 17 00:00:00 2001 +From: Daniel Martin +Date: Fri, 11 Dec 2015 12:05:22 +0100 +Subject: [PATCH xserver v2 11/14] modesetting: Consume all available udev + events at once + +We get multiple udev events for actions like docking a laptop into its +station or plugging a monitor to the station. By consuming as much +events as we can, we reduce the number of output re-evalutions. + +I.e. having a Lenovo X250 in a ThinkPad Ultra Dock and plugging a +monitor to the station generates 5 udev events. Or having 2 monitors +attached to the station and docking the laptop generates 7 events. + +It depends on the timing how many events can consumed at once. + +Signed-off-by: Daniel Martin +[hdegoede@redhat.com: Keep goto out so that we always call RRGetInfo()] +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +--- + hw/xfree86/drivers/modesetting/drmmode_display.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index 6b933e4..b895d62 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -2269,11 +2269,14 @@ drmmode_handle_uevents(int fd, void *closure) + drmModeResPtr mode_res; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn); + int i, j; +- Bool found; ++ Bool found = FALSE; + Bool changed = FALSE; + +- dev = udev_monitor_receive_device(drmmode->uevent_monitor); +- if (!dev) ++ while ((dev = udev_monitor_receive_device(drmmode->uevent_monitor))) { ++ udev_device_unref(dev); ++ found = TRUE; ++ } ++ if (!found) + return; + + mode_res = drmModeGetResources(drmmode->fd); +@@ -2339,7 +2342,6 @@ out_free_res: + drmModeFreeResources(mode_res); + out: + RRGetInfo(xf86ScrnToScreen(scrn), TRUE); +- udev_device_unref(dev); + } + #endif + +-- +2.9.3 + +From 351c9ed4f1720dc4789af272d1477e813732ce5a Mon Sep 17 00:00:00 2001 +From: Michael Thayer +Date: Fri, 16 Sep 2016 17:51:25 +0200 +Subject: [PATCH xserver v2 12/14] modesetting: only fall back to + drmModeSetCursor() on -EINVAL + +This change effectively reverts commit 074cf58. We were falling back from +drmModeSetCursor2() to drmModeSetCursor() whenever the first failed. This +fall-back only makes sense on pre-mid-2013 kernels which implemented the +cursor_set hook but not cursor_set2, and in this case the call to +drmModeSetCursor2() will always return -EINVAL. Specifically, a return +value of -ENXIO usually means that neither are supported. + +Signed-off-by: Michael Thayer +[hdegoede@redhat.com: initialize ret to -EINVAL] +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +--- + hw/xfree86/drivers/modesetting/drmmode_display.c | 12 ++++++++---- + 1 file changed, 8 insertions(+), 4 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index b895d62..61a0e27 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -756,7 +756,7 @@ drmmode_set_cursor(xf86CrtcPtr crtc) + drmmode_ptr drmmode = drmmode_crtc->drmmode; + uint32_t handle = drmmode_crtc->cursor_bo->handle; + modesettingPtr ms = modesettingPTR(crtc->scrn); +- int ret; ++ int ret = -EINVAL; + + if (!drmmode_crtc->set_cursor2_failed) { + CursorPtr cursor = xf86CurrentCursor(crtc->scrn->pScreen); +@@ -768,11 +768,15 @@ drmmode_set_cursor(xf86CrtcPtr crtc) + if (!ret) + return TRUE; + +- drmmode_crtc->set_cursor2_failed = TRUE; ++ /* -EINVAL can mean that an old kernel supports drmModeSetCursor but ++ * not drmModeSetCursor2, though it can mean other things too. */ ++ if (ret == -EINVAL) ++ drmmode_crtc->set_cursor2_failed = TRUE; + } + +- ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, handle, +- ms->cursor_width, ms->cursor_height); ++ if (ret == -EINVAL) ++ ret = drmModeSetCursor(drmmode->fd, drmmode_crtc->mode_crtc->crtc_id, ++ handle, ms->cursor_width, ms->cursor_height); + + if (ret) { + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); +-- +2.9.3 + +From eeabe942ba61910dc28b83718aca309e0f99ec5a Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Fri, 23 Sep 2016 14:06:52 +0300 +Subject: [PATCH xserver v2 13/14] Xext: Fix a memory leak + +Based on: https://patchwork.freedesktop.org/patch/85636/ + +Rewritten to also free the resources allocated by +panoramix_setup_ids(). + +Signed-off-by: Hans de Goede +Reviewed-by: Emi Velikov +--- + Xext/shm.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/Xext/shm.c b/Xext/shm.c +index 125000f..1b622e3 100644 +--- a/Xext/shm.c ++++ b/Xext/shm.c +@@ -991,7 +991,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client) + RT_PIXMAP, pMap, RT_NONE, NULL, DixCreateAccess); + if (result != Success) { + pDraw->pScreen->DestroyPixmap(pMap); +- return result; ++ break; + } + dixSetPrivate(&pMap->devPrivates, shmPixmapPrivateKey, shmdesc); + shmdesc->refcnt++; +@@ -1008,7 +1008,7 @@ ProcPanoramiXShmCreatePixmap(ClientPtr client) + } + } + +- if (result == BadAlloc) { ++ if (result != Success) { + while (j--) + FreeResource(newPix->info[j].id, RT_NONE); + free(newPix); +-- +2.9.3 + +From b2a438f6548a032c77bc54f7b52e683737b6756e Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Fri, 23 Sep 2016 14:11:52 +0300 +Subject: [PATCH xserver v2 14/14] XF86VidMode: Fix free() on walked pointer + +Based on: https://patchwork.freedesktop.org/patch/85636/ + +Rewritten to just not walk the pointer. + +Signed-off-by: Hans de Goede +Reviewed-by: Emi Velikov +--- + Xext/vidmode.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/Xext/vidmode.c b/Xext/vidmode.c +index 499a2a8..ea3ad13 100644 +--- a/Xext/vidmode.c ++++ b/Xext/vidmode.c +@@ -1364,7 +1364,7 @@ ProcVidModeGetDotClocks(ClientPtr client) + WriteToClient(client, sizeof(xXF86VidModeGetDotClocksReply), &rep); + if (!ClockProg) { + for (n = 0; n < numClocks; n++) { +- dotclock = *Clocks++; ++ dotclock = Clocks[n]; + if (client->swapped) { + WriteSwappedDataToClient(client, 4, (char *) &dotclock); + } +-- +2.9.3 + diff --git a/xserver-autobind-hotplug.patch b/xserver-autobind-hotplug.patch index 07395b0..43d8e66 100644 --- a/xserver-autobind-hotplug.patch +++ b/xserver-autobind-hotplug.patch @@ -1,32 +1,136 @@ -From cd6f931fb06f825f246222a4362fbf728f8dce73 Mon Sep 17 00:00:00 2001 +From 5b6faa0534453ea362de32a5bda0c4466c8e45b9 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 17 Aug 2012 09:49:24 +1000 -Subject: [PATCH] autobind GPUs to the screen, (v3) +Subject: [PATCH xserver v2] autobind GPUs to the screen -this is racy and really not what we want for hotplug going forward, -but until DE support is in GNOME its probably for the best. +This is a modified version of a patch we've been carry-ing in Fedora and +RHEL for years now. This patch automatically adds secondary GPUs to the +master as output sink / offload source making e.g. the use of +slave-outputs just work, with requiring the user to manually run +"xrandr --setprovideroutputsource" before he can hookup an external +monitor to his hybrid graphics laptop. -v2: fix if config or slave config is NULL -v3: fix multi useful slaves -DO NOT UPSTREAM. +There is one problem with this patch, which is why it was not upstreamed +before. What to do when a secondary GPU gets detected really is a policy +decission (e.g. one may want to autobind PCI GPUs but not USB ones) and +as such should be under control of the Desktop Environment. + +Unconditionally adding autobinding support to the xserver will result +in races between the DE dealing with the hotplug of a secondary GPU +and the server itself dealing with it. + +However we've waited for years for any Desktop Environments to actually +start doing some sort of autoconfiguration of secondary GPUs and there +is still not a single DE dealing with this, so I believe that it is +time to upstream this now. + +To avoid potential future problems if any DEs get support for doing +secondary GPU configuration themselves, the new autobind functionality +is made optional. Since no DEs currently support doing this themselves it +is enabled by default. When DEs grow support for doing this themselves +they can disable the servers autobinding through the servers cmdline or a +xorg.conf snippet. Signed-off-by: Dave Airlie +[hdegoede@redhat.com: Make configurable, submit upstream] +Signed-off-by: Hans de Goede +--- +Changes in v2: +-Make the default enabled instead of installing a xorg.conf + snippet which enables it unconditionally --- - hw/xfree86/common/xf86Init.c | 12 ++++++++++++ - hw/xfree86/common/xf86platformBus.c | 3 +++ - hw/xfree86/modes/xf86Crtc.c | 32 ++++++++++++++++++++++++++++++++ - 3 files changed, 47 insertions(+) + hw/xfree86/common/xf86Config.c | 19 +++++++++++++++++++ + hw/xfree86/common/xf86Globals.c | 2 ++ + hw/xfree86/common/xf86Init.c | 16 ++++++++++++++++ + hw/xfree86/common/xf86Priv.h | 1 + + hw/xfree86/common/xf86Privstr.h | 1 + + hw/xfree86/common/xf86platformBus.c | 2 ++ + hw/xfree86/man/Xorg.man | 7 +++++++ + hw/xfree86/man/xorg.conf.man | 6 ++++++ + hw/xfree86/modes/xf86Crtc.c | 28 ++++++++++++++++++++++++++++ + hw/xfree86/modes/xf86Crtc.h | 3 +++ + 10 files changed, 85 insertions(+) +diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c +index 560e2ea..31b34a2 100644 +--- a/hw/xfree86/common/xf86Config.c ++++ b/hw/xfree86/common/xf86Config.c +@@ -720,6 +720,7 @@ typedef enum { + FLAG_DRI2, + FLAG_USE_SIGIO, + FLAG_AUTO_ADD_GPU, ++ FLAG_AUTO_BIND_GPU, + FLAG_MAX_CLIENTS, + FLAG_IGLX, + } FlagValues; +@@ -781,6 +782,8 @@ static OptionInfoRec FlagOptions[] = { + {0}, FALSE}, + {FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN, + {0}, FALSE}, ++ {FLAG_AUTO_BIND_GPU, "AutoBindGPU", OPTV_BOOLEAN, ++ {0}, FALSE}, + {FLAG_MAX_CLIENTS, "MaxClients", OPTV_INTEGER, + {0}, FALSE }, + {FLAG_IGLX, "IndirectGLX", OPTV_BOOLEAN, +@@ -860,6 +863,22 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) + } + xf86Msg(from, "%sutomatically adding GPU devices\n", + xf86Info.autoAddGPU ? "A" : "Not a"); ++ ++ if (xf86AutoBindGPUDisabled) { ++ xf86Info.autoBindGPU = FALSE; ++ from = X_CMDLINE; ++ } ++ else if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_BIND_GPU)) { ++ xf86GetOptValBool(FlagOptions, FLAG_AUTO_BIND_GPU, ++ &xf86Info.autoBindGPU); ++ from = X_CONFIG; ++ } ++ else { ++ from = X_DEFAULT; ++ } ++ xf86Msg(from, "%sutomatically binding GPU devices\n", ++ xf86Info.autoBindGPU ? "A" : "Not a"); ++ + /* + * Set things up based on the config file information. Some of these + * settings may be overridden later when the command line options are +diff --git a/hw/xfree86/common/xf86Globals.c b/hw/xfree86/common/xf86Globals.c +index 07cfabf..072c3fc 100644 +--- a/hw/xfree86/common/xf86Globals.c ++++ b/hw/xfree86/common/xf86Globals.c +@@ -136,6 +136,7 @@ xf86InfoRec xf86Info = { + #else + .autoAddGPU = FALSE, + #endif ++ .autoBindGPU = TRUE, + }; + + const char *xf86ConfigFile = NULL; +@@ -196,6 +197,7 @@ Bool xf86FlipPixels = FALSE; + Gamma xf86Gamma = { 0.0, 0.0, 0.0 }; + + Bool xf86AllowMouseOpenFail = FALSE; ++Bool xf86AutoBindGPUDisabled = FALSE; + + #ifdef XF86VIDMODE + Bool xf86VidModeDisabled = FALSE; diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c -index 6282252..dc33ad1 100644 +index a544b65..70c5b7a 100644 --- a/hw/xfree86/common/xf86Init.c +++ b/hw/xfree86/common/xf86Init.c -@@ -361,6 +361,16 @@ xf86CreateRootWindow(WindowPtr pWin) - return ret; +@@ -76,6 +76,7 @@ + #include "xf86DDC.h" + #include "xf86Xinput.h" + #include "xf86InPriv.h" ++#include "xf86Crtc.h" + #include "picturestr.h" + + #include "xf86Bus.h" +@@ -298,6 +299,15 @@ xf86PrivsElevated(void) } -+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master); -+static void + static void +xf86AutoConfigOutputDevices(void) +{ + int i; @@ -35,10 +139,11 @@ index 6282252..dc33ad1 100644 + xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]); +} + - static void ++static void InstallSignalHandlers(void) { -@@ -949,6 +959,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) + /* +@@ -871,6 +881,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) for (i = 0; i < xf86NumGPUScreens; i++) AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); @@ -46,21 +151,55 @@ index 6282252..dc33ad1 100644 + xf86VGAarbiterWrapFunctions(); if (sigio_blocked) - OsReleaseSIGIO(); + input_unlock(); +@@ -1389,6 +1401,10 @@ ddxProcessArgument(int argc, char **argv, int i) + xf86Info.iglxFrom = X_CMDLINE; + return 0; + } ++ if (!strcmp(argv[i], "-noautoBindGPU")) { ++ xf86AutoBindGPUDisabled = TRUE; ++ return 1; ++ } + + /* OS-specific processing */ + return xf86ProcessArgument(argc, argv, i); +diff --git a/hw/xfree86/common/xf86Priv.h b/hw/xfree86/common/xf86Priv.h +index c1f8a18..9a3d0df 100644 +--- a/hw/xfree86/common/xf86Priv.h ++++ b/hw/xfree86/common/xf86Priv.h +@@ -46,6 +46,7 @@ + extern _X_EXPORT const char *xf86ConfigFile; + extern _X_EXPORT const char *xf86ConfigDir; + extern _X_EXPORT Bool xf86AllowMouseOpenFail; ++extern _X_EXPORT Bool xf86AutoBindGPUDisabled; + + #ifdef XF86VIDMODE + extern _X_EXPORT Bool xf86VidModeDisabled; +diff --git a/hw/xfree86/common/xf86Privstr.h b/hw/xfree86/common/xf86Privstr.h +index 9e327b9..a0a98aa 100644 +--- a/hw/xfree86/common/xf86Privstr.h ++++ b/hw/xfree86/common/xf86Privstr.h +@@ -104,6 +104,7 @@ typedef struct { + MessageType dri2From; + + Bool autoAddGPU; ++ Bool autoBindGPU; + } xf86InfoRec, *xf86InfoPtr; + + #ifdef DPMSExtension diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c -index 33b2b7d..be3bdd9 100644 +index 39fb1dd..3e2264f 100644 --- a/hw/xfree86/common/xf86platformBus.c +++ b/hw/xfree86/common/xf86platformBus.c -@@ -393,6 +393,8 @@ xf86platformProbeDev(DriverPtr drvp) - return foundScreen; - } +@@ -48,6 +48,7 @@ + #include "Pci.h" + #include "xf86platformBus.h" + #include "xf86Config.h" ++#include "xf86Crtc.h" -+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master); -+ - int - xf86platformAddDevice(int index) - { -@@ -465,6 +467,7 @@ xf86platformAddDevice(int index) + #include "randrstr.h" + int platformSlotClaimed; +@@ -560,6 +561,7 @@ xf86platformAddDevice(int index) } /* attach unbound to 0 protocol screen */ AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen); @@ -68,22 +207,58 @@ index 33b2b7d..be3bdd9 100644 RRResourcesChanged(xf86Screens[0]->pScreen); RRTellChanged(xf86Screens[0]->pScreen); +diff --git a/hw/xfree86/man/Xorg.man b/hw/xfree86/man/Xorg.man +index def9bfc..8df6b7d 100644 +--- a/hw/xfree86/man/Xorg.man ++++ b/hw/xfree86/man/Xorg.man +@@ -283,6 +283,13 @@ is a comma separated list of directories to search for + server modules. This option is only available when the server is run + as root (i.e, with real-uid 0). + .TP 8 ++.B \-noautoBindGPU ++Disable automatically setting secondary GPUs up as output sinks and offload ++sources. This is equivalent to setting the ++.B AutoBindGPU ++xorg.conf(__filemansuffix__) file option. To ++.B false. ++.TP 8 + .B \-nosilk + Disable Silken Mouse support. + .TP 8 +diff --git a/hw/xfree86/man/xorg.conf.man b/hw/xfree86/man/xorg.conf.man +index 94b199e..bdc121a 100644 +--- a/hw/xfree86/man/xorg.conf.man ++++ b/hw/xfree86/man/xorg.conf.man +@@ -676,6 +676,12 @@ Enabled by default. + If this option is disabled, then no GPU devices will be added from the udev + backend. Enabled by default. (May need to be disabled to setup Xinerama). + .TP 7 ++.BI "Option \*qAutoBindGPU\*q \*q" boolean \*q ++If enabled then secondary GPUs will be automatically set up as output-sinks and ++offload-sources. Making e.g. laptop outputs connected only to the secondary ++GPU directly available for use without needing to run ++"xrandr --setprovideroutputsource". Enabled by default. ++.TP 7 + .BI "Option \*qLog\*q \*q" string \*q + This option controls whether the log is flushed and/or synced to disk after + each message. diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c -index 4726f2a..e83ea13 100644 +index 966a168..4960678 100644 --- a/hw/xfree86/modes/xf86Crtc.c +++ b/hw/xfree86/modes/xf86Crtc.c -@@ -3440,3 +3440,35 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn) +@@ -3462,3 +3462,31 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn) crtc->x = crtc->y = 0; } } + -+ +void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master) +{ + RRProviderPtr master_provider; + xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(master); + xf86CrtcConfigPtr slave_config = XF86_CRTC_CONFIG_PTR(pScrn); -+ Bool unbound = FALSE; ++ ++ if (!xf86Info.autoBindGPU) ++ return; + + if (!config || !slave_config) + return; @@ -91,23 +266,30 @@ index 4726f2a..e83ea13 100644 + master_provider = config->randr_provider; + + if ((master->capabilities & RR_Capability_SinkOffload) && -+ pScrn->capabilities & RR_Capability_SourceOffload) { -+ /* source offload */ -+ -+ DetachUnboundGPU(pScrn->pScreen); -+ unbound = TRUE; ++ pScrn->capabilities & RR_Capability_SourceOffload) { ++ /* source offload */ + AttachOffloadGPU(master->pScreen, pScrn->pScreen); + slave_config->randr_provider->offload_sink = master_provider; + } + if ((master->capabilities & RR_Capability_SourceOutput) && + pScrn->capabilities & RR_Capability_SinkOutput) { + /* sink offload */ -+ if (!unbound) -+ DetachUnboundGPU(pScrn->pScreen); + AttachOutputGPU(master->pScreen, pScrn->pScreen); + slave_config->randr_provider->output_source = master_provider; + } +} +diff --git a/hw/xfree86/modes/xf86Crtc.h b/hw/xfree86/modes/xf86Crtc.h +index 14ba9d7..6cf7e89 100644 +--- a/hw/xfree86/modes/xf86Crtc.h ++++ b/hw/xfree86/modes/xf86Crtc.h +@@ -1051,4 +1051,7 @@ xf86ProviderSetup(ScrnInfoPtr scrn, + extern _X_EXPORT void + xf86DetachAllCrtc(ScrnInfoPtr scrn); + ++extern _X_EXPORT void ++xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master); ++ + #endif /* _XF86CRTC_H_ */ -- -1.8.3.1 +2.9.3 diff --git a/xserver-prime-fixes.patch b/xserver-prime-fixes.patch deleted file mode 100644 index 4f5ee35..0000000 --- a/xserver-prime-fixes.patch +++ /dev/null @@ -1,759 +0,0 @@ -From 94cc6e0424a08d007cc0a8cabcb7d2724ba0f740 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Tue, 14 Jun 2016 11:58:01 +0200 -Subject: [PATCH v2 xserver 01/11] modesetting: Load on GPU-s with 0 outputs - -In newer laptops with switchable graphics, the GPU may have 0 outputs, -in this case the modesetting driver should still load if the GPU is -SourceOffload capable, so that it can be used as an offload source provider. - -Signed-off-by: Hans de Goede -Reviewed-by: Eric Engestrom -(cherry picked from commit 60ad701a6a8cb9f1eacb72acfe2cb8d3b7a865dc) ---- - hw/xfree86/drivers/modesetting/driver.c | 29 ++++++++++++++++++------ - hw/xfree86/drivers/modesetting/drmmode_display.c | 6 ++--- - 2 files changed, 24 insertions(+), 11 deletions(-) - -diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c -index 14f80b3..718966b 100644 ---- a/hw/xfree86/drivers/modesetting/driver.c -+++ b/hw/xfree86/drivers/modesetting/driver.c -@@ -215,14 +215,26 @@ open_hw(const char *dev) - } - - static int --check_outputs(int fd) -+check_outputs(int fd, int *count) - { - drmModeResPtr res = drmModeGetResources(fd); - int ret; - - if (!res) - return FALSE; -+ -+ if (count) -+ *count = res->count_connectors; -+ - ret = res->count_connectors > 0; -+#if defined DRM_CAP_PRIME && GLAMOR_HAS_GBM_LINEAR -+ if (ret == FALSE) { -+ uint64_t value = 0; -+ if (drmGetCap(fd, DRM_CAP_PRIME, &value) == 0 && -+ (value & DRM_PRIME_CAP_EXPORT)) -+ ret = TRUE; -+ } -+#endif - drmModeFreeResources(res); - return ret; - } -@@ -237,13 +249,13 @@ probe_hw(const char *dev, struct xf86_platform_device *platform_dev) - fd = xf86_platform_device_odev_attributes(platform_dev)->fd; - if (fd == -1) - return FALSE; -- return check_outputs(fd); -+ return check_outputs(fd, NULL); - } - #endif - - fd = open_hw(dev); - if (fd != -1) { -- int ret = check_outputs(fd); -+ int ret = check_outputs(fd, NULL); - - close(fd); - return ret; -@@ -286,7 +298,7 @@ probe_hw_pci(const char *dev, struct pci_device *pdev) - devid = ms_DRICreatePCIBusID(pdev); - - if (id && devid && !strcmp(id, devid)) -- ret = check_outputs(fd); -+ ret = check_outputs(fd, NULL); - - close(fd); - free(id); -@@ -787,7 +799,7 @@ PreInit(ScrnInfoPtr pScrn, int flags) - EntityInfoPtr pEnt; - uint64_t value = 0; - int ret; -- int bppflags; -+ int bppflags, connector_count; - int defaultdepth, defaultbpp; - - if (pScrn->numEntities != 1) -@@ -824,6 +836,9 @@ PreInit(ScrnInfoPtr pScrn, int flags) - return FALSE; - ms->drmmode.fd = ms->fd; - -+ if (!check_outputs(ms->fd, &connector_count)) -+ return FALSE; -+ - drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp); - if (defaultdepth == 24 && defaultbpp == 24) { - ms->drmmode.force_24_32 = TRUE; -@@ -915,7 +930,7 @@ PreInit(ScrnInfoPtr pScrn, int flags) - #ifdef DRM_CAP_PRIME - ret = drmGetCap(ms->fd, DRM_CAP_PRIME, &value); - if (ret == 0) { -- if (value & DRM_PRIME_CAP_IMPORT) { -+ if (connector_count && (value & DRM_PRIME_CAP_IMPORT)) { - pScrn->capabilities |= RR_Capability_SinkOutput; - if (ms->drmmode.glamor) - pScrn->capabilities |= RR_Capability_SinkOffload; -@@ -943,7 +958,7 @@ PreInit(ScrnInfoPtr pScrn, int flags) - } - } - -- if (pScrn->modes == NULL) { -+ if (!(pScrn->is_gpu && connector_count == 0) && pScrn->modes == NULL) { - xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n"); - return FALSE; - } -diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c -index 9c54310..cc78890 100644 ---- a/hw/xfree86/drivers/modesetting/drmmode_display.c -+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c -@@ -1657,10 +1657,8 @@ static Bool - drmmode_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height) - { - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); -- -- drmmode_crtc_private_ptr -- drmmode_crtc = xf86_config->crtc[0]->driver_private; -- drmmode_ptr drmmode = drmmode_crtc->drmmode; -+ modesettingPtr ms = modesettingPTR(scrn); -+ drmmode_ptr drmmode = &ms->drmmode; - drmmode_bo old_front; - Bool ret; - ScreenPtr screen = xf86ScrnToScreen(scrn); --- -2.9.3 - -From 228e0622ef654bb3918cb62da32a34ab910572cc Mon Sep 17 00:00:00 2001 -From: Hans De Goede -Date: Mon, 8 Aug 2016 14:53:59 +0200 -Subject: [PATCH v2 xserver 02/11] Fix Xorg -configure not working anymore - -Xorg -configure relies on the bus implementation, e.g. -xf86pciBus.c to call xf86AddBusDeviceToConfigure(). The new -xf86platformBus code does not have support for this. - -Almost all drivers support both the xf86platformBus and xf86pciBus -nowadays, and the generic xf86Bus xf86CallDriverProbe() function -prefers the new xf86platformBus probe method when available. - -Since the platformBus paths do not call xf86AddBusDeviceToConfigure() -this results in Xorg -configure failing with the following error: -"No devices to configure. Configuration failed.". - -Adding support for the xf86Configure code to xf86platformBus.c -is non trivial and since we advise users to normally run without -any Xorg.conf at all not worth the trouble. - -However some users still want to use Xorg -configure to generate a -template config file, this commit implements a minimal fix to make -things work again for PCI devices by skipping the platform -probe method when xf86DoConfigure is set. - -This has been tested on a system with integrated intel graphics, -with both the intel and modesetting drivers and restores Xorg -configure -functionality on both cases. - -Reviewed-by: Adam Jackson -Signed-off-by: Hans de Goede -(cherry picked from commit 48c5c23a1b250c7f9d7a1747c76e4669ebf752cf) ---- - hw/xfree86/common/xf86Bus.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c -index bd36fc5..5b93940 100644 ---- a/hw/xfree86/common/xf86Bus.c -+++ b/hw/xfree86/common/xf86Bus.c -@@ -78,7 +78,8 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only) - Bool foundScreen = FALSE; - - #ifdef XSERVER_PLATFORM_BUS -- if (drv->platformProbe != NULL) { -+ /* xf86platformBus.c does not support Xorg -configure */ -+ if (!xf86DoConfigure && drv->platformProbe != NULL) { - foundScreen = xf86platformProbeDev(drv); - } - if (ServerIsNotSeat0() && foundScreen) --- -2.9.3 - -From 18d9bb82a1ca97157bf9f6168c78c263f42df8cf Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 15 Aug 2016 10:44:57 +0200 -Subject: [PATCH v2 xserver 03/11] modesetting: ms_dri2_create_buffer: check - screen of existing front buffers - -If a frontbuffer drawable already has a pixmap, make sure it was created -on the right screen. - -Signed-off-by: Hans de Goede ---- - hw/xfree86/drivers/modesetting/dri2.c | 20 +++++++------------- - 1 file changed, 7 insertions(+), 13 deletions(-) - -diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c -index 83cb3e0..b810d59 100644 ---- a/hw/xfree86/drivers/modesetting/dri2.c -+++ b/hw/xfree86/drivers/modesetting/dri2.c -@@ -117,17 +117,6 @@ get_drawable_pixmap(DrawablePtr drawable) - return screen->GetWindowPixmap((WindowPtr) drawable); - } - --static PixmapPtr --get_front_buffer(DrawablePtr drawable) --{ -- PixmapPtr pixmap; -- -- pixmap = get_drawable_pixmap(drawable); -- pixmap->refcnt++; -- -- return pixmap; --} -- - static DRI2Buffer2Ptr - ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, - unsigned int format) -@@ -151,8 +140,13 @@ ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, - } - - pixmap = NULL; -- if (attachment == DRI2BufferFrontLeft) -- pixmap = get_front_buffer(drawable); -+ if (attachment == DRI2BufferFrontLeft) { -+ pixmap = get_drawable_pixmap(drawable); -+ if (pixmap && pixmap->drawable.pScreen != screen) -+ pixmap = NULL; -+ if (pixmap) -+ pixmap->refcnt++; -+ } - - if (pixmap == NULL) { - int pixmap_width = drawable->width; --- -2.9.3 - -From 80327f92743e8456f229a833faff996d762b3e93 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 15 Aug 2016 11:10:15 +0200 -Subject: [PATCH v2 xserver 04/11] modesetting: Remove some dead code - -The "if (pixmap) ..." block this commit removes is inside an -"if (pixmap == NULL) ..." block, so it will never execute. - -Signed-off-by: Hans de Goede ---- - hw/xfree86/drivers/modesetting/dri2.c | 2 -- - 1 file changed, 2 deletions(-) - -diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c -index b810d59..9bc56c2 100644 ---- a/hw/xfree86/drivers/modesetting/dri2.c -+++ b/hw/xfree86/drivers/modesetting/dri2.c -@@ -186,8 +186,6 @@ ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, - pixmap_cpp, - 0); - if (pixmap == NULL) { -- if (pixmap) -- screen->DestroyPixmap(pixmap); - free(private); - free(buffer); - return NULL; --- -2.9.3 - -From 7a99b5d0110ce3553e8d94b78f6a1a737f93e1a7 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Mon, 15 Aug 2016 12:02:54 +0200 -Subject: [PATCH v2 xserver 05/11] modesetting: Implement DRI2InfoRec version 9 - callbacks - -Implement the CreateBuffer2 / DestroyBuffer2 / CopyRegion2 DRI2InfoRec -version 9 callbacks, this is necessary for being an offload source -provider with DRI2. - -Signed-off-by: Hans de Goede ---- - hw/xfree86/drivers/modesetting/dri2.c | 64 ++++++++++++++++++++++++++++++----- - 1 file changed, 55 insertions(+), 9 deletions(-) - -diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c -index 9bc56c2..ed94d63 100644 ---- a/hw/xfree86/drivers/modesetting/dri2.c -+++ b/hw/xfree86/drivers/modesetting/dri2.c -@@ -118,10 +118,9 @@ get_drawable_pixmap(DrawablePtr drawable) - } - - static DRI2Buffer2Ptr --ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, -- unsigned int format) -+ms_dri2_create_buffer2(ScreenPtr screen, DrawablePtr drawable, -+ unsigned int attachment, unsigned int format) - { -- ScreenPtr screen = drawable->pScreen; - ScrnInfoPtr scrn = xf86ScreenToScrn(screen); - DRI2Buffer2Ptr buffer; - PixmapPtr pixmap; -@@ -218,6 +217,14 @@ ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, - return buffer; - } - -+static DRI2Buffer2Ptr -+ms_dri2_create_buffer(DrawablePtr drawable, unsigned int attachment, -+ unsigned int format) -+{ -+ return ms_dri2_create_buffer2(drawable->pScreen, drawable, attachment, -+ format); -+} -+ - static void - ms_dri2_reference_buffer(DRI2Buffer2Ptr buffer) - { -@@ -227,7 +234,8 @@ ms_dri2_reference_buffer(DRI2Buffer2Ptr buffer) - } - } - --static void ms_dri2_destroy_buffer(DrawablePtr drawable, DRI2Buffer2Ptr buffer) -+static void ms_dri2_destroy_buffer2(ScreenPtr unused, DrawablePtr unused2, -+ DRI2Buffer2Ptr buffer) - { - if (!buffer) - return; -@@ -245,28 +253,55 @@ static void ms_dri2_destroy_buffer(DrawablePtr drawable, DRI2Buffer2Ptr buffer) - } - } - -+static void ms_dri2_destroy_buffer(DrawablePtr drawable, DRI2Buffer2Ptr buffer) -+{ -+ ms_dri2_destroy_buffer2(NULL, drawable, buffer); -+} -+ - static void --ms_dri2_copy_region(DrawablePtr drawable, RegionPtr pRegion, -- DRI2BufferPtr destBuffer, DRI2BufferPtr sourceBuffer) -+ms_dri2_copy_region2(ScreenPtr screen, DrawablePtr drawable, RegionPtr pRegion, -+ DRI2BufferPtr destBuffer, DRI2BufferPtr sourceBuffer) - { - ms_dri2_buffer_private_ptr src_priv = sourceBuffer->driverPrivate; - ms_dri2_buffer_private_ptr dst_priv = destBuffer->driverPrivate; - PixmapPtr src_pixmap = src_priv->pixmap; - PixmapPtr dst_pixmap = dst_priv->pixmap; -- ScreenPtr screen = drawable->pScreen; - DrawablePtr src = (sourceBuffer->attachment == DRI2BufferFrontLeft) - ? drawable : &src_pixmap->drawable; - DrawablePtr dst = (destBuffer->attachment == DRI2BufferFrontLeft) - ? drawable : &dst_pixmap->drawable; -+ int off_x = 0, off_y = 0; -+ Bool translate = FALSE; - RegionPtr pCopyClip; - GCPtr gc; - -+ if (destBuffer->attachment == DRI2BufferFrontLeft && -+ drawable->pScreen != screen) { -+ dst = DRI2UpdatePrime(drawable, destBuffer); -+ if (!dst) -+ return; -+ if (dst != drawable) -+ translate = TRUE; -+ } -+ -+ if (translate && drawable->type == DRAWABLE_WINDOW) { -+#ifdef COMPOSITE -+ PixmapPtr pixmap = get_drawable_pixmap(drawable); -+ off_x = -pixmap->screen_x; -+ off_y = -pixmap->screen_y; -+#endif -+ off_x += drawable->x; -+ off_y += drawable->y; -+ } -+ - gc = GetScratchGC(dst->depth, screen); - if (!gc) - return; - - pCopyClip = REGION_CREATE(screen, NULL, 0); - REGION_COPY(screen, pCopyClip, pRegion); -+ if (translate) -+ REGION_TRANSLATE(screen, pCopyClip, off_x, off_y); - (*gc->funcs->ChangeClip) (gc, CT_REGION, pCopyClip, 0); - ValidateGC(dst, gc); - -@@ -282,11 +317,19 @@ ms_dri2_copy_region(DrawablePtr drawable, RegionPtr pRegion, - gc->ops->CopyArea(src, dst, gc, - 0, 0, - drawable->width, drawable->height, -- 0, 0); -+ off_x, off_y); - - FreeScratchGC(gc); - } - -+static void -+ms_dri2_copy_region(DrawablePtr drawable, RegionPtr pRegion, -+ DRI2BufferPtr destBuffer, DRI2BufferPtr sourceBuffer) -+{ -+ ms_dri2_copy_region2(drawable->pScreen, drawable, pRegion, destBuffer, -+ sourceBuffer); -+} -+ - static uint64_t - gettime_us(void) - { -@@ -827,13 +870,16 @@ ms_dri2_screen_init(ScreenPtr screen) - info.driverName = NULL; /* Compat field, unused. */ - info.deviceName = drmGetDeviceNameFromFd(ms->fd); - -- info.version = 4; -+ info.version = 9; - info.CreateBuffer = ms_dri2_create_buffer; - info.DestroyBuffer = ms_dri2_destroy_buffer; - info.CopyRegion = ms_dri2_copy_region; - info.ScheduleSwap = ms_dri2_schedule_swap; - info.GetMSC = ms_dri2_get_msc; - info.ScheduleWaitMSC = ms_dri2_schedule_wait_msc; -+ info.CreateBuffer2 = ms_dri2_create_buffer2; -+ info.DestroyBuffer2 = ms_dri2_destroy_buffer2; -+ info.CopyRegion2 = ms_dri2_copy_region2; - - /* These two will be filled in by dri2.c */ - info.numDrivers = 0; --- -2.9.3 - -From 39ce336a223f2cdbffb3c774be70c9655f0de024 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Tue, 23 Aug 2016 12:18:56 +0200 -Subject: [PATCH v2 xserver 06/11] glamor: Add - glamor_shareable_fd_from_pixmap() - -Add glamor_shareable_fd_from_pixmap function to get dma-buf fds suitable -for sharing across GPUs (not using GPU specific tiling). - -This is necessary for the modesetting driver to correctly implement -the DRI2 SharePixmapBacking callback. - -Signed-off-by: Hans de Goede -Reviewed-by: Keith Packard ---- - glamor/glamor.c | 20 ++++++++++++++++++++ - glamor/glamor.h | 20 ++++++++++++++++++++ - 2 files changed, 40 insertions(+) - -diff --git a/glamor/glamor.c b/glamor/glamor.c -index 0cb73c4..f9020f0 100644 ---- a/glamor/glamor.c -+++ b/glamor/glamor.c -@@ -829,6 +829,26 @@ glamor_fd_from_pixmap(ScreenPtr screen, - return -1; - } - -+_X_EXPORT int -+glamor_shareable_fd_from_pixmap(ScreenPtr screen, -+ PixmapPtr pixmap, CARD16 *stride, CARD32 *size) -+{ -+ unsigned orig_usage_hint = pixmap->usage_hint; -+ int ret; -+ -+ /* -+ * The actual difference between a sharable and non sharable buffer -+ * is decided 4 call levels deep in glamor_make_pixmap_exportable() -+ * based on pixmap->usage_hint == CREATE_PIXMAP_USAGE_SHARED -+ * 2 of those calls are also exported API, so we cannot just add a flag. -+ */ -+ pixmap->usage_hint = CREATE_PIXMAP_USAGE_SHARED; -+ ret = glamor_fd_from_pixmap(screen, pixmap, stride, size); -+ pixmap->usage_hint = orig_usage_hint; -+ -+ return ret; -+} -+ - int - glamor_name_from_pixmap(PixmapPtr pixmap, CARD16 *stride, CARD32 *size) - { -diff --git a/glamor/glamor.h b/glamor/glamor.h -index 250dc83..e984092 100644 ---- a/glamor/glamor.h -+++ b/glamor/glamor.h -@@ -187,6 +187,26 @@ extern _X_EXPORT int glamor_fd_from_pixmap(ScreenPtr screen, - PixmapPtr pixmap, - CARD16 *stride, CARD32 *size); - -+/* @glamor_shareable_fd_from_pixmap: Get a dma-buf fd suitable for sharing -+ * with other GPUs from a pixmap. -+ * -+ * @screen: Current screen pointer. -+ * @pixmap: The pixmap from which we want the fd. -+ * @stride, @size: Pointers to fill the stride and size of the -+ * buffer associated to the fd. -+ * -+ * The returned fd will point to a buffer which is suitable for sharing -+ * across GPUs (not using GPU specific tiling). -+ * The pixmap and the buffer associated by the fd will share the same -+ * content. -+ * The pixmap's stride may be modified by this function. -+ * Returns the fd on success, -1 on error. -+ * */ -+extern _X_EXPORT int glamor_shareable_fd_from_pixmap(ScreenPtr screen, -+ PixmapPtr pixmap, -+ CARD16 *stride, -+ CARD32 *size); -+ - /** - * @glamor_name_from_pixmap: Gets a gem name from a pixmap. - * --- -2.9.3 - -From 63df9a26e04063667ab3a0da2fb7097b03605644 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 17 Aug 2016 12:03:41 +0200 -Subject: [PATCH v2 xserver 07/11] modesetting: Fix msSharePixmapBacking - returning a non-linear bo - -glamor_fd_from_pixmap() may return a tiled bo, which is not suitable -for sharing with another GPU as tiling usually is GPU specific. - -Switch to glamor_shareable_fd_from_pixmap(), which always returns a -linear bo. This fixes mis-rendering when running the mode setting -driver on the master gpu in a dual-gpu setup and running an opengl -app with DRI_PRIME=1. - -Signed-off-by: Hans de Goede -Reviewed-by: Keith Packard ---- - hw/xfree86/drivers/modesetting/driver.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c -index 718966b..1e98c80 100644 ---- a/hw/xfree86/drivers/modesetting/driver.c -+++ b/hw/xfree86/drivers/modesetting/driver.c -@@ -1087,7 +1087,8 @@ msSharePixmapBacking(PixmapPtr ppix, ScreenPtr screen, void **handle) - int ret; - CARD16 stride; - CARD32 size; -- ret = glamor_fd_from_pixmap(ppix->drawable.pScreen, ppix, &stride, &size); -+ ret = glamor_shareable_fd_from_pixmap(ppix->drawable.pScreen, ppix, -+ &stride, &size); - if (ret == -1) - return FALSE; - --- -2.9.3 - -From 4365b170822c8acefa36eb42378a9e87ae552042 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 24 Aug 2016 14:13:19 +0200 -Subject: [PATCH v2 xserver 08/11] modesetting: ms_covering_crtc: Remove unused - arguments, make static - -Remove unused arguments from ms_covering_crtc, make it static as it is -only used in vblank.c. - -While at it also change its first argument from a ScrnInfoPtr to a -ScreenPtr, this makes the next patch in this patch-set cleaner. - -Signed-off-by: Hans de Goede ---- - hw/xfree86/drivers/modesetting/driver.h | 2 -- - hw/xfree86/drivers/modesetting/vblank.c | 20 +++++--------------- - 2 files changed, 5 insertions(+), 17 deletions(-) - -diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h -index 5e1c5d9..747e4e7 100644 ---- a/hw/xfree86/drivers/modesetting/driver.h -+++ b/hw/xfree86/drivers/modesetting/driver.h -@@ -136,8 +136,6 @@ void ms_drm_abort_seq(ScrnInfoPtr scrn, uint32_t seq); - Bool ms_crtc_on(xf86CrtcPtr crtc); - - xf86CrtcPtr ms_dri2_crtc_covering_drawable(DrawablePtr pDraw); --xf86CrtcPtr ms_covering_crtc(ScrnInfoPtr scrn, BoxPtr box, -- xf86CrtcPtr desired, BoxPtr crtc_box_ret); - - int ms_get_crtc_ust_msc(xf86CrtcPtr crtc, CARD64 *ust, CARD64 *msc); - -diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c -index 77e0848..c2cb70c 100644 ---- a/hw/xfree86/drivers/modesetting/vblank.c -+++ b/hw/xfree86/drivers/modesetting/vblank.c -@@ -97,10 +97,10 @@ ms_crtc_on(xf86CrtcPtr crtc) - * with greater coverage - */ - --xf86CrtcPtr --ms_covering_crtc(ScrnInfoPtr scrn, -- BoxPtr box, xf86CrtcPtr desired, BoxPtr crtc_box_ret) -+static xf86CrtcPtr -+ms_covering_crtc(ScreenPtr pScreen, BoxPtr box) - { -+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen); - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); - xf86CrtcPtr crtc, best_crtc; - int coverage, best_coverage; -@@ -109,10 +109,6 @@ ms_covering_crtc(ScrnInfoPtr scrn, - - best_crtc = NULL; - best_coverage = 0; -- crtc_box_ret->x1 = 0; -- crtc_box_ret->x2 = 0; -- crtc_box_ret->y1 = 0; -- crtc_box_ret->y2 = 0; - for (c = 0; c < xf86_config->num_crtc; c++) { - crtc = xf86_config->crtc[c]; - -@@ -123,12 +119,7 @@ ms_covering_crtc(ScrnInfoPtr scrn, - ms_crtc_box(crtc, &crtc_box); - ms_box_intersect(&cover_box, &crtc_box, box); - coverage = ms_box_area(&cover_box); -- if (coverage && crtc == desired) { -- *crtc_box_ret = crtc_box; -- return crtc; -- } - if (coverage > best_coverage) { -- *crtc_box_ret = crtc_box; - best_crtc = crtc; - best_coverage = coverage; - } -@@ -140,15 +131,14 @@ xf86CrtcPtr - ms_dri2_crtc_covering_drawable(DrawablePtr pDraw) - { - ScreenPtr pScreen = pDraw->pScreen; -- ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); -- BoxRec box, crtcbox; -+ BoxRec box; - - box.x1 = pDraw->x; - box.y1 = pDraw->y; - box.x2 = box.x1 + pDraw->width; - box.y2 = box.y1 + pDraw->height; - -- return ms_covering_crtc(pScrn, &box, NULL, &crtcbox); -+ return ms_covering_crtc(pScreen, &box); - } - - static Bool --- -2.9.3 - -From 2feea233731855cbb4ec6021a287145b25c45f6d Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 24 Aug 2016 14:55:27 +0200 -Subject: [PATCH v2 xserver 09/11] modesetting: ms_covering_crtc: Allow calling - on non modesetting Screens - -99% of the code in ms_covering_crtc is video-driver agnostic. Add a -screen_is_ms parameter when when FALSE skips the one ms specific check, -this will allow calling ms_covering_crtc on slave GPUs. - -Signed-off-by: Hans de Goede ---- - hw/xfree86/drivers/modesetting/vblank.c | 12 +++++++++--- - 1 file changed, 9 insertions(+), 3 deletions(-) - -diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c -index c2cb70c..0b1abb0 100644 ---- a/hw/xfree86/drivers/modesetting/vblank.c -+++ b/hw/xfree86/drivers/modesetting/vblank.c -@@ -98,7 +98,7 @@ ms_crtc_on(xf86CrtcPtr crtc) - */ - - static xf86CrtcPtr --ms_covering_crtc(ScreenPtr pScreen, BoxPtr box) -+ms_covering_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) - { - ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen); - xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); -@@ -106,14 +106,20 @@ ms_covering_crtc(ScreenPtr pScreen, BoxPtr box) - int coverage, best_coverage; - int c; - BoxRec crtc_box, cover_box; -+ Bool crtc_on; - - best_crtc = NULL; - best_coverage = 0; - for (c = 0; c < xf86_config->num_crtc; c++) { - crtc = xf86_config->crtc[c]; - -+ if (screen_is_ms) -+ crtc_on = ms_crtc_on(crtc); -+ else -+ crtc_on = crtc->enabled; -+ - /* If the CRTC is off, treat it as not covering */ -- if (!ms_crtc_on(crtc)) -+ if (!crtc_on) - continue; - - ms_crtc_box(crtc, &crtc_box); -@@ -138,7 +144,7 @@ ms_dri2_crtc_covering_drawable(DrawablePtr pDraw) - box.x2 = box.x1 + pDraw->width; - box.y2 = box.y1 + pDraw->height; - -- return ms_covering_crtc(pScreen, &box); -+ return ms_covering_crtc(pScreen, &box, TRUE); - } - - static Bool --- -2.9.3 - -From d5783818bc567a4d0645decb7352f0f8bbcf8d44 Mon Sep 17 00:00:00 2001 -From: Hans de Goede -Date: Wed, 24 Aug 2016 15:00:13 +0200 -Subject: [PATCH v2 xserver 10/11] modesetting: Fall back to primary crtc for - vblank for drawables on slave outputs - -This fixes glxgears running at 1 fps when fully covering a slave-output -and the modesetting driver is used for the master gpu. - -Reported-by: Peter Wu -Signed-off-by: Hans de Goede ---- -Changes in v2: --Only fallback to primary crtc if it is in DPMSModeOn ---- - hw/xfree86/drivers/modesetting/vblank.c | 23 +++++++++++++++++++++++ - 1 file changed, 23 insertions(+) - -diff --git a/hw/xfree86/drivers/modesetting/vblank.c b/hw/xfree86/drivers/modesetting/vblank.c -index 0b1abb0..99100ec 100644 ---- a/hw/xfree86/drivers/modesetting/vblank.c -+++ b/hw/xfree86/drivers/modesetting/vblank.c -@@ -130,6 +130,29 @@ ms_covering_crtc(ScreenPtr pScreen, BoxPtr box, Bool screen_is_ms) - best_coverage = coverage; - } - } -+ -+ /* Fallback to primary crtc for drawable's on slave outputs */ -+ if (best_crtc == NULL && !pScreen->isGPU) { -+ RROutputPtr primary_output = NULL; -+ ScreenPtr slave; -+ -+ if (dixPrivateKeyRegistered(rrPrivKey)) -+ primary_output = RRFirstOutput(scrn->pScreen); -+ if (!primary_output || !primary_output->crtc) -+ return NULL; -+ -+ crtc = primary_output->crtc->devPrivate; -+ if (!ms_crtc_on(crtc)) -+ return NULL; -+ -+ xorg_list_for_each_entry(slave, &pScreen->output_slave_list, output_head) { -+ if (ms_covering_crtc(slave, box, FALSE)) { -+ /* The drawable is on a slave output, return primary crtc */ -+ return crtc; -+ } -+ } -+ } -+ - return best_crtc; - } - --- -2.9.3 -