From: "Eugenio Pérez" <eperezma@redhat.com>
To: mst@redhat.com
Cc: parav@nvidia.com, Eli Cohen <elic@nvidia.com>,
alvaro.karsz@solid-run.com,
virtualization@lists.linux-foundation.org,
Zhu Lingshan <lingshan.zhu@intel.com>,
lulu@redhat.com, Gautam Dawar <gdawar@xilinx.com>,
Laurent Vivier <lvivier@redhat.com>,
linux-kernel@vger.kernel.org, si-wei.liu@oracle.com,
sgarzare@redhat.com, leiyang@redhat.com, longpeng2@huawei.com
Subject: [PATCH] vdpa_sim: set last_used_idx as last_avail_idx in vdpasim_queue_ready
Date: Fri, 3 Feb 2023 15:07:36 +0100 [thread overview]
Message-ID: <20230203140736.298564-1-eperezma@redhat.com> (raw)
Starting from an used_idx different than 0 is needed in use cases like
virtual machine migration. Not doing so and letting the caller set an
avail idx different than 0 causes destination device to try to use old
buffers that source driver already recover and are not available
anymore.
Since vdpa_sim does not support receive inflight descriptors as a
destination of a migration, let's set both avail_idx and used_idx the
same at vq start. This is how vhost-user works in a
VHOST_SET_VRING_BASE call.
Although the simple fix is to set last_used_idx at vdpasim_set_vq_state,
it would be reset at vdpasim_queue_ready. The last_avail_idx case is
fixed with commit a09f493c ("vdpa_sim: not reset state in
vdpasim_queue_ready"). Since the only option is to make it equal to
last_avail_idx, adding the only change needed here.
This was discovered and tested live migrating the vdpa_sim_net device.
Fixes: 2c53d0f64c06 ("vdpasim: vDPA device simulator")
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
Cherry-picked from patch 2/2 of the series [1]. Differences are:
* Set the value of used_idx at vdpasim_queue_ready instead of fetching
from the guest vring like vhost-kernel.
Note that commit id present in the patch text is not in master but in
maintainer branch.
[1] https://lkml.org/lkml/2023/1/18/1041
---
drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 6a0a65814626..1b780e852359 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -68,6 +68,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
(uintptr_t)vq->device_addr);
vq->vring.last_avail_idx = last_avail_idx;
+ vq->vring.last_used_idx = last_avail_idx;
vq->vring.notify = vdpasim_vq_notify;
}
@@ -282,6 +283,7 @@ static int vdpasim_set_vq_state(struct vdpa_device *vdpa, u16 idx,
spin_lock(&vdpasim->lock);
vrh->last_avail_idx = state->split.avail_index;
+ vrh->last_used_idx = state->split.avail_index;
spin_unlock(&vdpasim->lock);
return 0;
--
2.31.1
reply other threads:[~2023-02-03 14:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230203140736.298564-1-eperezma@redhat.com \
--to=eperezma@redhat.com \
--cc=alvaro.karsz@solid-run.com \
--cc=elic@nvidia.com \
--cc=gdawar@xilinx.com \
--cc=leiyang@redhat.com \
--cc=lingshan.zhu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=longpeng2@huawei.com \
--cc=lulu@redhat.com \
--cc=lvivier@redhat.com \
--cc=mst@redhat.com \
--cc=parav@nvidia.com \
--cc=sgarzare@redhat.com \
--cc=si-wei.liu@oracle.com \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox