1
0
Dominique Leuenberger 2018-10-22 09:06:18 +00:00 committed by Git OBS Bridge
commit 69aaddf1c7
5 changed files with 303 additions and 59 deletions

View File

@ -1,7 +1,7 @@
From 3216e0c618cc330f053ed36a749c8d8cfeb87a2f Mon Sep 17 00:00:00 2001
From: Dave Airlie <airlied@redhat.com>
Date: Fri, 17 Aug 2012 09:49:24 +1000
Subject: [PATCH] autobind GPUs to the screen, (v3)
Subject: [PATCH] autobind GPUs to the screen, (v5)
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.
@ -13,6 +13,12 @@ v4: do not unbound GPUs before attaching them
compatibility fix for 5c7af02b10
-- Michal Srb <msrb@suse.com>
v5: Do not use xf86CrtcConfig, it is not filled by nvidia proprietary driver,
only use randr structures.
Auto configure outputs of additional GPUs on start, just like the outputs
of the main GPU are configured.
-- Michal Srb <msrb@suse.com>
DO NOT UPSTREAM.
Signed-off-by: Dave Airlie <airlied@gmail.com>
@ -22,28 +28,273 @@ Signed-off-by: Dave Airlie <airlied@gmail.com>
hw/xfree86/modes/xf86Crtc.c | 32 ++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
Index: xorg-server-1.19.6/hw/xfree86/common/xf86Init.c
===================================================================
--- xorg-server-1.19.6.orig/hw/xfree86/common/xf86Init.c
+++ xorg-server-1.19.6/hw/xfree86/common/xf86Init.c
@@ -297,6 +297,16 @@ xf86PrivsElevated(void)
return PrivsElevated();
diff --git a/dix/main.c b/dix/main.c
index 273f30330..b85c81034 100644
--- a/dix/main.c
+++ b/dix/main.c
@@ -122,6 +122,8 @@ extern void Dispatch(void);
CallbackListPtr RootWindowFinalizeCallback = NULL;
+CallbackListPtr RootWindowInitialized = NULL;
+
int
dix_main(int argc, char *argv[], char *envp[])
{
@@ -244,6 +246,8 @@ dix_main(int argc, char *argv[], char *envp[])
for (i = 0; i < screenInfo.numScreens; i++)
InitRootWindow(screenInfo.screens[i]->root);
+ CallCallbacks(&RootWindowInitialized, NULL);
+
InitCoreDevices();
InitInput(argc, argv);
InitAndStartDevices();
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index cc34a1952..766888b3e 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -73,6 +73,7 @@
#include "xf86DDC.h"
#include "xf86Xinput.h"
#include "xf86InPriv.h"
+#include "xf86Crtc.h"
#include "picturestr.h"
#include "randrstr.h"
#include "glxvndabi.h"
@@ -264,6 +265,231 @@ AddVTAtoms(CallbackListPtr *pcbl, void *data, void *screen)
"Failed to register VT properties\n");
}
+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
+/*
+ * This function activates all outputs of all GPU screens associated with the
+ * given master screen and sets them to their preferred resolution next to
+ * each other left-to-right.
+ */
+static void
+xf86AutoConfigureProviderOutputsForMaster(ScreenPtr pMasterScreen)
+{
+ ScreenPtr pScreen;
+ rrScrPrivPtr pMasterScrPriv, pScrPriv;
+ RROutputPtr pOutput;
+ RRCrtcPtr pCrtc;
+ RRCrtcPtr *pUsedCrtcs;
+ int usedCrtcsCount;
+ int screenWidth, screenHeight, screenWidthMM, screenHeightMM;
+ int i, j, k, l;
+
+ struct OutputConfig {
+ RROutputPtr pOutput;
+ RRCrtcPtr pCrtc;
+
+ int x;
+ int y;
+ } *outputConfigs;
+ int outputConfigsCount = 0, outputConfigsUsed = 0;
+
+ pMasterScrPriv = rrGetScrPriv(pMasterScreen);
+ if (!pMasterScrPriv)
+ return;
+
+ // Count the potential maximum of outputs that we will try to auto configure
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ pScreen = xf86GPUScreens[i]->pScreen;
+ if (pScreen->current_master != pMasterScreen || !pScreen->is_output_slave)
+ continue;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ if (!pScrPriv)
+ continue;
+
+ outputConfigsCount += pScrPriv->numOutputs;
+ }
+
+ if (outputConfigsCount == 0)
+ return;
+
+ outputConfigs = calloc(outputConfigsCount, sizeof(*outputConfigs));
+
+ screenWidth = 0;
+ screenHeight = 0;
+
+ // Consider the master's own outputs/crtcs that were already configured
+ for (i = 0; i < pMasterScrPriv->numCrtcs; i++) {
+ if (!pMasterScrPriv->crtcs[i]->mode)
+ continue;
+
+ screenWidth = max(screenWidth, pMasterScrPriv->crtcs[i]->x + pMasterScrPriv->crtcs[i]->mode->mode.width);
+ screenHeight = max(screenHeight, pMasterScrPriv->crtcs[i]->y + pMasterScrPriv->crtcs[i]->mode->mode.height);
+ }
+
+ // Now add as many outputs from slave GPUs as we can next to it
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ pScreen = xf86GPUScreens[i]->pScreen;
+ if (pScreen->current_master != pMasterScreen || !pScreen->is_output_slave)
+ continue;
+
+ pScrPriv = rrGetScrPriv(pScreen);
+ if (!pScrPriv)
+ continue;
+
+ pUsedCrtcs = calloc(pScrPriv->numCrtcs, sizeof(*pUsedCrtcs));
+ if (!pUsedCrtcs)
+ continue;
+
+ usedCrtcsCount = 0;
+
+ for (j = 0; j < pScrPriv->numOutputs; j++) {
+ pOutput = pScrPriv->outputs[j];
+
+ if (pOutput->connection != RR_Connected ||
+ pOutput->nonDesktop ||
+ pOutput->numModes == 0 ||
+ pOutput->numCrtcs == 0)
+ continue;
+
+ if (screenWidth + pOutput->modes[0]->mode.width > pMasterScrPriv->maxWidth ||
+ screenHeight + pOutput->modes[0]->mode.height > pMasterScrPriv->maxHeight)
+ {
+ // It can't fit into the maximal size, skip
+ continue;
+ }
+
+ for (k = 0; k < pOutput->numCrtcs; k++) {
+ pCrtc = pOutput->crtcs[k];
+ for (l = 0; l < usedCrtcsCount; l++) {
+ if (pCrtc == pUsedCrtcs[l]) {
+ pCrtc = NULL;
+ break;
+ }
+ }
+ if (pCrtc) {
+ break;
+ }
+ }
+
+ if (!pCrtc) {
+ // No more free CRTCs to setup this output, skip
+ continue;
+ }
+
+ pUsedCrtcs[usedCrtcsCount] = pCrtc;
+ usedCrtcsCount++;
+
+ assert(outputConfigsUsed < outputConfigsCount);
+ outputConfigs[outputConfigsUsed].pOutput = pOutput;
+ outputConfigs[outputConfigsUsed].pCrtc = pCrtc;
+ outputConfigs[outputConfigsUsed].x = screenWidth;
+ outputConfigs[outputConfigsUsed].y = 0;
+ outputConfigsUsed++;
+
+ screenWidth += pOutput->modes[0]->mode.width;
+ screenHeight += pOutput->modes[0]->mode.height;
+ }
+
+ free(pUsedCrtcs);
+ }
+
+ if (outputConfigsUsed == 0)
+ goto out;
+
+ if (screenWidth < pMasterScrPriv->minWidth)
+ screenWidth = pMasterScrPriv->minWidth;
+ if (screenHeight < pMasterScrPriv->minHeight)
+ screenHeight = pMasterScrPriv->minHeight;
+
+ if (pMasterScrPriv->mmWidth > 0 &&
+ pMasterScrPriv->mmHeight > 0 &&
+ pMasterScrPriv->width > 0 &&
+ pMasterScrPriv->height > 0)
+ {
+ // If the master screen already has some DPI, keep it
+ screenWidthMM = pMasterScrPriv->mmWidth * screenWidth / pMasterScreen->width;
+ screenHeightMM = pMasterScrPriv->mmHeight * screenHeight / pMasterScreen->height;
+ } else {
+ assert(outputConfigsUsed > 0);
+ // Otherwise use DPI of the first output
+ screenWidthMM = outputConfigs[0].pOutput->mmWidth * screenWidth / outputConfigs[0].pOutput->modes[0]->mode.width;
+ screenHeightMM = outputConfigs[0].pOutput->mmHeight * screenHeight / outputConfigs[0].pOutput->modes[0]->mode.height;
+ }
+
+ if (!RRScreenSizeSet(pMasterScreen, screenWidth, screenHeight, screenWidthMM, screenHeightMM))
+ goto out;
+
+ for (i = 0; i < outputConfigsUsed; i++) {
+ RRCrtcSet(
+ outputConfigs[i].pCrtc,
+ outputConfigs[i].pOutput->modes[0],
+ outputConfigs[i].x,
+ outputConfigs[i].y,
+ RR_Rotate_0,
+ 1,
+ &outputConfigs[i].pOutput
+ );
+ }
+
+out:
+ free(outputConfigs);
+}
+
+static void
+xf86AutoConfigProviderOutputs(CallbackListPtr *pcbl, void *data, void *call_data)
+{
+ int i;
+
+ for (i = 0; i < xf86NumScreens; i++) {
+ xf86AutoConfigureProviderOutputsForMaster(xf86Screens[i]->pScreen);
+ }
+}
+
+void
+xf86AutoConfigOutputDevice(ScreenPtr slave, ScreenPtr master)
+{
+ RRProviderPtr master_provider;
+ RRProviderPtr slave_provider;
+ rrScrPrivPtr master_rp;
+ rrScrPrivPtr slave_rp;
+
+ master_rp = rrGetScrPriv(master);
+ slave_rp = rrGetScrPriv(slave);
+
+ if (!master_rp || !slave_rp)
+ return;
+
+ master_provider = master_rp->provider;
+ slave_provider = slave_rp->provider;
+
+ if (!master_provider || !slave_provider)
+ return;
+
+ if ((master_provider->capabilities & RR_Capability_SinkOffload) &&
+ (slave_provider->capabilities & RR_Capability_SourceOffload)) {
+ /* source offload */
+ AttachOffloadGPU(master, slave);
+ slave_provider->offload_sink = master_provider;
+ }
+ if ((master_provider->capabilities & RR_Capability_SourceOutput) &&
+ (slave_provider->capabilities & RR_Capability_SinkOutput)) {
+ /* sink offload */
+ AttachOutputGPU(master, slave);
+ slave_provider->output_source = master_provider;
+ }
+}
+
+static void
+xf86AutoConfigOutputDevices(void)
+{
+ int i;
+
+ for (i = 0; i < xf86NumGPUScreens; i++)
+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
+ for (i = 0; i < xf86NumGPUScreens; i++) {
+ xf86AutoConfigOutputDevice(xf86GPUScreens[i]->pScreen, xf86Screens[0]->pScreen);
+ }
+
+ AddCallback(&RootWindowInitialized, xf86AutoConfigProviderOutputs, NULL);
+}
+
static void
TrapSignals(void)
static Bool
xf86ScreenInit(ScreenPtr pScreen, int argc, char **argv)
{
@@ -872,6 +882,8 @@ InitOutput(ScreenInfo * pScreenInfo, int
@@ -703,6 +929,8 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
for (i = 0; i < xf86NumGPUScreens; i++)
AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
@ -52,58 +303,37 @@ Index: xorg-server-1.19.6/hw/xfree86/common/xf86Init.c
xf86VGAarbiterWrapFunctions();
if (sigio_blocked)
input_unlock();
Index: xorg-server-1.19.6/hw/xfree86/common/xf86platformBus.c
===================================================================
--- xorg-server-1.19.6.orig/hw/xfree86/common/xf86platformBus.c
+++ xorg-server-1.19.6/hw/xfree86/common/xf86platformBus.c
@@ -489,6 +489,8 @@ xf86platformProbeDev(DriverPtr drvp)
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index cef47da03..395ce9400 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -594,6 +594,8 @@ xf86platformAddGPUDevices(DriverPtr drvp)
return foundScreen;
}
+extern void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master);
+extern void xf86AutoConfigOutputDevice(ScreenPtr slave, ScreenPtr master);
+
int
xf86platformAddDevice(int index)
{
@@ -560,6 +562,7 @@ xf86platformAddDevice(int index)
@@ -665,6 +667,7 @@ xf86platformAddDevice(int index)
}
/* attach unbound to 0 protocol screen */
AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
+ xf86AutoConfigOutputDevice(xf86GPUScreens[i], xf86Screens[0]);
+ xf86AutoConfigOutputDevice(xf86GPUScreens[i]->pScreen, xf86Screens[0]->pScreen);
RRResourcesChanged(xf86Screens[0]->pScreen);
RRTellChanged(xf86Screens[0]->pScreen);
Index: xorg-server-1.19.6/hw/xfree86/modes/xf86Crtc.c
===================================================================
--- xorg-server-1.19.6.orig/hw/xfree86/modes/xf86Crtc.c
+++ xorg-server-1.19.6/hw/xfree86/modes/xf86Crtc.c
@@ -3462,3 +3462,29 @@ xf86DetachAllCrtc(ScrnInfoPtr scrn)
crtc->x = crtc->y = 0;
}
}
diff --git a/include/dix.h b/include/dix.h
index 476559842..7372ba0d5 100644
--- a/include/dix.h
+++ b/include/dix.h
@@ -597,6 +597,8 @@ typedef struct {
extern _X_EXPORT CallbackListPtr RootWindowFinalizeCallback;
+extern _X_EXPORT CallbackListPtr RootWindowInitialized;
+
+
+void xf86AutoConfigOutputDevice(ScrnInfoPtr pScrn, ScrnInfoPtr master)
+{
+ RRProviderPtr master_provider;
+ xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(master);
+ xf86CrtcConfigPtr slave_config = XF86_CRTC_CONFIG_PTR(pScrn);
+
+ if (!config || !slave_config)
+ return;
+
+ master_provider = config->randr_provider;
+
+ if ((master->capabilities & RR_Capability_SinkOffload) &&
+ 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 */
+ AttachOutputGPU(master->pScreen, pScrn->pScreen);
+ slave_config->randr_provider->output_source = master_provider;
+ }
+}
extern int
XItoCoreType(int xi_type);
extern Bool

View File

@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:59c99fe86fe75b8164c6567bfc6e982aecc2e4a51e6fbac1b842d5d00549e918
size 6103772

View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0ed5f7bc48f22f54e1ae0229ad6f35a521da4232d9d5529d7cebb5e79b3ccee2
size 6204242

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Mon Oct 15 18:03:28 UTC 2018 - Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
- Update to version 1.20.2:
Lots of bugfixes all over the map especially for modesetting,
glamor and xwayland!
-------------------------------------------------------------------
Wed Aug 15 11:24:17 UTC 2018 - msrb@suse.com
- Update n_xserver-optimus-autoconfig-hack.patch to v5.
* Fixes provider auto-configuration with nvidia proprietary
driver. (bsc#1103816)
-------------------------------------------------------------------
Tue Aug 7 22:56:14 UTC 2018 - tobias.johannes.klausmann@mni.thm.de

View File

@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@ -46,7 +46,7 @@
%endif
Name: xorg-x11-server
Version: 1.20.1
Version: 1.20.2
Release: 0
Url: http://xorg.freedesktop.org/
BuildRoot: %{_tmppath}/%{name}-%{version}-build