Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp50165ybg; Mon, 27 Jul 2020 23:06:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/lYzRHk/8DafeOt6smr5aMiPvnMAQd8I67JL3B0TGkh6nk3DBlQVjqG4c8UlGBdrUAXbn X-Received: by 2002:a17:907:72c7:: with SMTP id du7mr25102394ejc.248.1595916405500; Mon, 27 Jul 2020 23:06:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595916405; cv=none; d=google.com; s=arc-20160816; b=dg0eyPmEMO/92AIU1dMCDdxZvI2Dipu/wV9B74VsRHGjvoj6gJJT17feqLNMIQZIKQ EcCSRo4YpgBJeqgiVTX/BUIvgrqcR9cJjBLsmfE5jYfd+0Fn6Su2agXSn8898HgCqAeA 66/933fJSkR9tMHg7KcF7UF5khEJhP8A376PA3LtzC9rfZE93/KbgD7IS3JESARp85aA 7qJsQ8gjnNPpEwqzXgQLvbdChMD7lwC8vq194Z5gBzSPdYUEusr41EQuSELllLV//0zy XMyE7mrXgNJZlB2I2hiXagylm6h8DsrHbOdHRHpkRvWfzzW1eL4AKzomvcALVXxeN1qg l6qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=p+PXCVDl98VjnfhzZYl7psI8fBHv95V9i6KJjuX36GM=; b=wRIS7bH22It6LicIWHJbmvcmX41Peahd+2+aaVPxIa1YFCAkH9+CMBVAn816TR/a1h f2ti2ToqG7nEZ7w/R1fX5kCMS3EKgERMoJe5JdYhDsEhUvFEdqUlbAZijRK2rpAmPtW5 REym0j2/9+euWbCfbfPA0hTtzNFYRHfcpNxxxHsLLyTbWYDK+uGhQmOc6mDz4gb2il/j SMDdnaakD8rluzn5dzOoPw+Tj+wLshrCZiQA4sxYN6y2ENIW2XSJPtmjuu4OIJuPXscs uotg/yiQaIrTVc/P+5XgUgTcDjNzR86dFvkutH+41jJoXj4j5O/NJPZH1TNE2qpy/NlJ qT0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si6963421edu.151.2020.07.27.23.06.23; Mon, 27 Jul 2020 23:06:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727774AbgG1GGH (ORCPT + 99 others); Tue, 28 Jul 2020 02:06:07 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:34833 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726880AbgG1GGG (ORCPT ); Tue, 28 Jul 2020 02:06:06 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 28 Jul 2020 09:06:00 +0300 Received: from nps-server-21.mtl.labs.mlnx (nps-server-21.mtl.labs.mlnx [10.237.240.120]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 06S660eJ016687; Tue, 28 Jul 2020 09:06:00 +0300 Received: from nps-server-21.mtl.labs.mlnx (localhost [127.0.0.1]) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 06S660IT004221; Tue, 28 Jul 2020 09:06:00 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06S660HF004220; Tue, 28 Jul 2020 09:06:00 +0300 From: Eli Cohen To: mst@redhat.com, jasowang@redhat.com, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org Cc: shahafs@mellanox.com, saeedm@mellanox.com, parav@mellanox.com Subject: [PATCH V3 vhost next 01/10] vhost-vdpa: support batch updating Date: Tue, 28 Jul 2020 09:05:30 +0300 Message-Id: <20200728060539.4163-2-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200728060539.4163-1-eli@mellanox.com> References: <20200728060539.4163-1-eli@mellanox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Wang Change-Id: Ifd7139cfbd122dc22493f4bb93fa884f8edbddb6 Signed-off-by: Jason Wang --- drivers/vhost/vdpa.c | 23 +++++++++++++++++------ include/uapi/linux/vhost_types.h | 2 ++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c index a54b60d6623f..8827ae31f96d 100644 --- a/drivers/vhost/vdpa.c +++ b/drivers/vhost/vdpa.c @@ -73,6 +73,7 @@ struct vhost_vdpa { int virtio_id; int minor; struct eventfd_ctx *config_ctx; + bool in_batch; }; static DEFINE_IDA(vhost_vdpa_ida); @@ -521,9 +522,9 @@ static int vhost_vdpa_map(struct vhost_vdpa *v, if (ops->dma_map) r = ops->dma_map(vdpa, iova, size, pa, perm); - else if (ops->set_map) - r = ops->set_map(vdpa, dev->iotlb); - else + else if (ops->set_map) { + + } else r = iommu_map(v->domain, iova, pa, size, perm_to_iommu_flags(perm)); @@ -540,9 +541,8 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v, u64 iova, u64 size) if (ops->dma_map) ops->dma_unmap(vdpa, iova, size); - else if (ops->set_map) - ops->set_map(vdpa, dev->iotlb); - else + else if (ops->set_map) { + } else iommu_unmap(v->domain, iova, size); } @@ -636,6 +636,8 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, struct vhost_iotlb_msg *msg) { struct vhost_vdpa *v = container_of(dev, struct vhost_vdpa, vdev); + struct vdpa_device *vdpa = v->vdpa; + const struct vdpa_config_ops *ops = vdpa->config; int r = 0; r = vhost_dev_check_owner(dev); @@ -649,6 +651,15 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, case VHOST_IOTLB_INVALIDATE: vhost_vdpa_unmap(v, msg->iova, msg->size); break; + case VHOST_IOTLB_BATCH_BEGIN: + v->in_batch = true; + break; + case VHOST_IOTLB_BATCH_END: + if (v->in_batch && ops->set_map) { + ops->set_map(vdpa, dev->iotlb); + } + v->in_batch = false; + break; default: r = -EINVAL; break; diff --git a/include/uapi/linux/vhost_types.h b/include/uapi/linux/vhost_types.h index 669457ce5c48..7f52245f8d5d 100644 --- a/include/uapi/linux/vhost_types.h +++ b/include/uapi/linux/vhost_types.h @@ -60,6 +60,8 @@ struct vhost_iotlb_msg { #define VHOST_IOTLB_UPDATE 2 #define VHOST_IOTLB_INVALIDATE 3 #define VHOST_IOTLB_ACCESS_FAIL 4 +#define VHOST_IOTLB_BATCH_BEGIN 5 +#define VHOST_IOTLB_BATCH_END 6 __u8 type; }; -- 2.26.0