lkml.org 
[lkml]   [2017]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH 56/60] hyper_dmabuf: add initialization and cleanup to bknd_ops
Date
From: Mateusz Polrola <mateuszx.potrola@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.potrola@intel.com>
Signed-off-by: Dongwon Kim <dongwon.kim@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
\
 
 \ /
  Last update: 2017-12-19 20:39    [W:0.331 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site