virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jianguo Sun <quic_jianguos@quicinc.com>
Cc: jasowang@redhat.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 2/2] virtio: Add polling virtio-mmio device reset completion
Date: Thu, 26 Sep 2024 02:46:53 -0400	[thread overview]
Message-ID: <20240926024619-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20240922123435.17946-2-quic_jianguos@quicinc.com>

On Sun, Sep 22, 2024 at 08:34:35PM +0800, Jianguo Sun 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 | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/virtio/virtio_mmio.c b/drivers/virtio/virtio_mmio.c
> index 90e784e7b721..c34ad1782145 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,13 @@ static void vm_reset(struct virtio_device *vdev)
>  
>  	/* 0 status means a reset. */
>  	writel(0, vm_dev->base + VIRTIO_MMIO_STATUS);
> +#ifdef CONFIG_VIRTIO_MMIO_POLL_RESET
> +	/* After writing 0 to device_status, the driver MUST wait for a read of
> +	 * device_status to return 0 before reinitializing the device.
> +	 */

This is not in the spec, is it? First you need a spec patch. Then implement it.


> +	while (readl(vm_dev->base + VIRTIO_MMIO_STATUS))
> +		usleep_range(1000, 1100);
> +#endif
>  }
>  
>  
> -- 
> 2.17.1


  parent reply	other threads:[~2024-09-26  6:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-22 12:34 [PATCH 1/2] Virtio: Add CONFIG_VIRTIO_MMIO_POLL_RESET Jianguo Sun
2024-09-22 12:34 ` [PATCH 2/2] virtio: Add polling virtio-mmio device reset completion Jianguo Sun
2024-09-24  7:40   ` Jason Wang
2024-09-26  6:46   ` Michael S. Tsirkin [this message]
2024-09-24  7:38 ` [PATCH 1/2] Virtio: Add CONFIG_VIRTIO_MMIO_POLL_RESET Jason Wang
2024-09-26  3:30   ` Jianguo Sun (QUIC)
2024-09-26  3:50     ` Jason Wang
2024-09-26  6:10       ` Michael S. Tsirkin
2024-09-26  6:46 ` 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=20240926024619-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 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).