Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3749306pxb; Sun, 7 Feb 2021 21:50:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxuxzX8g4aJFIgt/bsTGjtfaOJ2HhwqpbVU6jYXsvgkmlkySApUmrKrwQQgV3jciRJBjfz/ X-Received: by 2002:a17:907:3f29:: with SMTP id hq41mr15338271ejc.227.1612763459463; Sun, 07 Feb 2021 21:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612763459; cv=none; d=google.com; s=arc-20160816; b=cAMAglUTuuRYUWMhHU/8OsS5M7U7CfMtz8tHw7QOMT/TWmIcp6EeMf6hYIsWoAGGm8 eexqwOix2uX+1KArs7q/WduEqOWjvc5t4aWDWRdh3QZvN9oc+cyFj7NW0+jx7DkjSyaA 1GgqWE66wMwff5E4MoKJ010kxR/7jjXFUeR0GlGpcHQw/IBEFrPu52bfNCwHsSmVQIbj EDsKBvHCXAzfGdFDoVndp/6/i/KRRnhWql84VGK0v3zIudqXLAYNLjBhj2NydCRb1m3p o/YmI35YSTHegGzaO7MmplS79yZRXGfKEwSLf7dV4WNb0P5gsc/+1SNdVVDC5x/9zZSP GqDA== 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=pzMBuwiRWPHolizp590FGjmhEg9704U0QfdQdV3HCkA=; b=hVP5js5m1z0n6+4DFSuvDk16tEcVonks1Jc7lAoOwpMgng418ChbCQBG64xajGun6G qb/Hk3jD2M5tFcOGCuYmUMNrCwsksPcObMci9ZPX1BRKUFa39APPWIdNCeAChthC3yG6 8ITcIWyOgp0yzNvXBQ3YTRQzcWFF0RSu2wRnTxwxNq1i3f00f9uhO+MYp0quTLlWqSJp BxRs0iPZDX4V6Kwoo3p9L+Gsaa1VN9K7wO2+YvwZvCs+JaZtcn/KL2cdLEYCsBkq7dEN JkQ4EP0KX20c3MuQnaJ+kybMP8AZHbu1m6VN8IJ9Eziiwvc3nvOems/E5T+rPZCZKtwQ ampA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=AuPjjMUW; 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 f7si10373540ejx.19.2021.02.07.21.50.36; Sun, 07 Feb 2021 21:50:59 -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=AuPjjMUW; 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 S229631AbhBHFtI (ORCPT + 99 others); Mon, 8 Feb 2021 00:49:08 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:9573 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbhBHFtC (ORCPT ); Mon, 8 Feb 2021 00:49:02 -0500 Received: from hqmail.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, AES256-SHA) id ; Sun, 07 Feb 2021 21:48:22 -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.1473.3; Mon, 8 Feb 2021 05:48:20 +0000 Date: Mon, 8 Feb 2021 07:48:16 +0200 From: Eli Cohen To: Si-Wei Liu CC: , , , , Subject: Re: [PATCH 3/3] mlx5_vdpa: defer clear_virtqueues to until DRIVER_OK Message-ID: <20210208054816.GC137517@mtl-vdi-166.wap.labs.mlnx> References: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> <1612614564-4220-3-git-send-email-si-wei.liu@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1612614564-4220-3-git-send-email-si-wei.liu@oracle.com> 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=1612763302; bh=pzMBuwiRWPHolizp590FGjmhEg9704U0QfdQdV3HCkA=; 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=AuPjjMUW5UVtOQtPvtlWG2brZc/tBvp1k+pa3XbGySG9PiujkR+ArlJuUeWw9noXC JsBEaddaq2k87jcjA04wXjHTzv0qt775w/pcS8SOnUXq+zEJVSi8TMwEZlyKNa50td zyGWzhEOWgmZZ4hNLlmAH3FoggoFsOaYgCKEOUsqfK9K2fyGHKDCR2PyWApUISi8oO TuxvPQPDZ8CI6BgNjOwxuwNJjLnPN1zpK5tAPvr27i331yHkPhUYipgrUtEG8YXcDT zYkYVYz6MQ0una51GbY6BePMuPXhyEBC359iORrOWqzUOjqAKO628XLmdgO+1MWDdy 541ykjhQ1c3Ow== Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 06, 2021 at 04:29:24AM -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(). Not sure I understand the scenario. You are talking about reset of the device followed by up/down events on the interface. How can you trigger this? > > Fixes: b35ccebe3ef7 ("vdpa/mlx5: Restore the hardware used index after change map") > Signed-off-by: Si-Wei Liu > --- > 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 aa6f8cd..444ab58 100644 > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > @@ -1785,7 +1785,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; > @@ -1794,6 +1793,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 >