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 8A366A00C3; Thu, 3 Feb 2022 14:48:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0EE8140143; Thu, 3 Feb 2022 14:48:07 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 5771D40140 for ; Thu, 3 Feb 2022 14:48:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643896085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BX48XXW16OfuGo//vCXzntxTa9OVIyu8WgpmbtXSAPo=; b=JMQLKUrkq4O/vHZt7qPwC2Sh2q5U5vnFAbqypd1HGb9i2NJRIzSSfyztD6E8rSwvspSGs0 IoRFxxa27dKzbx9kcGiPs4VIsldgnSJPrONZeD0H3VVKj8x0MH8TNkZOocN9SxBnHtRq5y TjYiA5sETCFDd9jtoxCAI+jo+gCU5c4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-Cjd4-GkRPVmYdd-cKFlWkw-1; Thu, 03 Feb 2022 08:48:02 -0500 X-MC-Unique: Cjd4-GkRPVmYdd-cKFlWkw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8E9C9190B2A3; Thu, 3 Feb 2022 13:48:01 +0000 (UTC) Received: from [10.39.208.15] (unknown [10.39.208.15]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8590F6E1EE; Thu, 3 Feb 2022 13:48:00 +0000 (UTC) Message-ID: <26fc76e7-4de9-62e4-25cf-fd876f845e78@redhat.com> Date: Thu, 3 Feb 2022 14:47:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH v2] vhost: add vDPA resource cleanup callback To: Xueming Li , dev@dpdk.org Cc: Matan Azrad , Xia Chenbo References: <20211019113956.2254537-1-xuemingl@nvidia.com> <20220127084535.673527-1-xuemingl@nvidia.com> From: Maxime Coquelin In-Reply-To: <20220127084535.673527-1-xuemingl@nvidia.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 1/27/22 09:45, Xueming Li wrote: > This patch adds vDPA device cleanup callback to release resources on > vhost user connection close. > > Signed-off-by: Xueming Li > --- > lib/vhost/vdpa_driver.h | 3 +++ > lib/vhost/vhost_user.c | 6 ++++++ > 2 files changed, 9 insertions(+) > > diff --git a/lib/vhost/vdpa_driver.h b/lib/vhost/vdpa_driver.h > index fc2d6acedd1..fddbd506523 100644 > --- a/lib/vhost/vdpa_driver.h > +++ b/lib/vhost/vdpa_driver.h > @@ -34,6 +34,9 @@ struct rte_vdpa_dev_ops { > /** Driver close the device (Mandatory) */ > int (*dev_close)(int vid); > > + /** Connection closed, clean up resources */ > + int (*dev_cleanup)(int vid); > + > /** Enable/disable this vring (Mandatory) */ > int (*set_vring_state)(int vid, int vring, int state); > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 5eb1dd68123..798b0ca4c0d 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -220,6 +220,12 @@ free_mem_region(struct virtio_net *dev) > void > vhost_backend_cleanup(struct virtio_net *dev) > { > + struct rte_vdpa_device *vdpa_dev; > + > + vdpa_dev = dev->vdpa_dev; > + if (vdpa_dev && vdpa_dev->ops->dev_cleanup != NULL) > + vdpa_dev->ops->dev_cleanup(dev->vid); > + > if (dev->mem) { > free_mem_region(dev); > rte_free(dev->mem); Reviewed-by: Maxime Coquelin Thanks, Maxime