aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-graphics/xorg-driver/files/0001-xa-fix-leaked-xa-tracker.patch
blob: 68982fb6d458b58261bb2731a5ba9fdf203611b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From 33724ce4711ef98e93a9b16c1b7e974aa11086ed Mon Sep 17 00:00:00 2001
From: Rob Clark <robdclark@gmail.com>
Date: Fri, 15 May 2015 19:28:48 -0400
Subject: [PATCH] xa: fix leaked xa tracker

At CloseScreen, we wouldn't cleanup the XA tracker (so underlying
pipe_screen never got destroyed, so drm device fd never got closed).

Pull all this into MSMAccelFini() to make things match how things are
created at ScreenInit.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 src/msm-accel.c  | 28 +++++++++++++++++++++++++++-
 src/msm-driver.c | 14 ++------------
 src/msm-exa-xa.c |  1 +
 src/msm.h        |  3 ++-
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/msm-accel.c b/src/msm-accel.c
index b8d9c0c..2634c27 100644
--- a/src/msm-accel.c
+++ b/src/msm-accel.c
@@ -39,7 +39,7 @@
 #endif
 
 Bool
-MSMSetupAccel(ScreenPtr pScreen)
+MSMAccelInit(ScreenPtr pScreen)
 {
 	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
 	MSMPtr pMsm = MSMPTR(pScrn);
@@ -104,6 +104,32 @@ out:
 }
 
 void
+MSMAccelFini(ScreenPtr pScreen)
+{
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	MSMPtr pMsm = MSMPTR(pScrn);
+
+	/* Close DRI2 */
+	if (pMsm->dri) {
+		MSMDRI2CloseScreen(pScreen);
+	}
+
+	/* Close EXA */
+	if (pMsm->pExa) {
+		exaDriverFini(pScreen);
+		free(pMsm->pExa);
+		pMsm->pExa = NULL;
+	}
+
+#ifdef HAVE_XA
+	if (pMsm->xa) {
+		xa_tracker_destroy(pMsm->xa);
+		pMsm->xa = NULL;
+	}
+#endif
+}
+
+void
 MSMFlushAccel(ScreenPtr pScreen)
 {
 	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
diff --git a/src/msm-driver.c b/src/msm-driver.c
index 824eb17..9cb7da3 100644
--- a/src/msm-driver.c
+++ b/src/msm-driver.c
@@ -356,17 +356,7 @@ MSMCloseScreen(CLOSE_SCREEN_ARGS_DECL)
 
 	DEBUG_MSG("close screen");
 
-	/* Close DRI2 */
-	if (pMsm->dri) {
-		MSMDRI2CloseScreen(pScreen);
-	}
-
-	/* Close EXA */
-	if (pMsm->pExa) {
-		exaDriverFini(pScreen);
-		free(pMsm->pExa);
-		pMsm->pExa = NULL;
-	}
+	MSMAccelFini(pScreen);
 
 	if (pScrn->vtSema) {
 		MSMLeaveVT(VT_FUNC_ARGS(0));
@@ -459,7 +449,7 @@ MSMScreenInit(SCREEN_INIT_ARGS_DECL)
 	/* Set up EXA */
 	xf86LoadSubModule(pScrn, "exa");
 
-	if (!MSMSetupAccel(pScreen))
+	if (!MSMAccelInit(pScreen))
 		ERROR_MSG("Unable to setup EXA");
 
 	/* Set up the software cursor */
diff --git a/src/msm-exa-xa.c b/src/msm-exa-xa.c
index c296ce2..e2ec439 100644
--- a/src/msm-exa-xa.c
+++ b/src/msm-exa-xa.c
@@ -745,6 +745,7 @@ XACreatePixmap2(ScreenPtr pScreen, int width, int height,
 		uint32_t handle, stride;
 		xa_surface_handle(priv->surf, xa_handle_type_kms,
 				&handle, &stride);
+		priv->bo = fd_bo_from_handle(pMsm->dev, handle, 0);
 		*new_fb_pitch = stride;
 		return priv;
 	}
diff --git a/src/msm.h b/src/msm.h
index 76bcce5..adc596c 100644
--- a/src/msm.h
+++ b/src/msm.h
@@ -129,7 +129,8 @@ struct msm_pixmap_priv {
 #define MSMPTR_FROM_PIXMAP(_x)         \
 		MSMPTR_FROM_SCREEN((_x)->drawable.pScreen)
 
-Bool MSMSetupAccel(ScreenPtr pScreen);
+Bool MSMAccelInit(ScreenPtr pScreen);
+void MSMAccelFini(ScreenPtr pScreen);
 void MSMFlushAccel(ScreenPtr pScreen);
 Bool MSMSetupExa(ScreenPtr, Bool softexa);
 Bool MSMSetupExaXA(ScreenPtr);
-- 
2.4.6