Skip to content

Commit 5641f19

Browse files
Oleksandr AndrushchenkoBoris Ostrovsky
authored andcommitted
drm/xen-front: Use Xen common shared buffer implementation
Use page directory based shared buffer implementation now available as common code for Xen frontend drivers. Remove flushing of shared buffer on page flip as this workaround needs a proper fix. Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Reviewed-by: Noralf Trønnes <noralf@tronnes.org> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
1 parent b338397 commit 5641f19

File tree

6 files changed

+26
-520
lines changed

6 files changed

+26
-520
lines changed

drivers/gpu/drm/xen/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ config DRM_XEN_FRONTEND
1212
select DRM_KMS_HELPER
1313
select VIDEOMODE_HELPERS
1414
select XEN_XENBUS_FRONTEND
15+
select XEN_FRONT_PGDIR_SHBUF
1516
help
1617
Choose this option if you want to enable a para-virtualized
1718
frontend DRM/KMS driver for Xen guest OSes.

drivers/gpu/drm/xen/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ drm_xen_front-objs := xen_drm_front.o \
44
xen_drm_front_kms.o \
55
xen_drm_front_conn.o \
66
xen_drm_front_evtchnl.o \
7-
xen_drm_front_shbuf.o \
87
xen_drm_front_cfg.o \
98
xen_drm_front_gem.o
109

drivers/gpu/drm/xen/xen_drm_front.c

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,28 @@
1919
#include <xen/xen.h>
2020
#include <xen/xenbus.h>
2121

22+
#include <xen/xen-front-pgdir-shbuf.h>
2223
#include <xen/interface/io/displif.h>
2324

2425
#include "xen_drm_front.h"
2526
#include "xen_drm_front_cfg.h"
2627
#include "xen_drm_front_evtchnl.h"
2728
#include "xen_drm_front_gem.h"
2829
#include "xen_drm_front_kms.h"
29-
#include "xen_drm_front_shbuf.h"
3030

3131
struct xen_drm_front_dbuf {
3232
struct list_head list;
3333
u64 dbuf_cookie;
3434
u64 fb_cookie;
35-
struct xen_drm_front_shbuf *shbuf;
35+
36+
struct xen_front_pgdir_shbuf shbuf;
3637
};
3738

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)
4041
{
41-
struct xen_drm_front_dbuf *dbuf;
42-
43-
dbuf = kzalloc(sizeof(*dbuf), GFP_KERNEL);
44-
if (!dbuf)
45-
return -ENOMEM;
46-
4742
dbuf->dbuf_cookie = dbuf_cookie;
48-
dbuf->shbuf = shbuf;
4943
list_add(&dbuf->list, &front_info->dbuf_list);
50-
return 0;
5144
}
5245

5346
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,
6255
return NULL;
6356
}
6457

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-
7458
static void dbuf_free(struct list_head *dbuf_list, u64 dbuf_cookie)
7559
{
7660
struct xen_drm_front_dbuf *buf, *q;
7761

7862
list_for_each_entry_safe(buf, q, dbuf_list, list)
7963
if (buf->dbuf_cookie == dbuf_cookie) {
8064
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);
8367
kfree(buf);
8468
break;
8569
}
@@ -91,8 +75,8 @@ static void dbuf_free_all(struct list_head *dbuf_list)
9175

9276
list_for_each_entry_safe(buf, q, dbuf_list, list) {
9377
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);
9680
kfree(buf);
9781
}
9882
}
@@ -171,38 +155,39 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
171155
u32 bpp, u64 size, struct page **pages)
172156
{
173157
struct xen_drm_front_evtchnl *evtchnl;
174-
struct xen_drm_front_shbuf *shbuf;
158+
struct xen_drm_front_dbuf *dbuf;
175159
struct xendispl_req *req;
176-
struct xen_drm_front_shbuf_cfg buf_cfg;
160+
struct xen_front_pgdir_shbuf_cfg buf_cfg;
177161
unsigned long flags;
178162
int ret;
179163

180164
evtchnl = &front_info->evt_pairs[GENERIC_OP_EVT_CHNL].req;
181165
if (unlikely(!evtchnl))
182166
return -EIO;
183167

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+
184174
memset(&buf_cfg, 0, sizeof(buf_cfg));
185175
buf_cfg.xb_dev = front_info->xb_dev;
176+
buf_cfg.num_pages = DIV_ROUND_UP(size, PAGE_SIZE);
186177
buf_cfg.pages = pages;
187-
buf_cfg.size = size;
178+
buf_cfg.pgdir = &dbuf->shbuf;
188179
buf_cfg.be_alloc = front_info->cfg.be_alloc;
189180

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;
199184

200185
mutex_lock(&evtchnl->u.req.req_io_lock);
201186

202187
spin_lock_irqsave(&front_info->io_lock, flags);
203188
req = be_prepare_req(evtchnl, XENDISPL_OP_DBUF_CREATE);
204189
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);
206191
req->op.dbuf_create.buffer_sz = size;
207192
req->op.dbuf_create.dbuf_cookie = dbuf_cookie;
208193
req->op.dbuf_create.width = width;
@@ -221,7 +206,7 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
221206
if (ret < 0)
222207
goto fail;
223208

224-
ret = xen_drm_front_shbuf_map(shbuf);
209+
ret = xen_front_pgdir_shbuf_map(&dbuf->shbuf);
225210
if (ret < 0)
226211
goto fail;
227212

@@ -230,6 +215,7 @@ int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info,
230215

231216
fail:
232217
mutex_unlock(&evtchnl->u.req.req_io_lock);
218+
fail_shbuf_alloc:
233219
dbuf_free(&front_info->dbuf_list, dbuf_cookie);
234220
return ret;
235221
}
@@ -358,7 +344,6 @@ int xen_drm_front_page_flip(struct xen_drm_front_info *front_info,
358344
if (unlikely(conn_idx >= front_info->num_evt_pairs))
359345
return -EINVAL;
360346

361-
dbuf_flush_fb(&front_info->dbuf_list, fb_cookie);
362347
evtchnl = &front_info->evt_pairs[conn_idx].req;
363348

364349
mutex_lock(&evtchnl->u.req.req_io_lock);

drivers/gpu/drm/xen/xen_drm_front_gem.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <xen/balloon.h>
2323

2424
#include "xen_drm_front.h"
25-
#include "xen_drm_front_shbuf.h"
2625

2726
struct xen_gem_object {
2827
struct drm_gem_object base;

0 commit comments

Comments
 (0)