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 86B97A0548; Tue, 24 Aug 2021 17:40:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 05007406A3; Tue, 24 Aug 2021 17:40:50 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id B68B140687 for ; Tue, 24 Aug 2021 17:40:48 +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 EFBEB7F553; Tue, 24 Aug 2021 18:40:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru EFBEB7F553 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oktetlabs.ru; s=default; t=1629819648; bh=NWLjGotWLQ3vuhpVl6LwMh3O9XfSCSh2IZVk3UDG4Yc=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=VK3UHQ4rt+qL8tvb+OO+ArLgDHboXXgKefMUoNx5EH1T8oAGWT2NdnUlgHa0tViIq aqXqx1LhA9kyGcOUdchaLsy0VERfUm3T617ne9CHyOl/QU/DlRZDHZNvN8XgLAIQ1U jTKFJtwLH/hzybhQehU518SqJ2zob+GP3vocfj1k= To: "Xueming(Steven) 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: Tue, 24 Aug 2021 18:40:47 +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: 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 4:54 PM, Xueming(Steven) Li wrote: > > >> -----Original Message----- >> From: Andrew Rybchenko >> Sent: Monday, August 23, 2021 5:57 PM >> To: Xueming(Steven) Li >> Cc: dev@dpdk.org; Maxime Coquelin ; Chenbo Xia >> Subject: Re: [dpdk-dev] [PATCH] net/virtio: wait device ready in device reset >> >> 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? > > Good question, ideally we need, kernel driver function vp_reset() seems to have same issue. Yes, I've seen it. > How about leaving an error message before return? @Maxime, @Chenbo, what do you think?