Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753353AbdLSTvT (ORCPT ); Tue, 19 Dec 2017 14:51:19 -0500 Received: from mga01.intel.com ([192.55.52.88]:17633 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752812AbdLSTg2 (ORCPT ); Tue, 19 Dec 2017 14:36:28 -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="4018486" 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 06/60] hyper_dmabuf: map shared pages only once when importing. Date: Tue, 19 Dec 2017 11:29:22 -0800 Message-Id: <1513711816-2618-6-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 Content-Length: 1971 Lines: 52 From: Mateusz Polrola If shared pages of buffer were already mapped on importer side, do not map them again on next request to export fd. Signed-off-by: Mateusz Polrola Signed-off-by: Dongwon Kim --- drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c index 90e0c65..af94359 100644 --- a/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c +++ b/drivers/xen/hyper_dmabuf/hyper_dmabuf_ioctl.c @@ -203,7 +203,7 @@ static int hyper_dmabuf_export_fd_ioctl(void *data) if (!data) { printk("user data is NULL\n"); - return -1; + return -EINVAL; } export_fd_attr = (struct ioctl_hyper_dmabuf_export_fd *)data; @@ -218,15 +218,17 @@ static int hyper_dmabuf_export_fd_ioctl(void *data) imported_sgt_info->last_len, imported_sgt_info->nents, HYPER_DMABUF_ID_IMPORTER_GET_SDOMAIN_ID(imported_sgt_info->hyper_dmabuf_id)); - imported_sgt_info->sgt = hyper_dmabuf_map_pages(imported_sgt_info->gref, - imported_sgt_info->frst_ofst, - imported_sgt_info->last_len, - imported_sgt_info->nents, - HYPER_DMABUF_ID_IMPORTER_GET_SDOMAIN_ID(imported_sgt_info->hyper_dmabuf_id), - &imported_sgt_info->shared_pages_info); - if (!imported_sgt_info->sgt) { - return -1; + imported_sgt_info->sgt = hyper_dmabuf_map_pages(imported_sgt_info->gref, + imported_sgt_info->frst_ofst, + imported_sgt_info->last_len, + imported_sgt_info->nents, + HYPER_DMABUF_ID_IMPORTER_GET_SDOMAIN_ID(imported_sgt_info->hyper_dmabuf_id), + &imported_sgt_info->shared_pages_info); + if (!imported_sgt_info->sgt) { + printk("Failed to create sgt\n"); + return -EINVAL; + } } export_fd_attr->fd = hyper_dmabuf_export_fd(imported_sgt_info, export_fd_attr->flags); -- 2.7.4