From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 131F4A0C44; Tue, 15 Jun 2021 16:31:51 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5215C41175; Tue, 15 Jun 2021 16:31:41 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 540CF4117B for ; Tue, 15 Jun 2021 16:31:37 +0200 (CEST) IronPort-SDR: GcUxoK+WY4+Y10KyhEbeHHw1yJV5kMa8ojcaav/hbLDCAhlvPy2DPycdwmOVMnCInIkkvyZTED NgfqFUzuYK2g== X-IronPort-AV: E=McAfee;i="6200,9189,10015"; a="227472981" X-IronPort-AV: E=Sophos;i="5.83,275,1616482800"; d="scan'208";a="227472981" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jun 2021 07:31:36 -0700 IronPort-SDR: CBxf3UQQlopc1V/AL0VmWSsgThUJu1unvALYyWTmIfiFB5ouy0/NeRUK1BwnJ1fTnPmde5ZoMx 4BW7cYK1H7DQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.83,275,1616482800"; d="scan'208";a="484488342" Received: from dpdk_jiangcheng.sh.intel.com ([10.67.119.149]) by orsmga001.jf.intel.com with ESMTP; 15 Jun 2021 07:31:35 -0700 From: Cheng Jiang To: maxime.coquelin@redhat.com, Chenbo.Xia@intel.com Cc: dev@dpdk.org, jiayu.hu@intel.com, yvonnex.yang@intel.com Date: Tue, 15 Jun 2021 14:15:13 +0000 Message-Id: <20210615141513.16163-4-cheng1.jiang@intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210615141513.16163-1-cheng1.jiang@intel.com> References: <20210602042802.31943-1-cheng1.jiang@intel.com> <20210615141513.16163-1-cheng1.jiang@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 3/3] vhost: handle memory hotplug for async vhost X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Jiayu Hu When the guest memory is hotplugged, the vhost application which enables DMA acceleration must stop DMA transfers before the vhost re-maps the guest memory. This patch is to notify the vhost application of stopping DMA transfers. Signed-off-by: Jiayu Hu --- lib/vhost/vhost_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 8f0eba6412..6800e60c2d 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -1223,6 +1223,15 @@ vhost_user_set_mem_table(struct virtio_net **pdev, struct VhostUserMsg *msg, vdpa_dev->ops->dev_close(dev->vid); dev->flags &= ~VIRTIO_DEV_VDPA_CONFIGURED; } + + /* notify the backend application to stop DMA transfers */ + if (dev->async_copy && dev->notify_ops->vring_state_changed) { + for (i = 0; i < dev->nr_vring; i++) { + dev->notify_ops->vring_state_changed(dev->vid, + i, 0); + } + } + free_mem_region(dev); rte_free(dev->mem); dev->mem = NULL; -- 2.29.2