From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753352AbdLSTha (ORCPT ); Tue, 19 Dec 2017 14:37:30 -0500 Received: from mga11.intel.com ([192.55.52.93]:27379 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753348AbdLSThL (ORCPT ); Tue, 19 Dec 2017 14:37:11 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="4018687" From: Dongwon Kim To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, xen-devel@lists.xenproject.org, mateuszx.potrola@intel.com, dongwon.kim@intel.com Subject: [RFC PATCH 56/60] hyper_dmabuf: add initialization and cleanup to bknd_ops Date: Tue, 19 Dec 2017 11:30:12 -0800 Message-Id: <1513711816-2618-56-git-send-email-dongwon.kim@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1513711816-2618-1-git-send-email-dongwon.kim@intel.com> References: <1513711816-2618-1-git-send-email-dongwon.kim@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mateusz Polrola 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 Signed-off-by: Dongwon Kim --- 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