[v2] net/virtio: wait device ready during reset
Checks
Commit Message
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.
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(-)
Comments
On 9/15/21 1:12 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.
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> -----Original Message-----
> From: Xueming Li <xuemingl@nvidia.com>
> Sent: Wednesday, September 15, 2021 6:12 PM
> To: dev@dpdk.org
> Cc: xuemingl@nvidia.com; Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>;
> Maxime Coquelin <maxime.coquelin@redhat.com>; Xia, Chenbo
> <chenbo.xia@intel.com>
> Subject: [PATCH v2] net/virtio: wait device ready during reset
>
> 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.
>
> Signed-off-by: Xueming Li <xuemingl@nvidia.com>
> Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
> --
> 2.33.0
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
On 9/15/21 12:12, 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.
>
> 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(-)
>
Applied to dpdk-next-virtio/main.
Thanks,
Maxime
@@ -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, "port %u device reset timeout", hw->port_id);
+ break;
+ }
+ usleep(1000L);
+ }
}
void