From patchwork Tue Dec 19 19:29:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Kim, Dongwon" X-Patchwork-Id: 10124029 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 6BD106019C for ; Tue, 19 Dec 2017 19:36:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5DFC829230 for ; Tue, 19 Dec 2017 19:36:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52B7E29551; Tue, 19 Dec 2017 19:36:33 +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=ham 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 05E1529230 for ; Tue, 19 Dec 2017 19:36:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 59B236E335; Tue, 19 Dec 2017 19:36:29 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id 93E826E329 for ; Tue, 19 Dec 2017 19:36:27 +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 fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2017 11:36:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,428,1508828400"; d="scan'208";a="4018483" Received: from downor-z87x-ud5h.fm.intel.com ([10.1.122.11]) by orsmga007.jf.intel.com with ESMTP; 19 Dec 2017 11:36:26 -0800 From: Dongwon Kim To: linux-kernel@vger.kernel.org Subject: [RFC PATCH 05/60] hyper_dmabuf: skip creating a comm ch if exist for the VM Date: Tue, 19 Dec 2017 11:29:21 -0800 Message-Id: <1513711816-2618-5-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 hyper_dmabuf_importer_ring_setup creates new channel only if there is no existing downstream communication channel previously created for the exporter VM. Signed-off-by: Dongwon Kim --- drivers/xen/hyper_dmabuf/hyper_dmabuf_imp.c | 13 +++++++------ drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_imp.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_imp.c index 3b40ec0..6b16e37 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_imp.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_imp.c @@ -827,12 +827,11 @@ static const struct dma_buf_ops hyper_dmabuf_ops = { int hyper_dmabuf_export_fd(struct hyper_dmabuf_imported_sgt_info *dinfo, int flags) { int fd; - struct dma_buf* dmabuf; -/* call hyper_dmabuf_export_dmabuf and create and bind a handle for it - * then release */ - + /* call hyper_dmabuf_export_dmabuf and create + * and bind a handle for it then release + */ dmabuf = hyper_dmabuf_export_dma_buf(dinfo); fd = dma_buf_fd(dmabuf, flags); @@ -845,9 +844,11 @@ struct dma_buf* hyper_dmabuf_export_dma_buf(struct hyper_dmabuf_imported_sgt_inf DEFINE_DMA_BUF_EXPORT_INFO(exp_info); exp_info.ops = &hyper_dmabuf_ops; - exp_info.size = dinfo->sgt->nents * PAGE_SIZE; /* multiple of PAGE_SIZE, not considering offset */ + + /* multiple of PAGE_SIZE, not considering offset */ + exp_info.size = dinfo->sgt->nents * PAGE_SIZE; exp_info.flags = /* not sure about flag */0; exp_info.priv = dinfo; return dma_buf_export(&exp_info); -}; +} diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c index 665cada..90e0c65 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c @@ -12,6 +12,7 @@ #include "hyper_dmabuf_drv.h" #include "hyper_dmabuf_query.h" #include "xen/hyper_dmabuf_xen_comm.h" +#include "xen/hyper_dmabuf_xen_comm_list.h" #include "hyper_dmabuf_msg.h" struct hyper_dmabuf_private { @@ -31,6 +32,7 @@ static uint32_t hyper_dmabuf_id_gen(void) { static int hyper_dmabuf_exporter_ring_setup(void *data) { struct ioctl_hyper_dmabuf_exporter_ring_setup *ring_attr; + struct hyper_dmabuf_ring_info_export *ring_info; int ret = 0; if (!data) { @@ -39,6 +41,15 @@ static int hyper_dmabuf_exporter_ring_setup(void *data) } ring_attr = (struct ioctl_hyper_dmabuf_exporter_ring_setup *)data; + /* check if the ring ch already exists */ + ring_info = hyper_dmabuf_find_exporter_ring(ring_attr->remote_domain); + + if (ring_info) { + printk("(exporter's) ring ch to domid = %d already exist\ngref = %d, port = %d\n", + ring_info->rdomain, ring_info->gref_ring, ring_info->port); + return 0; + } + ret = hyper_dmabuf_exporter_ringbuf_init(ring_attr->remote_domain, &ring_attr->ring_refid, &ring_attr->port); @@ -49,6 +60,7 @@ static int hyper_dmabuf_exporter_ring_setup(void *data) static int hyper_dmabuf_importer_ring_setup(void *data) { struct ioctl_hyper_dmabuf_importer_ring_setup *setup_imp_ring_attr; + struct hyper_dmabuf_ring_info_import *ring_info; int ret = 0; if (!data) { @@ -58,6 +70,14 @@ static int hyper_dmabuf_importer_ring_setup(void *data) setup_imp_ring_attr = (struct ioctl_hyper_dmabuf_importer_ring_setup *)data; + /* check if the ring ch already exist */ + ring_info = hyper_dmabuf_find_importer_ring(setup_imp_ring_attr->source_domain); + + if (ring_info) { + printk("(importer's) ring ch to domid = %d already exist\n", ring_info->sdomain); + return 0; + } + /* user need to provide a port number and ref # for the page used as ring buffer */ ret = hyper_dmabuf_importer_ringbuf_init(setup_imp_ring_attr->source_domain, setup_imp_ring_attr->ring_refid,