From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 98C36A0C41; Wed, 15 Sep 2021 11:27:36 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 672B24003F; Wed, 15 Sep 2021 11:27:36 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id B81754003C for ; Wed, 15 Sep 2021 11:27:34 +0200 (CEST) Received: from [192.168.38.17] (aros.oktetlabs.ru [192.168.38.17]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id 631437F4FE; Wed, 15 Sep 2021 12:27:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 631437F4FE DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1631698054; bh=FbfKYVAv/5Axqd7FbDkAYuQ2O1cJEIbfquiIPFx8T4s=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=PicBoMIhBnGvmKEOTDfbWNTD9nUaa+ds6bq2YVgNUXJikNwRVHMIHJKcuy/0wDVTL NMDIotIQ+PuYMTXbZLPNmV6tPHPSNAwEDCj+5Z9esnfv9/A1t1SaurJgzsXsqPTnMV Eu7WdTEDeltD8o0Xz9BI6y3v8udO/uIICDgmhjs0= To: Xueming Li , dev@dpdk.org Cc: Maxime Coquelin , Chenbo Xia References: <20210823063906.1382544-1-xuemingl@nvidia.com> <20210915092113.79205-1-xuemingl@nvidia.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: <50db4150-c9c5-2e3e-6f0e-e54935b9631d@oktetlabs.ru> Date: Wed, 15 Sep 2021 12:27:34 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210915092113.79205-1-xuemingl@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v1] net/virtio: wait device ready during reset X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 > Cc: Andrew Rybchenko > --- > 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 > + > #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 >