Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1555406ybh; Mon, 20 Jul 2020 00:57:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaYOrg+exZ4atGVGT6WU8cONGnU6XaRbhCxw46UyduLdMCa6gEctT5fdS+IQSLiRV2l7FL X-Received: by 2002:a17:906:1151:: with SMTP id i17mr20420973eja.535.1595231835902; Mon, 20 Jul 2020 00:57:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595231835; cv=none; d=google.com; s=arc-20160816; b=s0jOIU+9oVHAQL6FUpSE7WqWkMYgWqQSX9cTU205tO714nIOhWOxXofYRq1yaw/h4z kGSN92rBfjI/kDNgY4E4PNWFaQQJrfvHlILfpaRhpQmKyRXDII/c2euQrlTR04qISmBr 8qXxXuJmMER80/4bCJu66a2y8EFH9VDA7FQW9musehsgGLMqOBRWEhABXoOC2fEn+7aB XDxykapQMmW9T4h9a6BKhuqdcJymuPkjDZQ/W+Irrl1RD7RSja8a9emTvL2PRalgnNIx IyF4SFkBFrIXmDpTVTlD0Kj/C2AplwYlWseQAwrIhERZLLFVNulVj1IO3Rzqavsf73yi oQGw== 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=v18/WnXkX0T4e42lvgEbV8ZQtRCRlLN+TFXQ8uAUFI0j/ISjCC1+mgQ+fag6VDUYOZ JkTd6WdLTTfNj9j7xBSVOaeADeyAR06B3be8EobQREbK1dYwNbgRFH6wAJmDVTqKmso6 2r8f6t3sMBpuBBpuNTr8lfR46qV8GiREzF2CIWn4jO/k/7UGZsGfZmApvnLTaB3ILt8e +nICdLeInKEG0aeYv36/HsscEtsl0iilkxB3s/AXKGZHew7c1+haCJ4xQ2Pr59wETl8x 9z+JdCgZWcFvGwOPMtopc1Q+PxqX0l9oA/Z3ViZbYlV4AP4FUqC6B85vVPlykdwPCeEg 1Ajw== 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 y17si10402584ejk.677.2020.07.20.00.56.52; Mon, 20 Jul 2020 00:57:15 -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 S1728242AbgGTHyA (ORCPT + 99 others); Mon, 20 Jul 2020 03:54:00 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41297 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728180AbgGTHxw (ORCPT ); Mon, 20 Jul 2020 03:53:52 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 20 Jul 2020 10:53:45 +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 06K7rjgP008217; Mon, 20 Jul 2020 10:53:45 +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 06K6speN031176; Mon, 20 Jul 2020 09:54:51 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06K6spj8031175; Mon, 20 Jul 2020 09:54:51 +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 V2 vhost next 01/10] vhost-vdpa: support batch updating Date: Mon, 20 Jul 2020 09:54:34 +0300 Message-Id: <20200720065443.31112-2-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200720065443.31112-1-eli@mellanox.com> References: <20200720065443.31112-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