Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1555297ybh; Mon, 20 Jul 2020 00:57:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+GFBgKksfO1StextBMKzVYbtBDWIzmNnGLpzHCFfNPUH0QCca9x8AmMzg/S77NARmtKsk X-Received: by 2002:a17:906:4d1:: with SMTP id g17mr17547253eja.78.1595231821453; Mon, 20 Jul 2020 00:57:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595231821; cv=none; d=google.com; s=arc-20160816; b=PJE0bXTFik6lbsgEi0PQp0uPGUvrsFUwYu2FTX8n6atqnqD1B/lz7Y5uq/gX7XDtoZ pdL+xSdMnSfrKLFE931GBNM67ZNHOULIDv5qfBOKhOSlZy1AW9w1GaujGbPG85ZFx7YI jtW0vhCT7j8OR1/H+J06yoLdPYrT7vgXVcxYJQhSRkRYFcte6VeKTjEvlLaK7iKCKnIq NcvQVph9u1tvZzUdIBKD2PfRP6P1TSMh+b6SaQUIbuiBQMIBWC93c5gpGGerHnRUwnbE DmPvX/4OFi6x5VS9eXwVss4698lpWy/Y0iupehjgPoSYglbhY+sFu8Gob27r+cgq0N/y SwNA== 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=hyHrKfePHiRpTjJ06Bgo+/vyo+cmCfnMc+i4vWdyofteJSjYOMjubCi+3Ry+MmTxiJ kTUn2oddr9IkuWGMVWt6M1EJVOsnXKAuMse+ArIzc8Mr295kYlfRzOGEPDfVmL7Howta BWrVCUJBrTxOdWvxZlqFMZgQmn0NZi78TyKeYEqbXkhgY3Mq/QagLlMylZI+f+Q3dAvg rfQoyMZEi0jA4gOI0wcJ6rehP1vHED8EouVA1Gh/swLYUJC3nPkc98HIIHmIVspu/ODt srBR57JW1VgIfzOF/US3QMYfqBirZ21irnNmzVqDq9r3KfUX4ViZX7wU5mJrYy8uoLSX CTMA== 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 h22si11035207ejf.256.2020.07.20.00.56.39; Mon, 20 Jul 2020 00:57:01 -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 S1728217AbgGTHxy (ORCPT + 99 others); Mon, 20 Jul 2020 03:53:54 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41287 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726689AbgGTHxw (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 06K7rjgN008217; 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 06K7ERZ9032181; Mon, 20 Jul 2020 10:14:27 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06K7ERGf032176; Mon, 20 Jul 2020 10:14:27 +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 10:14:07 +0300 Message-Id: <20200720071416.32112-2-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200720071416.32112-1-eli@mellanox.com> References: <20200720071416.32112-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