From feb4ec510b1328fdd9aa77305d3273d1f9c7e124 Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex@linutronix.de>
Date: Thu, 9 Jun 2022 11:42:05 +0200
Subject: [PATCH] swrast_kms: use swkmsDRI2Extension instead of
 driDRI2Extension

This set of changes:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15649

caused a regression in Xorg when using swrast_kms:
   (EE) AIGLX error: Calling driver entry point failed

This commit changes the swrast_kms driver to use a dedicated screen init function
(which I believe was overlooked); I also took the opportunity to rename the
associated plumbling to have swrast-specific names.

Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16942]
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 src/gallium/frontends/dri/dri2.c       | 16 ++++++++--------
 src/gallium/frontends/dri/dri_screen.h |  4 ++--
 src/gallium/frontends/dri/dri_util.c   |  2 +-
 src/gallium/targets/dri/target.c       |  2 +-
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index 63ac9d5..de33789 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -2508,7 +2508,7 @@ release_pipe:
  * Returns the struct gl_config supported by this driver.
  */
 static const __DRIconfig **
-dri_kms_init_screen(__DRIscreen * sPriv)
+dri_swrast_kms_init_screen(__DRIscreen * sPriv)
 {
 #if defined(GALLIUM_SOFTPIPE)
    const __DRIconfig **configs;
@@ -2613,8 +2613,8 @@ static const struct __DRIDriverVtableExtensionRec galliumdrm_vtable = {
  * hook. The latter is used to explicitly initialise the kms_swrast driver
  * rather than selecting the approapriate driver as suggested by the loader.
  */
-const struct __DriverAPIRec dri_kms_driver_api = {
-   .InitScreen = dri_kms_init_screen,
+const struct __DriverAPIRec dri_swrast_kms_driver_api = {
+   .InitScreen = dri_swrast_kms_init_screen,
    .DestroyScreen = dri_destroy_screen,
    .CreateBuffer = dri2_create_buffer,
    .DestroyBuffer = dri_destroy_buffer,
@@ -2633,17 +2633,17 @@ const __DRIextension *galliumdrm_driver_extensions[] = {
     NULL
 };
 
-static const struct __DRIDriverVtableExtensionRec dri_kms_vtable = {
+static const struct __DRIDriverVtableExtensionRec dri_swrast_kms_vtable = {
    .base = { __DRI_DRIVER_VTABLE, 1 },
-   .vtable = &dri_kms_driver_api,
+   .vtable = &dri_swrast_kms_driver_api,
 };
 
-const __DRIextension *dri_kms_driver_extensions[] = {
+const __DRIextension *dri_swrast_kms_driver_extensions[] = {
     &driCoreExtension.base,
     &driImageDriverExtension.base,
-    &driDRI2Extension.base,
+    &swkmsDRI2Extension.base,
     &gallium_config_options.base,
-    &dri_kms_vtable.base,
+    &dri_swrast_kms_vtable.base,
     NULL
 };
 
diff --git a/src/gallium/frontends/dri/dri_screen.h b/src/gallium/frontends/dri/dri_screen.h
index 0ee2feb..0bb8817 100644
--- a/src/gallium/frontends/dri/dri_screen.h
+++ b/src/gallium/frontends/dri/dri_screen.h
@@ -168,8 +168,8 @@ dri_destroy_screen_helper(struct dri_screen * screen);
 void
 dri_destroy_screen(__DRIscreen * sPriv);
 
-extern const struct __DriverAPIRec dri_kms_driver_api;
-extern const __DRIextension *dri_kms_driver_extensions[];
+extern const struct __DriverAPIRec dri_swrast_kms_driver_api;
+extern const __DRIextension *dri_swrast_kms_driver_extensions[];
 extern const struct __DriverAPIRec galliumdrm_driver_api;
 extern const __DRIextension *galliumdrm_driver_extensions[];
 extern const struct __DriverAPIRec galliumsw_driver_api;
diff --git a/src/gallium/frontends/dri/dri_util.c b/src/gallium/frontends/dri/dri_util.c
index 8d60526..03614e1 100644
--- a/src/gallium/frontends/dri/dri_util.c
+++ b/src/gallium/frontends/dri/dri_util.c
@@ -187,7 +187,7 @@ swkmsCreateNewScreen(int scrn, int fd,
 		     const __DRIconfig ***driver_configs, void *data)
 {
    return driCreateNewScreen2(scrn, fd, extensions,
-                              dri_kms_driver_extensions,
+                              dri_swrast_kms_driver_extensions,
                               driver_configs, data);
 }
 
diff --git a/src/gallium/targets/dri/target.c b/src/gallium/targets/dri/target.c
index 9b78351..e02b03b 100644
--- a/src/gallium/targets/dri/target.c
+++ b/src/gallium/targets/dri/target.c
@@ -25,7 +25,7 @@ const __DRIextension **__driDriverGetExtensions_kms_swrast(void);
 
 PUBLIC const __DRIextension **__driDriverGetExtensions_kms_swrast(void)
 {
-   return dri_kms_driver_extensions;
+   return dri_swrast_kms_driver_extensions;
 }
 
 #endif
