Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6788537pxb; Wed, 17 Feb 2021 13:32:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJziiX8u9lRpCJ6PaABv3nYbXiY/YgBDtmKFRzIMHR80EvxhOYV1YhpPNmE4W8dTk/jlmzoK X-Received: by 2002:a17:906:4d05:: with SMTP id r5mr839744eju.499.1613597522636; Wed, 17 Feb 2021 13:32:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613597522; cv=none; d=google.com; s=arc-20160816; b=Y9yA0WCBS0Pv/pNkP2D110KIuD9pxTu5zMfSOmsXGWxH7nx2C3+j1jCqvNgr9HaIZk 893uXxr6SeI1cMjq5ui6bSFH4FCcD9IqokS5V6fc5nEBHsoSNTfvxcznC0b3aeTikegc 4w26vAdYOf/xroqdZhrhIP3qKCba1OIc4oQXxRch0cY3DmXYYsX5Hq9d8fnzyPWGH6A5 QM6k1nRJlrr1sOCkTYCFfluBwosx2G0JDooWJVMMFBz+vMKMzbt1LNJdD+WTPyNeHTmG SJ39uF+uZ7lE0MlR/JxLeqUablv0uSIcmozynVNyNsvqna3i6bScNSwD53XJ35MKah0g BM5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=dnUfiwdq5gxWn7kuZ9KofRt51rZIFhafBYYbLyCXkSs=; b=d9DGFNJYKXPDqrq7PBCCG5tWP1YcDXXO2eOMeohE1zRuls7W4RHZFmFtPSXqXhJmbU gLKZDnkJwY4mELRFd2D7UsnIy2gccUWOD/DdjQyXXm+2pZGpM5v/9Ns8sYcZtoyS4qss py3UOlwdcuMGoBM8r/SqivCyX7Ri+dHHaMeFyQgpeSm0Pcm9MPkSbuRowsPADJUgL21h dJ6aQp9WQRMU6kIDlSFXEzrhFMM+O3X/mCbTV2NDSsxzv3f3V46L2bSDKFdv7xt9bo57 zSOnZL/NrNE0020GfneItUoDy7ouZneISEJpIjm47ZUL4jQTEoN+2gihVJM8nYbKBNtI O6OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=PKe4dnKa; 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 p88si2113077edp.145.2021.02.17.13.31.38; Wed, 17 Feb 2021 13:32:02 -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=PKe4dnKa; 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 S232974AbhBQVWO (ORCPT + 99 others); Wed, 17 Feb 2021 16:22:14 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59269 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233314AbhBQVVu (ORCPT ); Wed, 17 Feb 2021 16:21:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613596823; 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: in-reply-to:in-reply-to:references:references; bh=dnUfiwdq5gxWn7kuZ9KofRt51rZIFhafBYYbLyCXkSs=; b=PKe4dnKaBSMhU9p9Ti8OVPecVPkvnkkbOIPrmd+9nuMQhGYZsA4v9tfMRF733m92ghc96J MyLpsQ1kW9eAPmkn/BGDTYt6rncBv8fzJ4II+my++F88gwpL3c/qsn2HVlKTQDPxETzBqB gmREJk409NedMKtSE49ZeluJQ5q3jQM= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-442-DbrZhFJmPLyZddn5VVwlTw-1; Wed, 17 Feb 2021 16:20:20 -0500 X-MC-Unique: DbrZhFJmPLyZddn5VVwlTw-1 Received: by mail-ed1-f70.google.com with SMTP id m16so11274053edd.21 for ; Wed, 17 Feb 2021 13:20:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=dnUfiwdq5gxWn7kuZ9KofRt51rZIFhafBYYbLyCXkSs=; b=l8lGEjiCia+Wg3Z2PnmBFQ6tUNCRwy/nZcURyyoRA7rw7MP/+GfuUqltdZzfBLWlmQ 94F710zrIVpm8+HBOp/rpOfN3CN0JDXr02v1L25Ptf4ZZnD03qgr4sQPsQFS+3HyDVe1 51WY9TT6w8nuxBJWcvlhl3OX7p+o8O8I/IVsqxjK5a7DXtojIwFzTk7jUKSjlc2bD8GU S+URNnxkfERLjDXWUYGwiy6bLUyP9iUPsRgKTTL61cxFUnQ19bWMDNQuOiAZ3Fp7wATB AfuJojmWV3+dHxvHx6GIHCq11sFL2ZGnVpA3jJBsSSfGaPhNan3qqzD8mpBdMHMmHPrB iPyg== X-Gm-Message-State: AOAM532srJXrHHWrXLSm42k12HV8KWDZdLDxB/MhytLf8ANVTKyVHIno PYCD/MuhIOn7VIUzuXZzrNr4mzXTi0KzXfELBf67HG1A8pOtnHElzY8TeGZjLkzvfHv1ie5jtG3 qpDjRKRFrnWgxFFXGquZbRkr9 X-Received: by 2002:aa7:d68d:: with SMTP id d13mr728751edr.291.1613596819517; Wed, 17 Feb 2021 13:20:19 -0800 (PST) X-Received: by 2002:aa7:d68d:: with SMTP id d13mr728678edr.291.1613596818439; Wed, 17 Feb 2021 13:20:18 -0800 (PST) Received: from redhat.com (bzq-79-180-2-31.red.bezeqint.net. [79.180.2.31]) by smtp.gmail.com with ESMTPSA id x25sm1651338edv.65.2021.02.17.13.20.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 13:20:17 -0800 (PST) Date: Wed, 17 Feb 2021 16:20:14 -0500 From: "Michael S. Tsirkin" To: Si-Wei Liu Cc: Eli Cohen , jasowang@redhat.com, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: Re: [PATCH 1/2] vdpa/mlx5: Fix suspend/resume index restoration Message-ID: <20210217161858-mutt-send-email-mst@kernel.org> References: <20210216162001.83541-1-elic@nvidia.com> <4ecc1c7f-4f5a-68be-6734-e18dfeb91437@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4ecc1c7f-4f5a-68be-6734-e18dfeb91437@oracle.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 17, 2021 at 11:42:48AM -0800, Si-Wei Liu wrote: > > > On 2/16/2021 8:20 AM, Eli Cohen wrote: > > When we suspend the VM, the VDPA interface will be reset. When the VM is > > resumed again, clear_virtqueues() will clear the available and used > > indices resulting in hardware virqtqueue objects becoming out of sync. > > We can avoid this function alltogether since qemu will clear them if > > required, e.g. when the VM went through a reboot. > > > > Moreover, since the hw available and used indices should always be > > identical on query and should be restored to the same value same value > > for virtqueues that complete in order, we set the single value provided > > by set_vq_state(). In get_vq_state() we return the value of hardware > > used index. > > > > Fixes: 1a86b377aa21 ("vdpa/mlx5: Add VDPA driver for supported mlx5 devices") > > Signed-off-by: Eli Cohen > Acked-by: Si-Wei Liu Seems to also fix b35ccebe3ef76168aa2edaa35809c0232cb3578e, right? > > --- > > drivers/vdpa/mlx5/net/mlx5_vnet.c | 17 ++++------------- > > 1 file changed, 4 insertions(+), 13 deletions(-) > > > > diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > index b8e9d525d66c..a51b0f86afe2 100644 > > --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c > > +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c > > @@ -1169,6 +1169,7 @@ static void suspend_vq(struct mlx5_vdpa_net *ndev, struct mlx5_vdpa_virtqueue *m > > return; > > } > > mvq->avail_idx = attr.available_index; > > + mvq->used_idx = attr.used_index; > > } > > static void suspend_vqs(struct mlx5_vdpa_net *ndev) > > @@ -1426,6 +1427,7 @@ static int mlx5_vdpa_set_vq_state(struct vdpa_device *vdev, u16 idx, > > return -EINVAL; > > } > > + mvq->used_idx = state->avail_index; > > mvq->avail_idx = state->avail_index; > > return 0; > > } > > @@ -1443,7 +1445,7 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa > > * that cares about emulating the index after vq is stopped. > > */ > > if (!mvq->initialized) { > > - state->avail_index = mvq->avail_idx; > > + state->avail_index = mvq->used_idx; > > return 0; > > } > > @@ -1452,7 +1454,7 @@ static int mlx5_vdpa_get_vq_state(struct vdpa_device *vdev, u16 idx, struct vdpa > > mlx5_vdpa_warn(mvdev, "failed to query virtqueue\n"); > > return err; > > } > > - state->avail_index = attr.available_index; > > + state->avail_index = attr.used_index; > > return 0; > > } > > @@ -1532,16 +1534,6 @@ static void teardown_virtqueues(struct mlx5_vdpa_net *ndev) > > } > > } > > -static void clear_virtqueues(struct mlx5_vdpa_net *ndev) > > -{ > > - int i; > > - > > - for (i = ndev->mvdev.max_vqs - 1; i >= 0; i--) { > > - ndev->vqs[i].avail_idx = 0; > > - ndev->vqs[i].used_idx = 0; > > - } > > -} > > - > > /* TODO: cross-endian support */ > > static inline bool mlx5_vdpa_is_little_endian(struct mlx5_vdpa_dev *mvdev) > > { > > @@ -1777,7 +1769,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;