19
19
#include <xen/xen.h>
20
20
#include <xen/xenbus.h>
21
21
22
+ #include <xen/xen-front-pgdir-shbuf.h>
22
23
#include <xen/interface/io/displif.h>
23
24
24
25
#include "xen_drm_front.h"
25
26
#include "xen_drm_front_cfg.h"
26
27
#include "xen_drm_front_evtchnl.h"
27
28
#include "xen_drm_front_gem.h"
28
29
#include "xen_drm_front_kms.h"
29
- #include "xen_drm_front_shbuf.h"
30
30
31
31
struct xen_drm_front_dbuf {
32
32
struct list_head list ;
33
33
u64 dbuf_cookie ;
34
34
u64 fb_cookie ;
35
- struct xen_drm_front_shbuf * shbuf ;
35
+
36
+ struct xen_front_pgdir_shbuf shbuf ;
36
37
};
37
38
38
- static int dbuf_add_to_list (struct xen_drm_front_info * front_info ,
39
- struct xen_drm_front_shbuf * shbuf , u64 dbuf_cookie )
39
+ static void dbuf_add_to_list (struct xen_drm_front_info * front_info ,
40
+ struct xen_drm_front_dbuf * dbuf , u64 dbuf_cookie )
40
41
{
41
- struct xen_drm_front_dbuf * dbuf ;
42
-
43
- dbuf = kzalloc (sizeof (* dbuf ), GFP_KERNEL );
44
- if (!dbuf )
45
- return - ENOMEM ;
46
-
47
42
dbuf -> dbuf_cookie = dbuf_cookie ;
48
- dbuf -> shbuf = shbuf ;
49
43
list_add (& dbuf -> list , & front_info -> dbuf_list );
50
- return 0 ;
51
44
}
52
45
53
46
static struct xen_drm_front_dbuf * dbuf_get (struct list_head * dbuf_list ,
@@ -62,24 +55,15 @@ static struct xen_drm_front_dbuf *dbuf_get(struct list_head *dbuf_list,
62
55
return NULL ;
63
56
}
64
57
65
- static void dbuf_flush_fb (struct list_head * dbuf_list , u64 fb_cookie )
66
- {
67
- struct xen_drm_front_dbuf * buf , * q ;
68
-
69
- list_for_each_entry_safe (buf , q , dbuf_list , list )
70
- if (buf -> fb_cookie == fb_cookie )
71
- xen_drm_front_shbuf_flush (buf -> shbuf );
72
- }
73
-
74
58
static void dbuf_free (struct list_head * dbuf_list , u64 dbuf_cookie )
75
59
{
76
60
struct xen_drm_front_dbuf * buf , * q ;
77
61
78
62
list_for_each_entry_safe (buf , q , dbuf_list , list )
79
63
if (buf -> dbuf_cookie == dbuf_cookie ) {
80
64
list_del (& buf -> list );
81
- xen_drm_front_shbuf_unmap ( buf -> shbuf );
82
- xen_drm_front_shbuf_free ( buf -> shbuf );
65
+ xen_front_pgdir_shbuf_unmap ( & buf -> shbuf );
66
+ xen_front_pgdir_shbuf_free ( & buf -> shbuf );
83
67
kfree (buf );
84
68
break ;
85
69
}
@@ -91,8 +75,8 @@ static void dbuf_free_all(struct list_head *dbuf_list)
91
75
92
76
list_for_each_entry_safe (buf , q , dbuf_list , list ) {
93
77
list_del (& buf -> list );
94
- xen_drm_front_shbuf_unmap ( buf -> shbuf );
95
- xen_drm_front_shbuf_free ( buf -> shbuf );
78
+ xen_front_pgdir_shbuf_unmap ( & buf -> shbuf );
79
+ xen_front_pgdir_shbuf_free ( & buf -> shbuf );
96
80
kfree (buf );
97
81
}
98
82
}
@@ -171,38 +155,39 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
171
155
u32 bpp , u64 size , struct page * * pages )
172
156
{
173
157
struct xen_drm_front_evtchnl * evtchnl ;
174
- struct xen_drm_front_shbuf * shbuf ;
158
+ struct xen_drm_front_dbuf * dbuf ;
175
159
struct xendispl_req * req ;
176
- struct xen_drm_front_shbuf_cfg buf_cfg ;
160
+ struct xen_front_pgdir_shbuf_cfg buf_cfg ;
177
161
unsigned long flags ;
178
162
int ret ;
179
163
180
164
evtchnl = & front_info -> evt_pairs [GENERIC_OP_EVT_CHNL ].req ;
181
165
if (unlikely (!evtchnl ))
182
166
return - EIO ;
183
167
168
+ dbuf = kzalloc (sizeof (* dbuf ), GFP_KERNEL );
169
+ if (!dbuf )
170
+ return - ENOMEM ;
171
+
172
+ dbuf_add_to_list (front_info , dbuf , dbuf_cookie );
173
+
184
174
memset (& buf_cfg , 0 , sizeof (buf_cfg ));
185
175
buf_cfg .xb_dev = front_info -> xb_dev ;
176
+ buf_cfg .num_pages = DIV_ROUND_UP (size , PAGE_SIZE );
186
177
buf_cfg .pages = pages ;
187
- buf_cfg .size = size ;
178
+ buf_cfg .pgdir = & dbuf -> shbuf ;
188
179
buf_cfg .be_alloc = front_info -> cfg .be_alloc ;
189
180
190
- shbuf = xen_drm_front_shbuf_alloc (& buf_cfg );
191
- if (IS_ERR (shbuf ))
192
- return PTR_ERR (shbuf );
193
-
194
- ret = dbuf_add_to_list (front_info , shbuf , dbuf_cookie );
195
- if (ret < 0 ) {
196
- xen_drm_front_shbuf_free (shbuf );
197
- return ret ;
198
- }
181
+ ret = xen_front_pgdir_shbuf_alloc (& buf_cfg );
182
+ if (ret < 0 )
183
+ goto fail_shbuf_alloc ;
199
184
200
185
mutex_lock (& evtchnl -> u .req .req_io_lock );
201
186
202
187
spin_lock_irqsave (& front_info -> io_lock , flags );
203
188
req = be_prepare_req (evtchnl , XENDISPL_OP_DBUF_CREATE );
204
189
req -> op .dbuf_create .gref_directory =
205
- xen_drm_front_shbuf_get_dir_start ( shbuf );
190
+ xen_front_pgdir_shbuf_get_dir_start ( & dbuf -> shbuf );
206
191
req -> op .dbuf_create .buffer_sz = size ;
207
192
req -> op .dbuf_create .dbuf_cookie = dbuf_cookie ;
208
193
req -> op .dbuf_create .width = width ;
@@ -221,7 +206,7 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
221
206
if (ret < 0 )
222
207
goto fail ;
223
208
224
- ret = xen_drm_front_shbuf_map ( shbuf );
209
+ ret = xen_front_pgdir_shbuf_map ( & dbuf -> shbuf );
225
210
if (ret < 0 )
226
211
goto fail ;
227
212
@@ -230,6 +215,7 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
230
215
231
216
fail :
232
217
mutex_unlock (& evtchnl -> u .req .req_io_lock );
218
+ fail_shbuf_alloc :
233
219
dbuf_free (& front_info -> dbuf_list , dbuf_cookie );
234
220
return ret ;
235
221
}
@@ -358,7 +344,6 @@ int xen_drm_front_page_flip(struct xen_drm_front_info *front_info,
358
344
if (unlikely (conn_idx >= front_info -> num_evt_pairs ))
359
345
return - EINVAL ;
360
346
361
- dbuf_flush_fb (& front_info -> dbuf_list , fb_cookie );
362
347
evtchnl = & front_info -> evt_pairs [conn_idx ].req ;
363
348
364
349
mutex_lock (& evtchnl -> u .req .req_io_lock );
0 commit comments