From patchwork Tue Dec 19 19:30:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 10124155 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D95586019C for ; Tue, 19 Dec 2017 19:40:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5C93286C2 for ; Tue, 19 Dec 2017 19:40:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA6F22924D; Tue, 19 Dec 2017 19:40:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1810B286C2 for ; Tue, 19 Dec 2017 19:40:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EF29F6E38C; Tue, 19 Dec 2017 19:37:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id F32F66E365 for ; Tue, 19 Dec 2017 19:37:07 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2017 11:37:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="4018678" Received: from downor-z87x-ud5h.fm.intel.com ([10.1.122.11]) by orsmga007.jf.intel.com with ESMTP; 19 Dec 2017 11:37:07 -0800 From: Dongwon Kim To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 54/60] hyper_dmabuf: 'backend_ops' reduced to 'bknd_ops' and 'ops' to 'bknd_ops' Date: Tue, 19 Dec 2017 11:30:10 -0800 Message-Id: <1513711816-2618-54-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 Cc: xen-devel@lists.xenproject.org, mateuszx.potrola@intel.com, dri-devel@lists.freedesktop.org, dongwon.kim@intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP To make type's name compact, *_backend_ops is changed to '*_bknd_ops'. Also 'ops' is now changed to 'bknd_ops' to clarify it is a data structure with entry points of 'backend' operations. Signed-off-by: Dongwon Kim --- drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c | 14 +++++------ drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h | 4 ++-- drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c | 28 +++++++++++----------- drivers/xen/hyper_dmabuf/hyper_dmabuf_ops.c | 10 ++++---- drivers/xen/hyper_dmabuf/hyper_dmabuf_sgl_proc.c | 4 ++-- .../xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c | 2 +- .../xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.h | 2 +- 7 files changed, 33 insertions(+), 31 deletions(-) diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c index 387cc63..161fee7 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.c @@ -276,13 +276,13 @@ static int __init hyper_dmabuf_drv_init(void) /* currently only supports XEN hypervisor */ #ifdef CONFIG_HYPER_DMABUF_XEN - hy_drv_priv->backend_ops = &xen_backend_ops; + hy_drv_priv->bknd_ops = &xen_bknd_ops; #else - hy_drv_priv->backend_ops = NULL; + hy_drv_priv->bknd_ops = NULL; printk(KERN_ERR "hyper_dmabuf drv currently supports XEN only.\n"); #endif - if (hy_drv_priv->backend_ops == NULL) { + if (hy_drv_priv->bknd_ops == NULL) { printk(KERN_ERR "Hyper_dmabuf: no backend found\n"); return -1; } @@ -301,7 +301,7 @@ static int __init hyper_dmabuf_drv_init(void) ret = hyper_dmabuf_table_init(); if (ret < 0) { dev_err(hy_drv_priv->dev, - "failed to initialize table for exported/imported entries\n"); + "fail to init table for exported/imported entries\n"); mutex_unlock(&hy_drv_priv->lock); kfree(hy_drv_priv); return ret; @@ -330,9 +330,9 @@ static int __init hyper_dmabuf_drv_init(void) hy_drv_priv->pending = 0; #endif - hy_drv_priv->domid = hy_drv_priv->backend_ops->get_vm_id(); + hy_drv_priv->domid = hy_drv_priv->bknd_ops->get_vm_id(); - ret = hy_drv_priv->backend_ops->init_comm_env(); + ret = hy_drv_priv->bknd_ops->init_comm_env(); if (ret < 0) { dev_dbg(hy_drv_priv->dev, "failed to initialize comm-env.\n"); @@ -360,7 +360,7 @@ static void hyper_dmabuf_drv_exit(void) /* hash tables for export/import entries and ring_infos */ hyper_dmabuf_table_destroy(); - hy_drv_priv->backend_ops->destroy_comm(); + hy_drv_priv->bknd_ops->destroy_comm(); /* destroy workqueue */ if (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 049c694..4a51f9e 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_drv.h @@ -48,7 +48,7 @@ struct hyper_dmabuf_private { struct list_reusable_id *id_queue; /* backend ops - hypervisor specific */ - struct hyper_dmabuf_backend_ops *backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops; /* device global lock */ /* TODO: might need a lock per resource (e.g. EXPORT LIST) */ @@ -72,7 +72,7 @@ struct list_reusable_id { struct list_head list; }; -struct hyper_dmabuf_backend_ops { +struct hyper_dmabuf_bknd_ops { /* retreiving id of current virtual machine */ int (*get_vm_id)(void); diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c index d11f609..d1970c8 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c @@ -44,7 +44,7 @@ static int hyper_dmabuf_tx_ch_setup_ioctl(struct file *filp, void *data) { struct ioctl_hyper_dmabuf_tx_ch_setup *tx_ch_attr; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; int ret = 0; if (!data) { @@ -53,7 +53,7 @@ static int hyper_dmabuf_tx_ch_setup_ioctl(struct file *filp, void *data) } tx_ch_attr = (struct ioctl_hyper_dmabuf_tx_ch_setup *)data; - ret = ops->init_tx_ch(tx_ch_attr->remote_domain); + ret = bknd_ops->init_tx_ch(tx_ch_attr->remote_domain); return ret; } @@ -61,7 +61,7 @@ static int hyper_dmabuf_tx_ch_setup_ioctl(struct file *filp, void *data) static int hyper_dmabuf_rx_ch_setup_ioctl(struct file *filp, void *data) { struct ioctl_hyper_dmabuf_rx_ch_setup *rx_ch_attr; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; int ret = 0; if (!data) { @@ -71,7 +71,7 @@ static int hyper_dmabuf_rx_ch_setup_ioctl(struct file *filp, void *data) rx_ch_attr = (struct ioctl_hyper_dmabuf_rx_ch_setup *)data; - ret = ops->init_rx_ch(rx_ch_attr->source_domain); + ret = bknd_ops->init_rx_ch(rx_ch_attr->source_domain); return ret; } @@ -79,7 +79,7 @@ static int hyper_dmabuf_rx_ch_setup_ioctl(struct file *filp, void *data) static int send_export_msg(struct exported_sgt_info *exported, struct pages_info *pg_info) { - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; struct hyper_dmabuf_req *req; int op[MAX_NUMBER_OF_OPERANDS] = {0}; int ret, i; @@ -94,7 +94,7 @@ static int send_export_msg(struct exported_sgt_info *exported, op[4] = pg_info->nents; op[5] = pg_info->frst_ofst; op[6] = pg_info->last_len; - op[7] = ops->share_pages(pg_info->pgs, exported->rdomid, + op[7] = bknd_ops->share_pages(pg_info->pgs, exported->rdomid, pg_info->nents, &exported->refs_info); if (op[7] < 0) { dev_err(hy_drv_priv->dev, "pages sharing failed\n"); @@ -115,7 +115,7 @@ static int send_export_msg(struct exported_sgt_info *exported, /* composing a message to the importer */ hyper_dmabuf_create_req(req, HYPER_DMABUF_EXPORT, &op[0]); - ret = ops->send_req(exported->rdomid, req, true); + ret = bknd_ops->send_req(exported->rdomid, req, true); kfree(req); @@ -423,7 +423,7 @@ static int hyper_dmabuf_export_fd_ioctl(struct file *filp, void *data) { struct ioctl_hyper_dmabuf_export_fd *export_fd_attr = (struct ioctl_hyper_dmabuf_export_fd *)data; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; struct imported_sgt_info *imported; struct hyper_dmabuf_req *req; struct page **data_pgs; @@ -465,7 +465,7 @@ static int hyper_dmabuf_export_fd_ioctl(struct file *filp, void *data) hyper_dmabuf_create_req(req, HYPER_DMABUF_EXPORT_FD, &op[0]); - ret = ops->send_req(HYPER_DMABUF_DOM_ID(imported->hid), req, true); + ret = bknd_ops->send_req(HYPER_DMABUF_DOM_ID(imported->hid), req, true); if (ret < 0) { /* in case of timeout other end eventually will receive request, @@ -473,7 +473,7 @@ static int hyper_dmabuf_export_fd_ioctl(struct file *filp, void *data) */ hyper_dmabuf_create_req(req, HYPER_DMABUF_EXPORT_FD_FAILED, &op[0]); - ops->send_req(op[0], req, false); + bknd_ops->send_req(op[0], req, false); kfree(req); dev_err(hy_drv_priv->dev, "Failed to create sgt or notify exporter\n"); @@ -512,7 +512,7 @@ static int hyper_dmabuf_export_fd_ioctl(struct file *filp, void *data) imported->hid.id, imported->hid.rng_key[0], imported->hid.rng_key[1], imported->hid.rng_key[2]); - data_pgs = ops->map_shared_pages(imported->ref_handle, + data_pgs = bknd_ops->map_shared_pages(imported->ref_handle, HYPER_DMABUF_DOM_ID(imported->hid), imported->nents, &imported->refs_info); @@ -536,7 +536,7 @@ static int hyper_dmabuf_export_fd_ioctl(struct file *filp, void *data) hyper_dmabuf_create_req(req, HYPER_DMABUF_EXPORT_FD_FAILED, &op[0]); - ops->send_req(HYPER_DMABUF_DOM_ID(imported->hid), req, + bknd_ops->send_req(HYPER_DMABUF_DOM_ID(imported->hid), req, false); kfree(req); mutex_unlock(&hy_drv_priv->lock); @@ -570,7 +570,7 @@ static int hyper_dmabuf_export_fd_ioctl(struct file *filp, void *data) static void delayed_unexport(struct work_struct *work) { struct hyper_dmabuf_req *req; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; struct exported_sgt_info *exported = container_of(work, struct exported_sgt_info, unexport.work); int op[4]; @@ -602,7 +602,7 @@ static void delayed_unexport(struct work_struct *work) /* Now send unexport request to remote domain, marking * that buffer should not be used anymore */ - ret = ops->send_req(exported->rdomid, req, true); + ret = bknd_ops->send_req(exported->rdomid, req, true); if (ret < 0) { dev_err(hy_drv_priv->dev, "unexport message for buffer {id:%d key:%d %d %d} failed\n", diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ops.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ops.c index bf805b1..e85f619 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ops.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ops.c @@ -52,7 +52,7 @@ static int dmabuf_refcount(struct dma_buf *dma_buf) static int sync_request(hyper_dmabuf_id_t hid, int dmabuf_ops) { struct hyper_dmabuf_req *req; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; int op[5]; int i; int ret; @@ -72,7 +72,8 @@ static int sync_request(hyper_dmabuf_id_t hid, int dmabuf_ops) hyper_dmabuf_create_req(req, HYPER_DMABUF_OPS_TO_SOURCE, &op[0]); /* send request and wait for a response */ - ret = ops->send_req(HYPER_DMABUF_DOM_ID(hid), req, WAIT_AFTER_SYNC_REQ); + ret = bknd_ops->send_req(HYPER_DMABUF_DOM_ID(hid), req, + WAIT_AFTER_SYNC_REQ); if (ret < 0) { dev_dbg(hy_drv_priv->dev, @@ -186,7 +187,7 @@ static void hyper_dmabuf_ops_unmap(struct dma_buf_attachment *attachment, static void hyper_dmabuf_ops_release(struct dma_buf *dma_buf) { struct imported_sgt_info *imported; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; int ret; int finish; @@ -201,7 +202,8 @@ static void hyper_dmabuf_ops_release(struct dma_buf *dma_buf) imported->importers--; if (imported->importers == 0) { - ops->unmap_shared_pages(&imported->refs_info, imported->nents); + bknd_ops->unmap_shared_pages(&imported->refs_info, + imported->nents); if (imported->sgt) { sg_free_table(imported->sgt); diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_sgl_proc.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_sgl_proc.c index 9ad7ab9..d15eb17 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_sgl_proc.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_sgl_proc.c @@ -170,7 +170,7 @@ int hyper_dmabuf_cleanup_sgt_info(struct exported_sgt_info *exported, struct attachment_list *attachl; struct kmap_vaddr_list *va_kmapl; struct vmap_vaddr_list *va_vmapl; - struct hyper_dmabuf_backend_ops *ops = hy_drv_priv->backend_ops; + struct hyper_dmabuf_bknd_ops *bknd_ops = hy_drv_priv->bknd_ops; if (!exported) { dev_err(hy_drv_priv->dev, "invalid hyper_dmabuf_id\n"); @@ -231,7 +231,7 @@ int hyper_dmabuf_cleanup_sgt_info(struct exported_sgt_info *exported, } /* Start cleanup of buffer in reverse order to exporting */ - ops->unshare_pages(&exported->refs_info, exported->nents); + bknd_ops->unshare_pages(&exported->refs_info, exported->nents); /* unmap dma-buf */ dma_buf_unmap_attachment(exported->active_attached->attach, 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 23965b8..1d7249d 100644 --- a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c +++ b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.c @@ -30,7 +30,7 @@ #include "hyper_dmabuf_xen_comm.h" #include "hyper_dmabuf_xen_shm.h" -struct hyper_dmabuf_backend_ops xen_backend_ops = { +struct hyper_dmabuf_bknd_ops xen_bknd_ops = { .get_vm_id = xen_be_get_domid, .share_pages = xen_be_share_pages, .unshare_pages = xen_be_unshare_pages, diff --git a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.h b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.h index e5bff09..a4902b7 100644 --- a/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.h +++ b/drivers/xen/hyper_dmabuf/xen/hyper_dmabuf_xen_drv.h @@ -26,7 +26,7 @@ #define __HYPER_DMABUF_XEN_DRV_H__ #include -extern struct hyper_dmabuf_backend_ops xen_backend_ops; +extern struct hyper_dmabuf_bknd_ops xen_bknd_ops; /* Main purpose of this structure is to keep * all references created or acquired for sharing