From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Jianguo Sun <quic_jianguos@quicinc.com>,
xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
virtualization@lists.linux.dev,
Sreenad Menon <quic_sreemeno@quicinc.com>,
Anant Goel <quic_anantg@quicinc.com>
Subject: Re: [PATCH v2] virtio: Add polling virtio-mmio device reset completion
Date: Thu, 26 Sep 2024 02:09:14 -0400 [thread overview]
Message-ID: <20240926020709-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <CACGkMEu-r2K1Xb-797YnK80-YeKEsErSe=BBP=xMbBvHcDv6qA@mail.gmail.com>
On Thu, Sep 26, 2024 at 11:21:25AM +0800, Jason Wang wrote:
> On Thu, Sep 26, 2024 at 10:27 AM Jianguo Sun <quic_jianguos@quicinc.com> wrote:
> >
> > We write 0 to device_status to initiate reset of a virtio-mmio device.
> > The reset operation itself may or may not be completed by the time
> > write instruction completes. Add polling device_status to return
> > 0 to ensure reset completion before reinitializing the device.
> >
> > Change-Id: If15d11d090dfd0d4972ad35f49af03e076872413
> > Signed-off-by: Jianguo Sun <quic_jianguos@quicinc.com>
> > Signed-off-by: Sreenad Menon <quic_sreemeno@quicinc.com>
> > Signed-off-by: Anant Goel <quic_anantg@quicinc.com>
> > ---
> > drivers/virtio/virtio_mmio.c | 6 ++++++
> > 1 file changed, 6 insertions(+)
> >
> > diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> > index 90e784e7b721..cf1a4a3dd35d 100644
> > --- a/drivers/virtio/virtio_mmio.c
> > +++ b/drivers/virtio/virtio_mmio.c
> > @@ -70,6 +70,7 @@
> > #include <linux/virtio_config.h>
> > #include <uapi/linux/virtio_mmio.h>
> > #include <linux/virtio_ring.h>
> > +#include <linux/delay.h>
> >
> >
> >
> > @@ -269,6 +270,11 @@ static void vm_reset(struct virtio_device *vdev)
> >
> > /* 0 status means a reset. */
> > writel(0, vm_dev->base + VIRTIO_MMIO_STATUS);
> > + /* After writing 0 to device_status, the driver MUST wait for a read of
> > + * device_status to return 0 before reinitializing the device.
> > + */
>
> Is this copied from the spec? I can only see a similar description in
> the PCI but not MMIO part.
Not in spec. We can add something like this in spec, but it
can not be a MUST, has to be a SHOULD.
> > + while (readl(vm_dev->base + VIRTIO_MMIO_STATUS))
> > + msleep(1);
>
> Again, we probably need a feature bit to unbreak existing MMIO devices?
>
> THanks
We can do this unconditionally since legacy devices return 0
immediately, feature negotiation happens after reset, won't be useful
here.
> > }
> >
> >
> > --
> > 2.17.1
> >
next prev parent reply other threads:[~2024-09-26 6:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-26 2:25 [PATCH v2] virtio: Add polling virtio-mmio device reset completion Jianguo Sun
2024-09-26 3:21 ` Jason Wang
2024-09-26 6:09 ` Michael S. Tsirkin [this message]
2024-09-27 4:08 ` Jason Wang
2024-09-29 17:51 ` Michael S. Tsirkin
2024-10-09 8:24 ` Jason Wang
2024-10-09 9:31 ` Michael S. Tsirkin
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=20240926020709-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=eperezma@redhat.com \
--cc=jasowang@redhat.com \
--cc=quic_anantg@quicinc.com \
--cc=quic_jianguos@quicinc.com \
--cc=quic_sreemeno@quicinc.com \
--cc=virtualization@lists.linux.dev \
--cc=xuanzhuo@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.