Re: [PATCH xserver v3] autobind GPUs to the screen

2017-03-17 Thread Eric Anholt
Hans de Goede  writes:

> From: Dave Airlie 
>
> This is a modified version of a patch we've been carry-ing in Fedora and

"carrying"

> 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.
>
> 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.

Will there actually be races?  In the current patch, at least, doesn't
the new GPU get autoconfigured before the randr change notification goes
out?

> 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.

I think this is a sensible default.  It also helped with getting X up on
my VC4 + CLCD platform.

Reviewed-by: Eric Anholt 


signature.asc
Description: PGP signature
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCH xserver v3] autobind GPUs to the screen

2017-03-16 Thread Timo Aaltonen
On 06.12.2016 16:22, Hans de Goede wrote:
> From: Dave Airlie 
> 
> 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.
> 
> 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 
> [hdego...@redhat.com: Make configurable, fix with nvidia, 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
> Changes in v3:
> -Handle GPUScreen autoconfig in randr/rrprovider.c, looking at
>  rrScrPriv->provider, rather then in hw/xfree86/modes/xf86Crtc.c
>  looking at xf86CrtcConfig->provider. This fixes the autoconfig not
>  working with the nvidia binary driver

Tested-by: Timo Aaltonen 

Ubuntu has had the old version for some years, and now this one works
with 1.19.x so would like to see it upstream.


-- 
t
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xserver v3] autobind GPUs to the screen

2016-12-06 Thread Hans de Goede
From: Dave Airlie 

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.

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 
[hdego...@redhat.com: Make configurable, fix with nvidia, 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
Changes in v3:
-Handle GPUScreen autoconfig in randr/rrprovider.c, looking at
 rrScrPriv->provider, rather then in hw/xfree86/modes/xf86Crtc.c
 looking at xf86CrtcConfig->provider. This fixes the autoconfig not
 working with the nvidia binary driver
---
 hw/xfree86/common/xf86Config.c  | 19 +++
 hw/xfree86/common/xf86Globals.c |  2 ++
 hw/xfree86/common/xf86Init.c| 20 
 hw/xfree86/common/xf86Priv.h|  1 +
 hw/xfree86/common/xf86Privstr.h |  1 +
 hw/xfree86/common/xf86platformBus.c |  4 
 hw/xfree86/man/Xorg.man |  7 +++
 hw/xfree86/man/xorg.conf.man|  6 ++
 randr/randrstr.h|  3 +++
 randr/rrprovider.c  | 22 ++
 10 files changed, 85 insertions(+)

diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c
index 21daf1a..df3ca50 100644
--- a/hw/xfree86/common/xf86Config.c
+++ b/hw/xfree86/common/xf86Config.c
@@ -719,6 +719,7 @@ typedef enum {
 FLAG_DRI2,
 FLAG_USE_SIGIO,
 FLAG_AUTO_ADD_GPU,
+FLAG_AUTO_BIND_GPU,
 FLAG_MAX_CLIENTS,
 FLAG_IGLX,
 } FlagValues;
@@ -778,6 +779,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,
@@ -857,6 +860,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,
+  );
+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 e962b75..0d1e31b 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;
@@ -197,6 +198,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 a544b65..b0cba3d 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -76,6 +76,7 @@
 #include "xf86DDC.h"
 #include "xf86Xinput.h"
 #include "xf86InPriv.h"
+#include "xf86Crtc.h"
 #include "picturestr.h"