xserver: Branch 'master' - 3 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 30 00:33:19 UTC 2021


 glamor/glamor_egl.c                 |   11 ++++-
 hw/xfree86/common/xf86Bus.c         |   67 ++++++++++++++++++++++--------------
 hw/xfree86/common/xf86Init.c        |   12 ++++--
 hw/xfree86/common/xf86platformBus.c |   21 ++++++-----
 4 files changed, 70 insertions(+), 41 deletions(-)

New commits:
commit fb5322ce2819260c07e06ab22b47df0a5d19f07d
Author: Zoltán Böszörményi <zboszor at gmail.com>
Date:   Thu Jul 8 06:14:21 2021 +0200

    glamoregl: Initialize glamor on the main device
    
    This allows e.g. an UDL device (driven by llvmpipe) to be automatically
    set up with GPU acceleration via reverse PRIME.
    
    The result is e.g.:
    
      # DISPLAY=:0.2 xrandr --listproviders
      Providers: number : 2
      Provider 0: id: 0xec cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 1 outputs: 1 associated providers: 1 name:modesetting
      Provider 1: id: 0x12c cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 1 name:Intel
    
    Signed-off-by: Zoltán Böszörményi <zboszor at gmail.com>

diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
index dfa5d3e4f..91c36a361 100644
--- a/glamor/glamor_egl.c
+++ b/glamor/glamor_egl.c
@@ -1060,9 +1060,14 @@ glamor_egl_init(ScrnInfoPtr scrn, int fd)
         goto error;
     }
     if (strstr((const char *)renderer, "llvmpipe")) {
-        xf86DrvMsg(scrn->scrnIndex, X_INFO,
-                   "Refusing to try glamor on llvmpipe\n");
-        goto error;
+        if (scrn->confScreen->num_gpu_devices)
+            xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                       "Allowing glamor on llvmpipe for PRIME\n");
+        else {
+            xf86DrvMsg(scrn->scrnIndex, X_INFO,
+                       "Refusing to try glamor on llvmpipe\n");
+            goto error;
+        }
     }
 
     /*
commit f08bc32f5abc23ea715c15e8e86150434cc99e4f
Author: Zoltán Böszörményi <zboszor at gmail.com>
Date:   Thu Jul 8 06:13:24 2021 +0200

    xf86: Assign GPUs to screens according to configuration
    
    If there is an explicit configuration, assign the RandR provider
    of the GPUDevice to the screen it was specified for.
    
    If there is no configuration (default case) the screen number is
    still 0 so it doesn't change behaviour.
    
    The result is e.g:
    
      # DISPLAY=:0.2 xrandr --listproviders
      Providers: number : 2
      Provider 0: id: 0xd2 cap: 0x2, Sink Output crtcs: 1 outputs: 1 associated providers: 0 name:modesetting
      Provider 1: id: 0xfd cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 2 outputs: 2 associated providers: 0 name:Intel
    
    Signed-off-by: Zoltán Böszörményi <zboszor at gmail.com>

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 6dc1aebf0..fd144dbe7 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -107,9 +107,9 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
 }
 
 static screenLayoutPtr
-xf86BusConfigMatch(ScrnInfoPtr scrnInfo) {
+xf86BusConfigMatch(ScrnInfoPtr scrnInfo, Bool is_gpu) {
     screenLayoutPtr layout;
-    int i;
+    int i, j;
 
     for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
          layout++) {
@@ -118,9 +118,18 @@ xf86BusConfigMatch(ScrnInfoPtr scrnInfo) {
                 xf86GetDevFromEntity(scrnInfo->entityList[i],
                                      scrnInfo->entityInstanceList[i]);
 
-            if (dev == layout->screen->device) {
-                /* A match has been found */
-                return layout;
+            if (is_gpu) {
+                for (j = 0; j < layout->screen->num_gpu_devices; j++) {
+                    if (dev == layout->screen->gpu_devices[j]) {
+                        /* A match has been found */
+                        return layout;
+                    }
+                }
+            } else {
+                if (dev == layout->screen->device) {
+                    /* A match has been found */
+                    return layout;
+                }
             }
         }
     }
@@ -192,7 +201,7 @@ xf86BusConfig(void)
      *
      */
     for (i = 0; i < xf86NumScreens; i++) {
-        layout = xf86BusConfigMatch(xf86Screens[i]);
+        layout = xf86BusConfigMatch(xf86Screens[i], FALSE);
         if (layout && layout->screen)
             xf86Screens[i]->confScreen = layout->screen;
         else {
@@ -204,9 +213,12 @@ xf86BusConfig(void)
         }
     }
 
-    /* bind GPU conf screen to protocol screen 0 */
-    for (i = 0; i < xf86NumGPUScreens; i++)
-        xf86GPUScreens[i]->confScreen = xf86Screens[0]->confScreen;
+    /* bind GPU conf screen to the configured protocol screen, or 0 if not configured */
+    for (i = 0; i < xf86NumGPUScreens; i++) {
+        layout = xf86BusConfigMatch(xf86GPUScreens[i], TRUE);
+        int scrnum = (layout && layout->screen) ? layout->screen->screennum : 0;
+        xf86GPUScreens[i]->confScreen = xf86Screens[scrnum]->confScreen;
+    }
 
     /* If no screens left, return now.  */
     if (xf86NumScreens == 0) {
diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
index e6fb11398..2a0cfc361 100644
--- a/hw/xfree86/common/xf86Init.c
+++ b/hw/xfree86/common/xf86Init.c
@@ -209,9 +209,11 @@ xf86AutoConfigOutputDevices(void)
     if (!xf86Info.autoBindGPU)
         return;
 
-    for (i = 0; i < xf86NumGPUScreens; i++)
+    for (i = 0; i < xf86NumGPUScreens; i++) {
+        int scrnum = xf86GPUScreens[i]->confScreen->screennum;
         RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]),
-                                      xf86ScrnToScreen(xf86Screens[0]));
+                                      xf86ScrnToScreen(xf86Screens[scrnum]));
+    }
 }
 
 static void
@@ -689,8 +691,10 @@ InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv)
         }
     }
 
-    for (i = 0; i < xf86NumGPUScreens; i++)
-        AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
+    for (i = 0; i < xf86NumGPUScreens; i++) {
+        int scrnum = xf86GPUScreens[i]->confScreen->screennum;
+        AttachUnboundGPU(xf86Screens[scrnum]->pScreen, xf86GPUScreens[i]->pScreen);
+    }
 
     xf86AutoConfigOutputDevices();
 
diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index e43ff69af..0e0a995ac 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -608,7 +608,7 @@ xf86platformAddGPUDevices(DriverPtr drvp)
 int
 xf86platformAddDevice(int index)
 {
-    int i, old_screens, scr_index;
+    int i, old_screens, scr_index, scrnum;
     DriverPtr drvp = NULL;
     screenLayoutPtr layout;
     static const char *hotplug_driver_name = "modesetting";
@@ -674,14 +674,15 @@ xf86platformAddDevice(int index)
        xf86NumGPUScreens = old_screens;
        return -1;
    }
-   /* attach unbound to 0 protocol screen */
-   AttachUnboundGPU(xf86Screens[0]->pScreen, xf86GPUScreens[i]->pScreen);
+   /* attach unbound to the configured protocol screen (or 0) */
+   scrnum = xf86GPUScreens[i]->confScreen->screennum;
+   AttachUnboundGPU(xf86Screens[scrnum]->pScreen, xf86GPUScreens[i]->pScreen);
    if (xf86Info.autoBindGPU)
        RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]),
-                                     xf86ScrnToScreen(xf86Screens[0]));
+                                     xf86ScrnToScreen(xf86Screens[scrnum]));
 
-   RRResourcesChanged(xf86Screens[0]->pScreen);
-   RRTellChanged(xf86Screens[0]->pScreen);
+   RRResourcesChanged(xf86Screens[scrnum]->pScreen);
+   RRTellChanged(xf86Screens[scrnum]->pScreen);
 
    return 0;
 }
@@ -690,7 +691,7 @@ void
 xf86platformRemoveDevice(int index)
 {
     EntityPtr entity;
-    int ent_num, i, j;
+    int ent_num, i, j, scrnum;
     Bool found;
 
     for (ent_num = 0; ent_num < xf86NumEntities; ent_num++) {
@@ -717,6 +718,8 @@ xf86platformRemoveDevice(int index)
         goto out;
     }
 
+    scrnum = xf86GPUScreens[i]->confScreen->screennum;
+
     xf86GPUScreens[i]->pScreen->CloseScreen(xf86GPUScreens[i]->pScreen);
 
     RemoveGPUScreen(xf86GPUScreens[i]->pScreen);
@@ -726,8 +729,8 @@ xf86platformRemoveDevice(int index)
 
     xf86_remove_platform_device(index);
 
-    RRResourcesChanged(xf86Screens[0]->pScreen);
-    RRTellChanged(xf86Screens[0]->pScreen);
+    RRResourcesChanged(xf86Screens[scrnum]->pScreen);
+    RRTellChanged(xf86Screens[scrnum]->pScreen);
  out:
     return;
 }
commit cd567415cc5645f8cdc78e85e8887e5cce76e6d7
Author: Zoltán Böszörményi <zboszor at gmail.com>
Date:   Thu Jul 8 06:09:44 2021 +0200

    xf86: Extract screen configuration matching into its own function
    
    Signed-off-by: Zoltán Böszörményi <zboszor at gmail.com>

diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 8a7fc4327..6dc1aebf0 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -106,6 +106,28 @@ xf86CallDriverProbe(DriverPtr drv, Bool detect_only)
     return foundScreen;
 }
 
+static screenLayoutPtr
+xf86BusConfigMatch(ScrnInfoPtr scrnInfo) {
+    screenLayoutPtr layout;
+    int i;
+
+    for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
+         layout++) {
+        for (i = 0; i < scrnInfo->numEntities; i++) {
+            GDevPtr dev =
+                xf86GetDevFromEntity(scrnInfo->entityList[i],
+                                     scrnInfo->entityInstanceList[i]);
+
+            if (dev == layout->screen->device) {
+                /* A match has been found */
+                return layout;
+            }
+        }
+    }
+
+    return NULL;
+}
+
 /**
  * @return TRUE if all buses are configured and set up correctly and FALSE
  * otherwise.
@@ -114,7 +136,7 @@ Bool
 xf86BusConfig(void)
 {
     screenLayoutPtr layout;
-    int i, j;
+    int i;
 
     /*
      * 3 step probe to (hopefully) ensure that we always find at least 1
@@ -170,27 +192,10 @@ xf86BusConfig(void)
      *
      */
     for (i = 0; i < xf86NumScreens; i++) {
-        for (layout = xf86ConfigLayout.screens; layout->screen != NULL;
-             layout++) {
-            Bool found = FALSE;
-
-            for (j = 0; j < xf86Screens[i]->numEntities; j++) {
-
-                GDevPtr dev =
-                    xf86GetDevFromEntity(xf86Screens[i]->entityList[j],
-                                         xf86Screens[i]->entityInstanceList[j]);
-
-                if (dev == layout->screen->device) {
-                    /* A match has been found */
-                    xf86Screens[i]->confScreen = layout->screen;
-                    found = TRUE;
-                    break;
-                }
-            }
-            if (found)
-                break;
-        }
-        if (layout->screen == NULL) {
+        layout = xf86BusConfigMatch(xf86Screens[i]);
+        if (layout && layout->screen)
+            xf86Screens[i]->confScreen = layout->screen;
+        else {
             /* No match found */
             xf86Msg(X_ERROR,
                     "Screen %d deleted because of no matching config section.\n",


More information about the xorg-commit mailing list