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 C96B3A0C56; Mon, 23 Aug 2021 11:56:39 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 956F140687; Mon, 23 Aug 2021 11:56:39 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 9A2EF4014D for ; Mon, 23 Aug 2021 11:56:38 +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)) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPSA id E9B177F4FE; Mon, 23 Aug 2021 12:56:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru E9B177F4FE DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1629712598; bh=+BzLNfuvftOo8seEeZ5O5bggDlnYEp5IlpcsHckVJdQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=UtSaSCrro+rF8ewqmHMQJvIBvehVrF2kzLA9Ep3ujiIPKU1vFv8SQbqL996ossDKg fGVO3JIQf29Ee7s0nsIG+YH1nP58fimAyMQaqi5WNHiuF+KlaBu2oK9e+MaX8Bu9Qs 1hUWIO4ZDpYmkj30cM3DVOiuQsDyZsZRrgeZWQZk= To: Xueming Li Cc: dev@dpdk.org, Maxime Coquelin , Chenbo Xia References: <20210823063906.1382544-1-xuemingl@nvidia.com> From: Andrew Rybchenko Organization: OKTET Labs Message-ID: Date: Mon, 23 Aug 2021 12:56:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <20210823063906.1382544-1-xuemingl@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/virtio: wait device ready in device 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 8/23/21 9:39 AM, Xueming Li wrote: > According to virtio spec, the device MUST reset when 0 is written to > device_status, and present a 0 in device_status once that is done. > > This patch adds the missing part of waiting status 0 in reset function. > > Signed-off-by: Xueming Li > --- > drivers/net/virtio/virtio.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio/virtio.c b/drivers/net/virtio/virtio.c > index 7e1e77797f..f003f612d6 100644 > --- a/drivers/net/virtio/virtio.c > +++ b/drivers/net/virtio/virtio.c > @@ -3,6 +3,8 @@ > * Copyright(c) 2020 Red Hat, Inc. > */ > > +#include > + > #include "virtio.h" > > uint64_t > @@ -39,8 +41,9 @@ void > virtio_reset(struct virtio_hw *hw) > { > 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. */ > + while (VIRTIO_OPS(hw)->get_status(hw) != VIRTIO_CONFIG_STATUS_RESET) > + usleep(1000L); Don't we need a protection against forever loop here? > } > > void >