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 5F4F0A00BE; Thu, 10 Feb 2022 16:13:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4D4F642714; Thu, 10 Feb 2022 16:13:12 +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 5C3CB426EE for ; Thu, 10 Feb 2022 16:13:11 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644505990; 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=34lC4yIMk0lENFL0nAIZMZr1MrOYom3idvpl9AYdDJA=; b=fC5ihfVTrs6owZgmgEQIXdCZtSPp+ctREtoyr4+SDPcNkc1Q/8Xe4WdWabBGKe6riw28NF lVS/uXbFYtSgsOsciXYLazeF07vizqClYahg6Unp/GpFCjBV6XtMKfsdL7qwc7ALIsU/7N /Jc87fZZXdKl2aOG28qRce7N7ucmono= 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-392-fESi1bBwOxGgDDSJ8pdlPA-1; Thu, 10 Feb 2022 10:13:07 -0500 X-MC-Unique: fESi1bBwOxGgDDSJ8pdlPA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9DE011091DA0; Thu, 10 Feb 2022 15:13:06 +0000 (UTC) Received: from [10.39.208.19] (unknown [10.39.208.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 772D57CAD2; Thu, 10 Feb 2022 15:13:05 +0000 (UTC) Message-ID: <2de9347a-a259-2c50-1262-757f6d009546@redhat.com> Date: Thu, 10 Feb 2022 16:13:04 +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.12 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); Applied to dpdk-next-virtio/main. Thanks, Maxime