[Mesa-dev,v4,11/11] vc4: use common screen ref counting

Submitted by Rob Herring on July 22, 2016, 4:22 p.m.

Details

Message ID 20160722162222.21871-12-robh@kernel.org
State New
Headers show
Series "Common pipe screen ref counting" ( rev: 4 ) in Mesa

Not browsing as part of any series.

Commit Message

Rob Herring July 22, 2016, 4:22 p.m.
Use the common pipe_screen ref counting and fd hashing functions for
vc4. This is necessary to only create a single pipe_screen for a
process and avoid multiple imports of same prime fd among other things
(probably).

Cc: Eric Anholt <eric@anholt.net>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 src/gallium/winsys/vc4/drm/vc4_drm_winsys.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c
index c5434ad..e0d9cc2 100644
--- a/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c
+++ b/src/gallium/winsys/vc4/drm/vc4_drm_winsys.c
@@ -22,6 +22,7 @@ 
  */
 
 #include <unistd.h>
+#include "util/u_screen.h"
 
 #include "vc4_drm_public.h"
 
@@ -30,5 +31,13 @@ 
 struct pipe_screen *
 vc4_drm_screen_create(int fd)
 {
-	return vc4_screen_create(dup(fd));
+	int dupfd;
+	struct pipe_screen *pscreen = pipe_screen_reference(fd);
+	if (pscreen)
+		return pscreen;
+
+	dupfd = dup(fd);
+	pscreen = vc4_screen_create(dupfd);
+	pipe_screen_reference_init(pscreen, dupfd);
+	return pscreen;
 }

Comments

Rob Herring <robh@kernel.org> writes:

> Use the common pipe_screen ref counting and fd hashing functions for
> vc4. This is necessary to only create a single pipe_screen for a
> process and avoid multiple imports of same prime fd among other things
> (probably).

Reviewed-by: Eric Anholt <eric@anholt.net>