From: Cornelia Huck <cohuck@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: mst@redhat.com, thuth@redhat.com
Subject: Re: [PATCH 4/4] virtio-mmio: cleanup reset
Date: Thu, 09 Jun 2022 14:22:40 +0200 [thread overview]
Message-ID: <87ilpa9gbz.fsf@redhat.com> (raw)
In-Reply-To: <20220609091534.1416909-5-pbonzini@redhat.com>
On Thu, Jun 09 2022, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Make virtio_mmio_soft_reset reset the virtio device, which is performed by
> both the "soft" and the "hard" reset; and then call virtio_mmio_soft_reset
> from virtio_mmio_reset to emphasize that the latter is a superset of the
> former.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/virtio/virtio-mmio.c | 17 ++++++++---------
> 1 file changed, 8 insertions(+), 9 deletions(-)
>
> diff --git a/hw/virtio/virtio-mmio.c b/hw/virtio/virtio-mmio.c
> index 6d81a26473..d240efef97 100644
> --- a/hw/virtio/virtio-mmio.c
> +++ b/hw/virtio/virtio-mmio.c
> @@ -72,12 +72,12 @@ static void virtio_mmio_soft_reset(VirtIOMMIOProxy *proxy)
> {
> int i;
>
> - if (proxy->legacy) {
> - return;
> - }
> + virtio_bus_reset(&proxy->bus);
>
> - for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
> - proxy->vqs[i].enabled = 0;
> + if (!proxy->legacy) {
> + for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
> + proxy->vqs[i].enabled = 0;
> + }
> }
> }
The more I look at this, the more confused I get.
The current code calls soft_reset when the driver sets the status to 0,
after already having called virtio_reset(). But doesn't virtio_reset()
ultimately already trigger the virtio-mmio reset routine, which sets
enabled to 0 for all queues? Why do that again? (And why is soft_reset a
"soft reset"?)
Maybe I'm missing something obvious, or it is simply -ENOCOFFEE on my side.
>
> @@ -376,7 +376,7 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
> return;
> }
> if (value == 0) {
> - virtio_bus_reset(&vdev->bus);
> + virtio_mmio_soft_reset(proxy);
> } else {
> virtio_queue_set_addr(vdev, vdev->queue_sel,
> value << proxy->guest_page_shift);
> @@ -432,7 +432,6 @@ static void virtio_mmio_write(void *opaque, hwaddr offset, uint64_t value,
> }
>
> if (vdev->status == 0) {
> - virtio_reset(vdev);
> virtio_mmio_soft_reset(proxy);
> }
> break;
> @@ -627,7 +626,8 @@ static void virtio_mmio_reset(DeviceState *d)
> VirtIOMMIOProxy *proxy = VIRTIO_MMIO(d);
> int i;
>
> - virtio_bus_reset(&proxy->bus);
> + virtio_mmio_soft_reset(proxy);
> +
> proxy->host_features_sel = 0;
> proxy->guest_features_sel = 0;
> proxy->guest_page_shift = 0;
> @@ -636,7 +636,6 @@ static void virtio_mmio_reset(DeviceState *d)
> proxy->guest_features[0] = proxy->guest_features[1] = 0;
>
> for (i = 0; i < VIRTIO_QUEUE_MAX; i++) {
> - proxy->vqs[i].enabled = 0;
> proxy->vqs[i].num = 0;
> proxy->vqs[i].desc[0] = proxy->vqs[i].desc[1] = 0;
> proxy->vqs[i].avail[0] = proxy->vqs[i].avail[1] = 0;
next prev parent reply other threads:[~2022-06-09 14:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 9:15 [PATCH 0/4] virtio: various cleanups to reset code Paolo Bonzini
2022-06-09 9:15 ` [PATCH 1/4] s390x: simplify virtio_ccw_reset_virtio Paolo Bonzini
2022-06-09 11:40 ` Cornelia Huck
2022-06-09 9:15 ` [PATCH 2/4] virtio-mmio: stop ioeventfd on legacy reset Paolo Bonzini
2022-06-09 11:49 ` Cornelia Huck
2022-06-09 9:15 ` [PATCH 3/4] virtio: stop ioeventfd on reset Paolo Bonzini
2022-06-09 11:56 ` Cornelia Huck
2022-06-09 9:15 ` [PATCH 4/4] virtio-mmio: cleanup reset Paolo Bonzini
2022-06-09 12:22 ` Cornelia Huck [this message]
2022-06-09 14:44 ` Paolo Bonzini
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=87ilpa9gbz.fsf@redhat.com \
--to=cohuck@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).