Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp189766pxb; Mon, 8 Feb 2021 19:52:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJyA9CN7kZw5Xb1jnI/VbhKq2d6QkiTgT2MkDanRkGNk/qHPm0elVDZBQh9k/HZYe7/xWwu4 X-Received: by 2002:a05:6402:3585:: with SMTP id y5mr20314887edc.97.1612842732591; Mon, 08 Feb 2021 19:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612842732; cv=none; d=google.com; s=arc-20160816; b=Fkc+hgzzb9OU+cvcemi0hiPc0KuP5FZ69ww1kfXM6nW7NXUMOWIJ8lmLBTA9vBNb6m FcwP3akFOEPgc4+bsBkAfu61S/MmFUOCHOUuATO67qQUiygh1mAvlRX5sZvlpEtTvBcA KXdpk654izo3gGk4/MfPnrc8Aq52tv3M8/gIeKYZJI7KOtMUxQ3uut6aepNqs91tKLR6 k5lSjGq3rdf8V3Bx69e32gILBktJWqpYKCySzAZue8vsGWZwTwCrCaazAP7wa1w7iKMK yWtnFlYd904SaiJJV/IugiyFGlXDYJ5WyLQ9Qw33WW8TkHoWmR1H23yjUwH2zzbdQCEa +yeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=qXpTUfGjHXTgPLVJ/cRGBpFqZ3c/AyT0/M9azlEt+tE=; b=ikYs7Nx7xgm7mqRdHdMMFm8OFGPxaMcVvBdQYFHLHL8wYsxsApkwWT59o6NWUIiNhF Zd5mqMDLk9a/BGixxfXxheVbTwMuRUHadN2QVTf84TmVWVka1X0WekExwvGLIIeOEnW8 Fbp1X2Bola8iVC4aS8pq7B4ojXgIkdvzmy4bYdNLdryAxZTzIk+XKcZRAAyqwhRiuZOL z7RiMhjY5/IQLYKvW9NDUeCBmpcCsEU/3q7JV4cUaRo9H7DqeqXQaXyGlxpeQ6iow4ml tzJP5lxPcWKXUkqqlkg9ctkfUP+5LbqtHMCRzEIhSnD0HvWKKoZy5/NPbZZBnoY1QQXN cy7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TV7s03io; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e9si13649259eds.558.2021.02.08.19.51.49; Mon, 08 Feb 2021 19:52:12 -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=@redhat.com header.s=mimecast20190719 header.b=TV7s03io; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230208AbhBIDrY (ORCPT + 99 others); Mon, 8 Feb 2021 22:47:24 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28043 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbhBIDjf (ORCPT ); Mon, 8 Feb 2021 22:39:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612841854; 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=qXpTUfGjHXTgPLVJ/cRGBpFqZ3c/AyT0/M9azlEt+tE=; b=TV7s03ioDCE3u4QRh7trF3CPdlmI/BeKCYOcXOwABzHgg4S2f4mJvoIqUzwzVWfeCB7+uc YIVEfXAh29xmGFaqN6/ptc/9isjmgMoLnbkKGc2vzvECrEJTeULra1Gs7M46XPfWvmyPmj dXSkw5AZaiw0qx/HMw/noj+Rm3szj8E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-60-ojgRJJiUN0mVCBrkrovz2A-1; Mon, 08 Feb 2021 22:37:29 -0500 X-MC-Unique: ojgRJJiUN0mVCBrkrovz2A-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F318A6D4FE; Tue, 9 Feb 2021 03:37:25 +0000 (UTC) Received: from [10.72.13.32] (ovpn-13-32.pek2.redhat.com [10.72.13.32]) by smtp.corp.redhat.com (Postfix) with ESMTP id E4AC110013D7; Tue, 9 Feb 2021 03:37:23 +0000 (UTC) Subject: Re: [PATCH 3/3] mlx5_vdpa: defer clear_virtqueues to until DRIVER_OK To: Si-Wei Liu , mst@redhat.com, elic@nvidia.com Cc: linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org References: <1612614564-4220-1-git-send-email-si-wei.liu@oracle.com> <1612614564-4220-3-git-send-email-si-wei.liu@oracle.com> From: Jason Wang Message-ID: <2e2bc8d7-5d64-c28c-9aa0-1df32c7dcef3@redhat.com> Date: Tue, 9 Feb 2021 11:37:22 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <1612614564-4220-3-git-send-email-si-wei.liu@oracle.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/2/6 下午8:29, 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 > --- > 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); Rethink about this. As mentioned in another thread, this in fact breaks set_vq_state().  (See vhost_virtqueue_start() -> vhost_vdpa_set_vring_base() in qemu codes). The issue is that the avail idx is forgot, we need keep it. Thanks > err = setup_driver(ndev); > if (err) { > mlx5_vdpa_warn(mvdev, "failed to setup driver\n");