1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * Xen para-virtual DRM device
6 * Copyright (C) 2016-2018 EPAM Systems Inc.
8 * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
11 #include <linux/delay.h>
12 #include <linux/dma-mapping.h>
13 #include <linux/module.h>
14 #include <linux/of_device.h>
16 #include <drm/drm_atomic_helper.h>
17 #include <drm/drm_drv.h>
18 #include <drm/drm_ioctl.h>
19 #include <drm/drm_probe_helper.h>
20 #include <drm/drm_file.h>
21 #include <drm/drm_gem.h>
23 #include <xen/platform_pci.h>
25 #include <xen/xenbus.h>
27 #include <xen/xen-front-pgdir-shbuf.h>
28 #include <xen/interface/io/displif.h>
30 #include "xen_drm_front.h"
31 #include "xen_drm_front_cfg.h"
32 #include "xen_drm_front_evtchnl.h"
33 #include "xen_drm_front_gem.h"
34 #include "xen_drm_front_kms.h"
36 struct xen_drm_front_dbuf
{
37 struct list_head list
;
41 struct xen_front_pgdir_shbuf shbuf
;
44 static void dbuf_add_to_list(struct xen_drm_front_info
*front_info
,
45 struct xen_drm_front_dbuf
*dbuf
, u64 dbuf_cookie
)
47 dbuf
->dbuf_cookie
= dbuf_cookie
;
48 list_add(&dbuf
->list
, &front_info
->dbuf_list
);
51 static struct xen_drm_front_dbuf
*dbuf_get(struct list_head
*dbuf_list
,
54 struct xen_drm_front_dbuf
*buf
, *q
;
56 list_for_each_entry_safe(buf
, q
, dbuf_list
, list
)
57 if (buf
->dbuf_cookie
== dbuf_cookie
)
63 static void dbuf_free(struct list_head
*dbuf_list
, u64 dbuf_cookie
)
65 struct xen_drm_front_dbuf
*buf
, *q
;
67 list_for_each_entry_safe(buf
, q
, dbuf_list
, list
)
68 if (buf
->dbuf_cookie
== dbuf_cookie
) {
70 xen_front_pgdir_shbuf_unmap(&buf
->shbuf
);
71 xen_front_pgdir_shbuf_free(&buf
->shbuf
);
77 static void dbuf_free_all(struct list_head
*dbuf_list
)
79 struct xen_drm_front_dbuf
*buf
, *q
;
81 list_for_each_entry_safe(buf
, q
, dbuf_list
, list
) {
83 xen_front_pgdir_shbuf_unmap(&buf
->shbuf
);
84 xen_front_pgdir_shbuf_free(&buf
->shbuf
);
89 static struct xendispl_req
*
90 be_prepare_req(struct xen_drm_front_evtchnl
*evtchnl
, u8 operation
)
92 struct xendispl_req
*req
;
94 req
= RING_GET_REQUEST(&evtchnl
->u
.req
.ring
,
95 evtchnl
->u
.req
.ring
.req_prod_pvt
);
96 req
->operation
= operation
;
97 req
->id
= evtchnl
->evt_next_id
++;
98 evtchnl
->evt_id
= req
->id
;
102 static int be_stream_do_io(struct xen_drm_front_evtchnl
*evtchnl
,
103 struct xendispl_req
*req
)
105 reinit_completion(&evtchnl
->u
.req
.completion
);
106 if (unlikely(evtchnl
->state
!= EVTCHNL_STATE_CONNECTED
))
109 xen_drm_front_evtchnl_flush(evtchnl
);
113 static int be_stream_wait_io(struct xen_drm_front_evtchnl
*evtchnl
)
115 if (wait_for_completion_timeout(&evtchnl
->u
.req
.completion
,
116 msecs_to_jiffies(XEN_DRM_FRONT_WAIT_BACK_MS
)) <= 0)
119 return evtchnl
->u
.req
.resp_status
;
122 int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline
*pipeline
,
123 u32 x
, u32 y
, u32 width
, u32 height
,
124 u32 bpp
, u64 fb_cookie
)
126 struct xen_drm_front_evtchnl
*evtchnl
;
127 struct xen_drm_front_info
*front_info
;
128 struct xendispl_req
*req
;
132 front_info
= pipeline
->drm_info
->front_info
;
133 evtchnl
= &front_info
->evt_pairs
[pipeline
->index
].req
;
134 if (unlikely(!evtchnl
))
137 mutex_lock(&evtchnl
->u
.req
.req_io_lock
);
139 spin_lock_irqsave(&front_info
->io_lock
, flags
);
140 req
= be_prepare_req(evtchnl
, XENDISPL_OP_SET_CONFIG
);
141 req
->op
.set_config
.x
= x
;
142 req
->op
.set_config
.y
= y
;
143 req
->op
.set_config
.width
= width
;
144 req
->op
.set_config
.height
= height
;
145 req
->op
.set_config
.bpp
= bpp
;
146 req
->op
.set_config
.fb_cookie
= fb_cookie
;
148 ret
= be_stream_do_io(evtchnl
, req
);
149 spin_unlock_irqrestore(&front_info
->io_lock
, flags
);
152 ret
= be_stream_wait_io(evtchnl
);
154 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
158 int xen_drm_front_dbuf_create(struct xen_drm_front_info
*front_info
,
159 u64 dbuf_cookie
, u32 width
, u32 height
,
160 u32 bpp
, u64 size
, u32 offset
,
163 struct xen_drm_front_evtchnl
*evtchnl
;
164 struct xen_drm_front_dbuf
*dbuf
;
165 struct xendispl_req
*req
;
166 struct xen_front_pgdir_shbuf_cfg buf_cfg
;
170 evtchnl
= &front_info
->evt_pairs
[GENERIC_OP_EVT_CHNL
].req
;
171 if (unlikely(!evtchnl
))
174 dbuf
= kzalloc(sizeof(*dbuf
), GFP_KERNEL
);
178 dbuf_add_to_list(front_info
, dbuf
, dbuf_cookie
);
180 memset(&buf_cfg
, 0, sizeof(buf_cfg
));
181 buf_cfg
.xb_dev
= front_info
->xb_dev
;
182 buf_cfg
.num_pages
= DIV_ROUND_UP(size
, PAGE_SIZE
);
183 buf_cfg
.pages
= pages
;
184 buf_cfg
.pgdir
= &dbuf
->shbuf
;
185 buf_cfg
.be_alloc
= front_info
->cfg
.be_alloc
;
187 ret
= xen_front_pgdir_shbuf_alloc(&buf_cfg
);
189 goto fail_shbuf_alloc
;
191 mutex_lock(&evtchnl
->u
.req
.req_io_lock
);
193 spin_lock_irqsave(&front_info
->io_lock
, flags
);
194 req
= be_prepare_req(evtchnl
, XENDISPL_OP_DBUF_CREATE
);
195 req
->op
.dbuf_create
.gref_directory
=
196 xen_front_pgdir_shbuf_get_dir_start(&dbuf
->shbuf
);
197 req
->op
.dbuf_create
.buffer_sz
= size
;
198 req
->op
.dbuf_create
.data_ofs
= offset
;
199 req
->op
.dbuf_create
.dbuf_cookie
= dbuf_cookie
;
200 req
->op
.dbuf_create
.width
= width
;
201 req
->op
.dbuf_create
.height
= height
;
202 req
->op
.dbuf_create
.bpp
= bpp
;
203 if (buf_cfg
.be_alloc
)
204 req
->op
.dbuf_create
.flags
|= XENDISPL_DBUF_FLG_REQ_ALLOC
;
206 ret
= be_stream_do_io(evtchnl
, req
);
207 spin_unlock_irqrestore(&front_info
->io_lock
, flags
);
212 ret
= be_stream_wait_io(evtchnl
);
216 ret
= xen_front_pgdir_shbuf_map(&dbuf
->shbuf
);
220 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
224 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
226 dbuf_free(&front_info
->dbuf_list
, dbuf_cookie
);
230 static int xen_drm_front_dbuf_destroy(struct xen_drm_front_info
*front_info
,
233 struct xen_drm_front_evtchnl
*evtchnl
;
234 struct xendispl_req
*req
;
239 evtchnl
= &front_info
->evt_pairs
[GENERIC_OP_EVT_CHNL
].req
;
240 if (unlikely(!evtchnl
))
243 be_alloc
= front_info
->cfg
.be_alloc
;
246 * For the backend allocated buffer release references now, so backend
247 * can free the buffer.
250 dbuf_free(&front_info
->dbuf_list
, dbuf_cookie
);
252 mutex_lock(&evtchnl
->u
.req
.req_io_lock
);
254 spin_lock_irqsave(&front_info
->io_lock
, flags
);
255 req
= be_prepare_req(evtchnl
, XENDISPL_OP_DBUF_DESTROY
);
256 req
->op
.dbuf_destroy
.dbuf_cookie
= dbuf_cookie
;
258 ret
= be_stream_do_io(evtchnl
, req
);
259 spin_unlock_irqrestore(&front_info
->io_lock
, flags
);
262 ret
= be_stream_wait_io(evtchnl
);
265 * Do this regardless of communication status with the backend:
266 * if we cannot remove remote resources remove what we can locally.
269 dbuf_free(&front_info
->dbuf_list
, dbuf_cookie
);
271 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
275 int xen_drm_front_fb_attach(struct xen_drm_front_info
*front_info
,
276 u64 dbuf_cookie
, u64 fb_cookie
, u32 width
,
277 u32 height
, u32 pixel_format
)
279 struct xen_drm_front_evtchnl
*evtchnl
;
280 struct xen_drm_front_dbuf
*buf
;
281 struct xendispl_req
*req
;
285 evtchnl
= &front_info
->evt_pairs
[GENERIC_OP_EVT_CHNL
].req
;
286 if (unlikely(!evtchnl
))
289 buf
= dbuf_get(&front_info
->dbuf_list
, dbuf_cookie
);
293 buf
->fb_cookie
= fb_cookie
;
295 mutex_lock(&evtchnl
->u
.req
.req_io_lock
);
297 spin_lock_irqsave(&front_info
->io_lock
, flags
);
298 req
= be_prepare_req(evtchnl
, XENDISPL_OP_FB_ATTACH
);
299 req
->op
.fb_attach
.dbuf_cookie
= dbuf_cookie
;
300 req
->op
.fb_attach
.fb_cookie
= fb_cookie
;
301 req
->op
.fb_attach
.width
= width
;
302 req
->op
.fb_attach
.height
= height
;
303 req
->op
.fb_attach
.pixel_format
= pixel_format
;
305 ret
= be_stream_do_io(evtchnl
, req
);
306 spin_unlock_irqrestore(&front_info
->io_lock
, flags
);
309 ret
= be_stream_wait_io(evtchnl
);
311 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
315 int xen_drm_front_fb_detach(struct xen_drm_front_info
*front_info
,
318 struct xen_drm_front_evtchnl
*evtchnl
;
319 struct xendispl_req
*req
;
323 evtchnl
= &front_info
->evt_pairs
[GENERIC_OP_EVT_CHNL
].req
;
324 if (unlikely(!evtchnl
))
327 mutex_lock(&evtchnl
->u
.req
.req_io_lock
);
329 spin_lock_irqsave(&front_info
->io_lock
, flags
);
330 req
= be_prepare_req(evtchnl
, XENDISPL_OP_FB_DETACH
);
331 req
->op
.fb_detach
.fb_cookie
= fb_cookie
;
333 ret
= be_stream_do_io(evtchnl
, req
);
334 spin_unlock_irqrestore(&front_info
->io_lock
, flags
);
337 ret
= be_stream_wait_io(evtchnl
);
339 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
343 int xen_drm_front_page_flip(struct xen_drm_front_info
*front_info
,
344 int conn_idx
, u64 fb_cookie
)
346 struct xen_drm_front_evtchnl
*evtchnl
;
347 struct xendispl_req
*req
;
351 if (unlikely(conn_idx
>= front_info
->num_evt_pairs
))
354 evtchnl
= &front_info
->evt_pairs
[conn_idx
].req
;
356 mutex_lock(&evtchnl
->u
.req
.req_io_lock
);
358 spin_lock_irqsave(&front_info
->io_lock
, flags
);
359 req
= be_prepare_req(evtchnl
, XENDISPL_OP_PG_FLIP
);
360 req
->op
.pg_flip
.fb_cookie
= fb_cookie
;
362 ret
= be_stream_do_io(evtchnl
, req
);
363 spin_unlock_irqrestore(&front_info
->io_lock
, flags
);
366 ret
= be_stream_wait_io(evtchnl
);
368 mutex_unlock(&evtchnl
->u
.req
.req_io_lock
);
372 void xen_drm_front_on_frame_done(struct xen_drm_front_info
*front_info
,
373 int conn_idx
, u64 fb_cookie
)
375 struct xen_drm_front_drm_info
*drm_info
= front_info
->drm_info
;
377 if (unlikely(conn_idx
>= front_info
->cfg
.num_connectors
))
380 xen_drm_front_kms_on_frame_done(&drm_info
->pipeline
[conn_idx
],
384 void xen_drm_front_gem_object_free(struct drm_gem_object
*obj
)
386 struct xen_drm_front_drm_info
*drm_info
= obj
->dev
->dev_private
;
389 if (drm_dev_enter(obj
->dev
, &idx
)) {
390 xen_drm_front_dbuf_destroy(drm_info
->front_info
,
391 xen_drm_front_dbuf_to_cookie(obj
));
394 dbuf_free(&drm_info
->front_info
->dbuf_list
,
395 xen_drm_front_dbuf_to_cookie(obj
));
398 xen_drm_front_gem_free_object_unlocked(obj
);
401 static int xen_drm_drv_dumb_create(struct drm_file
*filp
,
402 struct drm_device
*dev
,
403 struct drm_mode_create_dumb
*args
)
405 struct xen_drm_front_drm_info
*drm_info
= dev
->dev_private
;
406 struct drm_gem_object
*obj
;
410 * Dumb creation is a two stage process: first we create a fully
411 * constructed GEM object which is communicated to the backend, and
412 * only after that we can create GEM's handle. This is done so,
413 * because of the possible races: once you create a handle it becomes
414 * immediately visible to user-space, so the latter can try accessing
415 * object without pages etc.
416 * For details also see drm_gem_handle_create
418 args
->pitch
= DIV_ROUND_UP(args
->width
* args
->bpp
, 8);
419 args
->size
= args
->pitch
* args
->height
;
421 obj
= xen_drm_front_gem_create(dev
, args
->size
);
427 ret
= xen_drm_front_dbuf_create(drm_info
->front_info
,
428 xen_drm_front_dbuf_to_cookie(obj
),
429 args
->width
, args
->height
, args
->bpp
,
431 xen_drm_front_gem_get_pages(obj
));
435 /* This is the tail of GEM object creation */
436 ret
= drm_gem_handle_create(filp
, obj
, &args
->handle
);
440 /* Drop reference from allocate - handle holds it now */
441 drm_gem_object_put(obj
);
445 xen_drm_front_dbuf_destroy(drm_info
->front_info
,
446 xen_drm_front_dbuf_to_cookie(obj
));
448 /* drop reference from allocate */
449 drm_gem_object_put(obj
);
451 DRM_ERROR("Failed to create dumb buffer: %d\n", ret
);
455 static void xen_drm_drv_release(struct drm_device
*dev
)
457 struct xen_drm_front_drm_info
*drm_info
= dev
->dev_private
;
458 struct xen_drm_front_info
*front_info
= drm_info
->front_info
;
460 xen_drm_front_kms_fini(drm_info
);
462 drm_atomic_helper_shutdown(dev
);
463 drm_mode_config_cleanup(dev
);
465 if (front_info
->cfg
.be_alloc
)
466 xenbus_switch_state(front_info
->xb_dev
,
467 XenbusStateInitialising
);
472 static const struct file_operations xen_drm_dev_fops
= {
473 .owner
= THIS_MODULE
,
475 .release
= drm_release
,
476 .unlocked_ioctl
= drm_ioctl
,
478 .compat_ioctl
= drm_compat_ioctl
,
483 .mmap
= xen_drm_front_gem_mmap
,
486 static const struct drm_driver xen_drm_driver
= {
487 .driver_features
= DRIVER_GEM
| DRIVER_MODESET
| DRIVER_ATOMIC
,
488 .release
= xen_drm_drv_release
,
489 .prime_handle_to_fd
= drm_gem_prime_handle_to_fd
,
490 .prime_fd_to_handle
= drm_gem_prime_fd_to_handle
,
491 .gem_prime_import_sg_table
= xen_drm_front_gem_import_sg_table
,
492 .gem_prime_mmap
= xen_drm_front_gem_prime_mmap
,
493 .dumb_create
= xen_drm_drv_dumb_create
,
494 .fops
= &xen_drm_dev_fops
,
496 .desc
= "Xen PV DRM Display Unit",
503 static int xen_drm_drv_init(struct xen_drm_front_info
*front_info
)
505 struct device
*dev
= &front_info
->xb_dev
->dev
;
506 struct xen_drm_front_drm_info
*drm_info
;
507 struct drm_device
*drm_dev
;
510 DRM_INFO("Creating %s\n", xen_drm_driver
.desc
);
512 drm_info
= kzalloc(sizeof(*drm_info
), GFP_KERNEL
);
518 drm_info
->front_info
= front_info
;
519 front_info
->drm_info
= drm_info
;
521 drm_dev
= drm_dev_alloc(&xen_drm_driver
, dev
);
522 if (IS_ERR(drm_dev
)) {
523 ret
= PTR_ERR(drm_dev
);
527 drm_info
->drm_dev
= drm_dev
;
529 drm_dev
->dev_private
= drm_info
;
531 ret
= xen_drm_front_kms_init(drm_info
);
533 DRM_ERROR("Failed to initialize DRM/KMS, ret %d\n", ret
);
537 ret
= drm_dev_register(drm_dev
, 0);
541 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
542 xen_drm_driver
.name
, xen_drm_driver
.major
,
543 xen_drm_driver
.minor
, xen_drm_driver
.patchlevel
,
544 xen_drm_driver
.date
, drm_dev
->primary
->index
);
549 drm_dev_unregister(drm_dev
);
551 drm_kms_helper_poll_fini(drm_dev
);
552 drm_mode_config_cleanup(drm_dev
);
553 drm_dev_put(drm_dev
);
559 static void xen_drm_drv_fini(struct xen_drm_front_info
*front_info
)
561 struct xen_drm_front_drm_info
*drm_info
= front_info
->drm_info
;
562 struct drm_device
*dev
;
567 dev
= drm_info
->drm_dev
;
571 /* Nothing to do if device is already unplugged */
572 if (drm_dev_is_unplugged(dev
))
575 drm_kms_helper_poll_fini(dev
);
579 front_info
->drm_info
= NULL
;
581 xen_drm_front_evtchnl_free_all(front_info
);
582 dbuf_free_all(&front_info
->dbuf_list
);
585 * If we are not using backend allocated buffers, then tell the
586 * backend we are ready to (re)initialize. Otherwise, wait for
587 * drm_driver.release.
589 if (!front_info
->cfg
.be_alloc
)
590 xenbus_switch_state(front_info
->xb_dev
,
591 XenbusStateInitialising
);
594 static int displback_initwait(struct xen_drm_front_info
*front_info
)
596 struct xen_drm_front_cfg
*cfg
= &front_info
->cfg
;
599 cfg
->front_info
= front_info
;
600 ret
= xen_drm_front_cfg_card(front_info
, cfg
);
604 DRM_INFO("Have %d connector(s)\n", cfg
->num_connectors
);
605 /* Create event channels for all connectors and publish */
606 ret
= xen_drm_front_evtchnl_create_all(front_info
);
610 return xen_drm_front_evtchnl_publish_all(front_info
);
613 static int displback_connect(struct xen_drm_front_info
*front_info
)
615 xen_drm_front_evtchnl_set_state(front_info
, EVTCHNL_STATE_CONNECTED
);
616 return xen_drm_drv_init(front_info
);
619 static void displback_disconnect(struct xen_drm_front_info
*front_info
)
621 if (!front_info
->drm_info
)
624 /* Tell the backend to wait until we release the DRM driver. */
625 xenbus_switch_state(front_info
->xb_dev
, XenbusStateReconfiguring
);
627 xen_drm_drv_fini(front_info
);
630 static void displback_changed(struct xenbus_device
*xb_dev
,
631 enum xenbus_state backend_state
)
633 struct xen_drm_front_info
*front_info
= dev_get_drvdata(&xb_dev
->dev
);
636 DRM_DEBUG("Backend state is %s, front is %s\n",
637 xenbus_strstate(backend_state
),
638 xenbus_strstate(xb_dev
->state
));
640 switch (backend_state
) {
641 case XenbusStateReconfiguring
:
642 case XenbusStateReconfigured
:
643 case XenbusStateInitialised
:
646 case XenbusStateInitialising
:
647 if (xb_dev
->state
== XenbusStateReconfiguring
)
650 /* recovering after backend unexpected closure */
651 displback_disconnect(front_info
);
654 case XenbusStateInitWait
:
655 if (xb_dev
->state
== XenbusStateReconfiguring
)
658 /* recovering after backend unexpected closure */
659 displback_disconnect(front_info
);
660 if (xb_dev
->state
!= XenbusStateInitialising
)
663 ret
= displback_initwait(front_info
);
665 xenbus_dev_fatal(xb_dev
, ret
, "initializing frontend");
667 xenbus_switch_state(xb_dev
, XenbusStateInitialised
);
670 case XenbusStateConnected
:
671 if (xb_dev
->state
!= XenbusStateInitialised
)
674 ret
= displback_connect(front_info
);
676 displback_disconnect(front_info
);
677 xenbus_dev_fatal(xb_dev
, ret
, "connecting backend");
679 xenbus_switch_state(xb_dev
, XenbusStateConnected
);
683 case XenbusStateClosing
:
685 * in this state backend starts freeing resources,
686 * so let it go into closed state, so we can also
691 case XenbusStateUnknown
:
692 case XenbusStateClosed
:
693 if (xb_dev
->state
== XenbusStateClosed
)
696 displback_disconnect(front_info
);
701 static int xen_drv_probe(struct xenbus_device
*xb_dev
,
702 const struct xenbus_device_id
*id
)
704 struct xen_drm_front_info
*front_info
;
705 struct device
*dev
= &xb_dev
->dev
;
708 ret
= dma_coerce_mask_and_coherent(dev
, DMA_BIT_MASK(64));
710 DRM_ERROR("Cannot setup DMA mask, ret %d", ret
);
714 front_info
= devm_kzalloc(&xb_dev
->dev
,
715 sizeof(*front_info
), GFP_KERNEL
);
719 front_info
->xb_dev
= xb_dev
;
720 spin_lock_init(&front_info
->io_lock
);
721 INIT_LIST_HEAD(&front_info
->dbuf_list
);
722 dev_set_drvdata(&xb_dev
->dev
, front_info
);
724 return xenbus_switch_state(xb_dev
, XenbusStateInitialising
);
727 static int xen_drv_remove(struct xenbus_device
*dev
)
729 struct xen_drm_front_info
*front_info
= dev_get_drvdata(&dev
->dev
);
732 xenbus_switch_state(dev
, XenbusStateClosing
);
735 * On driver removal it is disconnected from XenBus,
736 * so no backend state change events come via .otherend_changed
737 * callback. This prevents us from exiting gracefully, e.g.
738 * signaling the backend to free event channels, waiting for its
739 * state to change to XenbusStateClosed and cleaning at our end.
740 * Normally when front driver removed backend will finally go into
741 * XenbusStateInitWait state.
743 * Workaround: read backend's state manually and wait with time-out.
745 while ((xenbus_read_unsigned(front_info
->xb_dev
->otherend
, "state",
746 XenbusStateUnknown
) != XenbusStateInitWait
) &&
753 state
= xenbus_read_unsigned(front_info
->xb_dev
->otherend
,
754 "state", XenbusStateUnknown
);
755 DRM_ERROR("Backend state is %s while removing driver\n",
756 xenbus_strstate(state
));
759 xen_drm_drv_fini(front_info
);
760 xenbus_frontend_closed(dev
);
764 static const struct xenbus_device_id xen_driver_ids
[] = {
765 { XENDISPL_DRIVER_NAME
},
769 static struct xenbus_driver xen_driver
= {
770 .ids
= xen_driver_ids
,
771 .probe
= xen_drv_probe
,
772 .remove
= xen_drv_remove
,
773 .otherend_changed
= displback_changed
,
776 static int __init
xen_drv_init(void)
778 /* At the moment we only support case with XEN_PAGE_SIZE == PAGE_SIZE */
779 if (XEN_PAGE_SIZE
!= PAGE_SIZE
) {
780 DRM_ERROR(XENDISPL_DRIVER_NAME
": different kernel and Xen page sizes are not supported: XEN_PAGE_SIZE (%lu) != PAGE_SIZE (%lu)\n",
781 XEN_PAGE_SIZE
, PAGE_SIZE
);
788 if (!xen_has_pv_devices())
791 DRM_INFO("Registering XEN PV " XENDISPL_DRIVER_NAME
"\n");
792 return xenbus_register_frontend(&xen_driver
);
795 static void __exit
xen_drv_fini(void)
797 DRM_INFO("Unregistering XEN PV " XENDISPL_DRIVER_NAME
"\n");
798 xenbus_unregister_driver(&xen_driver
);
801 module_init(xen_drv_init
);
802 module_exit(xen_drv_fini
);
804 MODULE_DESCRIPTION("Xen para-virtualized display device frontend");
805 MODULE_LICENSE("GPL");
806 MODULE_ALIAS("xen:" XENDISPL_DRIVER_NAME
);