Skip to contentSkip to conversation

present: Fixup return type of nouveau_present_init()

PATCH In review Mario Kleiner 3 participants 4 messages Jul 29, 2015 – Jul 30, 2015 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 present: Fixup return type of nouveau_present_init()

Make it a Bool consistently, as declared in header.

---
 src/nouveau_present.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
src/nouveau_present.c +2 -2
index 4de1e6e..699a58d 100644
@@ -293,7 +293,7 @@ nouveau_present_fini(ScreenPtr screen)
 	}
 }
 
-int
+Bool
 nouveau_present_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
@@ -304,7 +304,7 @@ nouveau_present_init(ScreenPtr screen)
 
 	present = pNv->present = calloc(1, sizeof(*present));
 	if (!present)
-		return -ENOMEM;
+		return FALSE;
 
 	present->info.version = PRESENT_SCREEN_INFO_VERSION;
 	present->info.get_crtc = nouveau_present_crtc;
Signature · 6 lines
1.9.1

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1438173542-28299-1-git-send-email-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 2/2 Add Option "DRI" to allow selection of maximum DRI level. (v2)

Allow user to select the maximum level of DRI implementation to use, DRI2 or DRI3.

exa accel supports both DRI2 and, if the kernel supports rendernodes, also DRI3. However, DRI3 still seems to have some bugs on current implementations, and additionally it doesn't work well at all for X-Servers older than 1.16.3 due to X-Server bugs. Therefore we default to DRI2 on exa, but allow the user to enable DRI3 with this new option.

nouveau's glamor accel backend currently doesn't work under DRI2 at all, so we continue to use DRI3 whenever it is supported and ignore this new option for now.

Also add a bit more output about status of Present and DRI3 to aid debugging.

Note: This was originally meant to be a boolean parameter,
to just select between DRI3 on and off, but changed here to a DRI level to make it consistent with the same option in the released Intel-ddx.

v2: Use fixed up Bool return type of nouveau_present_init().

Cc Ilia Mirkin <[email protected]>
Cc Emil Velikov <[email protected]>
Cc Martin Peres <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 man/nouveau.man      |  6 ++++++
 src/nouveau_dri2.c   | 11 ++++++++++-
 src/nouveau_glamor.c |  2 +-
 src/nv_const.h       |  2 ++
 src/nv_driver.c      | 30 ++++++++++++++++++++++++++++--
 src/nv_type.h        |  1 +
 6 files changed, 48 insertions(+), 4 deletions(-)
man/nouveau.man +6 -0
index 129bb7f..3d5a428 100644
@@ -125,6 +125,12 @@ that relies on correct presentation timing behaviour as defined in that
 specification.
 .br
 Default: 1.
+.TP
+.BI "Option \*qDRI\*q \*q" integer \*q
+Define the maximum level of DRI to enable. Valid values are 2 or 3.
+exa acceleration will honor the maximum level if it is supported.
+Under glamor acceleration DRI3 is always enabled if supported,
+as glamor currently does not support DRI2. Default: 2 on exa, 3 on glamor.
 .SH "SEE ALSO"
 __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
 .SH AUTHORS
src/nouveau_dri2.c +10 -1
index ce6f53e..81ee9be 100644
@@ -1134,7 +1134,16 @@ nouveau_dri3_screen_init(ScreenPtr screen)
 	if (buf && stat(buf, &render) == 0 &&
 	    master.st_mode == render.st_mode) {
 		pNv->render_node = buf;
-		return dri3_screen_init(screen, &nouveau_dri3_screen_info);
+		if (dri3_screen_init(screen, &nouveau_dri3_screen_info)) {
+			xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+				   "DRI3 on EXA enabled\n");
+			return TRUE;
+		}
+		else {
+			xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+				   "DRI3 on EXA initialization failed\n");
+			return FALSE;
+		}
 	} else
 		free(buf);
 #endif
src/nouveau_glamor.c +1 -1
index b8bca17..a8e9206 100644
@@ -240,7 +240,7 @@ nouveau_glamor_init(ScreenPtr screen)
 	screen->SharePixmapBacking = nouveau_glamor_share_pixmap_backing;
 	screen->SetSharedPixmapBacking = nouveau_glamor_set_shared_pixmap_backing;
 
-	xf86DrvMsg(scrn->scrnIndex, X_INFO, "[GLAMOR] initialised\n");
+	xf86DrvMsg(scrn->scrnIndex, X_INFO, "[GLAMOR] initialised with DRI3\n");
 	pNv->Flush = nouveau_glamor_flush;
 	return TRUE;
 }
src/nv_const.h +2 -0
index f1b4e9b..3f18d23 100644
@@ -18,6 +18,7 @@ typedef enum {
     OPTION_SWAP_LIMIT,
     OPTION_ASYNC_COPY,
     OPTION_ACCELMETHOD,
+    OPTION_DRI,
 } NVOpts;
 
 
@@ -34,6 +35,7 @@ static const OptionInfoRec NVOptions[] = {
     { OPTION_SWAP_LIMIT,	"SwapLimit",	OPTV_INTEGER,	{0}, FALSE },
     { OPTION_ASYNC_COPY,	"AsyncUTSDFS",	OPTV_BOOLEAN,	{0}, FALSE },
     { OPTION_ACCELMETHOD,	"AccelMethod",	OPTV_STRING,	{0}, FALSE },
+    { OPTION_DRI,		"DRI",		OPTV_INTEGER,	{0}, FALSE },
     { -1,                       NULL,           OPTV_NONE,      {0}, FALSE }
 };
 
src/nv_driver.c +28 -2
index 4218e4f..514a8bc 100644
@@ -1095,6 +1095,25 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
 	pNv->ce_enabled =
 		xf86ReturnOptValBool(pNv->Options, OPTION_ASYNC_COPY, FALSE);
 
+	/* Define maximum allowed level of DRI implementation to use.
+	 * We default to DRI2 on EXA for now, as DRI3 still has some
+	 * problems. However, the max_dri_level can be only honored
+	 * by EXA, as GLAMOR only supports DRI3 at the moment.
+	 */
+	pNv->max_dri_level = (pNv->AccelMethod == GLAMOR) ? 3 : 2;
+	from = X_DEFAULT;
+
+	if (xf86GetOptValInteger(pNv->Options, OPTION_DRI,
+				 &pNv->max_dri_level)) {
+		from = X_CONFIG;
+		if (pNv->max_dri_level < 2)
+			pNv->max_dri_level = 2;
+		if (pNv->max_dri_level > 3)
+			pNv->max_dri_level = 3;
+	}
+	xf86DrvMsg(pScrn->scrnIndex, from, "Allowed maximum DRI level %i.\n",
+		   pNv->max_dri_level);
+
 	if (pNv->AccelMethod > NONE && pNv->dev->chipset >= 0x11) {
 		from = X_DEFAULT;
 		pNv->glx_vblank = TRUE;
@@ -1474,7 +1493,13 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
 
 	xf86SetBlackWhitePixels(pScreen);
 
-	nouveau_present_init(pScreen);
+	if (nouveau_present_init(pScreen))
+		xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+			   "Hardware support for Present enabled\n");
+	else
+		xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+			   "Hardware support for Present disabled\n");
+
 	nouveau_sync_init(pScreen);
 	nouveau_dri2_init(pScreen);
 	if (pNv->AccelMethod == GLAMOR) {
@@ -1482,7 +1507,8 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
 			return FALSE;
 	} else
 	if (pNv->AccelMethod == EXA) {
-		if (!nouveau_dri3_screen_init(pScreen))
+		if (pNv->max_dri_level >= 3 &&
+		    !nouveau_dri3_screen_init(pScreen))
 			return FALSE;
 
 		if (!nouveau_exa_init(pScreen))
src/nv_type.h +1 -0
index e6ab192..510a30c 100644
@@ -71,6 +71,7 @@ typedef struct _NVRec {
     Bool		has_pageflip;
     int 		swap_limit;
     int 		max_swap_limit;
+    int 		max_dri_level;
 
     ScreenBlockHandlerProcPtr BlockHandler;
     CreateScreenResourcesProcPtr CreateScreenResources;
Signature · 6 lines
1.9.1

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

A message that is not in the archive (sent off-list or not yet received): 1438173542-28299-2-git-send-email-mario.kleiner.de-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

Re: [PATCH 2/2] Add Option "DRI" to allow selection of maximum DRI level. (v2)

Series is Reviewed-by: Ilia Mirkin <[email protected]>

I'll let it sit for a day or so in case others have feedback.

Quoted 178 lines · Mario Kleiner

Allow user to select the maximum level of DRI implementation to use, DRI2 or DRI3.

exa accel supports both DRI2 and, if the kernel supports rendernodes, also DRI3. However, DRI3 still seems to have some bugs on current implementations, and additionally it doesn't work well at all for X-Servers older than 1.16.3 due to X-Server bugs. Therefore we default to DRI2 on exa, but allow the user to enable DRI3 with this new option.

nouveau's glamor accel backend currently doesn't work under DRI2 at all, so we continue to use DRI3 whenever it is supported and ignore this new option for now.

Also add a bit more output about status of Present and DRI3 to aid debugging.

Note: This was originally meant to be a boolean parameter,
to just select between DRI3 on and off, but changed here to a DRI level to make it consistent with the same option in the released Intel-ddx.

v2: Use fixed up Bool return type of nouveau_present_init().

Cc Ilia Mirkin <[email protected]>
Cc Emil Velikov <[email protected]>
Cc Martin Peres <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 man/nouveau.man      |  6 ++++++
 src/nouveau_dri2.c   | 11 ++++++++++-
 src/nouveau_glamor.c |  2 +-
 src/nv_const.h       |  2 ++
 src/nv_driver.c      | 30 ++++++++++++++++++++++++++++--
 src/nv_type.h        |  1 +
 6 files changed, 48 insertions(+), 4 deletions(-)
man/nouveau.man +6 -0
index 129bb7f..3d5a428 100644
@@ -125,6 +125,12 @@ that relies on correct presentation timing behaviour as defined in that
 specification.
 .br
 Default: 1.
+.TP
+.BI "Option \*qDRI\*q \*q" integer \*q
+Define the maximum level of DRI to enable. Valid values are 2 or 3.
+exa acceleration will honor the maximum level if it is supported.
+Under glamor acceleration DRI3 is always enabled if supported,
+as glamor currently does not support DRI2. Default: 2 on exa, 3 on glamor.
 .SH "SEE ALSO"
 __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
 .SH AUTHORS
src/nouveau_dri2.c +10 -1
index ce6f53e..81ee9be 100644
@@ -1134,7 +1134,16 @@ nouveau_dri3_screen_init(ScreenPtr screen)
        if (buf && stat(buf, &render) == 0 &&
            master.st_mode == render.st_mode) {
                pNv->render_node = buf;
-               return dri3_screen_init(screen, &nouveau_dri3_screen_info);
+               if (dri3_screen_init(screen, &nouveau_dri3_screen_info)) {
+                       xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                                  "DRI3 on EXA enabled\n");
+                       return TRUE;
+               }
+               else {
+                       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                                  "DRI3 on EXA initialization failed\n");
+                       return FALSE;
+               }
        } else
                free(buf);
 #endif
src/nouveau_glamor.c +1 -1
index b8bca17..a8e9206 100644
@@ -240,7 +240,7 @@ nouveau_glamor_init(ScreenPtr screen)
        screen->SharePixmapBacking = nouveau_glamor_share_pixmap_backing;
        screen->SetSharedPixmapBacking = nouveau_glamor_set_shared_pixmap_backing;
 
-       xf86DrvMsg(scrn->scrnIndex, X_INFO, "[GLAMOR] initialised\n");
+       xf86DrvMsg(scrn->scrnIndex, X_INFO, "[GLAMOR] initialised with DRI3\n");
        pNv->Flush = nouveau_glamor_flush;
        return TRUE;
 }
src/nv_const.h +2 -0
index f1b4e9b..3f18d23 100644
@@ -18,6 +18,7 @@ typedef enum {
     OPTION_SWAP_LIMIT,
     OPTION_ASYNC_COPY,
     OPTION_ACCELMETHOD,
+    OPTION_DRI,
 } NVOpts;
 
 
@@ -34,6 +35,7 @@ static const OptionInfoRec NVOptions[] = {
     { OPTION_SWAP_LIMIT,       "SwapLimit",    OPTV_INTEGER,   {0}, FALSE },
     { OPTION_ASYNC_COPY,       "AsyncUTSDFS",  OPTV_BOOLEAN,   {0}, FALSE },
     { OPTION_ACCELMETHOD,      "AccelMethod",  OPTV_STRING,    {0}, FALSE },
+    { OPTION_DRI,              "DRI",          OPTV_INTEGER,   {0}, FALSE },
     { -1,                       NULL,           OPTV_NONE,      {0}, FALSE }
 };
 
src/nv_driver.c +28 -2
index 4218e4f..514a8bc 100644
@@ -1095,6 +1095,25 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
        pNv->ce_enabled =
                xf86ReturnOptValBool(pNv->Options, OPTION_ASYNC_COPY, FALSE);
 
+       /* Define maximum allowed level of DRI implementation to use.
+        * We default to DRI2 on EXA for now, as DRI3 still has some
+        * problems. However, the max_dri_level can be only honored
+        * by EXA, as GLAMOR only supports DRI3 at the moment.
+        */
+       pNv->max_dri_level = (pNv->AccelMethod == GLAMOR) ? 3 : 2;
+       from = X_DEFAULT;
+
+       if (xf86GetOptValInteger(pNv->Options, OPTION_DRI,
+                                &pNv->max_dri_level)) {
+               from = X_CONFIG;
+               if (pNv->max_dri_level < 2)
+                       pNv->max_dri_level = 2;
+               if (pNv->max_dri_level > 3)
+                       pNv->max_dri_level = 3;
+       }
+       xf86DrvMsg(pScrn->scrnIndex, from, "Allowed maximum DRI level %i.\n",
+                  pNv->max_dri_level);
+
        if (pNv->AccelMethod > NONE && pNv->dev->chipset >= 0x11) {
                from = X_DEFAULT;
                pNv->glx_vblank = TRUE;
@@ -1474,7 +1493,13 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
 
        xf86SetBlackWhitePixels(pScreen);
 
-       nouveau_present_init(pScreen);
+       if (nouveau_present_init(pScreen))
+               xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                          "Hardware support for Present enabled\n");
+       else
+               xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                          "Hardware support for Present disabled\n");
+
        nouveau_sync_init(pScreen);
        nouveau_dri2_init(pScreen);
        if (pNv->AccelMethod == GLAMOR) {
@@ -1482,7 +1507,8 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
                        return FALSE;
        } else
        if (pNv->AccelMethod == EXA) {
-               if (!nouveau_dri3_screen_init(pScreen))
+               if (pNv->max_dri_level >= 3 &&
+                   !nouveau_dri3_screen_init(pScreen))
                        return FALSE;
 
                if (!nouveau_exa_init(pScreen))
src/nv_type.h +1 -1
index e6ab192..510a30c 100644
@@ -71,6 +71,7 @@ typedef struct _NVRec {
     Bool               has_pageflip;
     int                swap_limit;
     int                max_swap_limit;
+    int                max_dri_level;
 
     ScreenBlockHandlerProcPtr BlockHandler;
     CreateScreenResourcesProcPtr CreateScreenResources;
--
Quoted 2 lines

1.9.1

_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau

#5 lore raw

Re: [PATCH 2/2] Add Option "DRI" to allow selection of maximum DRI level. (v2)

In reply to a message not in the archive
Quoted 115 lines · Mario Kleiner

Allow user to select the maximum level of DRI implementation to use, DRI2 or DRI3.

exa accel supports both DRI2 and, if the kernel supports rendernodes, also DRI3. However, DRI3 still seems to have some bugs on current implementations, and additionally it doesn't work well at all for X-Servers older than 1.16.3 due to X-Server bugs. Therefore we default to DRI2 on exa, but allow the user to enable DRI3 with this new option.

nouveau's glamor accel backend currently doesn't work under DRI2 at all, so we continue to use DRI3 whenever it is supported and ignore this new option for now.

Also add a bit more output about status of Present and DRI3 to aid debugging.

Note: This was originally meant to be a boolean parameter,
to just select between DRI3 on and off, but changed here to a DRI level to make it consistent with the same option in the released Intel-ddx.

v2: Use fixed up Bool return type of nouveau_present_init().

Cc Ilia Mirkin <[email protected]>
Cc Emil Velikov <[email protected]>
Cc Martin Peres <[email protected]>
Cc Ben Skeggs <[email protected]>
---
 man/nouveau.man      |  6 ++++++
 src/nouveau_dri2.c   | 11 ++++++++++-
 src/nouveau_glamor.c |  2 +-
 src/nv_const.h       |  2 ++
 src/nv_driver.c      | 30 ++++++++++++++++++++++++++++--
 src/nv_type.h        |  1 +
 6 files changed, 48 insertions(+), 4 deletions(-)
man/nouveau.man +6 -0
index 129bb7f..3d5a428 100644
@@ -125,6 +125,12 @@ that relies on correct presentation timing behaviour as defined in that
 specification.
 .br
 Default: 1.
+.TP
+.BI "Option \*qDRI\*q \*q" integer \*q
+Define the maximum level of DRI to enable. Valid values are 2 or 3.
+exa acceleration will honor the maximum level if it is supported.
+Under glamor acceleration DRI3 is always enabled if supported,
+as glamor currently does not support DRI2. Default: 2 on exa, 3 on glamor.
 .SH "SEE ALSO"
 __xservername__(__appmansuffix__), __xconfigfile__(__filemansuffix__), Xserver(__appmansuffix__), X(__miscmansuffix__)
 .SH AUTHORS
src/nouveau_dri2.c +10 -1
index ce6f53e..81ee9be 100644
@@ -1134,7 +1134,16 @@ nouveau_dri3_screen_init(ScreenPtr screen)
        if (buf && stat(buf, &render) == 0 &&
            master.st_mode == render.st_mode) {
                pNv->render_node = buf;
-               return dri3_screen_init(screen, &nouveau_dri3_screen_info);
+               if (dri3_screen_init(screen, &nouveau_dri3_screen_info)) {
+                       xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+                                  "DRI3 on EXA enabled\n");
+                       return TRUE;
+               }
+               else {
+                       xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+                                  "DRI3 on EXA initialization failed\n");
+                       return FALSE;
+               }
        } else
                free(buf);
 #endif
src/nouveau_glamor.c +1 -1
index b8bca17..a8e9206 100644
@@ -240,7 +240,7 @@ nouveau_glamor_init(ScreenPtr screen)
        screen->SharePixmapBacking = nouveau_glamor_share_pixmap_backing;
        screen->SetSharedPixmapBacking = nouveau_glamor_set_shared_pixmap_backing;
 
-       xf86DrvMsg(scrn->scrnIndex, X_INFO, "[GLAMOR] initialised\n");
+       xf86DrvMsg(scrn->scrnIndex, X_INFO, "[GLAMOR] initialised with DRI3\n");
        pNv->Flush = nouveau_glamor_flush;
        return TRUE;
 }
src/nv_const.h +2 -0
index f1b4e9b..3f18d23 100644
@@ -18,6 +18,7 @@ typedef enum {
     OPTION_SWAP_LIMIT,
     OPTION_ASYNC_COPY,
     OPTION_ACCELMETHOD,
+    OPTION_DRI,
 } NVOpts;
 
 
@@ -34,6 +35,7 @@ static const OptionInfoRec NVOptions[] = {
     { OPTION_SWAP_LIMIT,       "SwapLimit",    OPTV_INTEGER,   {0}, FALSE },
     { OPTION_ASYNC_COPY,       "AsyncUTSDFS",  OPTV_BOOLEAN,   {0}, FALSE },
     { OPTION_ACCELMETHOD,      "AccelMethod",  OPTV_STRING,    {0}, FALSE },
+    { OPTION_DRI,              "DRI",          OPTV_INTEGER,   {0}, FALSE },
     { -1,                       NULL,           OPTV_NONE,      {0}, FALSE }
 };
 
src/nv_driver.c +0 -0
index 4218e4f..514a8bc 100644

src/nv_driver.c NVPreInit(ScrnInfoPtr pScrn, int flags) · line 1102

Quoted 8 lines
src/nv_driver.c +5 -0
@@ -1095,6 +1095,25 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
        pNv->ce_enabled =
                xf86ReturnOptValBool(pNv->Options, OPTION_ASYNC_COPY, FALSE);
 
+       /* Define maximum allowed level of DRI implementation to use.
+        * We default to DRI2 on EXA for now, as DRI3 still has some
+        * problems. However, the max_dri_level can be only honored
+        * by EXA, as GLAMOR only supports DRI3 at the moment.
+        */

Looks great afaict. On the bikeshed side: one could add a note to update the manpage as these change, but I doubt that'll be useful any time soon.

-Emil
_______________________________________________
Nouveau mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/nouveau