From: Mateusz Polrola <mateuszx.potr...@intel.com>

Introduced additional init and cleanup routines in the backend
API structure that might be useful for hypervisors other than Xen.

Signed-off-by: Mateusz Polrola <mateuszx.potr...@intel.com>
Signed-off-by: Dongwon Kim <dongwon....@intel.com>
---
 drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c         | 14 ++++++++++++++
 drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h         |  6 ++++++
 drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c |  2 ++
 3 files changed, 22 insertions(+)

diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c 
b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c
index 161fee7..f2731bf 100644
--- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c
+++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c
@@ -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);
diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h 
b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h
index 4a51f9e..9337d53 100644
--- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h
+++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h
@@ -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);
 
diff --git a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c 
b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c
index 1d7249d..14ed3bc 100644
--- a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c
+++ b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c
@@ -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,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to