vdpa_sim: Implement resume vdpa op
Implement resume operation for vdpa_sim devices, so vhost-vdpa will offer that backend feature and userspace can effectively resume the device. Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com> Message-Id: <15a4566826033c5dd9a2167e5cfb0ef4d90cea49.1672742878.git.sebastien.boeuf@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
committed by
Michael S. Tsirkin
parent
3b688d7a08
commit
f9d9f57ef0
@@ -358,6 +358,12 @@ static void vdpasim_kick_vq(struct vdpa_device *vdpa, u16 idx)
|
|||||||
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
|
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
|
||||||
struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
|
struct vdpasim_virtqueue *vq = &vdpasim->vqs[idx];
|
||||||
|
|
||||||
|
if (!vdpasim->running &&
|
||||||
|
(vdpasim->status & VIRTIO_CONFIG_S_DRIVER_OK)) {
|
||||||
|
vdpasim->pending_kick = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (vq->ready)
|
if (vq->ready)
|
||||||
schedule_work(&vdpasim->work);
|
schedule_work(&vdpasim->work);
|
||||||
}
|
}
|
||||||
@@ -528,6 +534,27 @@ static int vdpasim_suspend(struct vdpa_device *vdpa)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vdpasim_resume(struct vdpa_device *vdpa)
|
||||||
|
{
|
||||||
|
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
spin_lock(&vdpasim->lock);
|
||||||
|
vdpasim->running = true;
|
||||||
|
|
||||||
|
if (vdpasim->pending_kick) {
|
||||||
|
/* Process pending descriptors */
|
||||||
|
for (i = 0; i < vdpasim->dev_attr.nvqs; ++i)
|
||||||
|
vdpasim_kick_vq(vdpa, i);
|
||||||
|
|
||||||
|
vdpasim->pending_kick = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
spin_unlock(&vdpasim->lock);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static size_t vdpasim_get_config_size(struct vdpa_device *vdpa)
|
static size_t vdpasim_get_config_size(struct vdpa_device *vdpa)
|
||||||
{
|
{
|
||||||
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
|
struct vdpasim *vdpasim = vdpa_to_sim(vdpa);
|
||||||
@@ -720,6 +747,7 @@ static const struct vdpa_config_ops vdpasim_config_ops = {
|
|||||||
.set_status = vdpasim_set_status,
|
.set_status = vdpasim_set_status,
|
||||||
.reset = vdpasim_reset,
|
.reset = vdpasim_reset,
|
||||||
.suspend = vdpasim_suspend,
|
.suspend = vdpasim_suspend,
|
||||||
|
.resume = vdpasim_resume,
|
||||||
.get_config_size = vdpasim_get_config_size,
|
.get_config_size = vdpasim_get_config_size,
|
||||||
.get_config = vdpasim_get_config,
|
.get_config = vdpasim_get_config,
|
||||||
.set_config = vdpasim_set_config,
|
.set_config = vdpasim_set_config,
|
||||||
@@ -753,6 +781,7 @@ static const struct vdpa_config_ops vdpasim_batch_config_ops = {
|
|||||||
.set_status = vdpasim_set_status,
|
.set_status = vdpasim_set_status,
|
||||||
.reset = vdpasim_reset,
|
.reset = vdpasim_reset,
|
||||||
.suspend = vdpasim_suspend,
|
.suspend = vdpasim_suspend,
|
||||||
|
.resume = vdpasim_resume,
|
||||||
.get_config_size = vdpasim_get_config_size,
|
.get_config_size = vdpasim_get_config_size,
|
||||||
.get_config = vdpasim_get_config,
|
.get_config = vdpasim_get_config,
|
||||||
.set_config = vdpasim_set_config,
|
.set_config = vdpasim_set_config,
|
||||||
|
@@ -67,6 +67,7 @@ struct vdpasim {
|
|||||||
u64 features;
|
u64 features;
|
||||||
u32 groups;
|
u32 groups;
|
||||||
bool running;
|
bool running;
|
||||||
|
bool pending_kick;
|
||||||
/* spinlock to synchronize iommu table */
|
/* spinlock to synchronize iommu table */
|
||||||
spinlock_t iommu_lock;
|
spinlock_t iommu_lock;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user