@@ -330,6 +330,16 @@ static int __init hyper_dmabuf_drv_init(void)
hy_drv_priv->pending = 0;
#endif
+ if (hy_drv_priv->bknd_ops->init) {
+ ret = hy_drv_priv->bknd_ops->init();
+
+ if (ret < 0) {
+ dev_dbg(hy_drv_priv->dev,
+ "failed to initialize backend.\n");
+ return ret;
+ }
+ }
+
hy_drv_priv->domid = hy_drv_priv->bknd_ops->get_vm_id();
ret = hy_drv_priv->bknd_ops->init_comm_env();
@@ -362,6 +372,10 @@ static void hyper_dmabuf_drv_exit(void)
hy_drv_priv->bknd_ops->destroy_comm();
+ if (hy_drv_priv->bknd_ops->cleanup) {
+ hy_drv_priv->bknd_ops->cleanup();
+ };
+
/* destroy workqueue */
if (hy_drv_priv->work_queue)
destroy_workqueue(hy_drv_priv->work_queue);
@@ -73,6 +73,12 @@ struct list_reusable_id {
};
struct hyper_dmabuf_bknd_ops {
+ /* backend initialization routine (optional) */
+ int (*init)(void);
+
+ /* backend cleanup routine (optional) */
+ int (*cleanup)(void);
+
/* retreiving id of current virtual machine */
int (*get_vm_id)(void);
@@ -31,6 +31,8 @@
#include "hyper_dmabuf_xen_shm.h"
struct hyper_dmabuf_bknd_ops xen_bknd_ops = {
+ .init = NULL, /* not needed for xen */
+ .cleanup = NULL, /* not needed for xen */
.get_vm_id = xen_be_get_domid,
.share_pages = xen_be_share_pages,
.unshare_pages = xen_be_unshare_pages,