diff --git a/0001-randr-provider-only-allow-slave-gpu-to-be-offload-so.patch b/0001-randr-provider-only-allow-slave-gpu-to-be-offload-so.patch new file mode 100644 index 0000000..bc5d8eb --- /dev/null +++ b/0001-randr-provider-only-allow-slave-gpu-to-be-offload-so.patch @@ -0,0 +1,30 @@ +From fc1f61b75c9712e24ff665f95d62771f39eba1c7 Mon Sep 17 00:00:00 2001 +From: Dave Airlie +Date: Fri, 29 Apr 2016 14:01:30 +1000 +Subject: [PATCH 1/4] randr/provider: only allow slave gpu to be offload + sources. + +The other way around makes no sense. + +Reviewed-by: Alex Deucher +Signed-off-by: Dave Airlie +--- + randr/rrprovider.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/randr/rrprovider.c b/randr/rrprovider.c +index bbb8e51..5329f41 100644 +--- a/randr/rrprovider.c ++++ b/randr/rrprovider.c +@@ -325,6 +325,8 @@ ProcRRSetProviderOffloadSink(ClientPtr client) + VERIFY_RR_PROVIDER(stuff->provider, provider, DixReadAccess); + if (!(provider->capabilities & RR_Capability_SourceOffload)) + return BadValue; ++ if (!provider->pScreen->isGPU) ++ return BadValue; + + if (stuff->sink_provider) { + VERIFY_RR_PROVIDER(stuff->sink_provider, sink_provider, DixReadAccess); +-- +2.5.5 + diff --git a/0002-modesetting-set-driverPrivate-to-NULL-after-closing-.patch b/0002-modesetting-set-driverPrivate-to-NULL-after-closing-.patch new file mode 100644 index 0000000..1201209 --- /dev/null +++ b/0002-modesetting-set-driverPrivate-to-NULL-after-closing-.patch @@ -0,0 +1,36 @@ +From a41a171bcbae9aeafac2865faa904f15d9b59925 Mon Sep 17 00:00:00 2001 +From: Dave Airlie +Date: Fri, 29 Apr 2016 14:01:31 +1000 +Subject: [PATCH 2/4] modesetting: set driverPrivate to NULL after closing fd. + +Otherwise ms_ent_priv will return NULL and things will fall apart. + +Reviewed-by: Alex Deucher +Signed-off-by: Dave Airlie +--- + hw/xfree86/drivers/modesetting/driver.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index c97f33a..abf7e1a 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -635,7 +635,6 @@ FreeRec(ScrnInfoPtr pScrn) + ms = modesettingPTR(pScrn); + if (!ms) + return; +- pScrn->driverPrivate = NULL; + + if (ms->fd > 0) { + modesettingEntPtr ms_ent; +@@ -656,6 +655,7 @@ FreeRec(ScrnInfoPtr pScrn) + ms_ent->fd = 0; + } + } ++ pScrn->driverPrivate = NULL; + free(ms->drmmode.Options); + free(ms); + +-- +2.5.5 + diff --git a/0003-xf86Crtc-don-t-set-the-root-window-property-on-slave.patch b/0003-xf86Crtc-don-t-set-the-root-window-property-on-slave.patch new file mode 100644 index 0000000..c7ca4f0 --- /dev/null +++ b/0003-xf86Crtc-don-t-set-the-root-window-property-on-slave.patch @@ -0,0 +1,33 @@ +From 258588224d6b35de12f97d9092efa5cb3e426550 Mon Sep 17 00:00:00 2001 +From: Dave Airlie +Date: Fri, 29 Apr 2016 14:01:32 +1000 +Subject: [PATCH 3/4] xf86Crtc: don't set the root window property on slave + GPUs. + +Slave GPUs don't have a root window to set this on, so don't. + +This fixes some crashes I saw just playing around. + +Reviewed-by: Alex Deucher +Signed-off-by: Dave Airlie +--- + hw/xfree86/modes/xf86Crtc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/modes/xf86Crtc.c b/hw/xfree86/modes/xf86Crtc.c +index 6091b5e..4a13c13 100644 +--- a/hw/xfree86/modes/xf86Crtc.c ++++ b/hw/xfree86/modes/xf86Crtc.c +@@ -3285,7 +3285,8 @@ xf86OutputSetEDID(xf86OutputPtr output, xf86MonPtr edid_mon) + } + + /* Set the DDC properties for the 'compat' output */ +- if (output == xf86CompatOutput(scrn)) ++ /* GPU screens don't have a root window */ ++ if (output == xf86CompatOutput(scrn) && !scrn->is_gpu) + xf86SetDDCproperties(scrn, edid_mon); + + #ifdef RANDR_12_INTERFACE +-- +2.5.5 + diff --git a/0004-modesetting-set-capabilities-up-after-glamor-and-ena.patch b/0004-modesetting-set-capabilities-up-after-glamor-and-ena.patch new file mode 100644 index 0000000..9180a3c --- /dev/null +++ b/0004-modesetting-set-capabilities-up-after-glamor-and-ena.patch @@ -0,0 +1,65 @@ +From 2378adde6770385c06f7efcd32f270d00d49ce3f Mon Sep 17 00:00:00 2001 +From: Dave Airlie +Date: Fri, 29 Apr 2016 14:01:33 +1000 +Subject: [PATCH 4/4] modesetting: set capabilities up after glamor and enable + offload caps. + +This moves the capabilites setting to after glamor is initialised, and +enables the offload caps in cases where they work. This enables DRI2 +PRIME support with modesetting. + +Reviewed-by: Alex Deucher +Signed-off-by: Dave Airlie +--- + hw/xfree86/drivers/modesetting/driver.c | 28 ++++++++++++++++------------ + 1 file changed, 16 insertions(+), 12 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index abf7e1a..cd59c06 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -820,18 +820,6 @@ PreInit(ScrnInfoPtr pScrn, int flags) + return FALSE; + ms->drmmode.fd = ms->fd; + +- pScrn->capabilities = 0; +-#ifdef DRM_CAP_PRIME +- ret = drmGetCap(ms->fd, DRM_CAP_PRIME, &value); +- if (ret == 0) { +- if (value & DRM_PRIME_CAP_IMPORT) +- pScrn->capabilities |= RR_Capability_SinkOutput; +-#if GLAMOR_HAS_GBM_LINEAR +- if (value & DRM_PRIME_CAP_EXPORT) +- pScrn->capabilities |= RR_Capability_SourceOutput; +-#endif +- } +-#endif + drmmode_get_default_bpp(pScrn, &ms->drmmode, &defaultdepth, &defaultbpp); + if (defaultdepth == 24 && defaultbpp == 24) + bppflags = SupportConvert32to24 | Support24bppFb; +@@ -907,6 +895,22 @@ PreInit(ScrnInfoPtr pScrn, int flags) + ms->drmmode.pageflip = FALSE; + } + ++ pScrn->capabilities = 0; ++#ifdef DRM_CAP_PRIME ++ ret = drmGetCap(ms->fd, DRM_CAP_PRIME, &value); ++ if (ret == 0) { ++ if (value & DRM_PRIME_CAP_IMPORT) { ++ pScrn->capabilities |= RR_Capability_SinkOutput; ++ if (ms->drmmode.glamor) ++ pScrn->capabilities |= RR_Capability_SourceOffload; ++ } ++#if GLAMOR_HAS_GBM_LINEAR ++ if (value & DRM_PRIME_CAP_EXPORT && ms->drmmode.glamor) ++ pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SinkOffload; ++#endif ++ } ++#endif ++ + if (drmmode_pre_init(pScrn, &ms->drmmode, pScrn->bitsPerPixel / 8) == FALSE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "KMS setup failed\n"); + goto fail; +-- +2.5.5 + diff --git a/0005-modesetting-Properly-cleanup-fb-for-reverse-prime-of.patch b/0005-modesetting-Properly-cleanup-fb-for-reverse-prime-of.patch new file mode 100644 index 0000000..2231675 --- /dev/null +++ b/0005-modesetting-Properly-cleanup-fb-for-reverse-prime-of.patch @@ -0,0 +1,54 @@ +From 9b70aebc609c98719095229befd1a56532aaaa1c Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Wed, 1 Jun 2016 14:59:38 +0200 +Subject: [PATCH xserver 5/8] modesetting: Properly cleanup fb for + reverse-prime-offload + +drmmode_set_scanout_pixmap_gpu(pix) adds drmmod->fb_id through a call +to drmmode_xf86crtc_resize(), but on a subsequent +drmmode_set_scanout_pixmap_gpu(NULL) it would not remove the fb. + +This keeps the crtc marked as busy, which causes the dgpu to not +being able to runtime suspend, after an output attached to the dgpu +has been used once. Which causes burning through an additional 10W +of power and the laptop to run quite hot. + +This commit adds the missing remove fb call, allowing the dgpu to runtime +suspend after an external monitor has been plugged into the laptop. + +Note this also makes drmmode_set_scanout_pixmap_gpu(NULL) match the +behavior of drmmode_set_scanout_pixmap_cpu(NULL) which was already +removing the fb. + +Signed-off-by: Hans de Goede +Reviewed-by: Dave Airlie +--- + hw/xfree86/drivers/modesetting/drmmode_display.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c +index bb5f56e..bc2ca3d 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -577,11 +577,17 @@ drmmode_set_scanout_pixmap_gpu(xf86CrtcPtr crtc, PixmapPtr ppix) + PixmapPtr screenpix = screen->GetScreenPixmap(screen); + xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(crtc->scrn); + drmmode_crtc_private_ptr drmmode_crtc = crtc->driver_private; ++ drmmode_ptr drmmode = drmmode_crtc->drmmode; + int c, total_width = 0, max_height = 0, this_x = 0; + + if (!ppix) { +- if (crtc->randr_crtc->scanout_pixmap) ++ if (crtc->randr_crtc->scanout_pixmap) { + PixmapStopDirtyTracking(crtc->randr_crtc->scanout_pixmap, screenpix); ++ if (drmmode->fb_id) { ++ drmModeRmFB(drmmode->fd, drmmode->fb_id); ++ drmmode->fb_id = 0; ++ } ++ } + drmmode_crtc->prime_pixmap_x = 0; + return TRUE; + } +-- +2.7.4 + diff --git a/0006-modesetting-Clear-drmmode-fb_id-before-unflipping.patch b/0006-modesetting-Clear-drmmode-fb_id-before-unflipping.patch new file mode 100644 index 0000000..4fbd942 --- /dev/null +++ b/0006-modesetting-Clear-drmmode-fb_id-before-unflipping.patch @@ -0,0 +1,46 @@ +From 4565de368c4aecdd4f09fafd69ca59206744aabb Mon Sep 17 00:00:00 2001 +From: Lyude Paul +Date: Mon, 13 Jun 2016 15:31:02 -0400 +Subject: [PATCH xserver 6/8] modesetting: Clear drmmode->fb_id before + unflipping + +[fix copied from 40191d82370e in xf86-video-ati] + +Without this, we end up setting rotated CRTCs back to their previous +framebuffer right after we perform a rotation. Reproducer: + +- Have two monitors connected at the same resolution +- Rotate one monitor from normal straight to inverted +- Watch as the monitor you didn't rotate either freezes or shows intense + flickering + +Signed-off-by: Lyude +Reviewed-by: Hans de Goede +Signed-off-by: Hans de Goede +--- + hw/xfree86/drivers/modesetting/present.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c +index d65c8c8..9a596de 100644 +--- a/hw/xfree86/drivers/modesetting/present.c ++++ b/hw/xfree86/drivers/modesetting/present.c +@@ -626,6 +626,15 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id) + if (!crtc->enabled) + continue; + ++ /* info->drmmode.fb_id still points to the FB for the last flipped BO. ++ * Clear it, drmmode_set_mode_major will re-create it ++ */ ++ if (drmmode_crtc->drmmode->fb_id) { ++ drmModeRmFB(drmmode_crtc->drmmode->fd, ++ drmmode_crtc->drmmode->fb_id); ++ drmmode_crtc->drmmode->fb_id = 0; ++ } ++ + if (drmmode_crtc->dpms_mode == DPMSModeOn) + crtc->funcs->set_mode_major(crtc, &crtc->mode, crtc->rotation, + crtc->x, crtc->y); +-- +2.7.4 + diff --git a/0007-modesetting-Fix-swapping-of-provider-sink-source-cap.patch b/0007-modesetting-Fix-swapping-of-provider-sink-source-cap.patch new file mode 100644 index 0000000..8cd2528 --- /dev/null +++ b/0007-modesetting-Fix-swapping-of-provider-sink-source-cap.patch @@ -0,0 +1,39 @@ +From be6e5f6c126602c499f8104e91c525cd938b4a97 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Thu, 16 Jun 2016 15:21:03 +0200 +Subject: [PATCH xserver 7/8] modesetting: Fix swapping of provider sink / + source capabilities + +When a card has import capability it can be an offload _sink_, not +a source and vice versa for export capability. + +This commit fixes the modesetting driver to properly set these +capabilities, this went unnoticed sofar because most gpus have both +import and export capability. + +Signed-off-by: Hans de Goede +--- + hw/xfree86/drivers/modesetting/driver.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c +index fb05e2e..e7f6e8d 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -891,11 +891,11 @@ PreInit(ScrnInfoPtr pScrn, int flags) + if (value & DRM_PRIME_CAP_IMPORT) { + pScrn->capabilities |= RR_Capability_SinkOutput; + if (ms->drmmode.glamor) +- pScrn->capabilities |= RR_Capability_SourceOffload; ++ pScrn->capabilities |= RR_Capability_SinkOffload; + } + #if GLAMOR_HAS_GBM_LINEAR + if (value & DRM_PRIME_CAP_EXPORT && ms->drmmode.glamor) +- pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SinkOffload; ++ pScrn->capabilities |= RR_Capability_SourceOutput | RR_Capability_SourceOffload; + #endif + } + #endif +-- +2.7.4 + diff --git a/0008-modesetting-Load-on-GPU-s-with-0-outputs.patch b/0008-modesetting-Load-on-GPU-s-with-0-outputs.patch new file mode 100644 index 0000000..e917f16 --- /dev/null +++ b/0008-modesetting-Load-on-GPU-s-with-0-outputs.patch @@ -0,0 +1,129 @@ +From bf8084ac0e2e988ed985d6c151b1d7d74d6037d1 Mon Sep 17 00:00:00 2001 +From: Hans de Goede +Date: Tue, 14 Jun 2016 11:58:01 +0200 +Subject: [PATCH xserver 8/8] 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 +--- + 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 e7f6e8d..b05ad81 100644 +--- a/hw/xfree86/drivers/modesetting/driver.c ++++ b/hw/xfree86/drivers/modesetting/driver.c +@@ -214,14 +214,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; + } +@@ -236,13 +248,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; +@@ -285,7 +297,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); +@@ -772,7 +784,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) +@@ -809,6 +821,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) + bppflags = SupportConvert32to24 | Support24bppFb; +@@ -888,7 +903,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; +@@ -916,7 +931,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 bc2ca3d..35a372c 100644 +--- a/hw/xfree86/drivers/modesetting/drmmode_display.c ++++ b/hw/xfree86/drivers/modesetting/drmmode_display.c +@@ -1639,10 +1639,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.7.4 + diff --git a/xorg-x11-server.spec b/xorg-x11-server.spec index fd8dbd0..c43875a 100644 --- a/xorg-x11-server.spec +++ b/xorg-x11-server.spec @@ -45,7 +45,7 @@ Summary: X.Org X11 X server Name: xorg-x11-server Version: 1.18.3 -Release: 5%{?gitdate:.%{gitdate}}%{dist} +Release: 6%{?gitdate:.%{gitdate}}%{dist} URL: http://www.x.org License: MIT Group: User Interface/X @@ -81,6 +81,15 @@ Source40: driver-abi-rebuild.sh # This really could be done prettier. Patch5002: xserver-1.4.99-ssh-isnt-local.patch +Patch6000: 0001-randr-provider-only-allow-slave-gpu-to-be-offload-so.patch +Patch6001: 0002-modesetting-set-driverPrivate-to-NULL-after-closing-.patch +Patch6002: 0003-xf86Crtc-don-t-set-the-root-window-property-on-slave.patch +Patch6004: 0004-modesetting-set-capabilities-up-after-glamor-and-ena.patch +Patch6005: 0005-modesetting-Properly-cleanup-fb-for-reverse-prime-of.patch +Patch6006: 0006-modesetting-Clear-drmmode-fb_id-before-unflipping.patch +Patch6007: 0007-modesetting-Fix-swapping-of-provider-sink-source-cap.patch +Patch6008: 0008-modesetting-Load-on-GPU-s-with-0-outputs.patch + #Patch6044: xserver-1.6.99-hush-prerelease-warning.patch Patch7025: 0001-Always-install-vbe-and-int10-sdk-headers.patch @@ -640,6 +649,10 @@ find %{inst_srcdir}/hw/xfree86 -name \*.c -delete %changelog +* Fri Jun 17 2016 Hans de Goede - 1.18.3-6 +- Add switchable-graphics / prime fixes from f24 branch +- Add some more switchable-graphics / prime fixes from upstream + * Mon Jun 13 2016 Adam Jackson - 1.18.3-5 - Restore DRI1 for now