Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5778209pxb; Tue, 16 Feb 2021 07:24:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzeJb77VDQZJdr1Hf6VnmHOKLUqEjd6vbQlV9Wdw/HYibJSpv1PfMCnAmMtnKmLrza+lffV X-Received: by 2002:a50:ef0f:: with SMTP id m15mr22232931eds.175.1613489079098; Tue, 16 Feb 2021 07:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613489079; cv=none; d=google.com; s=arc-20160816; b=BK/MgdoBViTTSvX+BopYhMLjLinRg9PTk3kjSvZcbGoRBTQ7XRj4uUWdmiXL6DkRTT +jyAQ8DdkN5I4lKX8YbSMblkfl96PHm523lk7B/cw83N83BNRgXtuoTEslvwNWdtATbm KUcGGnsrA6g+B4G1gBhbue0XvWldBazJcIUDttIAEuXeg2jFMx6UG/d7725ZXL5S2dd+ VFn1Kwrk1cNKjmaizaiUNFT5fOtAv3+a048TN7F+EMp4l55phuIrnUFML3QpBb3HFa1n jvunHcH1xGnYjqSph19s5YHzxLyHpg7wNOKRH58vyYB6tNuD2WL/+/5otSlASuatmYLS CJFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:dkim-signature:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=oljyvW9QX6a5ATx1aSFBKfVM2GqJ4ZFr/3Fr2sk5rHw=; b=x0Yrnj/u6Rtw8DiEo0u7BUpHBFXrcsjEZg6G/26JKVm2iBDOnjEEqf4ibVHv+jTFyz 3X0OqqP4ED+4cGPce8I4hZO2coNtJZyaH9Z69FIqGlah4yuY0kXyYkwvT004fvNSdBwR HyJT6/KmFXyV0SH3PKoaAfrHnjR1gnrPXst7ElgSWCxtHIBmSDPhDTcZ/QnedBq3Rsz1 bkIxtxE/nYp2S3vpRYtZ4Bhn9QVVQdM+sw1MkvAeUqLyTmcCKjRIdLxw255OqFQO7zRR 9Sae7UAVfMnMHvByLytdudZhNsxvFzZwxGNYNl0oXEFgvUdh89fNBtrCSQ2a4imzdldo 3vLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=O73rwWcc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m13si14601321edb.227.2021.02.16.07.24.16; Tue, 16 Feb 2021 07:24:39 -0800 (PST) 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; dkim=pass header.i=@nvidia.com header.s=n1 header.b=O73rwWcc; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbhBPPWh (ORCPT + 99 others); Tue, 16 Feb 2021 10:22:37 -0500 Received: from hqnvemgate24.nvidia.com ([216.228.121.143]:5905 "EHLO hqnvemgate24.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229880AbhBPPWe (ORCPT ); Tue, 16 Feb 2021 10:22:34 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate24.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Tue, 16 Feb 2021 07:21:53 -0800 Received: from mtl-vdi-166.wap.labs.mlnx (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 16 Feb 2021 15:21:51 +0000 Date: Tue, 16 Feb 2021 17:21:48 +0200 From: Eli Cohen To: Si-Wei Liu CC: , , , , Subject: Re: [PATCH v2 3/3] vdpa/mlx5: defer clear_virtqueues to until DRIVER_OK Message-ID: <20210216152148.GA99540@mtl-vdi-166.wap.labs.mlnx> References: <1612993680-29454-1-git-send-email-si-wei.liu@oracle.com> <1612993680-29454-4-git-send-email-si-wei.liu@oracle.com> <20210211073314.GB100783@mtl-vdi-166.wap.labs.mlnx> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20210211073314.GB100783@mtl-vdi-166.wap.labs.mlnx> User-Agent: Mutt/1.9.5 (bf161cf53efb) (2018-04-13) X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1613488913; bh=oljyvW9QX6a5ATx1aSFBKfVM2GqJ4ZFr/3Fr2sk5rHw=; h=Date:From:To:CC:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To:User-Agent: X-Originating-IP:X-ClientProxiedBy; b=O73rwWccv6ouPtIofhZsE42cFZL9RoBYP4RIVxu9Gm3SEEPbBhajBhqBd1maE5xxs 3b80SDMrXHTn5HYWlByE7arBih42IEZQt9lW1508/PhIPTrM5zqDqmSsCZxESuAzud EZsnhI6A3JymxYBCCh7eSwEKwOTRHcUWXe1VdRSqYcTHDVz+sYfFrtYAJ2H9AevYK3 0YcidfiJeKyEwKYQzbpoiYXRNZVxY9SMHGO8kyYh9Er6NMJg1l1f3qv9sYFvbR0TLr NWkMgCggiKF9rm8nDQhgjTf4VVexAwL6etJANWcuN9CoFe5nW3U4kRrdupidx6nZ8a wCqi0BlEDg/ew== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 11, 2021 at 09:33:14AM +0200, Eli Cohen wrote: > On Wed, Feb 10, 2021 at 01:48:00PM -0800, Si-Wei Liu wrote: > > While virtq is stopped, get_vq_state() is supposed to > > be called to get sync'ed with the latest internal > > avail_index from device. The saved avail_index is used > > to restate the virtq once device is started. Commit > > b35ccebe3ef7 introduced the clear_virtqueues() routine > > to reset the saved avail_index, however, the index > > gets cleared a bit earlier before get_vq_state() tries > > to read it. This would cause consistency problems when > > virtq is restarted, e.g. through a series of link down > > and link up events. We could defer the clearing of > > avail_index to until the device is to be started, > > i.e. until VIRTIO_CONFIG_S_DRIVER_OK is set again in > > set_status(). > > > > Fixes: b35ccebe3ef7 ("vdpa/mlx5: Restore the hardware used index after change map") > > Signed-off-by: Si-Wei Liu > > Acked-by: Jason Wang > > Acked-by: Eli Cohen > I take it back. I think we don't need to clear the indexes at all. In case we need to restore indexes we'll get the right values through set_vq_state(). If we suspend the virtqueue due to VM being suspended, qemu will query first and will provide the the queried value. In case of VM reboot, it will provide 0 in set_vq_state(). I am sending a patch that addresses both reboot and suspend. > > --- > > drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > index 7c1f789..ce6aae8 100644 > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > @@ -1777,7 +1777,6 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) > > if (!status) { > > mlx5_vdpa_info(mvdev, "performing device reset\n"); > > teardown_driver(ndev); > > - clear_virtqueues(ndev); > > mlx5_vdpa_destroy_mr(&ndev->mvdev); > > ndev->mvdev.status = 0; > > ++mvdev->generation; > > @@ -1786,6 +1785,7 @@ static void mlx5_vdpa_set_status(struct vdpa_device *vdev, u8 status) > > > > if ((status ^ ndev->mvdev.status) & VIRTIO_CONFIG_S_DRIVER_OK) { > > if (status & VIRTIO_CONFIG_S_DRIVER_OK) { > > + clear_virtqueues(ndev); > > err = setup_driver(ndev); > > if (err) { > > mlx5_vdpa_warn(mvdev, "failed to setup driver\n"); > > -- > > 1.8.3.1 > >