DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Xueming Li <xuemingl@nvidia.com>, dev@dpdk.org
Cc: Maxime Coquelin <maxime.coquelin@redhat.com>,
	Chenbo Xia <chenbo.xia@intel.com>
Subject: Re: [dpdk-dev] [PATCH v1] net/virtio: wait device ready during reset
Date: Wed, 15 Sep 2021 12:27:34 +0300	[thread overview]
Message-ID: <50db4150-c9c5-2e3e-6f0e-e54935b9631d@oktetlabs.ru> (raw)
In-Reply-To: <20210915092113.79205-1-xuemingl@nvidia.com>

On 9/15/21 12:21 PM, Xueming Li wrote:
> According to virtio spec, the device MUST reset when 0 is written to
> device_status, and present 0 in device_status once reset is done.
> 
> This patch waits status value to be 0 during reset operation, if
> timeout in 3 seconds, log and continue.

I have no strong opinion on timeout.

> 
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> ---
>  drivers/net/virtio/virtio.c | 15 +++++++++++++--
>  1 file changed, 13 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio.c b/drivers/net/virtio/virtio.c
> index 7e1e77797f..f865b27b65 100644
> --- a/drivers/net/virtio/virtio.c
> +++ b/drivers/net/virtio/virtio.c
> @@ -3,7 +3,10 @@
>   * Copyright(c) 2020 Red Hat, Inc.
>   */
>  
> +#include <unistd.h>
> +
>  #include "virtio.h"
> +#include "virtio_logs.h"
>  
>  uint64_t
>  virtio_negotiate_features(struct virtio_hw *hw, uint64_t host_features)
> @@ -38,9 +41,17 @@ virtio_write_dev_config(struct virtio_hw *hw, size_t offset,
>  void
>  virtio_reset(struct virtio_hw *hw)
>  {
> +	uint32_t retry = 0;
> +
>  	VIRTIO_OPS(hw)->set_status(hw, VIRTIO_CONFIG_STATUS_RESET);
> -	/* flush status write */
> -	VIRTIO_OPS(hw)->get_status(hw);
> +	/* Flush status write and wait device ready max 3 seconds. */
> +	while (VIRTIO_OPS(hw)->get_status(hw) != VIRTIO_CONFIG_STATUS_RESET) {
> +		if (retry++ > 3000) {
> +			PMD_INIT_LOG(WARNING, "device reset timeout");

I think it would be very useful to log ethdev port ID here.

> +			break;
> +		}
> +		usleep(1000L);
> +	}
>  }
>  
>  void
> 


  reply	other threads:[~2021-09-15  9:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  6:39 [dpdk-dev] [PATCH] net/virtio: wait device ready in device reset Xueming Li
2021-08-23  9:56 ` Andrew Rybchenko
2021-08-23 13:54   ` Xueming(Steven) Li
2021-08-24 15:40     ` Andrew Rybchenko
2021-08-26  7:15       ` Xia, Chenbo
2021-09-15  9:23         ` Xueming(Steven) Li
2021-09-15  9:21 ` [dpdk-dev] [PATCH v1] net/virtio: wait device ready during reset Xueming Li
2021-09-15  9:27   ` Andrew Rybchenko [this message]
2021-09-15 10:14     ` Xueming(Steven) Li
2021-09-15 10:12 ` [dpdk-dev] [PATCH v2] " Xueming Li
2021-09-15 10:30   ` Andrew Rybchenko
2021-09-15 11:44   ` Xia, Chenbo
2021-09-28 15:31   ` Maxime Coquelin

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=50db4150-c9c5-2e3e-6f0e-e54935b9631d@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=xuemingl@nvidia.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).