Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1020349ybh; Thu, 16 Jul 2020 00:27:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlK33fho+e/8uTNcWcyro52KSqpjfgbqf7NCMuoK+Nzmb8OtoHLEmtA9eC+LCOZwMNDxyw X-Received: by 2002:a17:906:f2c4:: with SMTP id gz4mr2440741ejb.484.1594884463790; Thu, 16 Jul 2020 00:27:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594884463; cv=none; d=google.com; s=arc-20160816; b=edaUyfPZQ+rDxzFxhlaEoSQ7nITugZeIPWlsmTlsN/YG3xoKOZnOg4IN/cmZfVo21D nSjyr88n0qSaE7jAFlJgiaiIcI/AJs3hM2zEH/1itS0yqCtqx3KYlm/hFcKaXP1rIhn9 wvQRdT2OGFrbBTElBf/A7wGV2lOCvwhhwR8Pn6TQG9IbDtpp/nYA4gaW/6J2rcmwao7Q pS/e/q+ULeEbMRqFW+Hb0NZ0Fh0LSd0OQny8iA1cBZMjmDlYBQXiazrUZtDDeBd2PP3T zSH+pJADzrDdYH4SM2xZuEk0Tn25bumWN4nDlaP5vmi+2gxMqUOtBIWdWm3BL7/aMkMO YGdg== 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=uq2wJP8LHkZqicjMlpPgZxaWFMrz5rgh+VpNwd/au9g=; b=rK9namaj5L7Hb1HPNSFa9ARiGVcvY/ppNu8G2wD08aYxrDZkEI5XhDXgSHk0Wc3Pk3 IPNH9SMEWnMncVAyO3hlKpZMGgO1vNlit25LVhZW1bgsSA+i/DO5DrDgWQYLVE2b8OpW uTOz2oWE2j3cErJx3chD+7jpE/wX/OfHp+IFIzkUV4JKlXhnzmgsEaKKgBB7F68Dx8N2 eBeY3k3PLPJTYFxwiZ5wCB/OkBC8LFovvb3FrHO2T08sa73hUid4KF3IGN0400JPnXR4 LPBVijZltC6j7KbqPyRYw8re8XyHbqoxADNoWkTuEj3AXZdw4dA8Z2Tf00S3FJue23Ep unJA== 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 w19si2607726eju.41.2020.07.16.00.27.20; Thu, 16 Jul 2020 00:27:43 -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 S1728381AbgGPHXn (ORCPT + 99 others); Thu, 16 Jul 2020 03:23:43 -0400 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:60000 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728262AbgGPHXl (ORCPT ); Thu, 16 Jul 2020 03:23:41 -0400 Received: from Internal Mail-Server by MTLPINE1 (envelope-from eli@mellanox.com) with SMTP; 16 Jul 2020 10:23:35 +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 06G7NYoE006454; Thu, 16 Jul 2020 10:23:34 +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 06G7NYY4005412; Thu, 16 Jul 2020 10:23:34 +0300 Received: (from eli@localhost) by nps-server-21.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 06G7NYRq005411; Thu, 16 Jul 2020 10:23:34 +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 Subject: [PATCH vhost next 01/10] vhost-vdpa: support batch updating Date: Thu, 16 Jul 2020 10:23:18 +0300 Message-Id: <20200716072327.5359-2-eli@mellanox.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200716072327.5359-1-eli@mellanox.com> References: <20200716072327.5359-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.27.0