mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
virtio: Move virtio_reset()
Move virtio_reset() to a later part of the file to remove the forward declaration of virtio_set_features_nocheck() and to prepare the situation that we need more operations to perform during reset. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Message-Id: <20250421-reset-v2-2-e4c1ead88ea1@daynix.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
0caed25cd1
commit
77a9408fc7
1 changed files with 43 additions and 45 deletions
|
@ -2320,51 +2320,6 @@ void virtio_queue_enable(VirtIODevice *vdev, uint32_t queue_index)
|
|||
}
|
||||
}
|
||||
|
||||
static int virtio_set_features_nocheck(VirtIODevice *vdev, uint64_t val);
|
||||
|
||||
void virtio_reset(void *opaque)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
int i;
|
||||
|
||||
virtio_set_status(vdev, 0);
|
||||
if (current_cpu) {
|
||||
/* Guest initiated reset */
|
||||
vdev->device_endian = virtio_current_cpu_endian();
|
||||
} else {
|
||||
/* System reset */
|
||||
vdev->device_endian = virtio_default_endian();
|
||||
}
|
||||
|
||||
if (k->get_vhost) {
|
||||
struct vhost_dev *hdev = k->get_vhost(vdev);
|
||||
/* Only reset when vhost back-end is connected */
|
||||
if (hdev && hdev->vhost_ops) {
|
||||
vhost_reset_device(hdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (k->reset) {
|
||||
k->reset(vdev);
|
||||
}
|
||||
|
||||
vdev->start_on_kick = false;
|
||||
vdev->started = false;
|
||||
vdev->broken = false;
|
||||
virtio_set_features_nocheck(vdev, 0);
|
||||
vdev->queue_sel = 0;
|
||||
vdev->status = 0;
|
||||
vdev->disabled = false;
|
||||
qatomic_set(&vdev->isr, 0);
|
||||
vdev->config_vector = VIRTIO_NO_VECTOR;
|
||||
virtio_notify_vector(vdev, vdev->config_vector);
|
||||
|
||||
for(i = 0; i < VIRTIO_QUEUE_MAX; i++) {
|
||||
__virtio_queue_reset(vdev, i);
|
||||
}
|
||||
}
|
||||
|
||||
void virtio_queue_set_addr(VirtIODevice *vdev, int n, hwaddr addr)
|
||||
{
|
||||
if (!vdev->vq[n].vring.num) {
|
||||
|
@ -3175,6 +3130,49 @@ int virtio_set_features(VirtIODevice *vdev, uint64_t val)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void virtio_reset(void *opaque)
|
||||
{
|
||||
VirtIODevice *vdev = opaque;
|
||||
VirtioDeviceClass *k = VIRTIO_DEVICE_GET_CLASS(vdev);
|
||||
int i;
|
||||
|
||||
virtio_set_status(vdev, 0);
|
||||
if (current_cpu) {
|
||||
/* Guest initiated reset */
|
||||
vdev->device_endian = virtio_current_cpu_endian();
|
||||
} else {
|
||||
/* System reset */
|
||||
vdev->device_endian = virtio_default_endian();
|
||||
}
|
||||
|
||||
if (k->get_vhost) {
|
||||
struct vhost_dev *hdev = k->get_vhost(vdev);
|
||||
/* Only reset when vhost back-end is connected */
|
||||
if (hdev && hdev->vhost_ops) {
|
||||
vhost_reset_device(hdev);
|
||||
}
|
||||
}
|
||||
|
||||
if (k->reset) {
|
||||
k->reset(vdev);
|
||||
}
|
||||
|
||||
vdev->start_on_kick = false;
|
||||
vdev->started = false;
|
||||
vdev->broken = false;
|
||||
virtio_set_features_nocheck(vdev, 0);
|
||||
vdev->queue_sel = 0;
|
||||
vdev->status = 0;
|
||||
vdev->disabled = false;
|
||||
qatomic_set(&vdev->isr, 0);
|
||||
vdev->config_vector = VIRTIO_NO_VECTOR;
|
||||
virtio_notify_vector(vdev, vdev->config_vector);
|
||||
|
||||
for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
|
||||
__virtio_queue_reset(vdev, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_device_check_notification_compatibility(VirtIODevice *vdev,
|
||||
Error **errp)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue